Map resultToResult = new HashMap();
public CallService(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
serviceName = element.getAttribute("service-name");
inMapAcsr = new ContextAccessor(element.getAttribute("in-map-name"));
includeUserLoginStr = element.getAttribute("include-user-login");
breakOnErrorStr = element.getAttribute("break-on-error");
errorCode = element.getAttribute("error-code");
if (errorCode == null || errorCode.length() == 0) errorCode = "error";
this.requireNewTransactionStr = element.getAttribute("require-new-transaction");
String timeoutStr = UtilXml.checkEmpty(element.getAttribute("transaction-timeout"), element.getAttribute("transaction-timout"));
int timeout = -1;
if (!UtilValidate.isEmpty(timeoutStr)) {
try {
timeout = Integer.parseInt(timeoutStr);
} catch (NumberFormatException e) {
Debug.logWarning(e, "Setting timeout to 0 (default)", module);
timeout = 0;
}
}
this.transactionTimeout = timeout;
successCode = element.getAttribute("success-code");
if (successCode == null || successCode.length() == 0) successCode = "success";
errorPrefix = new FlexibleMessage(UtilXml.firstChildElement(element, "error-prefix"), "service.error.prefix");
errorSuffix = new FlexibleMessage(UtilXml.firstChildElement(element, "error-suffix"), "service.error.suffix");
successPrefix = new FlexibleMessage(UtilXml.firstChildElement(element, "success-prefix"), "service.success.prefix");
successSuffix = new FlexibleMessage(UtilXml.firstChildElement(element, "success-suffix"), "service.success.suffix");
messagePrefix = new FlexibleMessage(UtilXml.firstChildElement(element, "message-prefix"), "service.message.prefix");
messageSuffix = new FlexibleMessage(UtilXml.firstChildElement(element, "message-suffix"), "service.message.suffix");
defaultMessage = new FlexibleMessage(UtilXml.firstChildElement(element, "default-message"), "service.default.message");
List resultsToMapElements = UtilXml.childElementList(element, "results-to-map");
if (resultsToMapElements != null && resultsToMapElements.size() > 0) {
Iterator iter = resultsToMapElements.iterator();
while (iter.hasNext()) {
Element resultsToMapElement = (Element) iter.next();
resultsToMap.add(resultsToMapElement.getAttribute("map-name"));
}
}
List resultToFieldElements = UtilXml.childElementList(element, "result-to-field");
if (resultToFieldElements != null && resultToFieldElements.size() > 0) {
Iterator iter = resultToFieldElements.iterator();
while (iter.hasNext()) {
Element resultToFieldElement = (Element) iter.next();
ResultToFieldDef rtfDef = new ResultToFieldDef();
rtfDef.resultName = resultToFieldElement.getAttribute("result-name");
rtfDef.mapAcsr = new ContextAccessor(resultToFieldElement.getAttribute("map-name"));
rtfDef.fieldAcsr = new ContextAccessor(resultToFieldElement.getAttribute("field-name"), rtfDef.resultName);
resultToField.add(rtfDef);
}
}
// get result-to-request and result-to-session sub-ops
List resultToRequestElements = UtilXml.childElementList(element, "result-to-request");
if (resultToRequestElements != null && resultToRequestElements.size() > 0) {
Iterator iter = resultToRequestElements.iterator();
while (iter.hasNext()) {
Element resultToRequestElement = (Element) iter.next();
FlexibleServletAccessor reqAcsr = new FlexibleServletAccessor(resultToRequestElement.getAttribute("request-name"), resultToRequestElement.getAttribute("result-name"));
ContextAccessor resultAcsr = new ContextAccessor(resultToRequestElement.getAttribute("result-name"));
resultToRequest.put(reqAcsr, resultAcsr);
}
}
List resultToSessionElements = UtilXml.childElementList(element, "result-to-session");
if (resultToSessionElements != null && resultToSessionElements.size() > 0) {
Iterator iter = resultToSessionElements.iterator();
while (iter.hasNext()) {
Element resultToSessionElement = (Element) iter.next();
FlexibleServletAccessor sesAcsr = new FlexibleServletAccessor(resultToSessionElement.getAttribute("session-name"), resultToSessionElement.getAttribute("result-name"));
ContextAccessor resultAcsr = new ContextAccessor(resultToSessionElement.getAttribute("result-name"));
resultToSession.put(sesAcsr, resultAcsr);
}
}
List resultToResultElements = UtilXml.childElementList(element, "result-to-result");
if (resultToResultElements != null && resultToResultElements.size() > 0) {
Iterator iter = resultToResultElements.iterator();
while (iter.hasNext()) {
Element resultToResultElement = (Element) iter.next();
ContextAccessor serResAcsr = new ContextAccessor(resultToResultElement.getAttribute("service-result-name"), resultToResultElement.getAttribute("result-name"));
ContextAccessor resultAcsr = new ContextAccessor(resultToResultElement.getAttribute("result-name"));
resultToResult.put(serResAcsr, resultAcsr);
}
}
}