[solved]Writing a custom behaviour on user create

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2008 10:01 AM
Hi,
I'am writing a custom behavior after reading the good article named "behavior-article.pdf".
So here is what I want to do :
When the administration create a user, I want to "catch the event" (does it correspond to onCreateStore event ?) so to create automticaly two directories in his home space.
So I declared the bean for spring and wrote a "test" javascript to see if it is called. :
My-model-context.xml
onCreateUser.js :
I put the log4j for jscript to debug. When this script is run ? To which act the onCreateStore correspond to ? (is it when a new user is added ?)
More generally, to which action are binded the events ?
I'd like to catch the action on user create …
Thanks for your help !
I'am writing a custom behavior after reading the good article named "behavior-article.pdf".
So here is what I want to do :
When the administration create a user, I want to "catch the event" (does it correspond to onCreateStore event ?) so to create automticaly two directories in his home space.
So I declared the bean for spring and wrote a "test" javascript to see if it is called. :
My-model-context.xml
<bean id="onCreateUserStore" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration"> <property name="policyName"> <value>{http://www.alfresco.org}onCreateStore</value> </property> <property name="className"> <value>{http://www.alfresco.org/model/system/1.0}store_root</value> </property> <property name="behaviour"> <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour"> <property name="location"> <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation"> <constructor-arg> <value>alfresco/extension/scripts/onCreateUser.js</value> </constructor-arg> </bean> </property> </bean> </property> </bean>
onCreateUser.js :
logger.log("Start onCreateUser.js…");if (behaviour == null) { logger.log("The behaviour object has not been set");}//check the name of the behaviourif (behaviour.name == null && behaviour.name != "onCreateStore") { logger.log("The behaviour name has not been set correctly");}else { logger.log("Behaviour name: " + behaviour.name);}//check the argumentsif (behaviour.args == null) { logger.log("The args have not been set");} else { if (behaviour.args.length == 1) { var user = behaviour.args[0]; logger.log("init user's workspace"); logger.log("end user's workspace"); }}
I put the log4j for jscript to debug. When this script is run ? To which act the onCreateStore correspond to ? (is it when a new user is added ?)
More generally, to which action are binded the events ?
I'd like to catch the action on user create …
Thanks for your help !
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2008 02:17 PM
I noticed that the onCreateStore event is launched at the time alfresco is initializing when you do the first deployment….so it is usefull to prepare application environment I think (pre process before login into app)
I outlined the problem simply creating a rule when a folder is created in user's home space (ie, when we defined a new user and specify his home folder name)
.
I outlined the problem simply creating a rule when a folder is created in user's home space (ie, when we defined a new user and specify his home folder name)

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2008 05:47 AM
why don't you just bind your behavior to the type cm
erson and onCreateNode policy?

