Package org.exoplatform.common.util

Examples of org.exoplatform.common.util.HierarchicalProperty


      node.getNode("jcr:content").addNode("node", "nt:unstructured").setProperty("node-prop", "prop");
      node.getNode("jcr:content").setProperty("exo:prop", "prop");
      node.save();

      // test
      HierarchicalProperty body = new HierarchicalProperty("D:propfind", null, "DAV:");
      body.addChild(new HierarchicalProperty("D:allprop", null, "DAV:"));
      Response resp = new PropFindCommand().propfind(session, path, body, Depth.INFINITY_VALUE, "http://localhost");
      ByteArrayOutputStream bas = new ByteArrayOutputStream();
      ((PropFindResponseEntity)resp.getEntity()).write(bas);
      String find = new String(bas.toByteArray());
      assertFalse(find.contains("jcr:lockOnwer"));
View Full Code Here


      assertEquals(HTTPStatus.MULTISTATUS, response.getStatus());
      assertNotNull(response.getEntity());

      HierarchicalPropertyEntityProvider provider = new HierarchicalPropertyEntityProvider();
      InputStream inputStream = TestUtils.getResponseAsStream(response);
      HierarchicalProperty multistatus = provider.readFrom(null, null, null, null, null, inputStream);

      assertEquals(new QName("DAV:", "multistatus"), multistatus.getName());
      assertEquals(1, multistatus.getChildren().size());

      HierarchicalProperty resourceProp = multistatus.getChildren().get(0);

      HierarchicalProperty resourceHref = resourceProp.getChild(new QName("DAV:", "href"));
      assertNotNull(resourceHref);
      assertEquals(BASE_URI + getPathWS() + "/", resourceHref.getValue());

      HierarchicalProperty propstatProp = resourceProp.getChild(new QName("DAV:", "propstat"));
      HierarchicalProperty propProp = propstatProp.getChild(new QName("DAV:", "prop"));

      HierarchicalProperty ownerProp = propProp.getChild(new QName("DAV:", "owner"));
      HierarchicalProperty ownerHrefProp = ownerProp.getChild(new QName("DAV:", "href"));

      assertEquals("__system", ownerHrefProp.getValue());

      HierarchicalProperty aclProp = propProp.getChild(ACLProperties.ACL);
      assertEquals(1, aclProp.getChildren().size());

      HierarchicalProperty aceProp = aclProp.getChild(ACLProperties.ACE);
      assertEquals(2, aceProp.getChildren().size());

      HierarchicalProperty principalProp = aceProp.getChild(ACLProperties.PRINCIPAL);
      assertEquals(1, principalProp.getChildren().size());

      HierarchicalProperty allProp = principalProp.getChild(ACLProperties.ALL);
      assertNotNull(allProp);

      HierarchicalProperty grantProp = aceProp.getChild(ACLProperties.GRANT);
      assertEquals(2, grantProp.getChildren().size());

      HierarchicalProperty writeProp = grantProp.getChild(0).getChild(ACLProperties.WRITE);
      assertNotNull(writeProp);
      HierarchicalProperty readProp = grantProp.getChild(1).getChild(ACLProperties.READ);
      assertNotNull(readProp);
   }
View Full Code Here

      assertEquals(HTTPStatus.MULTISTATUS, cres.getStatus());

      HierarchicalPropertyEntityProvider provider = new HierarchicalPropertyEntityProvider();
      InputStream inputStream = TestUtils.getResponseAsStream(cres);
      HierarchicalProperty multistatus = provider.readFrom(null, null, null, null, null, inputStream);

      assertEquals(new QName("DAV:", "multistatus"), multistatus.getName());
      assertEquals(1, multistatus.getChildren().size());

      HierarchicalProperty resourceProp = multistatus.getChildren().get(0);

      HierarchicalProperty resourceHref = resourceProp.getChild(new QName("DAV:", "href"));
      assertNotNull(resourceHref);
      assertEquals(BASE_URI + getPathWS() + testNode.getPath() + "/", resourceHref.getValue());

      HierarchicalProperty propstatProp = resourceProp.getChild(new QName("DAV:", "propstat"));
      HierarchicalProperty propProp = propstatProp.getChild(new QName("DAV:", "prop"));

      HierarchicalProperty aclProp = propProp.getChild(ACLProperties.ACL);
      assertEquals(1, aclProp.getChildren().size());

      HierarchicalProperty aceProp = aclProp.getChild(ACLProperties.ACE);
      assertEquals(2, aceProp.getChildren().size());

      HierarchicalProperty principalProp = aceProp.getChild(ACLProperties.PRINCIPAL);
      assertEquals(1, principalProp.getChildren().size());

      assertEquals(userName, principalProp.getChildren().get(0).getValue());

      HierarchicalProperty grantProp = aceProp.getChild(ACLProperties.GRANT);
      assertEquals(2, grantProp.getChildren().size());

      HierarchicalProperty writeProp = grantProp.getChild(0).getChild(ACLProperties.WRITE);
      assertNotNull(writeProp);
      HierarchicalProperty readProp = grantProp.getChild(1).getChild(ACLProperties.READ);
      assertNotNull(readProp);

   }
