Remove node data model, home areas based on workspaces instead.
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / JcrUtils.java
index 3e3789aab3e42e05c56ab6564e2aafb98d603227..416d035f8b5925555e421c46ede06e21e85dd231 100644 (file)
@@ -1308,23 +1308,30 @@ public class JcrUtils {
                return true;
        }
 
-       /** Gets access control list for this path, throws exception if not found */
+       /**
+        * Gets the first available access control list for this path, throws exception
+        * if not found
+        */
        public synchronized static AccessControlList getAccessControlList(AccessControlManager acm, String path)
                        throws RepositoryException {
                // search for an access control list
                AccessControlList acl = null;
                AccessControlPolicyIterator policyIterator = acm.getApplicablePolicies(path);
-               if (policyIterator.hasNext()) {
+               applicablePolicies: if (policyIterator.hasNext()) {
                        while (policyIterator.hasNext()) {
                                AccessControlPolicy acp = policyIterator.nextAccessControlPolicy();
-                               if (acp instanceof AccessControlList)
+                               if (acp instanceof AccessControlList) {
                                        acl = ((AccessControlList) acp);
+                                       break applicablePolicies;
+                               }
                        }
                } else {
                        AccessControlPolicy[] existingPolicies = acm.getPolicies(path);
-                       for (AccessControlPolicy acp : existingPolicies) {
-                               if (acp instanceof AccessControlList)
+                       existingPolicies: for (AccessControlPolicy acp : existingPolicies) {
+                               if (acp instanceof AccessControlList) {
                                        acl = ((AccessControlList) acp);
+                                       break existingPolicies;
+                               }
                        }
                }
                if (acl != null)
@@ -1497,7 +1504,7 @@ public class JcrUtils {
                                contentNode = fileNode.getNode(Node.JCR_CONTENT);
                        } else {
                                fileNode = folderNode.addNode(fileName, NodeType.NT_FILE);
-                               contentNode = fileNode.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE);
+                               contentNode = fileNode.addNode(Node.JCR_CONTENT, NodeType.NT_UNSTRUCTURED);
                        }
                        binary = contentNode.getSession().getValueFactory().createBinary(in);
                        contentNode.setProperty(Property.JCR_DATA, binary);