Author: mbrohl
Date: Mon Dec 11 07:18:37 2017 New Revision: 1817746 URL: http://svn.apache.org/viewvc?rev=1817746&view=rev Log: Improved: General refactoring and code improvements, package org.apache.ofbiz.service. (OFBIZ-9869) The patch was modified to remove unnecessary Debug.is[Loglevel]On() conditions, see OFBIZ-10049. Thanks Dennis Balkir for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GeneralServiceException.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericDispatcherFactory.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericResultWaiter.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/RunningService.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceSynchronization.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceValidationException.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceXaWrapper.java Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GeneralServiceException.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GeneralServiceException.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GeneralServiceException.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GeneralServiceException.java Mon Dec 11 07:18:37 2017 @@ -68,7 +68,7 @@ public class GeneralServiceException ext public void addErrorMessages(List<? extends Object> errMsgs) { if (this.errorMsgList == null) { - this.errorMsgList = new LinkedList<Object>(); + this.errorMsgList = new LinkedList<>(); } this.errorMsgList.addAll(errMsgs); } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericDispatcherFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericDispatcherFactory.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericDispatcherFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericDispatcherFactory.java Mon Dec 11 07:18:37 2017 @@ -57,14 +57,14 @@ public class GenericDispatcherFactory im } this.name = name; this.dispatcher = ServiceDispatcher.getInstance(delegator); - /* + /* * FIXME: "this" reference escape. DispatchContext constructor uses * this object before it is fully constructed. */ DispatchContext ctx = new DispatchContext(name, loader, this); this.dispatcher.register(ctx); this.ctx = ctx; - if (Debug.verboseOn()) Debug.logVerbose("[GenericDispatcher] : Created Dispatcher for: " + name, module); + Debug.logVerbose("[GenericDispatcher] : Created Dispatcher for: " + name, module); } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericResultWaiter.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericResultWaiter.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericResultWaiter.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/GenericResultWaiter.java Mon Dec 11 07:18:37 2017 @@ -50,8 +50,7 @@ public class GenericResultWaiter impleme completed = true; status = SERVICE_FINISHED; notify(); - if (Debug.verboseOn()) - Debug.logVerbose("Received Result (" + completed + ") -- " + result, module); + Debug.logVerbose("Received Result (" + completed + ") -- " + result, module); } /** @@ -85,8 +84,9 @@ public class GenericResultWaiter impleme * @return Exception */ public synchronized Throwable getThrowable() { - if (!isCompleted()) + if (!isCompleted()) { throw new java.lang.IllegalStateException("Cannot return exception, synchronous call has not completed."); + } return this.t; } @@ -95,8 +95,9 @@ public class GenericResultWaiter impleme * @return Map */ public synchronized Map<String, Object> getResult() { - if (!isCompleted()) + if (!isCompleted()) { throw new java.lang.IllegalStateException("Cannot return result, asynchronous call has not completed."); + } return result; } @@ -114,11 +115,11 @@ public class GenericResultWaiter impleme * @return Map */ public synchronized Map<String, Object> waitForResult(long milliseconds) { - if (Debug.verboseOn()) Debug.logVerbose("Waiting for results...", module); + Debug.logVerbose("Waiting for results...", module); while (!isCompleted()) { try { this.wait(milliseconds); - if (Debug.verboseOn()) Debug.logVerbose("Waiting...", module); + Debug.logVerbose("Waiting...", module); } catch (java.lang.InterruptedException e) { Debug.logError(e, module); } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelNotification.java Mon Dec 11 07:18:37 2017 @@ -81,8 +81,8 @@ public class ModelNotification { } // template context - Map<String, Object> notifyContext = new HashMap<String, Object>(); - Map<String, Object> bodyParams = new HashMap<String, Object>(); + Map<String, Object> notifyContext = new HashMap<>(); + Map<String, Object> bodyParams = new HashMap<>(); bodyParams.put("serviceContext", context); bodyParams.put("serviceResult", result); bodyParams.put("service", model); @@ -139,7 +139,7 @@ public class ModelNotification { } private List<String> getAddressesByType(NotificationGroup group, String type) { - List<String> l = new ArrayList<String>(); + List<String> l = new ArrayList<>(); for (Notify n : group.getNotifyList()) { if (n.getType().equals(type)) { l.add(n.getContent()); Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java Mon Dec 11 07:18:37 2017 @@ -24,7 +24,6 @@ import java.util.Locale; import javax.wsdl.Definition; import javax.wsdl.Part; -import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import org.apache.ofbiz.base.util.Debug; @@ -108,7 +107,9 @@ public class ModelParam implements Seria this.stringMapPrefix = param.stringMapPrefix; this.stringListSuffix = param.stringListSuffix; this.validators = param.validators; - if (param.defaultValue != null) this.setDefaultValue(param.defaultValue); + if (param.defaultValue != null) { + this.setDefaultValue(param.defaultValue); + } this.optional = param.optional; this.overrideOptional = param.overrideOptional; this.formDisplay = param.formDisplay; @@ -198,7 +199,7 @@ public class ModelParam implements Seria if (this.defaultValue != null) { this.optional = true; } - if (Debug.verboseOn()) Debug.logVerbose("Default value for attribute [" + this.name + "] set to [" + this.defaultValue + "]", module); + Debug.logVerbose("Default value for attribute [" + this.name + "] set to [" + this.defaultValue + "]", module); } public void copyDefaultValue(ModelParam param) { this.setDefaultValue(param.defaultValue); @@ -233,19 +234,20 @@ public class ModelParam implements Seria buf.append(allowHtml).append("::"); buf.append(defaultValue).append("::"); buf.append(internal); - if (validators != null) + if (validators != null) { buf.append(validators.toString()).append("::"); + } return buf.toString(); } - public Part getWSDLPart(Definition def) throws WSDLException { + public Part getWSDLPart(Definition def) { Part part = def.createPart(); part.setName(this.name); part.setTypeName(new QName(ModelService.TNS, this.java2wsdlType())); return part; } - protected String java2wsdlType() throws WSDLException { + protected String java2wsdlType() { if (ObjectType.instanceOf(java.lang.Character.class, this.type)) { return "std-String"; } else if (ObjectType.instanceOf(java.lang.String.class, this.type)) { @@ -289,8 +291,6 @@ public class ModelParam implements Seria } else { return "cus-obj"; } - - //throw new WSDLException(WSDLException.OTHER_ERROR, "Service cannot be described with WSDL (" + this.name + " / " + this.type + ")"); } static class ModelParamValidator implements Serializable { Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java Mon Dec 11 07:18:37 2017 @@ -97,13 +97,6 @@ public class ModelPermission implements return false; } List<GenericValue> partyRoles = null; - /** (jaz) THIS IS NOT SECURE AT ALL - try { - partyRoles = delegator.findByAnd("PartyRole", "roleTypeId", nameOrRole, "partyId", userLogin.get("partyId")); - } catch (GenericEntityException e) { - Debug.logError(e, "Unable to lookup PartyRole records", module); - } - **/ if (UtilValidate.isNotEmpty(partyRoles)) { partyRoles = EntityUtil.filterByDate(partyRoles); Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java Mon Dec 11 07:18:37 2017 @@ -183,7 +183,7 @@ public class ModelService extends Abstra /** Require a new transaction for this service */ public boolean hideResultInLog; - + /** Set of services this service implements */ public Set<ModelServiceIface> implServices = new LinkedHashSet<>(); @@ -304,7 +304,9 @@ public class ModelService extends Abstra @Override public boolean equals(Object o) { - if (!(o instanceof ModelServiceMapEntry)) return false; + if (!(o instanceof ModelServiceMapEntry)) { + return false; + } ModelServiceMapEntry other = (ModelServiceMapEntry) o; return field.equals(other.field) && ModelService.this == other.getModelService(); } @@ -446,7 +448,9 @@ public class ModelService extends Abstra Set<String> nameList = new TreeSet<>(); for (ModelParam p: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT - if (p.isIn()) nameList.add(p.name); + if (p.isIn()) { + nameList.add(p.name); + } } return nameList; } @@ -457,7 +461,9 @@ public class ModelService extends Abstra for (ModelParam p: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT - if (p.isIn() && !p.internal) count++; + if (p.isIn() && !p.internal) { + count++; + } } return count; @@ -467,7 +473,9 @@ public class ModelService extends Abstra Set<String> nameList = new TreeSet<>(); for (ModelParam p: this.contextParamList) { // don't include IN parameters in this list, only OUT and INOUT - if (p.isOut()) nameList.add(p.name); + if (p.isOut()) { + nameList.add(p.name); + } } return nameList; } @@ -478,7 +486,9 @@ public class ModelService extends Abstra for (ModelParam p: this.contextParamList) { // don't include IN parameters in this list, only OUT and INOUT - if (p.isOut() && !p.internal) count++; + if (p.isOut() && !p.internal) { + count++; + } } return count; @@ -506,21 +516,19 @@ public class ModelService extends Abstra public void validate(Map<String, Object> context, String mode, Locale locale) throws ServiceValidationException { Map<String, String> requiredInfo = new HashMap<>(); Map<String, String> optionalInfo = new HashMap<>(); - boolean verboseOn = Debug.verboseOn(); - if (verboseOn) Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : Validating context - " + context, module); + Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : Validating context - " + context, module); // do not validate results with errors if (mode.equals(OUT_PARAM) && context != null && context.containsKey(RESPONSE_MESSAGE)) { if (RESPOND_ERROR.equals(context.get(RESPONSE_MESSAGE)) || RESPOND_FAIL.equals(context.get(RESPONSE_MESSAGE))) { - if (verboseOn) Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : response was an error, not validating.", module); + Debug.logVerbose("[ModelService.validate] : {" + this.name + "} : response was an error, not validating.", module); return; } } // get the info values for (ModelParam modelParam: this.contextParamList) { - // Debug.logInfo("In ModelService.validate preparing parameter [" + modelParam.name + (modelParam.optional?"(optional):":"(required):") + modelParam.mode + "] for service [" + this.name + "]", module); if (IN_OUT_PARAM.equals(modelParam.mode) || mode.equals(modelParam.mode)) { if (modelParam.optional) { optionalInfo.put(modelParam.name, modelParam.type); @@ -534,7 +542,9 @@ public class ModelService extends Abstra Map<String, Object> requiredTest = new HashMap<>(); Map<String, Object> optionalTest = new HashMap<>(); - if (context == null) context = new HashMap<>(); + if (context == null) { + context = new HashMap<>(); + } requiredTest.putAll(context); List<String> requiredButNull = new LinkedList<>(); @@ -565,7 +575,7 @@ public class ModelService extends Abstra throw new ServiceValidationException(missingMsg, this, requiredButNull, null, mode); } - if (verboseOn) { + if (Debug.verboseOn()) { StringBuilder requiredNames = new StringBuilder(); for (String key: requiredInfo.keySet()) { @@ -595,7 +605,7 @@ public class ModelService extends Abstra List<String> errorMessageList = new LinkedList<>(); for (ModelParam modelParam : this.contextInfo.values()) { // the param is a String, allow-html is not any, and we are looking at an IN parameter during input parameter validation - if (context.get(modelParam.name) != null && ("String".equals(modelParam.type) || "java.lang.String".equals(modelParam.type)) + if (context.get(modelParam.name) != null && ("String".equals(modelParam.type) || "java.lang.String".equals(modelParam.type)) && !"any".equals(modelParam.allowHtml) && (IN_OUT_PARAM.equals(modelParam.mode) || IN_PARAM.equals(modelParam.mode))) { String value = (String) context.get(modelParam.name); UtilCodec.checkStringForHtmlStrictNone(modelParam.name, value, errorMessageList); @@ -639,7 +649,9 @@ public class ModelService extends Abstra Set<String> keySet = info.keySet(); // Quick check for sizes - if (info.size() == 0 && test.size() == 0) return; + if (info.size() == 0 && test.size() == 0) { + return; + } // This is to see if the test set contains all from the info set (reverse) if (reverse && !testSet.containsAll(keySet)) { Set<String> missing = new TreeSet<>(keySet); @@ -906,8 +918,6 @@ public class ModelService extends Abstra } for (ModelParam param: contextParamList) { - //boolean internalParam = param.internal; - if (param.mode.equals(IN_OUT_PARAM) || param.mode.equals(mode)) { String key = param.name; @@ -1074,7 +1084,9 @@ public class ModelService extends Abstra } for (ModelParam modelParam: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT - if (OUT_PARAM.equals(modelParam.mode)) continue; + if (OUT_PARAM.equals(modelParam.mode)) { + continue; + } Object srcObject = source.get(modelParam.name); if (srcObject != null) { @@ -1102,7 +1114,9 @@ public class ModelService extends Abstra List<ModelParam> inList = new LinkedList<>(); for (ModelParam modelParam: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT - if (OUT_PARAM.equals(modelParam.mode)) continue; + if (OUT_PARAM.equals(modelParam.mode)) { + continue; + } inList.add(modelParam); } @@ -1124,7 +1138,7 @@ public class ModelService extends Abstra if (group != null) { for (GroupServiceModel sm: group.getServices()) { implServices.add(new ModelServiceIface(sm.getName(), sm.isOptional())); - if (Debug.verboseOn()) Debug.logVerbose("Adding service [" + sm.getName() + "] as interface of: [" + this.name + "]", module); + Debug.logVerbose("Adding service [" + sm.getName() + "] as interface of: [" + this.name + "]", module); } } } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java Mon Dec 11 07:18:37 2017 @@ -43,7 +43,6 @@ import org.apache.ofbiz.entity.GenericEn import org.apache.ofbiz.entity.model.ModelEntity; import org.apache.ofbiz.entity.model.ModelField; import org.apache.ofbiz.entity.model.ModelFieldType; -import org.apache.ofbiz.service.ModelParam.ModelParamValidator; import org.apache.ofbiz.service.group.GroupModel; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -91,14 +90,12 @@ public class ModelServiceReader implemen UtilTimer utilTimer = new UtilTimer(); Document document; if (this.isFromURL) { - // utilTimer.timerString("Before getDocument in file " + readerURL); document = getDocument(readerURL); if (document == null) { return null; } } else { - // utilTimer.timerString("Before getDocument in " + handler); try { document = handler.getDocument(); } catch (GenericConfigException e) { @@ -143,28 +140,10 @@ public class ModelServiceReader implemen Debug.logWarning("Service " + serviceName + " is defined more than once, " + "most recent will over-write previous definition(s)", module); } - - // utilTimer.timerString(" After serviceName -- " + i + " --"); ModelService service = createModelService(curServiceElement, resourceLocation); - // utilTimer.timerString(" After createModelService -- " + i + " --"); modelServices.put(serviceName, service); - // utilTimer.timerString(" After modelServices.put -- " + i + " --"); - /* - int reqIn = service.getParameterNames(ModelService.IN_PARAM, false).size(); - int optIn = service.getParameterNames(ModelService.IN_PARAM, true).size() - reqIn; - int reqOut = service.getParameterNames(ModelService.OUT_PARAM, false).size(); - int optOut = service.getParameterNames(ModelService.OUT_PARAM, true).size() - reqOut; - - if (Debug.verboseOn()) { - String msg = "-- getModelService: # " + i + " Loaded service: " + serviceName + - " (IN) " + reqIn + "/" + optIn + " (OUT) " + reqOut + "/" + optOut; - - Debug.logVerbose(msg, module); } - */ - - } } while ((curChild = curChild.getNextSibling()) != null); } else { Debug.logWarning("No child nodes found.", module); @@ -174,9 +153,7 @@ public class ModelServiceReader implemen Debug.logInfo("Loaded [" + i + "] Services from " + readerURL, module); } else { utilTimer.timerString("Finished document in " + handler + " - Total Services: " + i + " FINISHED"); - if (Debug.infoOn()) { - Debug.logInfo("Loaded [" + i + "] Services from " + resourceLocation, module); - } + Debug.logInfo("Loaded [" + i + "] Services from " + resourceLocation, module); } return modelServices; } @@ -207,7 +184,7 @@ public class ModelServiceReader implemen service.useTransaction = true; Debug.logWarning("In service definition [" + service.name + "] the value use-transaction has been changed from false to true as required when require-new-transaction is set to true", module); } - service.hideResultInLog = !"false".equalsIgnoreCase(serviceElement.getAttribute("hideResultInLog")); + service.hideResultInLog = !"false".equalsIgnoreCase(serviceElement.getAttribute("hideResultInLog")); // set the semaphore sleep/wait times String semaphoreWaitStr = UtilXml.checkEmpty(serviceElement.getAttribute("semaphore-wait-seconds")); @@ -258,7 +235,7 @@ public class ModelServiceReader implemen timeout = 0; } } - service.transactionTimeout = timeout; + service.transactionTimeout = timeout; service.description = getCDATADef(serviceElement, "description"); service.nameSpace = getCDATADef(serviceElement, "namespace"); @@ -392,7 +369,7 @@ public class ModelServiceReader implemen groupElement.setAttribute("name", "_" + service.name + ".group"); service.internalGroup = new GroupModel(groupElement); service.invoke = service.internalGroup.getGroupName(); - if (Debug.verboseOn()) Debug.logVerbose("Created INTERNAL GROUP model [" + service.internalGroup + "]", module); + Debug.logVerbose("Created INTERNAL GROUP model [" + service.internalGroup + "]", module); } } @@ -400,9 +377,9 @@ public class ModelServiceReader implemen for (Element implement: UtilXml.childElementList(baseElement, "implements")) { String serviceName = UtilXml.checkEmpty(implement.getAttribute("service")).intern(); boolean optional = UtilXml.checkBoolean(implement.getAttribute("optional"), false); - if (serviceName.length() > 0) + if (serviceName.length() > 0) { service.implServices.add(new ModelServiceIface(serviceName, optional)); - //service.implServices.add(serviceName); + } } } @@ -473,7 +450,6 @@ public class ModelServiceReader implemen // now add in all the remaining params for (ModelParam thisParam : modelParamMap.values()) { - //Debug.logInfo("Adding Param to " + service.name + ": " + thisParam.name + " [" + thisParam.mode + "] " + thisParam.type + " (" + thisParam.optional + ")", module); service.addParam(thisParam); } } catch (GenericEntityException e) { @@ -507,7 +483,7 @@ public class ModelServiceReader implemen // default value String defValue = attribute.getAttribute("default-value"); if (UtilValidate.isNotEmpty(defValue)) { - if (Debug.verboseOn()) Debug.logVerbose("Got a default-value [" + defValue + "] for service attribute [" + service.name + "." + param.name + "]", module); + Debug.logVerbose("Got a default-value [" + defValue + "] for service attribute [" + service.name + "." + param.name + "]", module); param.setDefaultValue(defValue.intern()); } @@ -720,8 +696,9 @@ public class ModelServiceReader implemen } private Document getDocument(URL url) { - if (url == null) + if (url == null) { return null; + } Document document = null; try { @@ -730,8 +707,9 @@ public class ModelServiceReader implemen // Error generated during parsing) Exception x = sxe; - if (sxe.getException() != null) + if (sxe.getException() != null) { x = sxe.getException(); + } x.printStackTrace(); } catch (ParserConfigurationException pce) { // Parser with specified options can't be built Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/RunningService.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/RunningService.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/RunningService.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/RunningService.java Mon Dec 11 07:18:37 2017 @@ -77,7 +77,7 @@ public class RunningService { } return false; } - + public int hashCode() { return System.identityHashCode(this); } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java Mon Dec 11 07:18:37 2017 @@ -33,11 +33,11 @@ import org.apache.ofbiz.entity.Delegator import org.apache.ofbiz.service.job.JobManager; /** - * A container for the service engine. + * A container for the service engine. */ public class ServiceContainer implements Container { private static final String module = ServiceContainer.class.getName(); - private static final ConcurrentHashMap<String, LocalDispatcher> dispatcherCache = new ConcurrentHashMap<String, LocalDispatcher>(); + private static final ConcurrentHashMap<String, LocalDispatcher> dispatcherCache = new ConcurrentHashMap<>(); private static LocalDispatcherFactory dispatcherFactory; private String name; @@ -92,7 +92,7 @@ public class ServiceContainer implements dispatcher = dispatcherFactory.createLocalDispatcher(dispatcherName, delegator); dispatcherCache.putIfAbsent(dispatcherName, dispatcher); dispatcher = dispatcherCache.get(dispatcherName); - if (Debug.infoOn()) Debug.logInfo("Created new dispatcher: " + dispatcherName, module); + Debug.logInfo("Created new dispatcher: " + dispatcherName, module); } return dispatcher; } @@ -105,7 +105,7 @@ public class ServiceContainer implements } public static LocalDispatcher removeFromCache(String dispatcherName) { - if (Debug.infoOn()) Debug.logInfo("Removing from cache dispatcher: " + dispatcherName, module); + Debug.logInfo("Removing from cache dispatcher: " + dispatcherName, module); return dispatcherCache.remove(dispatcherName); } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java Mon Dec 11 07:18:37 2017 @@ -162,8 +162,7 @@ public class ServiceDispatcher { String dispatcherKey = delegator != null ? delegator.getDelegatorName() : "null"; sd = dispatchers.get(dispatcherKey); if (sd == null) { - if (Debug.verboseOn()) - Debug.logVerbose("[ServiceDispatcher.getInstance] : No instance found (" + dispatcherKey + ").", module); + Debug.logVerbose("[ServiceDispatcher.getInstance] : No instance found (" + dispatcherKey + ").", module); sd = new ServiceDispatcher(delegator); ServiceDispatcher cachedDispatcher = dispatchers.putIfAbsent(dispatcherKey, sd); if (cachedDispatcher == null) { @@ -183,7 +182,7 @@ public class ServiceDispatcher { * @param context the context of the local dispatcher */ public void register(DispatchContext context) { - if (Debug.infoOn()) Debug.logInfo("Registering dispatcher: " + context.getName(), module); + Debug.logInfo("Registering dispatcher: " + context.getName(), module); this.localContext.put(context.getName(), context); } /** @@ -191,7 +190,7 @@ public class ServiceDispatcher { * @param local the LocalDispatcher to de-register */ public void deregister(LocalDispatcher local) { - if (Debug.infoOn()) Debug.logInfo("De-Registering dispatcher: " + local.getName(), module); + Debug.logInfo("De-Registering dispatcher: " + local.getName(), module); localContext.remove(local.getName()); if (localContext.size() == 0) { try { @@ -296,7 +295,6 @@ public class ServiceDispatcher { // set IN attributes with default-value as applicable modelService.updateDefaultValues(context, ModelService.IN_PARAM); - //Debug.logInfo("=========================== " + modelService.name + " 1 tx status =" + TransactionUtil.getStatusString() + ", modelService.requireNewTransaction=" + modelService.requireNewTransaction + ", modelService.useTransaction=" + modelService.useTransaction + ", TransactionUtil.isTransactionInPlace()=" + TransactionUtil.isTransactionInPlace(), module); if (modelService.useTransaction) { if (TransactionUtil.isTransactionInPlace()) { // if a new transaction is needed, do it here; if not do nothing, just use current tx @@ -340,18 +338,22 @@ public class ServiceDispatcher { // setup global transaction ECA listeners to execute later - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-rollback", ctx, context, result, isError, isFailure); - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-commit", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-rollback", ctx, context, result, isError, isFailure); + } + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-commit", ctx, context, result, isError, isFailure); + } // pre-auth ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "auth", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "auth", ctx, context, result, isError, isFailure); + } // check for pre-auth failure/errors isFailure = ServiceUtil.isFailure(result); isError = ServiceUtil.isError(result); - //Debug.logInfo("After [" + modelService.name + "] pre-auth ECA, before auth; isFailure=" + isFailure + ", isError=" + isError, module); - context = checkAuth(localName, context, modelService); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -365,14 +367,14 @@ public class ServiceDispatcher { } // pre-validate ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "in-validate", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "in-validate", ctx, context, result, isError, isFailure); + } // check for pre-validate failure/errors isFailure = ServiceUtil.isFailure(result); isError = ServiceUtil.isError(result); - //Debug.logInfo("After [" + modelService.name + "] pre-in-validate ECA, before in-validate; isFailure=" + isFailure + ", isError=" + isError, module); - // validate the context if (modelService.validate && !isError && !isFailure) { try { @@ -384,14 +386,14 @@ public class ServiceDispatcher { } // pre-invoke ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "invoke", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "invoke", ctx, context, result, isError, isFailure); + } // check for pre-invoke failure/errors isFailure = ServiceUtil.isFailure(result); isError = ServiceUtil.isError(result); - //Debug.logInfo("After [" + modelService.name + "] pre-invoke ECA, before invoke; isFailure=" + isFailure + ", isError=" + isError, module); - // ===== invoke the service ===== if (!isError && !isFailure) { Map<String, Object> invokeResult = null; @@ -408,8 +410,6 @@ public class ServiceDispatcher { isFailure = ServiceUtil.isFailure(result); isError = ServiceUtil.isError(result); - //Debug.logInfo("After [" + modelService.name + "] invoke; isFailure=" + isFailure + ", isError=" + isError, module); - if (beganTrans) { // crazy stuff here: see if there was a deadlock or other such error and if so retry... which we can ONLY do if we own the transaction! @@ -483,7 +483,9 @@ public class ServiceDispatcher { // validate the result if (modelService.validate && validateOut) { // pre-out-validate ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "out-validate", ctx, ecaContext, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "out-validate", ctx, ecaContext, result, isError, isFailure); + } try { modelService.validate(result, ModelService.OUT_PARAM, locale); } catch (ServiceValidationException e) { @@ -492,14 +494,18 @@ public class ServiceDispatcher { } // pre-commit ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "commit", ctx, ecaContext, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "commit", ctx, ecaContext, result, isError, isFailure); + } // check for pre-commit failure/errors isFailure = ServiceUtil.isFailure(result); isError = ServiceUtil.isError(result); // global-commit-post-run ECA, like global-commit but gets the context after the service is run - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-commit-post-run", ctx, ecaContext, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "global-commit-post-run", ctx, ecaContext, result, isError, isFailure); + } // check for failure and log on info level; this is used for debugging if (isFailure) { @@ -584,14 +590,16 @@ public class ServiceDispatcher { } // pre-return ECA - if (eventMap != null) ServiceEcaUtil.evalRules(modelService.name, eventMap, "return", ctx, ecaContext, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(modelService.name, eventMap, "return", ctx, ecaContext, result, isError, isFailure); + } rs.setEndStamp(); long timeToRun = System.currentTimeMillis() - serviceStartTime; long showServiceDurationThreshold = UtilProperties.getPropertyAsLong("service", "showServiceDurationThreshold", 0); long showSlowServiceThreshold = UtilProperties.getPropertyAsLong("service", "showSlowServiceThreshold", 1000); - + if (Debug.timingOn() && timeToRun > showServiceDurationThreshold) { Debug.logTiming("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module); } else if (Debug.infoOn() && timeToRun > showSlowServiceThreshold) { @@ -683,7 +691,9 @@ public class ServiceDispatcher { Map<String, List<ServiceEcaRule>> eventMap = ServiceEcaUtil.getServiceEventMap(service.name); // pre-auth ECA - if (eventMap != null) ServiceEcaUtil.evalRules(service.name, eventMap, "auth", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(service.name, eventMap, "auth", ctx, context, result, isError, isFailure); + } context = checkAuth(localName, context, service); Object userLogin = context.get("userLogin"); @@ -693,7 +703,9 @@ public class ServiceDispatcher { } // pre-validate ECA - if (eventMap != null) ServiceEcaUtil.evalRules(service.name, eventMap, "in-validate", ctx, context, result, isError, isFailure); + if (eventMap != null) { + ServiceEcaUtil.evalRules(service.name, eventMap, "in-validate", ctx, context, result, isError, isFailure); + } // check for pre-validate failure/errors isFailure = ModelService.RESPOND_FAIL.equals(result.get(ModelService.RESPONSE_MESSAGE)); @@ -950,7 +962,7 @@ public class ServiceDispatcher { private GenericValue getLoginObject(String service, String localName, String username, String password, Locale locale) throws GenericServiceException { Map<String, Object> context = UtilMisc.toMap("login.username", username, "login.password", password, "isServiceAuth", true, "locale", locale); - if (Debug.verboseOn()) Debug.logVerbose("[ServiceDispathcer.authenticate] : Invoking UserLogin Service", module); + Debug.logVerbose("[ServiceDispathcer.authenticate] : Invoking UserLogin Service", module); // get the dispatch context and service model DispatchContext dctx = getLocalContext(localName); Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceSynchronization.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceSynchronization.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceSynchronization.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceSynchronization.java Mon Dec 11 07:18:37 2017 @@ -36,7 +36,7 @@ import org.apache.ofbiz.entity.transacti import org.apache.ofbiz.entity.transaction.TransactionUtil; /** - * This class is used to execute services when a transaction is either + * This class is used to execute services when a transaction is either * committed or rolled back. It should generally be accessed via * LocalDispatcher's addCommitService and addRollbackService methods * or by using the service ECA event attribute values global-commit, @@ -72,11 +72,7 @@ public class ServiceSynchronization impl syncingleton.put(transaction, sync); } } - } catch (SystemException e) { - throw new GenericServiceException(e.getMessage(), e); - } catch (IllegalStateException e) { - throw new GenericServiceException(e.getMessage(), e); - } catch (RollbackException e) { + } catch (SystemException | IllegalStateException | RollbackException e) { throw new GenericServiceException(e.getMessage(), e); } return sync; @@ -144,10 +140,10 @@ public class ServiceSynchronization impl // set the userLogin object thisContext.put("userLogin", ServiceUtil.getUserLogin(dctx, thisContext, runAsUser)); if (async) { - if (Debug.infoOn()) Debug.logInfo(msgPrefix + "Invoking [" + serviceName + "] via runAsync", MODULE); + Debug.logInfo(msgPrefix + "Invoking [" + serviceName + "] via runAsync", MODULE); dctx.getDispatcher().runAsync(serviceName, thisContext, persist); } else { - if (Debug.infoOn()) Debug.logInfo(msgPrefix + "Invoking [" + serviceName + "] via runSyncIgnore", MODULE); + Debug.logInfo(msgPrefix + "Invoking [" + serviceName + "] via runSyncIgnore", MODULE); dctx.getDispatcher().runSyncIgnore(serviceName, thisContext); } } catch (Throwable t) { Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java Mon Dec 11 07:18:37 2017 @@ -179,8 +179,12 @@ public final class ServiceUtil { */ public static Map<String, Object> returnMessage(String code, String message) { Map<String, Object> result = new HashMap<>(); - if (code != null) result.put(ModelService.RESPONSE_MESSAGE, code); - if (message != null) result.put(ModelService.SUCCESS_MESSAGE, message); + if (code != null) { + result.put(ModelService.RESPONSE_MESSAGE, code); + } + if (message != null) { + result.put(ModelService.SUCCESS_MESSAGE, message); + } return result; } @@ -218,14 +222,17 @@ public final class ServiceUtil { } public static void setMessages(HttpServletRequest request, String errorMessage, String eventMessage, String defaultMessage) { - if (UtilValidate.isNotEmpty(errorMessage)) + if (UtilValidate.isNotEmpty(errorMessage)) { request.setAttribute("_ERROR_MESSAGE_", errorMessage); + } - if (UtilValidate.isNotEmpty(eventMessage)) + if (UtilValidate.isNotEmpty(eventMessage)) { request.setAttribute("_EVENT_MESSAGE_", eventMessage); + } - if (UtilValidate.isEmpty(errorMessage) && UtilValidate.isEmpty(eventMessage) && UtilValidate.isNotEmpty(defaultMessage)) + if (UtilValidate.isEmpty(errorMessage) && UtilValidate.isEmpty(eventMessage) && UtilValidate.isNotEmpty(defaultMessage)) { request.setAttribute("_EVENT_MESSAGE_", defaultMessage); + } } @@ -243,7 +250,9 @@ public final class ServiceUtil { public static String getErrorMessage(Map<String, ? extends Object> result) { StringBuilder errorMessage = new StringBuilder(); - if (result.get(ModelService.ERROR_MESSAGE) != null) errorMessage.append((String) result.get(ModelService.ERROR_MESSAGE)); + if (result.get(ModelService.ERROR_MESSAGE) != null) { + errorMessage.append((String) result.get(ModelService.ERROR_MESSAGE)); + } if (result.get(ModelService.ERROR_MESSAGE_LIST) != null) { List<? extends Object> errors = UtilGenerics.checkList(result.get(ModelService.ERROR_MESSAGE_LIST)); @@ -271,9 +280,13 @@ public final class ServiceUtil { StringBuilder outMsg = new StringBuilder(); if (errorMsg != null) { - if (msgPrefix != null) outMsg.append(msgPrefix); + if (msgPrefix != null) { + outMsg.append(msgPrefix); + } outMsg.append(errorMsg); - if (msgSuffix != null) outMsg.append(msgSuffix); + if (msgSuffix != null) { + outMsg.append(msgSuffix); + } } outMsg.append(makeMessageList(errorMsgList, msgPrefix, msgSuffix)); @@ -291,9 +304,13 @@ public final class ServiceUtil { if (outMsg.length() > 0) { StringBuilder strBuf = new StringBuilder(); - if (errorPrefix != null) strBuf.append(errorPrefix); + if (errorPrefix != null) { + strBuf.append(errorPrefix); + } strBuf.append(outMsg.toString()); - if (errorSuffix != null) strBuf.append(errorSuffix); + if (errorSuffix != null) { + strBuf.append(errorSuffix); + } return strBuf.toString(); } return null; @@ -310,16 +327,24 @@ public final class ServiceUtil { outMsg.append(makeMessageList(successMsgList, msgPrefix, msgSuffix)); if (successMsg != null) { - if (msgPrefix != null) outMsg.append(msgPrefix); + if (msgPrefix != null) { + outMsg.append(msgPrefix); + } outMsg.append(successMsg); - if (msgSuffix != null) outMsg.append(msgSuffix); + if (msgSuffix != null) { + outMsg.append(msgSuffix); + } } if (outMsg.length() > 0) { StringBuilder strBuf = new StringBuilder(); - if (successPrefix != null) strBuf.append(successPrefix); + if (successPrefix != null) { + strBuf.append(successPrefix); + } strBuf.append(outMsg.toString()); - if (successSuffix != null) strBuf.append(successSuffix); + if (successSuffix != null) { + strBuf.append(successSuffix); + } return strBuf.toString(); } return null; @@ -329,11 +354,17 @@ public final class ServiceUtil { StringBuilder outMsg = new StringBuilder(); if (UtilValidate.isNotEmpty(msgList)) { for (Object msg: msgList) { - if (msg == null) continue; + if (msg == null) { + continue; + } String curMsg = msg.toString(); - if (msgPrefix != null) outMsg.append(msgPrefix); + if (msgPrefix != null) { + outMsg.append(msgPrefix); + } outMsg.append(curMsg); - if (msgSuffix != null) outMsg.append(msgSuffix); + if (msgSuffix != null) { + outMsg.append(msgSuffix); + } } } return outMsg.toString(); @@ -423,7 +454,7 @@ public final class ServiceUtil { .from("JobSandbox") .where(EntityCondition.makeCondition(UtilMisc.toList(doneCond, pool))) .cursorScrollInsensitive() - .maxRows(1000); + .maxRows(1000); try (EntityListIterator foundJobs = eq.queryIterator()) { curList = foundJobs.getPartialList(1, 1000); @@ -603,8 +634,12 @@ public final class ServiceUtil { Timestamp now = UtilDateTime.nowTimestamp(); boolean reply = true; - if (fromDate != null && fromDate.after(now)) reply = false; - if (thruDate != null && thruDate.before(now)) reply = false; + if (fromDate != null && fromDate.after(now)) { + reply = false; + } + if (thruDate != null && thruDate.before(now)) { + reply = false; + } Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("conditionReply", reply); @@ -640,7 +675,9 @@ public final class ServiceUtil { throw new IllegalArgumentException("args is null in makeContext, this would throw a NullPointerExcption."); } for (int i = 0; i < args.length; i += 2) { - if (!(args[i] instanceof String)) throw new IllegalArgumentException("Arg(" + i + "), value(" + args[i] + ") is not a string."); + if (!(args[i] instanceof String)) { + throw new IllegalArgumentException("Arg(" + i + "), value(" + args[i] + ") is not a string."); + } } return UtilGenerics.checkMap(UtilMisc.toMap(args)); } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceValidationException.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceValidationException.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceValidationException.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceValidationException.java Mon Dec 11 07:18:37 2017 @@ -29,9 +29,9 @@ import org.apache.ofbiz.base.util.UtilVa @SuppressWarnings("serial") public class ServiceValidationException extends GenericServiceException { - protected List<String> messages = new ArrayList<String>(); - protected List<String> missingFields = new ArrayList<String>(); - protected List<String> extraFields = new ArrayList<String>(); + protected List<String> messages = new ArrayList<>(); + protected List<String> missingFields = new ArrayList<>(); + protected List<String> extraFields = new ArrayList<>(); protected String errorMode = null; protected ModelService service = null; @@ -125,9 +125,8 @@ public class ServiceValidationException public String getServiceName() { if (service != null) { return service.name; - } else { - return null; } + return null; } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceXaWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceXaWrapper.java?rev=1817746&r1=1817745&r2=1817746&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceXaWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceXaWrapper.java Mon Dec 11 07:18:37 2017 @@ -161,7 +161,7 @@ public class ServiceXaWrapper extends Ge @Override public void enlist() throws XAException { super.enlist(); - if (Debug.verboseOn()) Debug.logVerbose("Enlisted in transaction : " + this.toString(), module); + Debug.logVerbose("Enlisted in transaction : " + this.toString(), module); } // -- XAResource Methods @@ -170,7 +170,7 @@ public class ServiceXaWrapper extends Ge */ @Override public void commit(Xid xid, boolean onePhase) throws XAException { - if (Debug.verboseOn()) Debug.logVerbose("ServiceXaWrapper#commit() : " + onePhase + " / " + xid.toString(), module); + Debug.logVerbose("ServiceXaWrapper#commit() : " + onePhase + " / " + xid.toString(), module); // the commit listener if (this.active) { Debug.logWarning("commit() called without end()", module); @@ -205,7 +205,7 @@ public class ServiceXaWrapper extends Ge */ @Override public void rollback(Xid xid) throws XAException { - if (Debug.verboseOn()) Debug.logVerbose("ServiceXaWrapper#rollback() : " + xid.toString(), module); + Debug.logVerbose("ServiceXaWrapper#rollback() : " + xid.toString(), module); // the rollback listener if (this.active) { Debug.logWarning("rollback() called without end()", module); @@ -238,7 +238,7 @@ public class ServiceXaWrapper extends Ge @Override public int prepare(Xid xid) throws XAException { // overriding to log two phase commits - if (Debug.verboseOn()) Debug.logVerbose("ServiceXaWrapper#prepare() : " + xid.toString(), module); + Debug.logVerbose("ServiceXaWrapper#prepare() : " + xid.toString(), module); int rtn; try { rtn = super.prepare(xid); @@ -246,7 +246,7 @@ public class ServiceXaWrapper extends Ge Debug.logError(e, module); throw e; } - if (Debug.verboseOn()) Debug.logVerbose("ServiceXaWrapper#prepare() : " + rtn + " / " + (rtn == XA_OK) , module); + Debug.logVerbose("ServiceXaWrapper#prepare() : " + rtn + " / " + (rtn == XA_OK) , module); return rtn; } @@ -307,12 +307,12 @@ public class ServiceXaWrapper extends Ge // invoke based on mode switch (mode) { case MODE_ASYNC: - if (Debug.infoOn()) Debug.logInfo(msgPrefix + "Invoking [" + service + "] via runAsync", module); + Debug.logInfo(msgPrefix + "Invoking [" + service + "] via runAsync", module); dctx.getDispatcher().runAsync(service, thisContext, persist); break; case MODE_SYNC: - if (Debug.infoOn()) Debug.logInfo(msgPrefix + "Invoking [" + service + "] via runSyncIgnore", module); + Debug.logInfo(msgPrefix + "Invoking [" + service + "] via runSyncIgnore", module); dctx.getDispatcher().runSyncIgnore(service, thisContext); break; } @@ -349,7 +349,7 @@ public class ServiceXaWrapper extends Ge } } } else { - if (Debug.verboseOn()) Debug.logVerbose("No " + msgPrefix + "service defined; nothing to do", module); + Debug.logVerbose("No " + msgPrefix + "service defined; nothing to do", module); } this.xid = null; |
Free forum by Nabble | Edit this page |