Hi,
I have a KM folder where i have 20000 KM documents. Each of the file name has the user id in it. 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/Belgacom/SAP_DEV/822091_2014.pdf");as you can see in line 5 (looping through folder to read each file name is not included). Now, i am trying to give read only permission to user 822091 in this document.
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?
My coding is as given below
try { com.sapportals.portal.security.usermanagement.IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service"); IResourceContext resourceContext = new ResourceContext(serviceUser); RID pathRID1 = RID.getRID("/documents/Belgacom/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); }