UCSD - Example of running Java Script (Custom Workflow Task) from Command line for rapid testing

Version 3

    This is an example on how to run a custom workflow task (some modifications are necessary) from the command line for rapid custom task testing.

     

    Big thank you goes to

              Russ Whitear and James Spurin

     

    Tested on UCSD 6.0 (other versions may require jar file updates)

     

    1) SSH to the UCSD instance (root)

    2) It is important to be in the correct directory (cd /opt/infra/inframgr)

    3) Test file:


     

    [root@localhost inframgr]# cat /tmp/a

    //----------------------------------------------------------------------------------------

    // Load the Nashorn Engine, remove when uploading to UCSD

    load("nashorn:mozilla_compat.js");

    //----------------------------------------------------------------------------------------

    importPackage(java.io);

    importPackage(java.util);

    importPackage(com.cloupia.model.cEvent.notify);

    importPackage(com.cloupia.model.cIM);

    importPackage(com.cloupia.lib.util.mail);

    importPackage(com.cloupia.fw.objstore);

    importPackage(java.lang);

    importPackage(com.cloupia.service.cIM.inframgr);

     

     

    //----------------------------------------------------------------------------------------

    // Create the context usually created by UCSD, remove when passing to UCSD, disable

    // entries that use input.property

    //----------------------------------------------------------------------------------------

    importPackage(com.cloupia.service.cIM.inframgr.customactions)

    ctx = new CustomActionTriggerContext()

     

    var target = "www.cisco.com"

    var uri = "/getmystuff/lala"

    //----------------------------------------------------------------------------------------

    //var target = input.target;

    //var uri = input.uri;

     

     

    logger = new CustomActionLogger(ctx)

    var a=123;

    logger.addInfo("****************"+a+"*********");

    ar = new BufferedWriter(new FileWriter("/tmp/b.txt",true));

    ar.write("Varaibale " + a +"\r\n");

    ar.flush();

    ar.close();

     

     

    4) Execution (yes rather long, but notice /tmp/a is at the end of this long line):

     

     

    /opt/bin/jre/bin/jjs -cp .:inframgr.jar:google-gson.jar:ruby-gems-1.1.jar:java-xmlbuilder-0.6.jar:vmguest.jar:vim25-wsdl.jar:vijava60compat.jar:vijava55b20130927.jar:ssoclient-wsdl.jar:srm.jar:pbm-wsdl.jar:jaxen-1.1-beta-6.jar:dom4j-1.6.1.jar:velocity-1.6.2.jar:velocity-1.6.2-dep.jar:jclouds-vcloud-1.0-beta-7.jar:jclouds-terremark-1.0-beta-7.jar:jclouds-scriptbuilder-1.0-SNAPSHOT.jar:jclouds-log4j-1.0-beta-7.jar:jclouds-jsch-1.0-beta-7.jar:jclouds-core-1.0-beta-7-jar-with-dependencies.jar:jclouds-compute-1.0-beta-7.jar:vcloud-java-sdk-1.5.0.jar:rest-api-schemas-1.5.0.jar:syslog4j-0.9.43-bin.jar:maverick-all.jar:pd_ipc_server.jar:nesla-1.1.jar:libthrift-0.9.1.jar:jruby-complete-1.7.9.jar:javax.ws.rs-api-2.0.1.jar:javax.inject-2.3.0-b10.jar:javax.annotation-api-1.2.jar:gch_client.jar:aopalliance-repackaged-2.3.0-b10.jar:xalan-2.7.0.jar:trustpool.jar:quartz-2.1.7.jar:gch_server.jar:bcprov-jdk15on-151.jar:bcpkix-jdk15on-151.jar:slf4j-log4j12-1.7.6.jar:slf4j-api-1.7.6.jar:ant-1.8.4.jar:ss_css2.jar:pd4ml.jar:ojdbc14.jar:classes12.jar:manageontap-5.3.1.jar:mysql-connector-java-5.1.24-bin.jar:mongo-java-driver-2.11.3.jar:log4j-1.2.15.jar:jxl.jar:junit-4.9b2.jar:jsoup-1.7.3.jar:json-lib.jar:jackson-databind-2.8.0.jar:jackson-core-2.8.0.jar:jackson-annotations-2.8.0.jar:jackson-all-1.9.5.jar:jsch-0.1.45.jar:jfreechart-1.0.13.jar:jcommon-1.0.16.jar:jdepend-2.9.jar:smtp.jar:mailapi.jar:javassist.jar:jade.jar:jssc.jar:guava-15.0.jar:google-gson.jar:flexlm.jar:Vendor_info.jar:EccpressoAll.jar:ehcache-core-2.6.6.jar:aws-java-sdk-1.4.3.jar:jdo2-api-2.3-eb.jar:datanucleus-rdbms-4.1.0-release.jar:datanucleus-core-4.1.0-release.jar:datanucleus-cache-4.0.4.jar:datanucleus-api-jdo-4.1.0-release.jar:asm-5.0.4.jar:ucsd-rest-api-sdk-v2.jar:cuic-client.jar:bonecp-0.8.0.RELEASE.jar:servlet-api.jar:commons-validator-1.4.0.jar:commons-pool-1.6.jar:commons-pool-1.3.jar:commons-net-3.1.jar:commons-logging-1.1.jar:commons-lang3-3.1.jar:commons-lang-2.5.jar:commons-io-2.0.1.jar:commons-dbcp-1.4.jar:commons-configuration-1.10.jar:commons-compress-1.9.jar:commons-logging-1.1.jar:httpmime-4.2.2.jar:httpcore-4.3.2.jar:httpclient-osgi-4.3.jar:httpclient-4.3.2.jar:commons-httpclient-3.1.jar:commons-codec-1.9.jar:wsdl4j-1.5.1.jar:saaj.jar:jaxrpc.jar:commons-logging-1.0.4.jar:commons-discovery.jar:commons-discovery-0.2.jar:axis.jar:XmlSchema-1.4.3.jar:xalan.jar:serializer.jar:commons-logging.jar:commons-httpclient-3.0.1.jar:stax-api-1.0.jar:jaxb-api-2.0.jar:geronimo-jta_1.0.1B_spec-1.0.1.jar:geronimo-jms_1.1_spec-1.1.1.jar:geronimo-j2ee-management_1.0_spec-1.0.jar:commons-logging-1.1.jar:activemq-jaas-5.2.0.jar:activemq-core-5.2.0.jar:activemq-all-5.13.2.jar:activation-1.1.jar:vision-api-2.5.3.0.jar:iControl.jar /tmp/a



    5)RUN (very similar to step #4, just trying to show the prompt return)


     

    [root@localhost inframgr]# /opt/bin/jre/bin/jjs -cp .:inframgr.jar:google-gson.jar:ruby-gems-1.1.jar:java-xmlbuilder-0.6.jar:vmguest.jar:vim25-wsdl.jar:vijava60compat.jar:vijava55b20130927.jar:ssoclient-wsdl.jar:srm.jar:pbm-wsdl.jar:jaxen-1.1-beta-6.jar:dom4j-1.6.1.jar:velocity-1.6.2.jar:velocity-1.6.2-dep.jar:jclouds-vcloud-1.0-beta-7.jar:jclouds-terremark-1.0-beta-7.jar:jclouds-scriptbuilder-1.0-SNAPSHOT.jar:jclouds-log4j-1.0-beta-7.jar:jclouds-jsch-1.0-beta-7.jar:jclouds-core-1.0-beta-7-jar-with-dependencies.jar:jclouds-compute-1.0-beta-7.jar:vcloud-java-sdk-1.5.0.jar:rest-api-schemas-1.5.0.jar:syslog4j-0.9.43-bin.jar:maverick-all.jar:pd_ipc_server.jar:nesla-1.1.jar:libthrift-0.9.1.jar:jruby-complete-1.7.9.jar:javax.ws.rs-api-2.0.1.jar:javax.inject-2.3.0-b10.jar:javax.annotation-api-1.2.jar:gch_client.jar:aopalliance-repackaged-2.3.0-b10.jar:xalan-2.7.0.jar:trustpool.jar:quartz-2.1.7.jar:gch_server.jar:bcprov-jdk15on-151.jar:bcpkix-jdk15on-151.jar:slf4j-log4j12-1.7.6.jar:slf4j-api-1.7.6.jar:ant-1.8.4.jar:ss_css2.jar:pd4ml.jar:ojdbc14.jar:classes12.jar:manageontap-5.3.1.jar:mysql-connector-java-5.1.24-bin.jar:mongo-java-driver-2.11.3.jar:log4j-1.2.15.jar:jxl.jar:junit-4.9b2.jar:jsoup-1.7.3.jar:json-lib.jar:jackson-databind-2.8.0.jar:jackson-core-2.8.0.jar:jackson-annotations-2.8.0.jar:jackson-all-1.9.5.jar:jsch-0.1.45.jar:jfreechart-1.0.13.jar:jcommon-1.0.16.jar:jdepend-2.9.jar:smtp.jar:mailapi.jar:javassist.jar:jade.jar:jssc.jar:guava-15.0.jar:google-gson.jar:flexlm.jar:Vendor_info.jar:EccpressoAll.jar:ehcache-core-2.6.6.jar:aws-java-sdk-1.4.3.jar:jdo2-api-2.3-eb.jar:datanucleus-rdbms-4.1.0-release.jar:datanucleus-core-4.1.0-release.jar:datanucleus-cache-4.0.4.jar:datanucleus-api-jdo-4.1.0-release.jar:asm-5.0.4.jar:ucsd-rest-api-sdk-v2.jar:cuic-client.jar:bonecp-0.8.0.RELEASE.jar:servlet-api.jar:commons-validator-1.4.0.jar:commons-pool-1.6.jar:commons-pool-1.3.jar:commons-net-3.1.jar:commons-logging-1.1.jar:commons-lang3-3.1.jar:commons-lang-2.5.jar:commons-io-2.0.1.jar:commons-dbcp-1.4.jar:commons-configuration-1.10.jar:commons-compress-1.9.jar:commons-logging-1.1.jar:httpmime-4.2.2.jar:httpcore-4.3.2.jar:httpclient-osgi-4.3.jar:httpclient-4.3.2.jar:commons-httpclient-3.1.jar:commons-codec-1.9.jar:wsdl4j-1.5.1.jar:saaj.jar:jaxrpc.jar:commons-logging-1.0.4.jar:commons-discovery.jar:commons-discovery-0.2.jar:axis.jar:XmlSchema-1.4.3.jar:xalan.jar:serializer.jar:commons-logging.jar:commons-httpclient-3.0.1.jar:stax-api-1.0.jar:jaxb-api-2.0.jar:geronimo-jta_1.0.1B_spec-1.0.1.jar:geronimo-jms_1.1_spec-1.1.1.jar:geronimo-j2ee-management_1.0_spec-1.0.jar:commons-logging-1.1.jar:activemq-jaas-5.2.0.jar:activemq-core-5.2.0.jar:activemq-all-5.13.2.jar:activation-1.1.jar:vision-api-2.5.3.0.jar:iControl.jar /tmp/a

    [root@localhost inframgr]#


    6)Result:

     

    [root@localhost inframgr]# cat /tmp/b.txt

    Varaibale 123

    Varaibale 123

     

    [root@localhost inframgr]#