11-10-2010 04:04 AM
11-10-2010 06:06 AM
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="onCreateChild_ChangeSpacePermission"
class="org.alfresco.repo.policy.registration.AssociationPolicyRegistration"
parent="policyRegistration">
<property name="policyNames">
<list>
<value>{http://www.alfresco.org}onCreateChildAssociation</value>
</list>
</property>
<property name="className">
<value>{http://www.alfresco.org/model/content/1.0}folder</value>
</property>
<property name="associationType">
<value>{http://www.alfresco.org/model/content/1.0}contains</value>
</property>
<property name="behaviour">
<bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour">
<property name="notificationFrequency">
<value>TRANSACTION_COMMIT</value>
</property>
<property name="location">
<bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
<constructor-arg>
<value>alfresco/extension/onCreateChild_SetSpacePermission.js</value>
</constructor-arg>
</bean>
</property>
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
</property>
</bean>
</beans>
Create the file onCreateChild_SetSpacePermission.js in extension folder
var nodeRef = behaviour.args[0];
var isNew = behaviour.args[1];
if(isNew)
{
logger.log("LX IsNew");
//If this is not a folder, then just bail out
if(nodeRef.child.isContainer)
{
try {
nodeRef.child.setInheritsPermission(false);
//Set local permissions
nodeRef.child.setPermission("Coordinator", "GROUP_ITGurus");
nodeRef.child.setPermission("Consumer", "GROUP_Managers");
} catch (e) {
//Do nothing about the error, except logg
if (logger.isWarnEnabled()) {
logger.warn("FAILED Setting permission: " +e.description);
}
}
}
}
Of course you can do more test in your javascript code to make sure the folder meets certain criteria, before doing anything. Read more http://wiki.alfresco.com/wiki/3.4_JavaScript_API.11-25-2010 08:44 AM
11-28-2010 08:32 AM
11-28-2010 12:00 PM
var companyhome = search.findNode("path", ['workspace','SpacesStore','app:company_home']);
//Prior 3.4, use this variant
//var companyhome = search.findNode("path", ['workspace','SpacesStore','/']);
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.