try {
cad.addNewCreateActivity().addNewActivityDocument()
.setJobDefinition(JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition());
} catch (Exception e1) {
throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
}
FactoryClient factory = null;
try {
factory = new FactoryClient(eprt, secProperties);
} catch (Exception e) {
throw new GFacProviderException("");
}
CreateActivityResponseDocument response = null;
try {
log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
response = factory.createActivity(cad);
log.info(String.format("Activity Submitted to %s \n", factoryUrl));
} catch (Exception e) {
e.printStackTrace();
throw new GFacProviderException("Cannot create activity.", e);
}
EndpointReferenceType activityEpr = response
.getCreateActivityResponse().getActivityIdentifier();
log.debug("Activity EPR: "+activityEpr);
log.info("Activity: "+activityEpr.getAddress().getStringValue()+ " Submitted.");
//factory.waitWhileActivityIsDone(activityEpr, 1000);
jobId = WSUtilities.extractResourceID(activityEpr);
if (jobId == null) {
jobId = new Long(Calendar.getInstance().getTimeInMillis())
.toString();
}
log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), factory.getActivityStatus(activityEpr)
.toString()));
//TODO publish the status messages to the message bus
while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
(factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
ActivityStatusType activityStatus = null;
try {
activityStatus = getStatus(factory, activityEpr);
log.info (subStatusAsString(activityStatus));
} catch (UnknownActivityIdentifierFault e) {
throw new GFacProviderException(e.getMessage(), e.getCause());
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
continue;
}
ActivityStatusType activityStatus = null;
try {
activityStatus = getStatus(factory, activityEpr);
} catch (UnknownActivityIdentifierFault e) {
throw new GFacProviderException(e.getMessage(), e.getCause());
}
log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {