cancel
Showing results for 
Search instead for 
Did you mean: 

Execute rule on home user space

louiswu
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to execute a rule that sets permissions through a javascript on a user home space when a new user is created. The rule never gets executed when the user is created, but the javascript runs as expected when executed as an action through the web client.

The rule is defined in the space "User Homes" as follows:
    Rule type: Inbound/Update (it doesn't work either way)
    Apply rule to sub spaces: yes/no (it doesn't work either way)
    Run rule in background: no
    Disable rule: no
    Conditions: All Items
    Actions: Executes script 'script3.js'
Where script3.js contains the following code:
space.setPermission("Consumer", "abc");
abc being one of the users that I have defined

I'm using Alfresco Labs 3.0.0 (b 1164) schema 131

I'm totally lost. Can somebody please give me a hint about how to make this work?
4 REPLIES 4

alexander
Champ in-the-making
Champ in-the-making
Not sure about rule, but you can achieve similar things by changing "personalHomeFolderProvider" bean in authentication-services-context.xml

Thanks
Alexander

louiswu
Champ in-the-making
Champ in-the-making
Hi Alexander,

Thanks for your reply, I already tried that without success (see post http://forums.alfresco.com/en/viewtopic.php?f=9&t=15435). If you have been able to do so, I could certainly use some help.

Regards

alexander
Champ in-the-making
Champ in-the-making
Hi

I did not tried this myself, but looking at this code in AbstractHomeFolderProvider:

if (permissionsToSetOnCreate != null)
                    {
                        for (String user : permissionsToSetOnCreate.keySet())
                        {
                            Set<String> set = permissionsToSetOnCreate.get(user);
                            if (set != null)
                            {
                                for (String permission : set)
                                {
                                    serviceRegistry.getPermissionService().setPermission(homeFolder.getNodeRef(), user,
                                            permission, true);
                                }
                            }
                        }
                    }

I can suggest to include something like this in userHomesHomeFolderProvider bean

        <property name="userPermissions">
         <map>      
             <entry key="your group here">
               <set>
                <value>Consumer</value>
               </set>
             </entry>   
        </map> 
        </property>

louiswu
Champ in-the-making
Champ in-the-making
I already did that in version 2.2, and I've done it again without success in 3.0. More specifically, I modified the file authentication-services-context.xml and I introduced the following code in the userHomesHomeFolderProvider bean:
        <property name="userPermissions">
         <map>
             <entry key="GROUP_pruebas">
               <set>
                <value>Consumer</value>
               </set>
             </entry>
        </map>
        </property>
However, that role/permission never gets assigned to the new user's folder. There must be some setting in some other file that prevents this change from taking place, but I'm clueless.

The only thing that I can think of is that I modified the property home-space-permission in the web-client-config.xml file (more specifically in web-client-config-custom.xml) from
<home-space-permission>Consumer</home-space-permission>
to
<home-space-permission></home-space-permission>
, but I would expect authentication-services-context.xml to override web-client-config-custom.xml

Incidentally, I figured out how to do this with a rule (use "document" in the script as opposed to "space" and set the rule to "Inbound"), but I agree that the bean definition is a much better way of doing that.

As I said, I would appreciate some help
Thanks