Examples of HierarchicalProperty


Examples of org.exoplatform.common.util.HierarchicalProperty

   {
      Map<String, Set<HierarchicalProperty>> propStats = new HashMap<String, Set<HierarchicalProperty>>();

      for (int i = 0; i < setList.size(); i++)
      {
         HierarchicalProperty setProperty = setList.get(i);

         String statname = WebDavConst.getStatusDescription(HTTPStatus.OK);

         try
         {

            if (setProperty.getStringName().equals(WebDavConst.NodeTypes.JCR_CONTENT))
            {
               for (HierarchicalProperty child : setProperty.getChildren())
               {

                  if (child.getChildren().isEmpty())
                  {

                     if (node.isNodeType(WebDavConst.NodeTypes.MIX_VERSIONABLE) && !node.isCheckedOut())
                     {
                        node.checkout();
                        node.save();
                     }

                     Node content = getContentNode();
                     statname = setProperty(content, child);

                     if (!propStats.containsKey(statname))
                     {
                        propStats.put(statname, new HashSet<HierarchicalProperty>());
                     }

                     Set<HierarchicalProperty> propSet = propStats.get(statname);

                     HierarchicalProperty jcrContentProp = new HierarchicalProperty(PropertyConstants.JCR_CONTENT);
                     jcrContentProp.addChild(new HierarchicalProperty(child.getName()));

                     propSet.add(jcrContentProp);

                  }
                  else
                  {
                  }

               }
            }
            else
            {
               statname = setProperty(node, setProperty);

               if (!propStats.containsKey(statname))
               {
                  propStats.put(statname, new HashSet<HierarchicalProperty>());
               }

               Set<HierarchicalProperty> propSet = propStats.get(statname);
               propSet.add(new HierarchicalProperty(setProperty.getName()));

            }

         }
         catch (RepositoryException e)
         {
            statname = WebDavConst.getStatusDescription(HTTPStatus.CONFLICT);
         }

      }

      for (int i = 0; i < removeList.size(); i++)
      {
         HierarchicalProperty removeProperty = removeList.get(i);

         String statname = WebDavConst.getStatusDescription(HTTPStatus.OK);

         if (NON_REMOVING_PROPS.contains(removeProperty.getName()))
         {
            statname = WebDavConst.getStatusDescription(HTTPStatus.CONFLICT);

            if (!propStats.containsKey(statname))
            {
               propStats.put(statname, new HashSet<HierarchicalProperty>());
            }

            Set<HierarchicalProperty> propSet = propStats.get(statname);
            propSet.add(new HierarchicalProperty(removeProperty.getName()));

            continue;

         }

         if (removeProperty.getStringName().equals(WebDavConst.NodeTypes.JCR_CONTENT))
         {
            for (HierarchicalProperty child : removeProperty.getChildren())
            {
               try
               {
                  Node content = getContentNode();
                  statname = removeProperty(content, child);
                  if (!propStats.containsKey(statname))
                  {
                     propStats.put(statname, new HashSet<HierarchicalProperty>());
                  }

                  Set<HierarchicalProperty> propSet = propStats.get(statname);

                  HierarchicalProperty jcrContentProp =
                     new HierarchicalProperty(new QName(WebDavConst.NodeTypes.JCR_CONTENT));
                  jcrContentProp.addChild(new HierarchicalProperty(child.getName()));
                  propSet.add(jcrContentProp);

               }
               catch (RepositoryException e)
               {
                  statname = WebDavConst.getStatusDescription(HTTPStatus.CONFLICT);
               }
            }
         }
         else
         {
            statname = removeProperty(node, removeProperty);
            if (!propStats.containsKey(statname))
            {
               propStats.put(statname, new HashSet<HierarchicalProperty>());
            }

            Set<HierarchicalProperty> propSet = propStats.get(statname);
            propSet.add(new HierarchicalProperty(removeProperty.getName()));
         }

      }

      return propStats;
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

         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)
            {
               return Response.ok().header(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength)).header(
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

   public Set<HierarchicalProperty> getProperties(boolean namesOnly) throws PathNotFoundException,
      AccessDeniedException, RepositoryException
   {
      Set<HierarchicalProperty> props = super.getProperties(namesOnly);

      props.add(namesOnly ? new HierarchicalProperty(GETLASTMODIFIED) : getProperty(GETLASTMODIFIED));
      props.add(namesOnly ? new HierarchicalProperty(GETCONTENTLENGTH) : getProperty(GETCONTENTLENGTH));
      props.add(namesOnly ? new HierarchicalProperty(GETCONTENTTYPE) : getProperty(GETCONTENTTYPE));

      QName nodeTypeName = namespaceContext.createQName("jcr:nodeType");
      HierarchicalProperty noneTypeProp =
         new HierarchicalProperty(nodeTypeName, contentNode().getPrimaryNodeType().getName());
      props.add(noneTypeProp);

      Set<QName> presents = new HashSet<QName>();

      PropertyIterator jcrProps = node.getProperties();
      while (jcrProps.hasNext())
      {
         Property property = jcrProps.nextProperty();
         if (!FILE_SKIP.contains(property.getName()))
         {
            QName name = namespaceContext.createQName(property.getName());
            presents.add(name);
            props.add((namesOnly) ? new HierarchicalProperty(name) : getProperty(name));
            if (name.getLocalPart().equals("isCheckedOut"))
            {
               QName qname = namespaceContext.createQName("D:checked-in");
               presents.add(qname);
               props.add(new HierarchicalProperty(qname));
            }
         }
      }

      jcrProps = contentNode().getProperties();
      HierarchicalProperty jcrContentProp =
         new HierarchicalProperty(namespaceContext.createQName(WebDavConst.NodeTypes.JCR_CONTENT));

      while (jcrProps.hasNext())
      {
         Property property = jcrProps.nextProperty();
         if (!CONTENT_SKIP.contains(property.getName()))
         {
            QName name = namespaceContext.createQName(property.getName());

            if (presents.contains(name))
            {
               continue;
            }

            jcrContentProp.addChild((namesOnly) ? new HierarchicalProperty(name) : getProperty(name));
         }
      }

      if (!jcrContentProp.getChildren().isEmpty())
      {
         props.add(jcrContentProp);
      }
      return props;
   }
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

   public HierarchicalProperty getProperty(QName name) throws PathNotFoundException, AccessDeniedException,
      RepositoryException
   {
      if (name.equals(DISPLAYNAME))
      {
         return new HierarchicalProperty(name, node.getName());
      }
      else if (name.equals(CREATIONDATE))
      {
         Calendar created = node.getProperty("jcr:created").getDate();

         HierarchicalProperty creationDate = new HierarchicalProperty(name, created, CREATION_PATTERN);
         creationDate.setAttribute("b:dt", "dateTime.tz");
         return creationDate;
      }
      else if (name.equals(CHILDCOUNT))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(GETCONTENTLENGTH))
      {
         return new HierarchicalProperty(name, String.valueOf(dataProperty().getLength()));
      }
      else if (name.equals(GETCONTENTTYPE))
      {
         return new HierarchicalProperty(name, contentNode().getProperty("jcr:mimeType").getString());
      }
      else if (name.equals(GETLASTMODIFIED))
      {
         Calendar modified = contentNode().getProperty("jcr:lastModified").getDate();
         HierarchicalProperty lastModified = new HierarchicalProperty(name, modified, MODIFICATION_PATTERN);
         lastModified.setAttribute("b:dt", "dateTime.rfc1123");
         return lastModified;
      }
      else if (name.equals(HASCHILDREN))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(ISCOLLECTION))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(ISFOLDER))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(ISROOT))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(PARENTNAME))
      {
         return new HierarchicalProperty(name, node.getParent().getName());
      }
      else if (name.equals(RESOURCETYPE))
      {
         return new HierarchicalProperty(name);
      }
      else if (name.equals(SUPPORTEDLOCK))
      {
         if (!node.canAddMixin("mix:lockable"))
         {
            throw new PathNotFoundException();
         }
         return supportedLock();
      }
      else if (name.equals(LOCKDISCOVERY))
      {
         if (node.isLocked())
         {
            String token = node.getLock().getLockToken();
            String owner = node.getLock().getLockOwner();
            return lockDiscovery(token, owner, "86400");
         }
         else
            throw new PathNotFoundException();
      }
      else if (name.equals(ISVERSIONED))
      {
         return new HierarchicalProperty(name, "0");
      }
      else if (name.equals(SUPPORTEDMETHODSET))
      {
         return supportedMethodSet();
      }
      else
      {
         try
         {
            Property property = node.getProperty(WebDavNamespaceContext.createName(name));
            String propertyValue;
            if (property.getDefinition().isMultiple())
            {
               if (property.getValues().length == 0)
               {
                  throw new PathNotFoundException();
               }

               propertyValue = property.getValues()[0].getString();
            }
            else
            {
               propertyValue = property.getString();
            }
            return new HierarchicalProperty(name, propertyValue);
         }
         catch (PathNotFoundException e)
         {
            Property property = contentNode().getProperty(WebDavNamespaceContext.createName(name));
            String propertyValue;
            if (property.getDefinition().isMultiple())
            {
               propertyValue = property.getValues()[0].getString();
            }
            else
            {
               propertyValue = property.getString();
            }
            return new HierarchicalProperty(name, propertyValue);
         }

      }
   }
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

    */
   private Set<QName> propertyNames(HierarchicalProperty body)
   {
      HashSet<QName> names = new HashSet<QName>();

      HierarchicalProperty propBody = body.getChild(0);

      List<HierarchicalProperty> properties = propBody.getChildren();
      Iterator<HierarchicalProperty> propIter = properties.iterator();
      while (propIter.hasNext())
      {
         HierarchicalProperty property = propIter.next();
         names.add(property.getName());
      }

      return names;
   }
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

         {
            QName name = namespaceContext.createQName(property.getName());

            try
            {
               props.add((namesOnly) ? new HierarchicalProperty(name) : getProperty(name));
            }
            catch (Exception exc)
            {
               if (LOG.isDebugEnabled())
                  LOG.error(exc.getMessage(), exc);
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

   public HierarchicalProperty getProperty(QName name) throws PathNotFoundException, AccessDeniedException,
      RepositoryException
   {
      if (name.equals(DISPLAYNAME))
      {
         return new HierarchicalProperty(name, node.getName());

      }
      else if (name.equals(CHILDCOUNT))
      {
         return new HierarchicalProperty(name, "" + node.getNodes().getSize());

      }
      else if (name.equals(CREATIONDATE))
      {
         if (node.isNodeType("nt:hierarchyNode"))
         {
            Calendar created = node.getProperty("jcr:created").getDate();
            HierarchicalProperty creationDate = new HierarchicalProperty(name, created, CREATION_PATTERN);
            creationDate.setAttribute("b:dt", "dateTime.tz");
            return creationDate;

         }
         else
         {
            throw new PathNotFoundException("Property not found " + CREATIONDATE);
         }

      }
      else if (name.equals(HASCHILDREN))
      {
         if (node.getNodes().getSize() > 0)
         {
            return new HierarchicalProperty(name, "1");
         }
         else
         {
            return new HierarchicalProperty(name, "0");
         }

      }
      else if (name.equals(ISCOLLECTION))
      {
         return new HierarchicalProperty(name, "1");

      }
      else if (name.equals(ISFOLDER))
      {
         return new HierarchicalProperty(name, "1");

      }
      else if (name.equals(ISROOT))
      {
         return new HierarchicalProperty(name, (node.getDepth() == 0) ? "1" : "0");

      }
      else if (name.equals(PARENTNAME))
      {
         if (node.getDepth() == 0)
         {
            throw new PathNotFoundException();
         }
         return new HierarchicalProperty(name, node.getParent().getName());

      }
      else if (name.equals(RESOURCETYPE))
      {
         HierarchicalProperty collectionProp = new HierarchicalProperty(new QName("DAV:", "collection"));
         HierarchicalProperty resourceType = new HierarchicalProperty(name);
         resourceType.addChild(collectionProp);
         return resourceType;

      }
      else if (name.equals(SUPPORTEDLOCK))
      {
         if (!node.canAddMixin("mix:lockable"))
         {
            throw new PathNotFoundException();
         }
         return supportedLock();

      }
      else if (name.equals(LOCKDISCOVERY))
      {
         if (node.isLocked())
         {
            String token = node.getLock().getLockToken();
            String owner = node.getLock().getLockOwner();

            return lockDiscovery(token, owner, "86400");
         }
         throw new PathNotFoundException();

      }
      else if (name.equals(ISVERSIONED))
      {
         return new HierarchicalProperty(name, "0");

      }
      else if (name.equals(SUPPORTEDMETHODSET))
      {
         return supportedMethodSet();

      }
      else if (name.equals(ORDERING_TYPE))
      {
         if (node.getPrimaryNodeType().hasOrderableChildNodes())
         {
            HierarchicalProperty orderingType = new HierarchicalProperty(name);

            // <D:href>DAV:custom</D:href>

            HierarchicalProperty orderHref = orderingType.addChild(new HierarchicalProperty(new QName("DAV:", "href")));
            orderHref.setValue("DAV:custom");

            return orderingType;
         }
         throw new PathNotFoundException();

      }
      else
      {

         if ("DAV:".equals(name.getNamespaceURI()))
         {
            throw new PathNotFoundException();
         }

         Property property = node.getProperty(WebDavNamespaceContext.createName(name));

         if (property.getDefinition().isMultiple())
         {
            Value[] values = property.getValues();
            return new HierarchicalProperty(name, values[0].getString());
         }
         else
         {
            return new HierarchicalProperty(name, property.getString());
         }

      }
   }
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

            xmlStreamWriter.writeStartDocument();

            xmlStreamWriter.writeStartElement("D", "prop", "DAV:");
            xmlStreamWriter.writeNamespace("D", "DAV:");

            HierarchicalProperty lockDiscovery = GenericResource.lockDiscovery(lockToken, lockOwner, timeOut);
            PropertyWriteUtil.writeProperty(xmlStreamWriter, lockDiscovery);

            xmlStreamWriter.writeEndElement();

            xmlStreamWriter.writeEndDocument();
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

   public HierarchicalProperty getProperty(QName name) throws PathNotFoundException, AccessDeniedException,
      RepositoryException
   {
      if (DeltaVConstants.VERSIONNAME.equals(name))
      {
         return new HierarchicalProperty(name, version.getName());
      }
      else if (DeltaVConstants.DISPLAYNAME.equals(name))
      {
         return new HierarchicalProperty(name, version.getName());
      }
      else if (DeltaVConstants.VERSIONHISTORY.equals(name))
      {
         return new HierarchicalProperty(name);
      }
      else if (DeltaVConstants.CHECKEDIN.equals(name))
      {

         HierarchicalProperty checkedInProperty = new HierarchicalProperty(name);
         HierarchicalProperty href = checkedInProperty.addChild(new HierarchicalProperty(new QName("DAV:", "href")));
         href.setValue(identifier.toASCIIString());
         return checkedInProperty;

      }
      else if (DeltaVConstants.PREDECESSORSET.equals(name))
      {
         Version[] predecessors = version.getPredecessors();
         HierarchicalProperty predecessorsProperty = new HierarchicalProperty(name);
         for (Version curVersion : predecessors)
         {
            if ("jcr:rootVersion".equals(curVersion.getName()))
            {
               continue;
            }

            String versionHref =
               versionedResource.getIdentifier().toASCIIString() + "/?version=" + curVersion.getName();
            HierarchicalProperty href =
               predecessorsProperty.addChild(new HierarchicalProperty(new QName("DAV:", "href")));
            href.setValue(versionHref);
         }
         return predecessorsProperty;

      }
      else if (DeltaVConstants.SUCCESSORSET.equals(name))
      {
         Version[] successors = version.getSuccessors();
         HierarchicalProperty successorsProperty = new HierarchicalProperty(name);
         for (Version curVersion : successors)
         {
            String versionHref =
               versionedResource.getIdentifier().toASCIIString() + "/?version=" + curVersion.getName();
            HierarchicalProperty href =
               successorsProperty.addChild(new HierarchicalProperty(new QName("DAV:", "href")));
            href.setValue(versionHref);
         }
         return successorsProperty;

      }
      else if (DeltaVConstants.RESOURCETYPE.equals(name))
      {
         HierarchicalProperty resourceType = new HierarchicalProperty(name);
         if (versionedResource.isCollection())
         {
            // new HierarchicalProperty("DAV:", "collection")
            resourceType.addChild(new HierarchicalProperty(new QName("DAV:", "collection")));
         }
         return resourceType;

      }
      else if (DeltaVConstants.GETCONTENTLENGTH.equals(name))
      {
         if (versionedResource.isCollection())
         {
            throw new PathNotFoundException();
         }
         HierarchicalProperty getContentLength = new HierarchicalProperty(name);
         Property jcrDataProperty = contentNode().getProperty("jcr:data");
         getContentLength.setValue("" + jcrDataProperty.getLength());
         return getContentLength;

      }
      else if (DeltaVConstants.GETCONTENTTYPE.equals(name))
      {
         if (versionedResource.isCollection())
         {
            throw new PathNotFoundException();
         }

         HierarchicalProperty getContentType = new HierarchicalProperty(name);
         Property mimeType = contentNode().getProperty("jcr:mimeType");
         getContentType.setValue(mimeType.getString());
         return getContentType;

      }
      else if (DeltaVConstants.CREATIONDATE.equals(name))
      {
         Calendar created = version.getNode("jcr:frozenNode").getProperty("jcr:created").getDate();
         HierarchicalProperty creationDate = new HierarchicalProperty(name, created, CREATION_PATTERN);
         creationDate.setAttribute("b:dt", "dateTime.tz");
         return creationDate;

      }
      else
      {
View Full Code Here

Examples of org.exoplatform.common.util.HierarchicalProperty

      else
      {

         for (QName propName : propNames)
         {
            HierarchicalProperty prop = new HierarchicalProperty(propName);
            try
            {
               prop = resource.getProperty(propName);
               statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.