jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1646435 [3/3] - in /jackrabbit/trunk: jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ jackrabbit-jcr-server/src/main/java/org/apache/jackrab...
Date Thu, 18 Dec 2014 10:43:32 GMT
Added: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/XmlTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/XmlTree.java?rev=1646435&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/XmlTree.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/XmlTree.java
Thu Dec 18 10:43:31 2014
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi2jcr;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.Tree;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.tree.AbstractTree;
+
+class XmlTree extends AbstractTree {
+
+    private final StringBuilder properties = new StringBuilder();
+
+    protected XmlTree(Name nodeName, Name ntName, String uniqueId, NamePathResolver resolver)
{
+        super(nodeName, ntName, uniqueId, resolver);
+    }
+
+    //-------------------------------------------------------< AbstractTree >---
+    @Override
+    protected Tree createChild(Name name, Name primaryTypeName, String uniqueId) {
+        return new XmlTree(name, primaryTypeName, uniqueId, getResolver());
+    }
+
+    //---------------------------------------------------------------< Tree >---
+    @Override
+    public void addProperty(Name propertyName, int propertyType, QValue value) throws RepositoryException
{
+        addProperty(propertyName, propertyType, new QValue[] {value});
+
+    }
+
+    @Override
+    public void addProperty(Name propertyName, int propertyType, QValue[] values) throws
RepositoryException {
+        properties.append("<sv:property sv:name=\"").append(getResolver().getJCRName(propertyName)).append("\"");
+        properties.append(" sv:type=\"").append(PropertyType.nameFromValue(propertyType)
+ "\">");
+        for (QValue value : values) {
+            properties.append("<sv:value>").append(value.getString()).append("</sv:value>");
+        }
+        properties.append("</sv:property>");
+    }
+
+    //--------------------------------------------------------------------------
+    String toXML() throws RepositoryException {
+        StringBuilder xml = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+        createXMLNodeFragment(xml, this, getResolver(), true);
+        return xml.toString();
+    }
+
+    private static void createXMLNodeFragment(StringBuilder xml, XmlTree tree, NamePathResolver
resolver, boolean includeNsInfo) throws RepositoryException {
+        xml.append("<sv:node ");
+        if (includeNsInfo) {
+           xml.append("xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"");
+        }
+        xml.append("sv:name=\"").append(resolver.getJCRName(tree.getName())).append("\">");
+        // jcr:primaryType
+        xml.append("<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">");
+        xml.append("<sv:value>").append(resolver.getJCRName(tree.getPrimaryTypeName())).append("</sv:value>");
+        xml.append("</sv:property>");
+        // jcr:uuid
+        String uniqueId = tree.getUniqueId();
+        if (uniqueId != null) {
+            xml.append("<sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">");
+            xml.append("<sv:value>").append(uniqueId).append("</sv:value>");
+            xml.append("</sv:property>");
+        }
+
+        // create the xml fragment for all the child properties.
+        xml.append(tree.properties);
+
+        // create xml for all child nodes
+        for (Tree child : tree.getChildren()) {
+            createXMLNodeFragment(xml, (XmlTree) child, resolver, false);
+        }
+
+        xml.append("</sv:node>");
+    }
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/CurrentUserPrivilegeSetProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/CurrentUserPrivilegeSetProperty.java?rev=1646435&r1=1646434&r2=1646435&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/CurrentUserPrivilegeSetProperty.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/CurrentUserPrivilegeSetProperty.java
Thu Dec 18 10:43:31 2014
@@ -29,6 +29,8 @@ import java.util.Set;
 
 /**
  * <code>CurrentUserPrivilegeSetProperty</code>...
+ *
+ * TODO: should respect aggregation of privileges.....
  */
 public class CurrentUserPrivilegeSetProperty extends AbstractDavProperty<Collection<Privilege>>
{
 

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/SupportedPrivilegeSetProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/SupportedPrivilegeSetProperty.java?rev=1646435&r1=1646434&r2=1646435&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/SupportedPrivilegeSetProperty.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/security/SupportedPrivilegeSetProperty.java
Thu Dec 18 10:43:31 2014
@@ -67,8 +67,8 @@ public class SupportedPrivilegeSetProper
         List<SupportedPrivilege> supportedPrivs = new ArrayList<SupportedPrivilege>();
         
         for (Object obj : Collections.singletonList(p.getValue())) {
-            if (p instanceof Element) {
-                supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) p));
+            if (obj instanceof Element) {
+                supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) obj));
             } else if (obj instanceof Collection) {
                 for (Object entry : ((Collection<?>) obj)) {
                     if (entry instanceof Element) {



Mime
View raw message