<workflow-app name="Orcid Download" xmlns="uri:oozie:workflow:0.5">
    <parameters>
        <property>
            <name>workingPathOrcid</name>
            <description>the working dir base path</description>
        </property>
        <property>
            <name>token</name>
            <description>access token</description>
        </property>
    </parameters>
    
    <start to="ResetWorkingPath"/>
    
    
    <kill name="Kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    
    <action name="ResetWorkingPath">
        <fs>
            <delete path='${workingPathOrcid}/download'/>
            <mkdir path='${workingPathOrcid}/download'/>
        </fs>
        <ok to="DownloadOrcidData"/>
        <error to="Kill"/>
    </action>
	
	<action name="DownloadOrcidData">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidDownloader</main-class>
            <arg>-d</arg><arg>${workingPathOrcid}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>last_modified.csv</arg>
            <arg>-o</arg><arg>download/</arg>
            <arg>-t</arg><arg>${token}</arg>
        </java>
        <ok to="End"/>
        <error to="Kill"/>
    </action>
    
   <end name="End"/>
</workflow-app>