Cut Inherit permission in a fileshare folder
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2007 04:45 AM
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?
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?
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2007 08:02 AM
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 well
// 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?

// 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?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2007 06:23 AM
The method in the JS API is called 'setInheritsPermissions' - the docs are correct on the wiki.
Thanks,
Kevin
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2007 08:36 AM
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 topic
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");
}
.
.
.
I found the definition of setInheritsPermission in the JS API (wiki) and some tips here on the forum on this spesific topic

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");
}
.
.
.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2007 07:19 AM
OK. I solved this one. Users can now log in again.
Thanks for guiding me in the right direction!
Thanks for guiding me in the right direction!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2007 08:25 AM
hi Kevin/Ruby,
Can you please post the solution, because now I stuck in same situation.
–Hani
Can you please post the solution, because now I stuck in same situation.
–Hani
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2007 04:32 AM
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");
}
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");
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2007 01:13 AM
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
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
