Package org.exoplatform.services.jcr.webdav.resource

Examples of org.exoplatform.services.jcr.webdav.resource.Resource


         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         Resource resource;
         InputStream istream;

         if (ResourceUtil.isFile(node))
         {

            HierarchicalProperty lastModifiedProperty;
           
            if (version != null)
            {
               VersionedResource versionedFile = new VersionedFileResource(uri, node, nsContext);
               resource = versionedFile.getVersionHistory().getVersion(version);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((VersionResource)resource).getContentAsStream();
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((FileResource)resource).getContentAsStream();
            }

            // check before any other reads
            if (ifModifiedSince != null)
            {
               DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION, Locale.US);
               Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
              
               dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
               Date ifModifiedSinceDate = dateFormat.parse(ifModifiedSince);
              
               if(ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime()){
                  return Response.notModified().entity("Not Modified").build();
               }
            }

            HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
            long contentLength = new Long(contentLengthProperty.getValue());

            // content length is not present
            if (contentLength == 0)
            {
               return Response.ok().header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(istream).build();
            }

            HierarchicalProperty mimeTypeProperty = resource.getProperty(FileResource.GETCONTENTTYPE);
            String contentType = mimeTypeProperty.getValue();

            // no ranges request
            if (ranges.size() == 0)
            {
View Full Code Here


            URI uri = new URI(TextUtil.escape(baseURI + nextNode.getPath(), '%', true));

            // if URI is new, and wasn't previously being written, then write it
            if (resultNodes.add(uri))
            {
               Resource resource;
               if (ResourceUtil.isVersioned(nextNode))
               {
                  if (ResourceUtil.isFile(nextNode))
                  {
                     resource = new VersionedFileResource(uri, nextNode, nsContext);
                  }
                  else
                  {
                     resource = new VersionedCollectionResource(uri, nextNode, nsContext);
                  }
               }
               else
               {
                  if (ResourceUtil.isFile(nextNode))
                  {
                     resource = new FileResource(uri, nextNode, nsContext);
                  }
                  else
                  {
                     resource = new CollectionResource(uri, nextNode, nsContext);
                  }
               }

               xmlStreamWriter.writeStartElement("DAV:", "response");

               xmlStreamWriter.writeStartElement("DAV:", "href");
               xmlStreamWriter.writeCharacters(resource.getIdentifier().toASCIIString());
               xmlStreamWriter.writeEndElement();

               PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false);

               PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
View Full Code Here

         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         Resource resource;
         InputStream istream;

         if (ResourceUtil.isFile(node))
         {

            HierarchicalProperty lastModifiedProperty;
           
            if (version != null)
            {
               VersionedResource versionedFile = new VersionedFileResource(uri, node, nsContext);
               resource = versionedFile.getVersionHistory().getVersion(version);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((VersionResource)resource).getContentAsStream();
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((FileResource)resource).getContentAsStream();
            }

            // check before any other reads
           
            if (ifModifiedSince != null)
            {
               DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION, Locale.US);
               Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
              
               dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
               Date ifModifiedSinceDate = dateFormat.parse(ifModifiedSince);
              
               if(ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime()){
                  return Response.notModified().entity("Not Modified").build();
               }
            }

            HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
            long contentLength = new Long(contentLengthProperty.getValue());

            // content length is not present
            if (contentLength == 0)
            {
               return Response.ok().header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(istream).build();
            }

            HierarchicalProperty mimeTypeProperty = resource.getProperty(FileResource.GETCONTENTTYPE);
            String contentType = mimeTypeProperty.getValue();

            // no ranges request
            if (ranges.size() == 0)
            {
View Full Code Here

               }
            }

            URI uri = new URI(TextUtil.escape(baseURI + nextNode.getPath(), '%', true));

            Resource resource;
            if (ResourceUtil.isVersioned(nextNode))
            {
               if (ResourceUtil.isFile(nextNode))
               {
                  resource = new VersionedFileResource(uri, nextNode, nsContext);
               }
               else
               {
                  resource = new VersionedCollectionResource(uri, nextNode, nsContext);
               }
            }
            else
            {
               if (ResourceUtil.isFile(nextNode))
               {
                  resource = new FileResource(uri, nextNode, nsContext);
               }
               else
               {
                  resource = new CollectionResource(uri, nextNode, nsContext);
               }
            }

            xmlStreamWriter.writeStartElement("DAV:", "response");

            xmlStreamWriter.writeStartElement("DAV:", "href");
            xmlStreamWriter.writeCharacters(resource.getIdentifier().toASCIIString());
            xmlStreamWriter.writeEndElement();

            PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false);

            PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
View Full Code Here

         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         Resource resource;
         InputStream istream;

         if (ResourceUtil.isFile(node))
         {

            HierarchicalProperty lastModifiedProperty;
           
            if (version != null)
            {
               VersionedResource versionedFile = new VersionedFileResource(uri, node, nsContext);
               resource = versionedFile.getVersionHistory().getVersion(version);
              
               lastModifiedProperty = resource.getProperty(FileResource.CREATIONDATE);
               istream = ((VersionResource)resource).getContentAsStream();
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((FileResource)resource).getContentAsStream();
            }

            // check before any other reads
            if ((ifModifiedSince != null) && (ifModifiedSince.equals(lastModifiedProperty.getValue())))
            {
               return Response.notModified().entity("Not Modified").build();
            }

            HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
            long contentLength = new Long(contentLengthProperty.getValue());

            // content length is not present
            if (contentLength == 0)
            {
               return Response.ok().header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(istream).build();
            }

            HierarchicalProperty mimeTypeProperty = resource.getProperty(FileResource.GETCONTENTTYPE);
            String contentType = mimeTypeProperty.getValue();

            // no ranges request
            if (ranges.size() == 0)
            {
View Full Code Here

         log.error(exc.getMessage(), exc);
         return Response.serverError().entity(exc.getMessage()).build();
      }

      WebDavNamespaceContext nsContext;
      Resource resource;
      try
      {
         nsContext = new WebDavNamespaceContext(session);

         resource = null;
View Full Code Here

         log.error(exc.getMessage(), exc);
         return Response.serverError().build();
      }

      WebDavNamespaceContext nsContext;
      Resource resource;
      try
      {
         nsContext = new WebDavNamespaceContext(session);

         resource = null;
View Full Code Here

         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         Resource resource;
         InputStream istream;

         if (ResourceUtil.isFile(node))
         {

            if (version != null)
            {
               VersionedResource versionedFile = new VersionedFileResource(uri, node, nsContext);
               resource = versionedFile.getVersionHistory().getVersion(version);
               istream = ((VersionResource)resource).getContentAsStream();
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
               istream = ((FileResource)resource).getContentAsStream();
            }

            HierarchicalProperty lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
            // check before any other reads
            if ((ifModifiedSince != null) && (ifModifiedSince.equals(lastModifiedProperty.getValue())))
            {
               return Response.notModified().entity("Not Modified").build();
            }

            HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
            long contentLength = new Long(contentLengthProperty.getValue());

            // content length is not present
            if (contentLength == 0)
            {
               return Response.ok().header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(istream).build();
            }

            HierarchicalProperty mimeTypeProperty = resource.getProperty(FileResource.GETCONTENTTYPE);
            String contentType = mimeTypeProperty.getValue();

            // no ranges request
            if (ranges.size() == 0)
            {
View Full Code Here

               }
            }

            URI uri = new URI(TextUtil.escape(baseURI + nextNode.getPath(), '%', true));

            Resource resource;
            if (ResourceUtil.isVersioned(nextNode))
            {
               if (ResourceUtil.isFile(nextNode))
               {
                  resource = new VersionedFileResource(uri, nextNode, nsContext);
               }
               else
               {
                  resource = new VersionedCollectionResource(uri, nextNode, nsContext);
               }
            }
            else
            {
               if (ResourceUtil.isFile(nextNode))
               {
                  resource = new FileResource(uri, nextNode, nsContext);
               }
               else
               {
                  resource = new CollectionResource(uri, nextNode, nsContext);
               }
            }

            xmlStreamWriter.writeStartElement("DAV:", "response");

            xmlStreamWriter.writeStartElement("DAV:", "href");
            xmlStreamWriter.writeCharacters(URLDecoder.decode(resource.getIdentifier().toASCIIString(), "UTF-8"));
            xmlStreamWriter.writeEndElement();

            PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false);

            PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
View Full Code Here

         Node node = (Node)session.getItem(path);

         WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session);
         URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true));

         Resource resource;
         InputStream istream;

         if (ResourceUtil.isFile(node))
         {

            HierarchicalProperty lastModifiedProperty;
           
            if (version != null)
            {
               VersionedResource versionedFile = new VersionedFileResource(uri, node, nsContext);
               resource = versionedFile.getVersionHistory().getVersion(version);
              
               lastModifiedProperty = resource.getProperty(FileResource.CREATIONDATE);
               istream = ((VersionResource)resource).getContentAsStream();
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
               istream = ((FileResource)resource).getContentAsStream();
            }

            // check before any other reads
            if (ifModifiedSince != null)
            {
               DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
               Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
              
               dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION, Locale.US);
               Date ifModifiedSinceDate = dateFormat.parse(ifModifiedSince);
              
               if(ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime()){
                  return Response.notModified().entity("Not Modified").build();
               }
            }

            HierarchicalProperty contentLengthProperty = resource.getProperty(FileResource.GETCONTENTLENGTH);
            long contentLength = new Long(contentLengthProperty.getValue());

            // content length is not present
            if (contentLength == 0)
            {
               return Response.ok().header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(istream).build();
            }

            HierarchicalProperty mimeTypeProperty = resource.getProperty(FileResource.GETCONTENTTYPE);
            String contentType = mimeTypeProperty.getValue();

            // no ranges request
            if (ranges.size() == 0)
            {
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.webdav.resource.Resource

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.