return buf.toString();
}
public boolean eval(String serviceName, DispatchContext dctx, Map<String, Object> context) throws GenericServiceException {
if (serviceName == null || dctx == null || context == null || dctx.getClassLoader() == null) {
throw new GenericServiceException("Cannot have null Service, Context or DispatchContext!");
}
if (Debug.verboseOn()) Debug.logVerbose(this.toString() + ", In the context: " + context, module);
// condition-service; run the service and return the reply result
if (isService) {
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> conditionServiceResult = dispatcher.runSync(conditionService,
UtilMisc.<String, Object>toMap("serviceContext", context, "serviceName", serviceName,
"userLogin", context.get("userLogin")));
Boolean conditionReply = Boolean.FALSE;
if (ServiceUtil.isError(conditionServiceResult)) {
Debug.logError("Error in condition-service : " +
ServiceUtil.getErrorMessage(conditionServiceResult), module);
} else {
conditionReply = (Boolean) conditionServiceResult.get("conditionReply");
}
return conditionReply.booleanValue();
}
Object lhsValue = null;
Object rhsValue = null;
if (UtilValidate.isNotEmpty(lhsMapName)) {
try {
if (context.containsKey(lhsMapName)) {
Map<String, ? extends Object> envMap = UtilGenerics.checkMap(context.get(lhsMapName));
lhsValue = envMap.get(lhsValueName);
} else {
Debug.logWarning("From Map (" + lhsMapName + ") not found in context, defaulting to null.", module);
}
} catch (ClassCastException e) {
throw new GenericServiceException("From Map field [" + lhsMapName + "] is not a Map.", e);
}
} else {
if (context.containsKey(lhsValueName)) {
lhsValue = context.get(lhsValueName);
} else {
Debug.logWarning("From Field (" + lhsValueName + ") is not found in context for " + serviceName + ", defaulting to null.", module);
}
}
if (isConstant) {
rhsValue = rhsValueName;
} else if (UtilValidate.isNotEmpty(rhsMapName)) {
try {
if (context.containsKey(rhsMapName)) {
Map<String, ? extends Object> envMap = UtilGenerics.checkMap(context.get(rhsMapName));
rhsValue = envMap.get(rhsValueName);
} else {
Debug.logWarning("To Map (" + rhsMapName + ") not found in context for " + serviceName + ", defaulting to null.", module);
}
} catch (ClassCastException e) {
throw new GenericServiceException("To Map field [" + rhsMapName + "] is not a Map.", e);
}
} else {
if (context.containsKey(rhsValueName)) {
rhsValue = context.get(rhsValueName);
} else {