try {
this.config.loadConfiguration(configPath);
} catch (RuntimeException e) {
String message = "Error while reading config file, " + configPath;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-title".equalsIgnoreCase(arg)) {
index++;
this.config.setTitle(args[index]);
} else if ("-workflow".equalsIgnoreCase(arg)) {
index++;
this.config.setWorkflow(args[index]);
} else if ("-gfacURL".equalsIgnoreCase(arg)) {
index++;
String url = args[index];
try {
this.config.setGFacURL(parseURL(url));
} catch (URISyntaxException e) {
String message = "The GFac URL is in wrong format: " + url;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-dscURL".equalsIgnoreCase(arg)) {
index++;
String url = args[index];
try {
this.config.setDSCURL(parseURL(url));
} catch (URISyntaxException e) {
String message = "The DSC URL is in wrong format: " + url;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-startMonitor".equalsIgnoreCase(arg)) {
this.config.setStartMonitor(true);
} else if ("-brokerURL".equalsIgnoreCase(arg)) {
index++;
String brokerURL = args[index];
try {
this.config.setBrokerURL(parseURL(brokerURL));
} catch (URISyntaxException e) {
String message = "The broker URL is in wrong format: " + brokerURL;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-odeEngine".equalsIgnoreCase(arg)) {
index++;
this.config.setOdeURL(args[index]);
} else if ("-templateID".equalsIgnoreCase(arg)) {
index++;
this.config.setWorkflow(args[index]);
} else if ("-topic".equalsIgnoreCase(arg)) {
index++;
this.config.setTopic(args[index]);
} else if ("-pullMode".equalsIgnoreCase(arg)) {
if (index < args.length - 1) {
String nextArg = args[index + 1];
if (nextArg.startsWith("-")) {
this.config.setPullMode(true);
} else if ("true".equalsIgnoreCase(nextArg)) {
index++;
this.config.setPullMode(true);
} else if ("false".equalsIgnoreCase(nextArg)) {
index++;
this.config.setPullMode(false);
} else {
String message = "-pullMode has to be either true or false, not " + nextArg;
logger.warn(message);
this.config.addError(new WorkflowException(message));
}
} else {
// This is the last arg
this.config.setPullMode(true);
}
} else if ("-messageBoxURL".equalsIgnoreCase(arg) || "-msgBoxURL".equalsIgnoreCase(arg)) {
index++;
String messageBoxURL = args[index];
try {
this.config.setMessageBoxURL(parseURL(messageBoxURL));
} catch (URISyntaxException e) {
String message = "The message box URL is in wrong format: " + messageBoxURL;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-registryURL".equalsIgnoreCase(arg)) {
index++;
String registryURL = args[index];
try {
this.config.setRegistryURL(parseURL(registryURL));
} catch (URISyntaxException e) {
String message = "The message box URL is in wrong format: " + registryURL;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-registryUserName".equalsIgnoreCase(arg)) {
index++;
this.config.setRegigstryUserName(args[index]);
} else if ("-registryPassphrase".equalsIgnoreCase(arg)) {
index++;
this.config.setRegistryPassphrase(args[index]);
} else if ("-width".equalsIgnoreCase(arg)) {
index++;
String width = args[index];
try {
this.config.setWidth(Integer.parseInt(width));
} catch (NumberFormatException e) {
String message = "The width must be an integer: " + width;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-height".equalsIgnoreCase(arg)) {
index++;
String height = args[index];
try {
this.config.setHeight(Integer.parseInt(height));
} catch (NumberFormatException e) {
String message = "The height must be an integer: " + height;
logger.warn(message, e);
this.config.addError(new WorkflowException(message, e));
}
} else if ("-exitOnClose".equalsIgnoreCase(arg)) {
index++;
String exit = args[index];
if ("false".equalsIgnoreCase(exit)) {
this.config.setCloseOnExit(false);
}
} else if ("-enableProvenance".equalsIgnoreCase(arg)) {
index++;
String exit = args[index];
if ("true".equalsIgnoreCase(exit)) {
this.config.setCollectProvenance(true);
}
} else if ("-enableProvenanceSmartRun".equalsIgnoreCase(arg)) {
index++;
String exit = args[index];
if ("true".equalsIgnoreCase(exit)) {
this.config.setProvenanceSmartRun(true);
}
} else if ("-runWithCrossProduct".equalsIgnoreCase(arg)) {
index++;
String exit = args[index];
if ("false".equalsIgnoreCase(exit)) {
this.config.setRunWithCrossProduct(false);
}
} else if ("-mode".equalsIgnoreCase(arg)) {
index++;
String modeValue = args[index].toUpperCase();
this.config.setXbayaExecutionMode(XBayaExecutionMode.valueOf(modeValue));
} else if ("-x".equalsIgnoreCase(arg)) {
index++;
this.config.setX(Integer.parseInt(args[index]));
} else if ("-y".equalsIgnoreCase(arg)) {
index++;
this.config.setY(Integer.parseInt(args[index]));
} else {
String message = "Unknown option: " + arg;
logger.error(message);
this.config.addError(new WorkflowException(message));
}
this.config.setJcrComponentRegistry(new JCRComponentRegistry(this.config.getRegistryUserName(),this.config.getRegistryPassphrase()));
index++;
}
} catch (ArrayIndexOutOfBoundsException e) {
String message = "Argument is missing after " + args[args.length - 1];
logger.error(message, e);
this.config.addError(new WorkflowException(message));
} catch (Throwable e) {
logger.error(e.getMessage(), e);
String message = "Unknown error while parsing the arguments";
this.config.addError(new WorkflowException(message, e));
}
}