incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r897054 - /sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
Date Thu, 07 Jan 2010 23:33:50 GMT
Author: ieb
Date: Thu Jan  7 23:33:50 2010
New Revision: 897054

URL: http://svn.apache.org/viewvc?rev=897054&view=rev
Log:
SLING-1251 Applied Patch from Ray Davis (Thanks) fixes acl policies after JR16 upgrade, and
fixes a potential NPE.

Modified:
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java?rev=897054&r1=897053&r2=897054&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
Thu Jan  7 23:33:50 2010
@@ -813,16 +813,24 @@
 
 		AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
 		AccessControlList updatedAcl = null;
-		AccessControlPolicyIterator applicablePolicies = accessControlManager.getApplicablePolicies(resourcePath);
-		while (applicablePolicies.hasNext()) {
-			AccessControlPolicy policy = applicablePolicies.nextAccessControlPolicy();
-			if (policy instanceof AccessControlList) {
-				updatedAcl = (AccessControlList)policy;
-				break;
-			}
+		AccessControlPolicy[] policies = accessControlManager.getPolicies(resourcePath);
+		for (AccessControlPolicy policy : policies) {
+		  if (policy instanceof AccessControlList) {
+		    updatedAcl = (AccessControlList)policy;
+		    break;
+		  }
+		}
+		if (updatedAcl == null) {
+		  AccessControlPolicyIterator applicablePolicies = accessControlManager.getApplicablePolicies(resourcePath);
+		  while (applicablePolicies.hasNext()) {
+		    AccessControlPolicy policy = applicablePolicies.nextAccessControlPolicy();
+		    if (policy instanceof AccessControlList) {
+		      updatedAcl = (AccessControlList)policy;
+		    }
+		  }
 		}
 		if (updatedAcl == null) {
-			throw new RepositoryException("Unable to find an access conrol policy to update.");
+			throw new RepositoryException("Unable to find or create an access control policy to update
for " + resourcePath);
 		}
 
 		Set<String> postedPrivilegeNames = new HashSet<String>();
@@ -869,12 +877,14 @@
 
 		//add a fresh ACE with the granted privileges
 		List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
-		for (String name : grantedPrivilegeNames) {
-			if (name.length() == 0) {
-				continue; //empty, skip it.
-			}
-			Privilege privilege = accessControlManager.privilegeFromName(name);
-			grantedPrivilegeList.add(privilege);
+		if (grantedPrivilegeNames != null) {
+		  for (String name : grantedPrivilegeNames) {
+			  if (name.length() == 0) {
+				  continue; //empty, skip it.
+			  }
+			  Privilege privilege = accessControlManager.privilegeFromName(name);
+			  grantedPrivilegeList.add(privilege);
+	    }
 		}
 		//add the privileges that should be preserved
 		grantedPrivilegeList.addAll(preserveGrantedPrivileges);
@@ -888,13 +898,14 @@
 		if (!authorizable.isGroup()) {
 			//add a fresh ACE with the denied privileges
 			List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
-			for (String name : deniedPrivilegeNames) {
-				if (name.length() == 0) {
-					continue; //empty, skip it.
-				}
-				Privilege privilege = accessControlManager.privilegeFromName(name);
-				deniedPrivilegeList.add(privilege);
-
+			if (deniedPrivilegeNames != null) {
+			  for (String name : deniedPrivilegeNames) {
+				  if (name.length() == 0) {
+					  continue; //empty, skip it.
+				  }
+				  Privilege privilege = accessControlManager.privilegeFromName(name);
+				  deniedPrivilegeList.add(privilege);
+			  }
 			}
 			//add the privileges that should be preserved
 			deniedPrivilegeList.addAll(preserveDeniedPrivileges);



Mime
View raw message