Run the Application
To run the product we must first instantiate an Execution object, optionally specifying runtime parameters to be passed to the process. Then we must call the startExecution function to being the processing.
private static Execution execute(Provisioning provisioning, String sessionId) throws InvalidSessionException, CloudAPIException {
//create an execution for the provisioning
Execution execution = new Execution();
//optionally set any job-specific parameters
execution.setParameters(new Execution.Parameters());
ExecutionParameter executionParameter = new ExecutionParameter();
executionParameter.setKey("recordId");
executionParameter.setValue("abc123xyz");
execution.getParameters().getParameter().add(executionParameter);
//persist the execution
execution = port.createExecution(execution, provisioning.getId(), sessionId);
//start the process execution
port.startExecution(execution.getId(), sessionId);
return execution;
}
Wait for Completion
To track the status of the execution, poll with findExecution.
• If the startTime is null, it has not yet started.
• If the finishTime is null, but the start time is not null, it is executing.
• If the finishTime is not null, the job completed (successfully or unsuccessfully).
while (execution.getFinishTime() == null) {
execution = port.findExecution(execution.getId(), sessionId);
if (execution.getStartTime() != null) {
System.out.println("Execution has started");
} else {
System.out.println("Execution has not yet started");
}
Thread.sleep(10 * 1000);
}
System.out.println("Execution is finished");
Retrieve Log Files
Logs are stored in the log folder under the provisioning folder, with the execution id as the file name. Once the execution is complete, we can download the file for review.
File logFile = new File("C:\\logs\\mylog.txt");
DataHandler logFileHandler = port.getProvisioningFile(provisioning.getId(), "log/" + execution.getId(), sessionId);
OutputStream fos = new FileOutputStream(logFile);
logFileHandler.writeTo(fos);
fos.flush();
fos.close();
Last modified date: 12/17/2021