hi, i wonder if there is some "Alfresco way" like some xml configuration to invoke the command line shell for some actions.
For example i have a executable jar i foo.jar, there is way in the xml configuration of alfresco to invoke the command "java -jar foo.jar" like i already do for some tranformer ?
Here a example with the tranformers :
<bean id="transformer.worker.p7s2doc" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>java -version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>java -version</value>
</list>
</entry>
</map>
</property>
<!-- Error codes unknown -->
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>java -jar foo.jar ${source} ${target}</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>java -jar foo.jar ${source} ${target}</value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
<!-- Error codes unknown -->
</bean>
</property>
</bean>
It's possible do a similar thing with actions ?
Solved! Go to Solution.
In general, you can not.
You can only use as shell comands those that depend on external linux commands, which is the method used for some simple extensions.
Regards.
--C.
In general, you can not.
You can only use as shell comands those that depend on external linux commands, which is the method used for some simple extensions.
Regards.
--C.
Actions are just Java classes, so if you need to invoke a Java class from an action, write an Action using Java that invokes the public methods in the Java class. (In other words, it doesn't make sense to do "java -jar" from an Action because you are already in Java.)
If you really just want to run shell commands from an Action, then write an Action using Java that uses the Runtime and Process classes to do that. Note that there are many reasons you should think twice before doing something like that, not the least of which is the security implications and the reduced portability of your code.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.