📄 simplemethod.java
字号:
returnValue = response;
} else if (methodContext.getMethodType() == MethodContext.SERVICE) {
boolean forceError = false;
String tempErrorMsg = (String) methodContext.getEnv(serviceErrorMessageName);
if (errorMsg.length() > 0 || (tempErrorMsg != null && tempErrorMsg.length() > 0)) {
errorMsg += tempErrorMsg;
methodContext.putResult(ModelService.ERROR_MESSAGE, errorMsg);
forceError = true;
}
List errorMsgList = (List) methodContext.getEnv(serviceErrorMessageListName);
if (errorMsgList != null && errorMsgList.size() > 0) {
methodContext.putResult(ModelService.ERROR_MESSAGE_LIST, errorMsgList);
forceError = true;
}
Map errorMsgMap = (Map) methodContext.getEnv(serviceErrorMessageMapName);
if (errorMsgMap != null && errorMsgMap.size() > 0) {
methodContext.putResult(ModelService.ERROR_MESSAGE_MAP, errorMsgMap);
forceError = true;
}
String successMsg = (String) methodContext.getEnv(serviceSuccessMessageName);
if (successMsg != null && successMsg.length() > 0) {
methodContext.putResult(ModelService.SUCCESS_MESSAGE, successMsg);
}
List successMsgList = (List) methodContext.getEnv(serviceSuccessMessageListName);
if (successMsgList != null && successMsgList.size() > 0) {
methodContext.putResult(ModelService.SUCCESS_MESSAGE_LIST, successMsgList);
}
response = (String) methodContext.getEnv(serviceResponseMessageName);
if (response == null || response.length() == 0) {
if (forceError) {
//override response code, always use error code
Debug.logVerbose("No response code string found, but error messages found so assuming error; returning code [" + defaultErrorCode + "]", module);
response = defaultErrorCode;
} else {
Debug.logVerbose("No response code string or errors found, assuming success; returning code [" + defaultSuccessCode + "]", module);
response = defaultSuccessCode;
}
}
methodContext.putResult(ModelService.RESPONSE_MESSAGE, response);
returnValue = null;
} else {
response = defaultSuccessCode;
returnValue = defaultSuccessCode;
}
// decide whether or not to commit based on the response message, ie only rollback if error is returned and not finished
boolean doCommit = true;
if (!finished) {
if (defaultErrorCode.equals(response)) {
doCommit = false;
}
}
if (doCommit) {
// commit here passing beganTransaction to perform it properly
try {
TransactionUtil.commit(beganTransaction);
} catch (GenericTransactionException e) {
String errMsg = "Error trying to commit transaction, could not process method: " + e.getMessage();
Debug.logWarning(errMsg, module);
Debug.logWarning(e, module);
errorMsg += errMsg + "<br>";
}
} else {
// rollback here passing beganTransaction to either rollback, or set rollback only
try {
TransactionUtil.rollback(beganTransaction);
} catch (GenericTransactionException e) {
String errMsg = "Error trying to rollback transaction, could not process method: " + e.getMessage();
Debug.logWarning(errMsg, module);
Debug.logWarning(e, module);
errorMsg += errMsg + "<br>";
}
}
return returnValue;
}
public static void readOperations(Element simpleMethodElement, List methodOperations, SimpleMethod simpleMethod) {
List operationElements = UtilXml.childElementList(simpleMethodElement, null);
if (operationElements != null && operationElements.size() > 0) {
Iterator operElemIter = operationElements.iterator();
while (operElemIter.hasNext()) {
Element curOperElem = (Element) operElemIter.next();
String nodeName = curOperElem.getNodeName();
if ("call-map-processor".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallSimpleMapProcessor(curOperElem, simpleMethod));
} else if ("check-errors".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CheckErrors(curOperElem, simpleMethod));
} else if ("add-error".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.AddError(curOperElem, simpleMethod));
} else if ("return".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.Return(curOperElem, simpleMethod));
} else if ("set-service-fields".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.SetServiceFields(curOperElem, simpleMethod));
} else if ("call-service".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallService(curOperElem, simpleMethod));
} else if ("call-service-asynch".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallServiceAsynch(curOperElem, simpleMethod));
} else if ("call-bsh".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallBsh(curOperElem, simpleMethod));
} else if ("call-simple-method".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallSimpleMethod(curOperElem, simpleMethod));
} else if ("call-object-method".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallObjectMethod(curOperElem, simpleMethod));
} else if ("call-class-method".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CallClassMethod(curOperElem, simpleMethod));
} else if ("create-object".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.callops.CreateObject(curOperElem, simpleMethod));
} else if ("field-to-request".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.FieldToRequest(curOperElem, simpleMethod));
} else if ("field-to-session".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.FieldToSession(curOperElem, simpleMethod));
} else if ("request-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.RequestToField(curOperElem, simpleMethod));
} else if ("request-parameters-to-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.RequestParametersToList(curOperElem, simpleMethod));
} else if ("session-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.SessionToField(curOperElem, simpleMethod));
} else if ("webapp-property-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.eventops.WebappPropertyToField(curOperElem, simpleMethod));
} else if ("field-to-result".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.serviceops.FieldToResult(curOperElem, simpleMethod));
} else if ("map-to-map".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.MapToMap(curOperElem, simpleMethod));
} else if ("field-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.FieldToField(curOperElem, simpleMethod));
} else if ("field-to-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.FieldToList(curOperElem, simpleMethod));
} else if ("list-to-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.ListToList(curOperElem, simpleMethod));
} else if ("env-to-env".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.EnvToEnv(curOperElem, simpleMethod));
} else if ("env-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.EnvToField(curOperElem, simpleMethod));
} else if ("field-to-env".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.FieldToEnv(curOperElem, simpleMethod));
} else if ("string-append".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.StringAppend(curOperElem, simpleMethod));
} else if ("string-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.StringToField(curOperElem, simpleMethod));
} else if ("string-to-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.StringToList(curOperElem, simpleMethod));
} else if ("to-string".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.ToString(curOperElem, simpleMethod));
} else if ("clear-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.ClearField(curOperElem, simpleMethod));
} else if ("iterate".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.Iterate(curOperElem, simpleMethod));
} else if ("iterate-map".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.IterateMap(curOperElem, simpleMethod));
} else if ("first-from-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.envops.FirstFromList(curOperElem, simpleMethod));
} else if ("transaction-begin".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.TransactionBegin(curOperElem, simpleMethod));
} else if ("transaction-commit".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.TransactionCommit(curOperElem, simpleMethod));
} else if ("transaction-rollback".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.TransactionRollback(curOperElem, simpleMethod));
} else if ("now-timestamp-to-env".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.NowTimestampToEnv(curOperElem, simpleMethod));
} else if ("now-date-to-env".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.NowDateToEnv(curOperElem, simpleMethod));
} else if ("sequenced-id-to-env".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.SequencedIdToEnv(curOperElem, simpleMethod));
} else if ("make-next-seq-id".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.MakeNextSeqId(curOperElem, simpleMethod));
} else if ("set-current-user-login".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.SetCurrentUserLogin(curOperElem, simpleMethod));
} else if ("find-by-primary-key".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.FindByPrimaryKey(curOperElem, simpleMethod));
} else if ("find-by-and".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.FindByAnd(curOperElem, simpleMethod));
} else if ("get-related-one".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.GetRelatedOne(curOperElem, simpleMethod));
} else if ("get-related".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.GetRelated(curOperElem, simpleMethod));
} else if ("filter-list-by-and".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.FilterListByAnd(curOperElem, simpleMethod));
} else if ("filter-list-by-date".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.FilterListByDate(curOperElem, simpleMethod));
} else if ("order-value-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.OrderValueList(curOperElem, simpleMethod));
} else if ("make-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.MakeValue(curOperElem, simpleMethod));
} else if ("clone-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.CloneValue(curOperElem, simpleMethod));
} else if ("create-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.CreateValue(curOperElem, simpleMethod));
} else if ("store-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.StoreValue(curOperElem, simpleMethod));
} else if ("refresh-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.RefreshValue(curOperElem, simpleMethod));
} else if ("remove-value".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.RemoveValue(curOperElem, simpleMethod));
} else if ("remove-related".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.RemoveRelated(curOperElem, simpleMethod));
} else if ("remove-by-and".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.RemoveByAnd(curOperElem, simpleMethod));
} else if ("clear-cache-line".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.ClearCacheLine(curOperElem, simpleMethod));
} else if ("clear-entity-caches".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.ClearEntityCaches(curOperElem, simpleMethod));
} else if ("set-pk-fields".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.SetPkFields(curOperElem, simpleMethod));
} else if ("set-nonpk-fields".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.SetNonpkFields(curOperElem, simpleMethod));
} else if ("store-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.StoreList(curOperElem, simpleMethod));
} else if ("remove-list".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.entityops.RemoveList(curOperElem, simpleMethod));
} else if ("if".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.conditional.MasterIf(curOperElem, simpleMethod));
} else if ("if-validate-method".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfValidateMethod(curOperElem, simpleMethod));
} else if ("if-compare".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfCompare(curOperElem, simpleMethod));
} else if ("if-compare-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfCompareField(curOperElem, simpleMethod));
} else if ("if-regexp".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfRegexp(curOperElem, simpleMethod));
} else if ("if-empty".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfEmpty(curOperElem, simpleMethod));
} else if ("if-not-empty".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfNotEmpty(curOperElem, simpleMethod));
} else if ("if-has-permission".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.IfHasPermission(curOperElem, simpleMethod));
} else if ("check-permission".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.CheckPermission(curOperElem, simpleMethod));
} else if ("check-id".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.ifops.CheckId(curOperElem, simpleMethod));
} else if ("else".equals(nodeName)) {
// don't add anything, but don't complain either, this one is handled in the individual operations
} else if ("property-to-field".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.otherops.PropertyToField(curOperElem, simpleMethod));
} else if ("calculate".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.otherops.Calculate(curOperElem, simpleMethod));
} else if ("log".equals(nodeName)) {
methodOperations.add(new org.ofbiz.minilang.method.otherops.Log(curOperElem, simpleMethod));
} else {
Debug.logWarning("Operation element \"" + nodeName + "\" no recognized", module);
}
}
}
}
/** Execs the given operations returning true if all return true, or returning
* false and stopping if any return false.
*/
public static boolean runSubOps(List methodOperations, MethodContext methodContext) {
Iterator methodOpsIter = methodOperations.iterator();
while (methodOpsIter.hasNext()) {
MethodOperation methodOperation = (MethodOperation) methodOpsIter.next();
if (!methodOperation.exec(methodContext)) {
return false;
}
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -