Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.webdav.resource;
 
 import java.net.URI;
 
 import javax.jcr.Node;
 
Created by The eXo Platform SARL .

Author(s):
Gennady Azarenkov
Version:
$Id: $
 
 
 public class VersionResource extends GenericResource
 {

   
resource version.
 
    protected final Version version;

   
versioned resource.
 
    protected final VersionedResource versionedResource;

   

Parameters:
identifier resource identifier
versionedResource resource
version version
namespaceContext namespace context
 
    public VersionResource(final URI identifierVersionedResource versionedResourceVersion version,
       final WebDavNamespaceContext namespaceContext)
    {
       super(identifiernamespaceContext);
       this. = version;
       this. = versionedResource;
    }

   
 
       RepositoryException
    {
       if (..equals(name))
       {
          return new HierarchicalProperty(name.getName());
       }
       else if (..equals(name))
       {
          return new HierarchicalProperty(name.getName());
       }
       else if (..equals(name))
       {
          return new HierarchicalProperty(name);
       }
       else if (..equals(name))
       {
 
          HierarchicalProperty checkedInProperty = new HierarchicalProperty(name);
          HierarchicalProperty href = checkedInProperty.addChild(new HierarchicalProperty(new QName("DAV:""href")));
          href.setValue(.toASCIIString());
          return checkedInProperty;
 
       }
       else if (..equals(name))
       {
         Version[] predecessors = .getPredecessors();
         HierarchicalProperty predecessorsProperty = new HierarchicalProperty(name);
         for (Version curVersion : predecessors)
         {
            if ("jcr:rootVersion".equals(curVersion.getName()))
            {
               continue;
            }
            String versionHref =
               .getIdentifier().toASCIIString() + "/?version=" + curVersion.getName();
            HierarchicalProperty href =
               predecessorsProperty.addChild(new HierarchicalProperty(new QName("DAV:""href")));
            href.setValue(versionHref);
         }
         return predecessorsProperty;
      }
      else if (..equals(name))
      {
         Version[] successors = .getSuccessors();
         HierarchicalProperty successorsProperty = new HierarchicalProperty(name);
         for (Version curVersion : successors)
         {
            String versionHref =
               .getIdentifier().toASCIIString() + "/?version=" + curVersion.getName();
            HierarchicalProperty href =
               successorsProperty.addChild(new HierarchicalProperty(new QName("DAV:""href")));
            href.setValue(versionHref);
         }
         return successorsProperty;
      }
      else if (..equals(name))
      {
         HierarchicalProperty resourceType = new HierarchicalProperty(name);
         if (.isCollection())
         {
            // new HierarchicalProperty("DAV:", "collection")
            resourceType.addChild(new HierarchicalProperty(new QName("DAV:""collection")));
         }
         return resourceType;
      }
      else if (..equals(name))
      {
         if (.isCollection())
         {
            throw new PathNotFoundException();
         }
         HierarchicalProperty getContentLength = new HierarchicalProperty(name);
         Property jcrDataProperty = contentNode().getProperty("jcr:data");
         getContentLength.setValue("" + jcrDataProperty.getLength());
         return getContentLength;
      }
      else if (..equals(name))
      {
         if (.isCollection())
         {
            throw new PathNotFoundException();
         }
         HierarchicalProperty getContentType = new HierarchicalProperty(name);
         Property mimeType = contentNode().getProperty("jcr:mimeType");
         getContentType.setValue(mimeType.getString());
         return getContentType;
      }
      else if (..equals(name))
      {
         Calendar created = .getNode("jcr:frozenNode").getProperty("jcr:created").getDate();
         HierarchicalProperty creationDate = new HierarchicalProperty(namecreated);
         creationDate.setAttribute("b:dt""dateTime.tz");
         return creationDate;
      }
      else if (..equals(name))
      {
         Calendar created = .getNode("jcr:frozenNode").getProperty("jcr:created").getDate();
         HierarchicalProperty creationDate = new HierarchicalProperty(namecreated);
         creationDate.setAttribute("b:dt""dateTime.1123");
         return creationDate;
      }
      else
      {
         throw new PathNotFoundException();
      }
   }

   
   public final boolean isCollection()
   {
      return false;
   }

   
Returns content node.

   public Node contentNode() throws RepositoryException
   {
      return .getNode("jcr:frozenNode").getNode("jcr:content");
   }

   
Returns the content of node as a stream.

   {
      return contentNode().getProperty("jcr:data").getStream();
   }
New to GrepCode? Check out our FAQ X