cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Folder At Share and Add User Role

kyriakos
Champ in-the-making
Champ in-the-making
Hello alfresco mates,
I'd like to know if it is possible to create a script that can do the thing below,
a)copy a folder and rename it
b)add user roles to it.
Thanx,
Kyriakos
3 REPLIES 3

sanket
Champ on-the-rise
Champ on-the-rise
Well..for the first one you can create your own webscript class…extend AbstractWebScript
use FileFolderService. Generate its getter-setters
And in your execute method, you can try

getFileFolderService().copy(src,destination,"Name_of_space_u_want_to_Create");

getFileFolderService().rename(noderef, string);

For your second question, I am too looking for its answer. Please post if you get it.

Thanks,
Sanket.

sanket
Champ on-the-rise
Champ on-the-rise
You can add roles as follows.

You need to use the following services in your webscript class.
AuthorityService
PermissionService
PersonService

String lStrSpaceUserName = request.getParameter("spaceUserName");
String lStrSpaceNodeRef = request.getParameter("spaceNodeRef");

String userName = getAuthorityService().getName(AuthorityType.USER, lStrSpaceUserName);
if(personService.personExists(userName)){
         nodeRefOfPermissiveSpace = new NodeRef(Repository.getStoreRef(),lStrSpaceNodeRef);
          Set set = getPermissionService().getPermissions(nodeRefOfPermissiveSpace);
           Iterator iter = set.iterator();
           while(iter.hasNext()){
              System.out.println("******PErmissions*****:"+iter.next());
              }
              getPermissionService().setInheritParentPermissions(nodeRefOfPermissiveSpace, true);
              getPermissionService().setPermission(nodeRefOfPermissiveSpace,userName ,PermissionService.COORDINATOR, true);
           }
/*in this way, I gave the Coordinator role to the userName*/

I hope this helps.
Thanks,
Sanket.

kyriakos
Champ in-the-making
Champ in-the-making
wow man thanx for this when i finish the whole script i'll give it to you. thanx again