View Full Code Here

         Resource resource;

         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);
            }
            else
            {
               resource = new FileResource(uri, node, nsContext);
              
               lastModifiedProperty = resource.getProperty(FileResource.GETLASTMODIFIED);
            }

            // 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)
            {
               istream = openStream(resource, version != null);
               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)
            {
               istream = openStream(resource, version != null);
View Full Code Here

         }

         //String value = node.getProperty(name).getString();

         String ns = ((ExtendedSession)node.getSession()).getLocationFactory().parseJCRName(name).getNamespace();
         return new HierarchicalProperty(name, value, ns);
      }
      catch (PathNotFoundException e)
      {
         return null;
      }
View Full Code Here

         if (p.getDefinition().isMultiple())
         {
            Value[] v = p.getValues();
            for (int i = 0; i < v.length; i++)
            {
               props.add(new HierarchicalProperty(name, v[i].getString(), ns));
            }
         }
         else
         {
            props.add(new HierarchicalProperty(name, p.getString(), ns));
         }

         //      PropertyIterator iter = node.getProperties(name);
         //      while (iter.hasNext()) {
         //        Property prop = iter.nextProperty();
View Full Code Here

            if (bodyIsEmpty)
            {
               lock = node.getLock();
               lock.refresh();

               body = new HierarchicalProperty(new QName("DAV", "activelock", "D"));
               HierarchicalProperty owner = new HierarchicalProperty(PropertyConstants.OWNER);
               HierarchicalProperty href = new HierarchicalProperty(new QName("D", "href"), lock.getLockOwner());
               body.addChild(owner).addChild(href);
            }
            else
            {
               lock = node.lock((depth.getIntValue() != 1), false);
View Full Code Here

            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

      Map<String, String[]> permissionsToDeny = new HashMap<String, String[]>();

      for (HierarchicalProperty ace : requestBody.getChildren())
      {

         HierarchicalProperty principalProperty = ace.getChild(ACLProperties.PRINCIPAL);
         // each ace element must contain principal element
         // <!ELEMENT ace ((principal | invert), (grant|deny), protected?, inherited?)>
         if (principalProperty == null)
         {
            throw new IllegalArgumentException("Malformed ace element (seems that no principal element specified)");
         }

         String principal;

         if (principalProperty.getChild(ACLProperties.HREF) != null)
         {
            principal = principalProperty.getChild(ACLProperties.HREF).getValue();
         }
         else if (principalProperty.getChild(ACLProperties.ALL) != null)
         {
            principal = IdentityConstants.ANY;
         }

         // each principal must contain either href or all element
         // <!ELEMENT principal (href | all | authenticated | unauthenticated | property | self)>
         else
         {
            throw new IllegalArgumentException("Malformed principal element");
         }

         HierarchicalProperty denyProperty = ace.getChild(ACLProperties.DENY);
         HierarchicalProperty grantProperty = ace.getChild(ACLProperties.GRANT);

         // each ace element must contain at least one grant or deny property
         // <!ELEMENT ace ((principal | invert), (grant|deny), protected?, inherited?)>
         if (denyProperty == null && grantProperty == null)
         {
View Full Code Here

         throw new IllegalArgumentException("Malformed grant|deny element (seems that no privilige is specified)");
      }

      for (HierarchicalProperty propertyRunner : property.getChildren())
      {
         HierarchicalProperty permissionProperty;

         // obviously privilege must be single named
         // <!ELEMENT privilege ANY>
         if (ACLProperties.PRIVILEGE.equals(propertyRunner.getName()))
         {
            if (propertyRunner.getChildren().size() > 1)
            {
               throw new IllegalArgumentException(
                  "Malformed privilege name (element privilege must contain only one element)");
            }
            permissionProperty = propertyRunner.getChild(0);
         }
         else
         {
            permissionProperty = propertyRunner;
         }

         if (ACLProperties.READ.equals(permissionProperty.getName()))
         {
            permissionsToBeChanged.add(PermissionType.READ);

         }
         else if (ACLProperties.WRITE.equals(permissionProperty.getName()))
         {
            permissionsToBeChanged.add(PermissionType.ADD_NODE);
            permissionsToBeChanged.add(PermissionType.SET_PROPERTY);
            permissionsToBeChanged.add(PermissionType.REMOVE);

         }
         else if (ACLProperties.ALL.equals(permissionProperty.getName()))
         {
            permissionsToBeChanged.add(PermissionType.READ);
            permissionsToBeChanged.add(PermissionType.ADD_NODE);
            permissionsToBeChanged.add(PermissionType.SET_PROPERTY);
            permissionsToBeChanged.add(PermissionType.REMOVE);
View Full Code Here

TOP

Related Classes of org.exoplatform.common.util.HierarchicalProperty

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.