Author: arunpatidar
Date: Sat Aug 27 09:45:23 2016 New Revision: 1757979 URL: http://svn.apache.org/viewvc?rev=1757979&view=rev Log: Applied patch from jira issue - OFBIZ-7912 - Enforce noninstantiability to ServiceUtil class. Thanks Rishi Solanki and Pratik Kulshreshth for your contribution. Modified: ofbiz/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisServices.java ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisShipmentServices.java Modified: ofbiz/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java?rev=1757979&r1=1757978&r2=1757979&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java (original) +++ ofbiz/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java Sat Aug 27 09:45:23 2016 @@ -287,7 +287,7 @@ public class PartyServices { String partyId = getPartyId(context); if (UtilValidate.isEmpty(partyId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.resource, + return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.getResource(), "serviceUtil.party_id_missing", locale)); } @@ -465,7 +465,7 @@ public class PartyServices { String partyId = getPartyId(context); if (UtilValidate.isEmpty(partyId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.resource, + return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.getResource(), "serviceUtil.party_id_missing", locale)); } @@ -605,7 +605,7 @@ public class PartyServices { String partyId = getPartyId(context); if (UtilValidate.isEmpty(partyId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.resource, + return ServiceUtil.returnError(UtilProperties.getMessage(ServiceUtil.getResource(), "serviceUtil.party_id_missing", locale)); } Modified: ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java?rev=1757979&r1=1757978&r2=1757979&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java (original) +++ ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java Sat Aug 27 09:45:23 2016 @@ -549,7 +549,7 @@ public class ModelService extends Abstra for (String missingKey: requiredButNull) { String message = this.getParam(missingKey).getPrimaryFailMessage(locale); if (message == null) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "ModelService.following_required_parameter_missing", locale); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "ModelService.following_required_parameter_missing", locale); message = errMsg + " [" + this.name + "." + missingKey + "]"; } missingMsg.add(message); @@ -625,7 +625,7 @@ public class ModelService extends Abstra for (String key: missing) { String msg = model.getParam(key).getPrimaryFailMessage(locale); if (msg == null) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "ModelService.following_required_parameter_missing", locale) ; + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "ModelService.following_required_parameter_missing", locale) ; msg = errMsg + " [" + mode + "] [" + model.name + "." + key + "]"; } missingMsgs.add(msg); Modified: ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java?rev=1757979&r1=1757978&r2=1757979&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java (original) +++ ofbiz/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java Sat Aug 27 09:45:23 2016 @@ -55,10 +55,12 @@ import com.ibm.icu.util.Calendar; /** * Generic Service Utility Class */ -public class ServiceUtil { +public final class ServiceUtil { public static final String module = ServiceUtil.class.getName(); - public static final String resource = "ServiceErrorUiLabels"; + private static final String resource = "ServiceErrorUiLabels"; + + private ServiceUtil () {} /** A little short-cut method to check to see if a service returned an error */ public static boolean isError(Map<String, ? extends Object> results) { @@ -728,4 +730,8 @@ public class ServiceUtil { return outMap; } + + public static String getResource() { + return resource; + } } Modified: ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisServices.java?rev=1757979&r1=1757978&r2=1757979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisServices.java Sat Aug 27 09:45:23 2016 @@ -209,7 +209,7 @@ public class OagisServices { } dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoContext, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } @@ -223,7 +223,7 @@ public class OagisServices { oagisMsgInfoContext.put("processingStatusId", "OAGMP_SENT"); dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoContext, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "OagisServiceCompletedSuccessfully", locale)); Modified: ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisShipmentServices.java?rev=1757979&r1=1757978&r2=1757979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisShipmentServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/main/java/org/apache/ofbiz/oagis/OagisShipmentServices.java Sat Aug 27 09:45:23 2016 @@ -769,7 +769,7 @@ public class OagisShipmentServices { comiCtx.put("userLogin", userLogin); dispatcher.runSync("createOagisMessageInfo", comiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } if (Debug.infoOn()) Debug.logInfo("Saved OagisMessageInfo for oagisSendProcessShipment message for orderId [" + orderId + "]", module); @@ -896,7 +896,7 @@ public class OagisShipmentServices { } dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } @@ -909,7 +909,7 @@ public class OagisShipmentServices { uomiCtx.put("userLogin", userLogin); dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } return sendMessageReturn; @@ -923,7 +923,7 @@ public class OagisShipmentServices { uomiCtx.put("userLogin", userLogin); dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } } catch (Throwable t) { @@ -1062,7 +1062,7 @@ public class OagisShipmentServices { comiCtx.put("userLogin", userLogin); dispatcher.runSync("createOagisMessageInfo", comiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } @@ -1141,7 +1141,7 @@ public class OagisShipmentServices { } dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } @@ -1154,7 +1154,7 @@ public class OagisShipmentServices { uomiCtx.put("userLogin", userLogin); dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } return sendMessageReturn; @@ -1167,7 +1167,7 @@ public class OagisShipmentServices { uomiCtx.put("userLogin", userLogin); dispatcher.runSync("updateOagisMessageInfo", uomiCtx, 60, true); } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + String errMsg = UtilProperties.getMessage(ServiceUtil.getResource(), "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } } catch (Throwable t) { |
Free forum by Nabble | Edit this page |