//Linea agregada por Oswin Ondarza
String allParams = "";
try {
tools = getActivity().getDefinitionObject().getRelated("WorkflowActivityTool");
} catch (GenericEntityException e) {
throw new WfException(e.getMessage(), e);
}
if (tools == null) {
setComplete(true);
return; // Null tools mean nothing to do (same as route?)
}
if (Debug.verboseOn())
Debug.logVerbose("[WfActivity.runTool] : Running tools (" + tools.size() + ").", module);
List waiters = new ArrayList();
Iterator i = tools.iterator();
while (i.hasNext()) {
GenericValue thisTool = (GenericValue) i.next();
String serviceName = null;
String toolId = thisTool.getString("toolId");
String params = thisTool.getString("actualParameters");
String toolTypeEnumId = thisTool.getString("toolTypeEnumId");
//Linea agregada por Oswin Ondarza
allParams = allParams + "," + params;
String extend = thisTool.getString("extendedAttributes");
Map extendedAttr = StringUtil.strToMap(extend);
if (extendedAttr != null && extendedAttr.containsKey("serviceName"))
serviceName = (String) extendedAttr.get("serviceName");
serviceName = serviceName != null ? serviceName : (toolTypeEnumId.equals("WTT_APPLICATION") ?
"wfActivateApplication" : toolId);
waiters.add(runService(serviceName, params, extend));
}
while (waiters.size() > 0) {
Iterator wi = waiters.iterator();
Collection remove = new ArrayList();
while (wi.hasNext()) {
GenericResultWaiter thw = (GenericResultWaiter) wi.next();
if (thw.isCompleted()) {
Map thwResult = null;
if (thw.status() == GenericResultWaiter.SERVICE_FINISHED) {
thwResult = thw.getResult();
Debug.logVerbose("Service finished.", module);
} else if (thw.status() == GenericResultWaiter.SERVICE_FAILED) {
Debug.logError(thw.getThrowable(), "Service failed", module);
}
if (thwResult != null && thwResult.containsKey(ModelService.RESPONSE_MESSAGE)) {
if (thwResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) {
String errorMsg = (String) thwResult.remove(ModelService.ERROR_MESSAGE);
Debug.logError("Service Error: " + errorMsg, module);
}
thwResult.remove(ModelService.RESPONSE_MESSAGE);
}
try {
if (thwResult != null)
this.setResult(thwResult, allParams);
} catch (IllegalStateException e) {
throw new WfException("Unknown error", e);
}
remove.add(thw);
}
}
waiters.removeAll(remove);