Quantcast
Channel: SCN : Popular Discussions - SAP Enterprise Portal: Content Management and Collaboration
Viewing all articles
Browse latest Browse all 1826

KM - ACL already exists exception

$
0
0


Hi Experts,

 

I have a KM folder where i have 20000 employee documents. The super_admin role has access to this folder. I am trying to set read only permission to each of these files individually to the respective employee.

 

The file name has the user id of the employee( ex: 822091_2014.pdf - belongs to user 822091). I am trying to write a code which loops through the folder read each file name, get the user id and provide read permission to that user to his or her document.

 

To start off with, i have chosen one document ("/documents/Company/SAP_DEV/822091_2014.pdf") as you can see in line 9

(I have still not started to code the logic to loop through folder and read each file name and extract user id from file name).

 

I am only trying to give read only permission to user 822091 to this document ("/documents/Company/SAP_DEV/822091_2014.pdf").

 

My coding is as given below.

However, i am getting AclExistsException. I read from various posts that this could because acl already exists. And, i tried various options mentioned, but i still get the AclExistsException exception. Can you please help?

 

 

 

try 
{   
 com.sapportals.portal.security.usermanagement.IUser serviceUser = 
 WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
IResourceContext resourceContext = new ResourceContext(serviceUser);
 // Get document 822091_2014.pdf and assign read permission to user 822091
 RID pathRID1 = RID.getRID("/documents/Company/SAP_DEV/822091_2014.pdf");
com.sapportals.wcm.repository.IResource resource =
 ResourceFactory.getInstance().getResource(pathRID1, resourceContext);
com.sapportals.portal.security.usermanagement.IUser user =  WPUMFactory.getUserFactory().getUser("822091");
//get Security Manager 
 ISecurityManager securityManager = 
 resource.getRepositoryManager().getSecurityManager(resource);
//get ACLSecurity Manager
 IResourceAclManager irm =  
 ((IAclSecurityManager)securityManager).getAclManager();   
 //get ResourceAcl
 IResourceAcl iracl = irm.createAcl(resource);   
 //get ACLPermission
 IAclPermission aclperm =  
 irm.getPermission(IAclPermission.ACL_PERMISSION_READ);   
 //create ACL entry 
 IResourceAclEntry iraclentry = irm.createAclEntry(user, false,aclperm,1);
//add ACL entry to ACL
iracl.addEntry(iraclentry);
}   
catch (ResourceException e) {
 wdComponentAPI.getMessageManager().reportException("ResourceException",false);
} 
catch (AclPersistenceException e) 
{
 wdComponentAPI.getMessageManager().reportException("AclPersistenceException",false);
} 
catch (NotAuthorizedException e) 
{
 wdComponentAPI.getMessageManager().reportException("NotAuthorizedException",false);
} 
catch (AclExistsException e) 
{
 wdComponentAPI.getMessageManager().reportException("AclExistsException",false);
} 
catch (InvalidClassException e)
{
 wdComponentAPI.getMessageManager().reportException("InvalidClassException",false);
} 
catch (AlreadyAssignedToAclException e) 
{
 wdComponentAPI.getMessageManager().reportException("AlreadyAssignedToAclException",false);
} 
catch (PermissionNotSupportedException e) 
{
 wdComponentAPI.getMessageManager().reportException("PermissionNotSupportedException",false);
} 
catch (UnsupportedOperationException e) 
{
wdComponentAPI.getMessageManager().reportException("UnsupportedOperationException",false);
} 
catch (UserManagementException e) 
{
 wdComponentAPI.getMessageManager().reportException("UserManagementException",false);
}

Viewing all articles
Browse latest Browse all 1826

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>