directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cp...@apache.org
Subject [02/43] directory-fortress-core git commit: delete pa from set now deletes by name, not full value
Date Thu, 06 Oct 2016 17:49:19 GMT
delete pa from set now deletes by name, not full value


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/b5886dac
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/b5886dac
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/b5886dac

Branch: refs/heads/master
Commit: b5886dac7cf03d86debc0e2d8c668247a05f8795
Parents: 9d11f77
Author: clp207 <clp207@psu.edu>
Authored: Mon Feb 1 10:35:31 2016 -0500
Committer: clp207 <clp207@psu.edu>
Committed: Wed Mar 30 15:44:22 2016 -0400

----------------------------------------------------------------------
 .../directory/fortress/core/GlobalErrIds.java   |  5 +++++
 .../directory/fortress/core/impl/PermP.java     | 21 +++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5886dac/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
index cb56ac5..7704d89 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
@@ -673,6 +673,11 @@ public final class GlobalErrIds
      * The supplied Permission Attribute Set name is required but was passed as null.
      */
     public static final int PERM_ATTRIBUTE_SET_NM_NULL = 3036;
+    /**
+     * The supplied Permission Attribute was not found
+     */
+    public static final int PERM_ATTRIBUTE_NOT_FOUND = 3037;
+    
     
     /**
      * 4000's - Password Policy Entity

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5886dac/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
index 3e5a7c7..c72c38b 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
@@ -27,6 +27,8 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.fortress.core.FinderException;
 import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.ReviewMgr;
+import org.apache.directory.fortress.core.ReviewMgrFactory;
 import org.apache.directory.fortress.core.SecurityException;
 import org.apache.directory.fortress.core.ValidationException;
 import org.apache.directory.fortress.core.model.AdminRole;
@@ -392,7 +394,24 @@ final class PermP
     void delete( PermissionAttribute entity, String attributeSetName ) throws SecurityException
     {
         //TODO: add validation
-        pDao.deletePermissionAttribute( entity, attributeSetName );
+    	
+    	//want to remove by attribute name, not full ftPA value, so find existing and delete
that
+    	PermissionAttribute existingPa = null;
+    	
+    	ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
+    	PermissionAttributeSet paSet = reviewMgr.readPermAttributeSet(new PermissionAttributeSet(attributeSetName));
+    	for(PermissionAttribute pa : paSet.getAttributes()){
+    		if(pa.getAttributeName().equals(entity.getAttributeName())){
+    			existingPa = pa;
+    			break;
+    		}
+    	}
+    	
+    	if(existingPa == null){
+    		throw new ValidationException(GlobalErrIds.PERM_ATTRIBUTE_NOT_FOUND, "Could not find
permission attribute with name [" + entity.getAttributeName() + "] on attribute set [" + attributeSetName
+ "]");
+    	}
+    	
+        pDao.deletePermissionAttribute( existingPa, attributeSetName );
     }
 
     /**


Mime
View raw message