cancel
Showing results for 
Search instead for 
Did you mean: 

To modify permissions

limarin
Champ in-the-making
Champ in-the-making
Hi,

I add two new aspects: state folder (opened/closed) and finish date

And I have created a scheduled job to update the state folder.

It does:

To look for the folders and for every folder:
If the folder has my new aspect assigned (state folder) and the finish date has expired,
1. The state is modified: closed
2. Delete permissions:

The step 1 it's ok, but the step 2 does not work

public void execUpdateWork()
{
    TransactionWork<Object> updWork = new TransactionWork<Object>()
    {
        public Object doWork() throws Exception
        {
               ….. search folders
      
      authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
      QName qStFolder = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "stateFolder");
      for(ResultSetRow row : results)
      {
         currentNodeRef = row.getNodeRef();
         if (currentDate.compareTo(closeDate)>-1) {
         this.nodeService.setProperty(nodeRef, qStFolder, "CLOSED");
                              
         Set<String> users = this.authorityService.getContainedAuthorities(AuthorityType.USER,"GROUP_MyGroup",false);
         for (String userAuth : users)
         {
            this.permissionService.deletePermission(nodeRef, userAuth, PermissionService.ALL_PERMISSIONS);
         }
         }
      }
      
      ….. results.close();
      
                return null;
        }
    };
    TransactionUtil.executeInUserTransaction(this.transactionService, updWork);
}

Why does not work deletePermission or clearPermission ???

Thanks for your help
3 REPLIES 3

andy
Champ on-the-rise
Champ on-the-rise
Hi

Delete permission removes a single entry - clear permissions removes all.

Regards

Andy

limarin
Champ in-the-making
Champ in-the-making
Hi,

Now I am using the method clearPermission:

public void execUpdateWork()
{
    TransactionWork<Object> updWork = new TransactionWork<Object>()
    {
        public Object doWork() throws Exception
        {
               ….. search folders
       
      authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
      QName qStFolder = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "stateFolder");
      for(ResultSetRow row : results)
      {
         currentNodeRef = row.getNodeRef();
         if (currentDate.compareTo(closeDate)>-1) {
         this.nodeService.setProperty(nodeRef, qStFolder, "CLOSED");
         
         this.permissionService.clearPermission(nodeRef,"GROUP_MyGroup");
         
      }
       
      ….. results.close();
       
                return null;
        }
    };
    TransactionUtil.executeInUserTransaction(this.transactionService, updWork);
}

The users of the group do not have permissions on the folders and now they are not visualized in the browse page…

but the creator user (owner) of the folder (who also belongs to the group GROUP_MyGroup) continues having the permissions and continues seeing the folder.

Is it possible that cannot clean the permissions of access to the folder of the owner user?

I view http://forums.alfresco.com/viewtopic.php?t=3498

Exist a dynamic authority for owner.

I need to assign only the global permissions. I do not want that the user who creates a folder (owner) has all the permissions on the folder.

When the user creates the folder, is possible to disable this dynamic authority?

Thanks.

andy
Champ on-the-rise
Champ on-the-rise
Hi

There is a dynamic authority for OWNER. You can remove this from the confg or set the correct global permission for OWNER in the config.

Regards

Andy