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

Change Folder Permissions -& How to initialise IResource Object

$
0
0

Hi All,

 

I Was just trying to programatically change the permission of a folder  ['/documents/Aditya'].

 

The folder name is 'Aditya' located in /documents.

[E.g. /documents/Aditya]

 

I was thinking of doing the above by creating a Portal Component & deploying a par file of it & create a iview of it.

 

In the below code i was not able to figure out, how to intialize the IResource object, Please help:

 

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

    {

          

          

          //here i am not quite clear how to initialize this resource object

          IResource resource;

 

 

          String root = "/documents/Aditya";

 

               try{

                    String rid = RID rid = RID.getRID(root);

                     

                         ISecurityManager sm = resource.getRepositoryManager().getSecurityManager(resource);

                         if(sm != null && sm instanceof IAclSecurityManager){

                              IAclSecurityManager asm = (IAclSecurityManager)sm;

                              IResourceAclManager ram = asm.getAclManager();

                              ram.removeAcl(resource);

                              IResourceAcl ra = ram.createAcl(resource);

                              IUMPrincipal everyone = WPUMFactory.getGroupFactory().getGroup("Everyone");

                               

                              IUMPrincipal owner = WPUMFactory.getUserFactory().getUser(resource.getCreatedBy());

                              IResourceAclEntryList rel = ra.getEntries();

                              IResourceAclEntryListIterator it = rel.iterator();

                              while(it.hasNext()){

                                   ra.removeEntry(it.next());

                              }

                              ra.addEntry(ram.createAclEntry(everyone, false, ram.getPermission(IAclPermission.ACL_PERMISSION_READ), 0));

                              ra.addEntry(ram.createAclEntry(owner, false, ram.getPermission(IAclPermission.ACL_PERMISSION_FULL_CONTROL), 2));

                         }

                     

               }catch(AclPersistenceException e){

                    LOCATION.errorT("I raised an AclPersistenceException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(ResourceException e){

                    LOCATION.errorT("I raised a ResourceException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(NotAuthorizedException e){

                    LOCATION.errorT("I raised a NotAuthorizedException @"(new Date()).toString()": " +e.getMessage() + "**" + LoggingFormatter.extractCallstack(e));

               }catch(AclExistsException e){

                    LOCATION.errorT("I raised an AclExistsException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(UserManagementException e){

                    LOCATION.errorT("I raised a UserManagementException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(InvalidClassException e){

                    LOCATION.errorT("I raised an InvalidClassException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(AlreadyAssignedToAclException e){

                    LOCATION.errorT("I raised an AlreadyAssignedToAclException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }catch(PermissionNotSupportedException e){

                    LOCATION.errorT("I raised a PermissionNotSupportedException @"(new Date()).toString()": " + LoggingFormatter.extractCallstack(e));

               }

            }

 

 

}


Viewing all articles
Browse latest Browse all 1826

Trending Articles



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