behaviourFilter.disableBehaviour in JavaScript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2014 09:14 AM
How can I do the behaviour disable in javascript as it is
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
in Java.
Thanks
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2014 09:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2014 01:23 PM
Have tried to provide you the steps at high-level below.
1. Create a java class which extends BaseProcessorExtension
2. Register the class in your context.xml
<bean id="myjscriptbean" parent="baseJavaScriptExtension" class="com.my.jscript"> <property name="extensionName"> <value>myjscript</value> </property> <property name="behaviourFilter" ref="policyBehaviourFilter" /> <!– you may inject other required services if you want –> </bean>
3. In your java class, create public method and inside that method, perform behaviourFilter.disableBehaviour.
4. From the javascript, invoke the method using myjscript.methodname.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2014 10:04 PM
Having said that there is a sneaky way of doing this with pure JavaScript if your script is part of a web script. JavaScript run from a web script that is loaded from the classpath has elevated permissions compared to a web script that is run with the execute script action or that is loaded from the repository. Also, if this is a regular script and you execute it from the JavaScript Console (see Share Extras on GitHub), you will also get the elevated security. With the elevated security you have access to the Package "root object" that Rhino makes available; with this you can do things like:
var foo = new Package.java.io.File("test.txt");
now you have a JavaScript object foo that can access the Java File object you just constructed. Given this insight you can get a handle on the Alfresco Spring Application Context. From that you can obtain the bean named policyBehaviourFilter. From there you can call the disableBehaviour() method.
I plan to show details of how to do this exact thing in my talk at summit this year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2014 03:45 AM
I've already tried that and it didn't work. I've created a topic in the french forum about that:
https://forums.alfresco.com/fr/forum/d%C3%A9veloppement/d%C3%A9veloppement-autour-dalfresco/d%C3%A9s...
I've also tried to create a new action based on "executeScript": it doesn't work neither.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2014 03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2014 05:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2014 07:58 AM
I am not sure what you have tried did not work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2016 09:02 AM
Can we go a little more low level.
I've been trying to create a javascript extension as Romschn adviced but I can't figure out how to deploy my Java Class and the Bean.
Can we have some documentation or some step on how to achieve this, I'm sure it's not something to complicated.
Thanks guys,
Bert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2016 11:28 AM
To do a custom root object, or javascript api extension you need to create an AMP file. ( And it's the only way according to what I read in alfresco documentation ).
To create an amp use the following maven command :
mvn archetype:generate -Dfilter=org.alfresco:
Pick option 1
then
You need to add your Java file at the path
/src/main/java of your amp folder previously generated
then add the service-context at
src/main/amp/config/alfresco/module/repo-amp/context/service-context.xml
You can build your amp using the command
mvn clean install
—————-
Go to target, get your amp file freshly created and upload it on your server at <your_alfresco_install> (often /opt/alfresco-share/) copy in /amps
Execute bin/apply_amps.sh
Then execute alfreso.sh restart
There you go

Here are the two best link to my opinion to understand how it works :
How to create the amp : http://docs.alfresco.com/5.1/tasks/alfresco-sdk-tutorials-share-amp-archetype.html
How to modify/custom the amp : http://docs.alfresco.com/5.1/references/dev-extension-points-javascript-root-objects.html
For the runAS : https://shahpritesh.wordpress.com/2013/07/17/run-javascript-function-as-admin-privileges/comment-pag...
Good luck everyone !
