Package org.exoplatform.services.jcr.ext.resource

Examples of org.exoplatform.services.jcr.ext.resource.NodeRepresentation


   {

      try
      {

         NodeRepresentation content =
            nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"), mediaTypeHint);

         // return nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"),
         // mediaTypeHint);
         return new NtFileNodeRepresentation(node, content);
View Full Code Here


                  xsw.writeStartElement("tr");
                  if (RESTArtifactLoaderService.isFile(node))
                  {
                     if (node.getName().endsWith("sha1"))
                        continue;
                     NodeRepresentation nodeRepresentation =
                        nodeRepresentationService.getNodeRepresentation(node, null);
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "fileicon");
                     xsw.writeEndElement();// td

                     xsw.writeStartElement("td");
                     xsw.writeAttribute("style", "font-style: italic;");
                     xsw.writeStartElement("a");
                     xsw.writeAttribute("href", (mavenPath.endsWith("/") ? mavenPath + node.getName() : mavenPath + "/"
                        + node.getName())
                        + "?view=true&gadget=" + gadget);
                     xsw.writeCharacters(node.getName());
                     xsw.writeEndElement(); // a
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(nodeRepresentation.getMediaType());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters("" + nodeRepresentation.getContentLenght());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(new Date(nodeRepresentation.getLastModified()).toString());
                     xsw.writeEndElement(); // td
                  }
                  else
                  {
                     xsw.writeStartElement("td");
View Full Code Here

    * @throws Exception
    *           if any errors occurs.
    */
   private Response downloadArtifact(Node node) throws Exception
   {
      NodeRepresentation nodeRepresentation = nodeRepresentationService.getNodeRepresentation(node, null);
      if (node.canAddMixin("exo:mavencounter"))
      {
         node.addMixin("exo:mavencounter");
         node.getSession().save();
      }
      node.setProperty("exo:downloadcounter", node.getProperty("exo:downloadcounter").getLong() + 1l);
      node.getSession().save();
      long lastModified = nodeRepresentation.getLastModified();
      String contentType = nodeRepresentation.getMediaType();
      long contentLength = nodeRepresentation.getContentLenght();
      InputStream entity = nodeRepresentation.getInputStream();
      Response response =
         Response.ok(entity, contentType).header(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength))
            .lastModified(new Date(lastModified)).build();
      return response;
   }
View Full Code Here

    *           if any errors occurs.
    */
   private Response getArtifactInfo(Node node, final String mavenPath, final String gadget, Node shaNode)
      throws Exception
   {
      NodeRepresentation nodeRepresentation = nodeRepresentationService.getNodeRepresentation(node, null);

      NodeRepresentation shNodeRepresentation = null;
      if (shaNode != null)
         shNodeRepresentation = nodeRepresentationService.getNodeRepresentation(shaNode, null);

      final PipedOutputStream po = new PipedOutputStream();
      final PipedInputStream pi = new PipedInputStream(po);

      long lastModified = nodeRepresentation.getLastModified();
      long contentLength = nodeRepresentation.getContentLenght();

      try
      {

         if (node.canAddMixin("exo:mavencounter"))
         {
            node.addMixin("exo:mavencounter");
            node.getSession().save();
         }
         int count = (int)node.getProperty("exo:downloadcounter").getLong();

         XMLOutputFactory factory = XMLOutputFactory.newInstance();
         factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
         XMLStreamWriter xsw = factory.createXMLStreamWriter(po, Constants.DEFAULT_ENCODING);
         xsw.writeStartDocument(Constants.DEFAULT_ENCODING, "1.0");
         xsw.writeDTD("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
            + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
         xsw.writeCharacters("\n");
         xsw.writeStartElement("html");
         xsw.writeDefaultNamespace(XHTML_NS);
         xsw.writeStartElement("head");
         xsw.writeStartElement("style");
         xsw.writeAttribute("type", "text/css");
         xsw.writeCharacters("a {text-decoration: none; color: #10409C;}" + "a:hover {text-decoration: underline;}"
            + ".centered { text-align: center; }" + ".underlined { border-bottom : 1px solid #cccccc; }\n");
         xsw.writeEndElement(); // style
         xsw.writeStartElement("title");
         xsw.writeCharacters("Maven2 Artifact Information");
         xsw.writeEndElement(); // title
         xsw.writeEndElement(); // head
         xsw.writeStartElement("body");

         xsw.writeStartElement("b");
         xsw.writeCharacters("Artifact Information :");
         xsw.writeEndElement();
         xsw.writeEmptyElement("br");

         xsw.writeCharacters("Name:  " + node.getName());
         xsw.writeEmptyElement("br");

         xsw.writeCharacters("Size:  " + contentLength);
         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Last modified:  " + new Date(lastModified).toString());
         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Download:  ");
         xsw.writeStartElement("a");
         xsw.writeAttribute("href", mavenPath.endsWith("/") ? mavenPath.substring(0, mavenPath.length() - 1)
            : mavenPath);
         xsw.writeCharacters("Link");
         xsw.writeEndElement(); // a

         if (shNodeRepresentation != null)
         {
            xsw.writeEmptyElement("br");
            xsw.writeCharacters("Checksum:  " + getStreamAsString(shNodeRepresentation.getInputStream()));
            xsw.writeEmptyElement("br");
         }

         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Downloads count :  " + count);
View Full Code Here

                  xsw.writeStartElement("tr");
                  if (RESTArtifactLoaderService.isFile(node))
                  {
                     if (node.getName().endsWith("sha1"))
                        continue;
                     NodeRepresentation nodeRepresentation =
                        nodeRepresentationService.getNodeRepresentation(node, null);
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "fileicon");
                     xsw.writeEndElement();// td

                     xsw.writeStartElement("td");
                     xsw.writeAttribute("style", "font-style: italic;");
                     xsw.writeStartElement("a");
                     xsw.writeAttribute("href", (mavenPath.endsWith("/") ? mavenPath + node.getName() : mavenPath + "/"
                        + node.getName())
                        + "?view=true&gadget=" + gadget);
                     xsw.writeCharacters(node.getName());
                     xsw.writeEndElement(); // a
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(nodeRepresentation.getMediaType());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters("" + nodeRepresentation.getContentLenght());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(new Date(nodeRepresentation.getLastModified()).toString());
                     xsw.writeEndElement(); // td
                  }
                  else
                  {
                     xsw.writeStartElement("td");
View Full Code Here

    * @throws Exception
    *           if any errors occurs.
    */
   private Response downloadArtifact(Node node) throws Exception
   {
      NodeRepresentation nodeRepresentation = nodeRepresentationService.getNodeRepresentation(node, null);
      if (node.canAddMixin("exo:mavencounter"))
      {
         node.addMixin("exo:mavencounter");
         node.getSession().save();
      }
      node.setProperty("exo:downloadcounter", node.getProperty("exo:downloadcounter").getLong() + 1l);
      node.getSession().save();
      long lastModified = nodeRepresentation.getLastModified();
      String contentType = nodeRepresentation.getMediaType();
      long contentLength = nodeRepresentation.getContentLenght();
      InputStream entity = nodeRepresentation.getInputStream();
      Response response =
         Response.ok(entity, contentType).header(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength))
            .lastModified(new Date(lastModified)).build();
      return response;
   }
View Full Code Here

    *           if any errors occurs.
    */
   private Response getArtifactInfo(Node node, final String mavenPath, final String gadget, Node shaNode)
      throws Exception
   {
      NodeRepresentation nodeRepresentation = nodeRepresentationService.getNodeRepresentation(node, null);

      NodeRepresentation shNodeRepresentation = null;
      if (shaNode != null)
         shNodeRepresentation = nodeRepresentationService.getNodeRepresentation(shaNode, null);

      final PipedOutputStream po = new PipedOutputStream();
      final PipedInputStream pi = new PipedInputStream(po);

      long lastModified = nodeRepresentation.getLastModified();
      long contentLength = nodeRepresentation.getContentLenght();

      try
      {

         if (node.canAddMixin("exo:mavencounter"))
         {
            node.addMixin("exo:mavencounter");
            node.getSession().save();
         }
         int count = (int)node.getProperty("exo:downloadcounter").getLong();

         XMLOutputFactory factory = XMLOutputFactory.newInstance();
         factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
         XMLStreamWriter xsw = factory.createXMLStreamWriter(po, Constants.DEFAULT_ENCODING);
         xsw.writeStartDocument(Constants.DEFAULT_ENCODING, "1.0");
         xsw.writeDTD("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
            + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
         xsw.writeCharacters("\n");
         xsw.writeStartElement("html");
         xsw.writeDefaultNamespace(XHTML_NS);
         xsw.writeStartElement("head");
         xsw.writeStartElement("style");
         xsw.writeAttribute("type", "text/css");
         xsw.writeCharacters("a {text-decoration: none; color: #10409C;}" + "a:hover {text-decoration: underline;}"
            + ".centered { text-align: center; }" + ".underlined { border-bottom : 1px solid #cccccc; }\n");
         xsw.writeEndElement(); // style
         xsw.writeStartElement("title");
         xsw.writeCharacters("Maven2 Artifact Information");
         xsw.writeEndElement(); // title
         xsw.writeEndElement(); // head
         xsw.writeStartElement("body");

         xsw.writeStartElement("b");
         xsw.writeCharacters("Artifact Information :");
         xsw.writeEndElement();
         xsw.writeEmptyElement("br");

         xsw.writeCharacters("Name:  " + node.getName());
         xsw.writeEmptyElement("br");

         xsw.writeCharacters("Size:  " + contentLength);
         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Last modified:  " + new Date(lastModified).toString());
         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Download:  ");
         xsw.writeStartElement("a");
         xsw.writeAttribute("href", mavenPath.endsWith("/") ? mavenPath.substring(0, mavenPath.length() - 1)
            : mavenPath);
         xsw.writeCharacters("Link");
         xsw.writeEndElement(); // a

         if (shNodeRepresentation != null)
         {
            xsw.writeEmptyElement("br");
            xsw.writeCharacters("Checksum:  " + getStreamAsString(shNodeRepresentation.getInputStream()));
            xsw.writeEmptyElement("br");
         }

         xsw.writeEmptyElement("br");
         xsw.writeCharacters("Downloads count :  " + count);
View Full Code Here

   {

      try
      {

         NodeRepresentation content =
            nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"), mediaTypeHint);

         // return nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"),
         // mediaTypeHint);
         return new NtFileNodeRepresentation(node, content);
View Full Code Here

   {

      try
      {

         NodeRepresentation content =
            nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"), mediaTypeHint);

         // return nodeRepresentationService.getNodeRepresentation(node.getNode("jcr:content"),
         // mediaTypeHint);
         return new NtFileNodeRepresentation(node, content);
View Full Code Here

                  xsw.writeStartElement("tr");
                  if (RESTArtifactLoaderService.isFile(node))
                  {
                     if (node.getName().endsWith("sha1"))
                        continue;
                     NodeRepresentation nodeRepresentation =
                        nodeRepresentationService.getNodeRepresentation(node, null);
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "fileicon");
                     xsw.writeEndElement();// td

                     xsw.writeStartElement("td");
                     xsw.writeAttribute("style", "font-style: italic;");
                     xsw.writeStartElement("a");
                     xsw.writeAttribute("href", (mavenPath.endsWith("/") ? mavenPath + node.getName() : mavenPath + "/"
                        + node.getName())
                        + "?view=true&gadget=" + gadget);
                     xsw.writeCharacters(node.getName());
                     xsw.writeEndElement(); // a
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(nodeRepresentation.getMediaType());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters("" + nodeRepresentation.getContentLenght());
                     xsw.writeEndElement(); // td
                     xsw.writeStartElement("td");
                     xsw.writeAttribute("class", "centered");
                     xsw.writeCharacters(new Date(nodeRepresentation.getLastModified()).toString());
                     xsw.writeEndElement(); // td
                  }
                  else
                  {
                     xsw.writeStartElement("td");
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.ext.resource.NodeRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.