cancel
Showing results for 
Search instead for 
Did you mean: 

run ant build from web client action

davidheijl
Champ in-the-making
Champ in-the-making
Hey all

how can I realise this user experience:
- working in a space, view a specific file's details.
- i pick an action "publish to …<format>"
- this action runs an ant build target (i have the whole ant side set up and working)

so i guess my question is: how can i run the ant command (do i need to this with java or can i use a javascript with new web scripts)? i know how to add the action to the ui in the webclient, but as from there… any pointers would be welcome!

david
5 REPLIES 5

gavinc
Champ in-the-making
Champ in-the-making
You will have to use Java to accomplish this.

You have 2  methods of calling Ant, either using the native Ant Java object or calling the Ant script via Runtime.exec(), both of which will need to be done via Java.

I would question why you're using Ant though, it would be preferable to try and do whatever the Ant script is doing in Java as there is going to be a lot of overhead in calling out to Ant.

If you need to however, I'd suggest taking a look at the Ant documentation to see how the Ant process is invoked: http://ant.apache.org/manual/running.html#viajava

davidheijl
Champ in-the-making
Champ in-the-making
hi gavin,

thanks for the reply. I kind of figured this was going to need Java. I spotted an example of someone doing a Runtime.exec() approach elsewhere on the forum, but I'm not entirely sure what the different steps would be.

As for why I want to do this: I'd like to publish DITA xml documents in an Alfresco space using the DITA open toolkit, which is essentially an ant-managed chain of xslt transformations. To rebuild this chain of transformations in Java would be quite a daunting challenge, I fear.

Let's say that I do want to go with the Runtime.exec() approach, what elements would I need to create? could you give me some step by step pointers?

thanks

david

davidheijl
Champ in-the-making
Champ in-the-making
ok, now this is purely because i'm not entirely sure how the whole jsf and beans framework works, but i'm not getting something 😞

let's say i have a bean defined as follows:

<bean id="transformer.dita-xml.eclipse"
class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer"
parent="baseContentTransformer">
<property name="transformCommand">
<bean class="org.alfresco.util.exec.RuntimeExec">
<property name="commandMap">
<map>
<entry key="Windows.*">
<value>D:\DITA-OT1.3.1\ant -f build_custom.xml mycompany.mydocument.eclipse</value>
</entry>
</map>
</property>
<property name="errorCodes">
<value>2</value>
</property>
</bean>
</property>
<property name="explicitTransformations">
<list>
<bean class="org.alfresco.repo.content.transform.ContentTransformerRegistry$TransformationKey" >
<constructor-arg><value>text/xml</value></constructor-arg>
<constructor-arg><value>text/xml</value></constructor-arg>
</bean>
</list>
</property>
</bean>

in which file do i store this code? what else do i need to do to be able to call on this transformation from an action link in the web client?
i have the following custom action set up but obviously there's something wrong with my action-listener code.

<actions>
      <!– Run the DITA OT –>
      <action id="run_DITA_transform">
        <label>Publish DITA to Eclipse</label>
        <image>/images/icons/create_webapp.gif</image>
        <action-listener>#{transformer.dita-xml.eclipse}</action-listener>
      </action>
     
      <action-group id="doc_details_actions">
        <action idref="run_DITA_transform" />
      </action-group>
    </actions>

help!

gavinc
Champ in-the-making
Champ in-the-making
You actually need to create a custom action not a transformation, see this wiki page on creating a custom action: http://wiki.alfresco.com/wiki/Custom_Actions

The bottom of that page also has a link to http://wiki.alfresco.com/wiki/Custom_Action_UI which will tell you how to add the action to the UI.

davidheijl
Champ in-the-making
Champ in-the-making
thanks gavin! i'll certainly try that - as soon as I get back from my holidays 🙂