Again this is Spring magic, i didn't know how to get Spring to update an Array, so I replaced it, but then you must check Alfresco context-xml for each version to check if it changes - dependencies :(
<!-- adds to script-services-context.xml -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="jsonConversionComponent">
<property name="targetObject" >
<ref bean="jsonConversionComponent"/>
</property>
<property name="targetMethod" value="setUserPermissions" />
<property name="arguments">
<list>
<array value-type="java.lang.String">
<!-- Standard ones -->
<value>CancelCheckOut</value>
<value>ChangePermissions</value>
<value>CreateChildren</value>
<value>Delete</value>
<value>Write</value>
<!-- customised ones -->
<value>Finalise</value>
</array>
</list>
</property>
</bean>
This will let Alfresco Share see the CRUD-permission 'Finalise' defined as 'Permission' in the Alfresco Repository Permission Model (extension). Then you can use this in your share-config-custom.xml where your actions now can be dependant on this permission
<action id="...
<permissions>
<permission allow="true">Finalise</permission>
</permissions>
...
</action>
About making custom share actions see here http://blogs.alfresco.com/wp/mikeh/2011/09/26/share-document-library-extensions-in-v4-0/ among others
Friday, November 30, 2012
Thursday, November 29, 2012
Adding custom permissions in Alfresco
If your extending the PermssionModel of Alfresco, you might get an Exception when using the new permission groups .. like:
...
Caused by: java.lang.NullPointerException
at org.alfresco.repo.site.RoleComparatorImpl.compare(RoleComparatorImpl.java:39)
at org.alfresco.repo.site.RoleComparatorImpl.compare(RoleComparatorImpl.java:24)
at java.util.TreeMap.put(TreeMap.java:530)
at java.util.TreeSet.add(TreeSet.java:238)
at org.alfresco.repo.site.SiteServiceImpl.getMembersRole(SiteServiceImpl.java:1717)
...
This is caused by this RoleComparator not knowing the groups. This can be resolved by some spring magic:
<!-- adds to script-services-context.xml -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="siteRoleComparator">
<property name="targetObject">
<util:property-path path="siteRoleComparator.RolePrecedence" />
</property>
<property name="targetMethod" value="putAll" />
<property name="arguments">
<list>
<map key-type="java.lang.String" value-type="java.lang.Integer">
<entry key="User" value="10" />
</map>
</list>
</property>
</bean>
This is an addition to the guides http://keytocontent.blogspot.dk/2011/04/alfresco-share-permissionsroles-part-ii.html and https://wiki.alfresco.com/wiki/Custom_Permissions_in_Share
...
Caused by: java.lang.NullPointerException
at org.alfresco.repo.site.RoleComparatorImpl.compare(RoleComparatorImpl.java:39)
at org.alfresco.repo.site.RoleComparatorImpl.compare(RoleComparatorImpl.java:24)
at java.util.TreeMap.put(TreeMap.java:530)
at java.util.TreeSet.add(TreeSet.java:238)
at org.alfresco.repo.site.SiteServiceImpl.getMembersRole(SiteServiceImpl.java:1717)
...
This is caused by this RoleComparator not knowing the groups. This can be resolved by some spring magic:
<!-- adds to script-services-context.xml -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="siteRoleComparator">
<property name="targetObject">
<util:property-path path="siteRoleComparator.RolePrecedence" />
</property>
<property name="targetMethod" value="putAll" />
<property name="arguments">
<list>
<map key-type="java.lang.String" value-type="java.lang.Integer">
<entry key="User" value="10" />
</map>
</list>
</property>
</bean>
This is an addition to the guides http://keytocontent.blogspot.dk/2011/04/alfresco-share-permissionsroles-part-ii.html and https://wiki.alfresco.com/wiki/Custom_Permissions_in_Share
Monday, October 15, 2012
.. and posting to action afterwards
in continuation of previous post, you can use the form engine to retrieve your properties for current node and post to your action for special handling by using the share action settings:
<param name="mode">create</param>
<param name="submissionUrl">/api/action/ACTION-ID/formprocessor</param>
Where ACTION-ID is the bean action is in the repo, and mode must be create for html id 'alf_destination' which is needed by ActionFormProcessor :)
Best of both worlds, properties retrieved by form framework and action handling ...
<param name="mode">create</param>
<param name="submissionUrl">/api/action/ACTION-ID/formprocessor</param>
Where ACTION-ID is the bean action is in the repo, and mode must be create for html id 'alf_destination' which is needed by ActionFormProcessor :)
Best of both worlds, properties retrieved by form framework and action handling ...
Make Doclib action with a subset of properties for edit
Tested using the 'OnActionFormDialog' for editing properties ...
<action id=".." icon="..." type="javascript" label="...">
<param name="formId">FORM-ID</param>
<param name="function">onActionFormDialog</param>
<param name="itemKind">node</param>
<param name="itemId">{node.nodeRef}</param>
<param name="mode">edit</param>
<param name="destination">{node.nodeRef}</param>
...
Now you can specify a new form with id FORM-ID in your node-type form definition! Now this will not call an action anymore thou ... but will persist your property changes.
<action id=".." icon="..." type="javascript" label="...">
<param name="formId">FORM-ID</param>
<param name="function">onActionFormDialog</param>
<param name="itemKind">node</param>
<param name="itemId">{node.nodeRef}</param>
<param name="mode">edit</param>
<param name="destination">{node.nodeRef}</param>
...
Now you can specify a new form with id FORM-ID in your node-type form definition! Now this will not call an action anymore thou ... but will persist your property changes.
Thursday, October 11, 2012
Ordering forms aspecs and types
The Alfresco Share form can sometimes be tricky, because aspects are configured in one form-config section and the type in another (if you do not duplicate everything for every type). But luckily the order in the form config section matters, and the order in which form-config files are loaded matters. First comes first! So to make an aspect form presentation appear first move in above the type definition and visa versa :)
Wednesday, August 22, 2012
Remember to define title and description for actions in repo/alfresco
If you still use the alfresco web app (JSP repo access), then remember to give your repo actions a property for title and one for description in a bootstraped properties-file/messages.
<action-bean-id>.title=lala
<action-bean-id>.description=lololo
If you don't do this, you will see non-informational exception.
Another version of this issue is provided here: http://stackoverflow.com/questions/21886116/custom-type-not-showing-up-in-rule-config
regarding missing specialise type in content rule config.
<action-bean-id>.title=lala
<action-bean-id>.description=lololo
If you don't do this, you will see non-informational exception.
Another version of this issue is provided here: http://stackoverflow.com/questions/21886116/custom-type-not-showing-up-in-rule-config
regarding missing specialise type in content rule config.
Tuesday, August 14, 2012
Note on share node type evaluator
I noted that using the NodeTypeEvaluator for alfresco share 4.0, the subtypes configuration does not work if your bean configuration does not add DictionaryQuery bean ... no logging :( If you do not add it, the allowSubTypes=true does not work.
Snipplet defining a NodeTypeEvaluator (point in bold)
</list>
</property>
</bean>
Snipplet defining a NodeTypeEvaluator (point in bold)
<bean id="myEvaluator" class="org.alfresco.web.evaluator.c">
<property name="allowSubtypes" value="true" />
<property name="dictionary" ref="slingshot.scriptprocessor.dictionaryQuery" />
<property name="types">
<list>
<value>x:yz</value>
....<property name="allowSubtypes" value="true" />
<property name="dictionary" ref="slingshot.scriptprocessor.dictionaryQuery" />
<property name="types">
<list>
<value>x:yz</value>
</list>
</property>
</bean>
Subscribe to:
Posts (Atom)