cancel
Showing results for 
Search instead for 
Did you mean: 

Create a rule in Java?

future_healthca
Champ in-the-making
Champ in-the-making
Hi everyone,

I am trying to connect to RuntimeAPI of my bonita server via alfresco when a file is uploaded to a folder to launch a certain process in it.

I saw that we can make a rule in javascript when files are uploaded to a folder. But to connect to bonita i dunno if is possible or how to do it in js.
We can make a rule that runs in Java / Groovy?

If not does any of u had a clue how can i connect to bonita with a rule ?

Thank you.
4 REPLIES 4

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

You can write a Custom Javascript api implented in Java.

That method/api can be called in javscript and add it as a rule.
You can find Information about Adding Custom Script APIs here
http://wiki.alfresco.com/wiki/4.0_JavaScript_API#Adding_Custom_Script_APIs

mrogers
Star Contributor
Star Contributor
In Java its perhaps easiest to create a policy/behaviour.   Its what the rule service uses underneath the covers.

future_healthca
Champ in-the-making
Champ in-the-making
Hi,

You can write a Custom Javascript api implented in Java.

That method/api can be called in javscript and add it as a rule.
You can find Information about Adding Custom Script APIs here
http://wiki.alfresco.com/wiki/4.0_JavaScript_API#Adding_Custom_Script_APIs

Thanks lementree.

Following you link i found  this example that i believe is what i want to do (put javascriptAPI calling some class in JavaAPI):
http://wiki.alfresco.com/wiki/Configuring_the_ServiceRegistry_as_a_Javascript_Root_Object

I just have one small doubt, where (in what folder) do i place that class i created and what xmls must contain the bean in the given example?

By exploring the folders i think the bean must be placed here: Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\script-services-context.xml.

The Javascript code i the alfresco repository named Scrips?

Now the Java code i have no clue… Smiley Frustrated

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

You can [ut those class files with the package folder structure in tomcat/webapps/alfresco/WEB-INF/classes.

To map the webscript with the java class you need to add a xml file in tomcat/shared/classes/alfresco/extension

<?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="loggerScript" parent="baseJavaScriptExtension" class="com.reva.service.JsonPdfRendition">
  <property name="extensionName">
   <value>JsonPdfRendition</value>
  </property>
</bean>
</beans>