Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8985

Re: Importing from command prompt - no error code

$
0
0

Hi Nanda,

 

Here is an example:

 

 

import com.redwood.scheduler.api.tool.ToolConnection;

import com.redwood.scheduler.api.tool.ToolConnectionFactory;

import java.io.File;

import java.util.Collection;

import java.util.Map;

 

public class Uploader

{

  public static void main(String [] args)

  throws Exception

  {

  if (args.length > 1)

  {

  ToolConnection tConnection = ToolConnectionFactory.createConnection(args[0], 60000);

 

  if (args[1].toLowerCase().endsWith("car"))

  {

  System.out.println("Uploading CAR file");

  String importSet = "";

  if(args.length == 3)

  {

  importSet = args[2];

  }

  Map mp = tConnection.uploadCAR(new File(args[1]), importSet);

 

  if (mp.size() > 0)

  {

  Collection cl = mp.values();

  System.out.println("JobId: "+cl.iterator().next());

  }

  }

  else if (args[1].toLowerCase().endsWith("jar")&& args.length == 3)

  {

  System.out.println("Uploading JAR file");

  Map mp = tConnection.uploadJAR(new File(args[1]), args[2]);

 

  if (mp.size() > 0)

  {

  Collection cl = mp.values();

  System.out.println("JobId: "+cl.iterator().next());

  }

  }

  else

  {

  System.out.println("Invalid Arguments.");

  System.out.println("Usage: Main <connection_file> <car_file> [<importRuleSet>]");

  System.out.println(" Main <connection_file> <jar_file> <library>");

  }

 

  }

  else

  {

  System.out.println("Invalid Arguments.");

  System.out.println("Usage: Main <connection_file> <car_file> [<importRuleSet>]");

  System.out.println(" Main <connection_file> <jar_file> <library>");

  }

  }

}

 

Hope this helps.

 

After the tConnection.uploadCAR() I use the map to retrieve the job id, with that you could then check whether the JobStatusState is final or not every 10 seconds in a loop ... Depending on the size of the CAR files, you might want to increase that. If you are going to push CAR files with, say, 1000 objects, the time the job runs to import the car file can be quite long, several minutes ...

 

How to compile and run it:

 

$ javac -cp api-tool.jar Uploader.java

$ java -cp api-tool.jar:. Uploader <------- HERE I run it without arguments, so the program prints out which arguments it needs

Invalid Arguments.

Usage: Uploader <connection_file> <car_file> [<importRuleSet>]

  Uploader <connection_file> <jar_file> <library>

$ java -cp api-tool.jar:. Uploader net/connect.rw /tmp/JobDefinition_RS_MSLN_DB_Backup.car

$ java -cp api-tool.jar:. Uploader net/connect.rw /tmp/myJar.jar Custom_Masalan

 

Hope that helps ...

 

Regards,

 

HP


Viewing all articles
Browse latest Browse all 8985

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>