cancel
Showing results for 
Search instead for 
Did you mean: 

Cut Inherit permission in a fileshare folder

rubi
Champ in-the-making
Champ in-the-making
I have a problem with inheritance form parent folder in alfresco 2.0. I have a fileshare folder where all users can contribute (Everyone is a Contributor) to add content, but the issue is to make it possible to just see the content that the spesific user have added. The user that contributes just sees what he/she has contributed.

I have removed Inherit Parent Space Permissions checkbox on the filestore folder, but when new files or folders are added these permission rights are still inherited.

One solution I have worked with is a javascript file in a rule on the filestore folder that breaks the inheritance. 
……..
permissionService.setInheritParentPermissions(nodeRef, false);   
    // Allow EVERYONE has CONSUMER
   permissionService.setPermission(nodeRef,
   PermissionService.ALL_AUTHORITIES, PermissionService.CONSUMER, true);
   // Allow GUEST has CONSUMER
   permissionService.setPermission(nodeRef,
   PermissionService.GUEST_AUTHORITY, PermissionService.CONSUMER, true);
…….
but I always get an error on the function setInheritParentPermissions, that it is not defined?

Anyone who has a simple solution to the script or an other script who will do the trick here? Is it even possible? Or is there some other way to solve this problem?
7 REPLIES 7

rubi
Champ in-the-making
Champ in-the-making
Still strugling to get a javascript (.js file inn a content rule) that removes inheritance on the subfolder an files. I have tested other .js files an those rule rules with scripts are functioning pretty wellSmiley Happy

// remove inheritance in subfolders and files.
var permissionService = companyhome.childByNamePath("Fildeling/test3");
if (permissionService != null)
{
   permissionService = space.setInheritParentPermissions(nodeRef, false);   
}

Here is the error message I get?

A system error happened during the operation: Transaction didn't commit: Failed to execute script 'workspace://SpacesStore/e7d58c4d-4be8-11dc-9dae-cd5281c789f2': TypeError: Cannot find function setInheritParentPermissions. (AlfrescoScript#9)

I am sure that this it is my poor programing skills i JS and that this is a easy syntax to complete. Anyone who have any suggestions?

kevinr
Star Contributor
Star Contributor
The method in the JS API is called 'setInheritsPermissions' - the docs are correct on the wiki.

Thanks,

Kevin

rubi
Champ in-the-making
Champ in-the-making
Yes! Thanks for reply!

I found the definition of setInheritsPermission in the JS API (wiki) and some tips here on the forum on this spesific topicSmiley Happy

So now I have a JS script that removes permission inheritance when something is added or created to my filestore folder or in the subfolders, as long as I am logged in as admin.

But for other users, they can't contribute because of an error when trying to add or create subfolders in the filestore folder.

The filestore folder has invited EVERYONE as a contributer so I don't see why they can add when I'm removing the rule, but when the rule is active they get an error message.
.
.
.

var permissionFolder = space.childByNamePath("xxxx");

if (permissionFolder != null)
{
document.setInheritsPermissions(false);
document.setOwner("contributor");
}
.
.
.

rubi
Champ in-the-making
Champ in-the-making
OK. I solved this one. Users can now log in again.

Thanks for guiding me in the right direction!

hani
Champ in-the-making
Champ in-the-making
hi Kevin/Ruby,

Can you please post the solution, because now I stuck in same situation.


–Hani

rubi
Champ in-the-making
Champ in-the-making
This is a part of my JS file that I use in a rule to remove inherit permission files and folder where the rule is executed.

Hope this helps.

——————————————————–
var permissionFolder = space.childByNamePath;

if (permissionFolder != null)
{
  
document.removePermission("Read");
document.removePermission("Write");
document.removePermission("Delete");

// remove inherit permissons and set Owner

document.setInheritsPermissions(false);
document.setOwner("contributor");

}

hani
Champ in-the-making
Champ in-the-making
Thaks Rubi,

       Sorrry for the delay to respond because last 2 days I was out of office.
Yes I did the same way only but the issue is when I add any content it is being uploaded and the rule is being applied but after that showing the access denied message. If we login as admin we can see the uploaded doc.  I also tried by giving the ChangePermissions permission to the user. No change.  What is wrong with me any idea ?
       One more question instead of seting owner as contributor, how can I set the current user as owner. I tried by giving person. Is there proeprty for person to get the name or any other way to do this.
please ….

Thanks once more for your reply.

–Hani