cancel
Showing results for 
Search instead for 
Did you mean: 

Create New Custom Role

jhassler
Champ in-the-making
Champ in-the-making
I would like to add a new role.  It can see all folders in the Document Library (except those prevented by the folder's owner) and upload to them but can only see its own documents within them.  I've seen a couple of posts related to creating new roles…

http://forums1.man.alfresco.com/en/viewtopic.php?f=10&t=13385
http://wiki.alfresco.com/wiki/Custom_Permissions_in_Share

Both of these give some good information but…

1.  The wiki article says it will break the site if the role is created after the site is already created.  My site is already created so I need to know what additional steps are needed to prevent that.
2.  I need to figure out what permissionGroups would allow seeing all folders (except those prevented by the owner) but prevent seeing anyone else's documents within them.

Thanks.

Jim
4 REPLIES 4

marco_altieri
Star Contributor
Star Contributor
I don't know if you still need this information.
I had the same problem and I solved it creating manually some groups.
If the site is called sitename and the role is called RoleName you have to create the group: site_sitename_RoleName
I wrote the following code to automatically create these groups:


var allSites = siteService.listSites(null, null, 0);

for (var siteIndex = 0; siteIndex < allSites.length; siteIndex++) {
   createAuthorities(allSites[siteIndex].shortName, ["YourCustomContributor", "YourCustomConsumer"]);
}

function createAuthorities(siteName, rolesList) {
   var prefix = "site_" + siteName + "_";
   for (var roleIndex = 0; roleIndex < rolesList.length; roleIndex++) {
      var groupName = prefix + rolesList[roleIndex];
      
      if (people.getGroup("GROUP_" + groupName) == null) {
         people.createGroup(groupName);
      }
   }
}

alessandromiazo
Champ in-the-making
Champ in-the-making
hi guys,
I have already created my web site and now i want to create new custom roles..I'm facing the same issue;
Could you please tell me where did you add the Java Code Marco?

marco_altieri
Star Contributor
Star Contributor
hi guys,
I have already created my web site and now i want to create new custom roles..I'm facing the same issue;
Could you please tell me where did you add the Java Code Marco?

It's not a Java code. It's javascript. You should create a new javascript in Data Dictionary/Scripts and execute it manually. If you have created only one site, you don't need to do it: it's better to create the groups manually.

marco_altieri
Star Contributor
Star Contributor
The groups created manually or using the javascript are not 100% equivalent to the groups automatically created by Alfresco: Alfresco doesn't create these "role groups" in the default zone, that's way they aren't visible.

To do the same, it's necessary to use the Java AuthorityService