cancel
Showing results for 
Search instead for 
Did you mean: 

Managing complex organization

princeali
Champ in-the-making
Champ in-the-making
Hi,

i'm extending the content model and I want to include roles management in the "edit properties" page. So actually, I have two properties whose values correspond to groups. I plan to  make a user who is a member of BOTH these groups, have the consumer rights. Is it possible to do so?

6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
Yes, this is possible. One way to do it would be to define your properties in an aspect, then write a behavior that binds to that aspect. The behavior can check the value of the two properties and then make the associated changes to the permissions.

Jeff

princeali
Champ in-the-making
Champ in-the-making
Ok, thanks Jeff!

I'm trying to implement a basic behavior using javascript but it won't work. Here's my context.xml file:



<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <!– Registration of new models –>
    <bean id="someco.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/model/scModel.xml</value>
            </list>
        </property>
    </bean>
   
   <bean id="managePermissions"
   class="org.alfresco.repo.policy.registration.ClassPolicyRegistration"
   parent="policyRegistration">
      <property name="policyName">
         <value>{http://www.alfresco.org}onUpdateProperties</value>
      </property>
      <property name="className">
         <value>{http://www.someco.com/model/content/1.0}doc</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/managePermissions.js</value>
                  </constructor-arg>
               </bean>
            </property>
         </bean>
      </property>
   </bean>
   
</beans>



My managePermissions.js is like :


var scriptFailed = false;

// Have a look at the behaviour object that should have been passed
if (behaviour == null) {
    logger.log("The behaviour object has not been set.");
    scriptFailed = true;
}

// Check the name of the behaviour
if (behaviour.name == null && behaviour.name != "onUpdateProperties") {
    logger.log("The behaviour name has not been set correctly.");
    scriptFailed = true;
} else {
    logger.log("Behaviour name: " + behaviour.name);
}

// Check the arguments
if (behaviour.args == null) {
    logger.log("The args have not been set.");
    scriptFailed = true;
} else {
    if (behaviour.args.length == 1) {
        var childAssoc = behaviour.args[0];
        logger.log("Calling manage permissions");
      childAssoc.properties["{http://www.alfresco.org/model/content/1.0}description"] = "A definition!";
    } else {
        logger.log("The number of arguments is incorrect.");
        scriptFailed = true;
    }
}


But, when I update the properties using the edit-metadata form, the cm:description won't change.

jpotts
World-Class Innovator
World-Class Innovator
Try adding childAssoc.save() after setting the properties.

Jeff

princeali
Champ in-the-making
Champ in-the-making
I've added childAssoc.save() after setting the properties but it still won't work. I can't even do some debugging due to logger.log not working.

You can check this post for more info http://forums.alfresco.com/forum/developer-discussions/web-scripts/problem-scriptdebugger-04112014-1...

kaynezhang
World-Class Innovator
World-Class Innovator
Add following line to your code
logger.getSystem().out("*****");
,it will print log information on tomcat console .
I doubt if you place your context.xml in the right location and if your js is executed .

princeali
Champ in-the-making
Champ in-the-making
Ok, I found why my script didn't work. The onUpdateProperties behavior has 3 args and not only one.
Now, it works fine. Thanks for your help!