This is an automated email from the ASF dual-hosted git repository.
pawan pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new 4374776 Improved: Change resources with proper naming convention in framework(OFBIZ-11834) 4374776 is described below commit 43747764bc153f935a808cc7e34e46380ea8395d Author: Pawan Verma <[hidden email]> AuthorDate: Thu Jun 18 15:30:00 2020 +0530 Improved: Change resources with proper naming convention in framework(OFBIZ-11834) Also, modified checkstyleMain.maxErrors to 26735(-24) Thanks: Jacques and Suraj for review. --- build.gradle | 2 +- .../org/apache/ofbiz/common/CdyneServices.java | 10 +-- .../org/apache/ofbiz/common/CommonServices.java | 18 ++-- .../java/org/apache/ofbiz/common/FindServices.java | 8 +- .../java/org/apache/ofbiz/common/FtpServices.java | 24 +++--- .../apache/ofbiz/common/email/EmailServices.java | 28 +++---- .../ofbiz/common/email/NotificationServices.java | 14 ++-- .../apache/ofbiz/common/image/ImageTransform.java | 26 +++--- .../apache/ofbiz/common/login/LoginServices.java | 98 +++++++++++----------- .../common/preferences/PreferenceServices.java | 30 +++---- .../apache/ofbiz/common/status/StatusServices.java | 4 +- .../ofbiz/entityext/data/EntityDataServices.java | 32 +++---- .../ofbiz/entityext/data/UpgradeServices.java | 8 +- .../synchronization/EntitySyncServices.java | 34 ++++---- .../org/apache/ofbiz/service/ModelPermission.java | 16 ++-- .../org/apache/ofbiz/service/ModelService.java | 4 +- .../ofbiz/service/engine/EntityAutoEngine.java | 16 ++-- .../org/apache/ofbiz/service/job/JobServices.java | 14 ++-- .../test/ServiceEngineTestPermissionServices.java | 2 +- .../service/test/ServiceEngineTestServices.java | 50 +++++------ .../org/apache/ofbiz/service/test/XmlRpcTests.java | 8 +- .../apache/ofbiz/webtools/WebToolsServices.java | 74 ++++++++-------- .../webtools/labelmanager/LabelManagerFactory.java | 2 +- .../webtools/labelmanager/SaveLabelsToXmlFile.java | 14 ++-- 24 files changed, 268 insertions(+), 268 deletions(-) diff --git a/build.gradle b/build.gradle index 649a4b5..496673e 100644 --- a/build.gradle +++ b/build.gradle @@ -287,7 +287,7 @@ checkstyle { // the sum of errors found last time it was changed after using the // ‘checkstyle’ tool present in the framework and in the official // plugins. - tasks.checkstyleMain.maxErrors = 26759 + tasks.checkstyleMain.maxErrors = 26735 // Currently there are a lot of errors so we need to temporarily // hide them to avoid polluting the terminal output. showViolations = false diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/CdyneServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/CdyneServices.java index 93efc06..dbda4ff 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/CdyneServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/CdyneServices.java @@ -42,7 +42,7 @@ import org.xml.sax.SAXException; public class CdyneServices { public final static String MODULE = CdyneServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; public final static String licenseKey = UtilProperties.getPropertyValue("cdyne", "LicenseKey", "0"); /** @@ -65,19 +65,19 @@ public class CdyneServices { populateCdyneAddress(addressRootElement, response); if ("true".equals(response.get("ServiceError"))) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneServiceError", UtilMisc.toMap("zipcode", zipcode), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonCDyneServiceError", UtilMisc.toMap("zipcode", zipcode), locale)); } if ("true".equals(response.get("AddressError"))) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneAddressError", UtilMisc.toMap("zipcode", zipcode), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonCDyneAddressError", UtilMisc.toMap("zipcode", zipcode), locale)); } return response; } catch (HttpClientException e) { Debug.logError(e, "Error calling CDyne service at URL [" + serviceUrl + "]: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneCallingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonCDyneCallingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } catch (SAXException | ParserConfigurationException | IOException e) { Debug.logError(e, "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneParsingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonCDyneParsingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java index c00e3f6..c7f838c 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java @@ -71,7 +71,7 @@ import org.apache.ofbiz.service.mail.MimeMessageWrapper; public class CommonServices { public final static String MODULE = CommonServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; /** * Generic Test Service @@ -143,7 +143,7 @@ public class CommonServices { Debug.logError(e, MODULE); } Locale locale = (Locale) context.get("locale"); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonTestRollingBack", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonTestRollingBack", locale)); } public static Map<String, Object> testCommitListener(DispatchContext dctx, Map<String, ?> context) { @@ -190,7 +190,7 @@ public class CommonServices { delegator.create(newValue); } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNoteCannotBeUpdated", UtilMisc.toMap("errorString", e.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNoteCannotBeUpdated", UtilMisc.toMap("errorString", e.getMessage()), locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -238,7 +238,7 @@ public class CommonServices { */ public static Map<String, Object> returnErrorService(DispatchContext dctx, Map<String, ?> context) { Locale locale = (Locale) context.get("locale"); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonServiceReturnError", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonServiceReturnError", locale)); } /** @@ -273,7 +273,7 @@ public class CommonServices { delegator.create(newEntity); } catch (GenericEntityException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEntityTestFailure", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEntityTestFailure", locale)); } return ServiceUtil.returnSuccess(); @@ -501,7 +501,7 @@ public class CommonServices { count = EntityQuery.use(delegator).from("SequenceValueItem").queryCount(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonPingDatasourceCannotConnect", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonPingDatasourceCannotConnect", locale)); } if (count != 0L) { @@ -509,7 +509,7 @@ public class CommonServices { result.put("message", message); return result; } - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonPingDatasourceInvalidCount", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonPingDatasourceInvalidCount", locale)); } public static Map<String, Object> getAllMetrics(DispatchContext dctx, Map<String, ?> context) { @@ -533,13 +533,13 @@ public class CommonServices { Locale locale = (Locale)context.get("locale"); String name = UtilCodec.getDecoder("url").decode(originalName); if (name == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonExceptionThrownWhileDecodingMetric", UtilMisc.toMap("originalName", originalName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonExceptionThrownWhileDecodingMetric", UtilMisc.toMap("originalName", originalName), locale)); } Metrics metric = MetricsFactory.getMetric(name); if (metric != null) { metric.reset(); return ServiceUtil.returnSuccess(); } - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonMetricNotFound", UtilMisc.toMap("name", name), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonMetricNotFound", UtilMisc.toMap("name", name), locale)); } } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java index e4506f9..cd6a404 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java @@ -68,7 +68,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class FindServices { private static final String MODULE = FindServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; public static final Map<String, EntityComparisonOperator<?, ?>> entityOperators; static { @@ -549,7 +549,7 @@ public class FindServices { "filterByDateValue", filterByDateValue, "userLogin", userLogin, "fromDateName", fromDateName, "thruDateName", thruDateName, "locale", context.get("locale"), "timeZone", context.get("timeZone"))); } catch (GenericServiceException gse) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorPreparingConditions", UtilMisc.toMap("errorString", gse.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonFindErrorPreparingConditions", UtilMisc.toMap("errorString", gse.getMessage()), locale)); } EntityConditionList<EntityCondition> exprList = UtilGenerics.cast(prepareResult.get("entityConditionList")); List<String> orderByList = checkCollection(prepareResult.get("orderByList"), String.class); @@ -562,7 +562,7 @@ public class FindServices { "locale", context.get("locale"), "timeZone", context.get("timeZone"), "maxRows", maxRows)); } catch (GenericServiceException gse) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorRetrieveIterator", UtilMisc.toMap("errorString", gse.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonFindErrorRetrieveIterator", UtilMisc.toMap("errorString", gse.getMessage()), locale)); } if (executeResult.get("listIt") == null) { @@ -697,7 +697,7 @@ public class FindServices { listSize = listIt.getResultsSizeAfterPartialList(); } } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorRunning", UtilMisc.toMap("entityName", entityName, "errorString", e.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonFindErrorRunning", UtilMisc.toMap("entityName", entityName, "errorString", e.getMessage()), locale)); } Map<String, Object> results = ServiceUtil.returnSuccess(); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java index 143dfaf..a55e3aa 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java @@ -46,7 +46,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class FtpServices { public final static String MODULE = FtpServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; public static Map<String, Object> putFile(DispatchContext dctx, Map<String, ?> context) { Locale locale = (Locale) context.get("locale"); @@ -56,7 +56,7 @@ public class FtpServices { localFile = new FileInputStream((String) context.get("localFilename")); } catch (IOException ioe) { Debug.logError(ioe, "[putFile] Problem opening local file", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFtpFileCannotBeOpen", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonFtpFileCannotBeOpen", locale)); } List<String> errorList = new LinkedList<>(); FTPClient ftp = new FTPClient(); @@ -70,14 +70,14 @@ public class FtpServices { ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { Debug.logInfo("[putFile] Server refused connection", MODULE); - errorList.add(UtilProperties.getMessage(resource, "CommonFtpConnectionRefused", locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpConnectionRefused", locale)); } else { String username = (String) context.get("username"); String password = (String) context.get("password"); Debug.logInfo("[putFile] logging in: username=" + username + ", password=" + password, MODULE); if (!ftp.login(username, password)) { Debug.logInfo("[putFile] login failed", MODULE); - errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); } else { Boolean binaryTransfer = (Boolean) context.get("binaryTransfer"); boolean binary = (binaryTransfer == null) ? false : binaryTransfer; @@ -92,7 +92,7 @@ public class FtpServices { Debug.logInfo("[putFile] storing local file remotely as: " + context.get("remoteFilename"), MODULE); if (!ftp.storeFile((String) context.get("remoteFilename"), localFile)) { Debug.logInfo("[putFile] store was unsuccessful", MODULE); - errorList.add(UtilProperties.getMessage(resource, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); } else { Debug.logInfo("[putFile] store was successful", MODULE); List<String> siteCommands = checkCollection(context.get("siteCommands"), String.class); @@ -100,7 +100,7 @@ public class FtpServices { for (String command : siteCommands) { Debug.logInfo("[putFile] sending SITE command: " + command, MODULE); if (!ftp.sendSiteCommand(command)) { - errorList.add(UtilProperties.getMessage(resource, "CommonFtpSiteCommandFailed", UtilMisc.toMap("command", command, "replyString", ftp.getReplyString()), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpSiteCommandFailed", UtilMisc.toMap("command", command, "replyString", ftp.getReplyString()), locale)); } } } @@ -110,7 +110,7 @@ public class FtpServices { } } catch (IOException ioe) { Debug.logWarning(ioe, "[putFile] caught exception: " + ioe.getMessage(), MODULE); - errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } finally { try { if (ftp.isConnected()) { @@ -136,7 +136,7 @@ public class FtpServices { localFile = new FileOutputStream(localFilename); } catch (IOException ioe) { Debug.logError(ioe, "[getFile] Problem opening local file", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFtpFileCannotBeOpen", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonFtpFileCannotBeOpen", locale)); } List<String> errorList = new LinkedList<>(); FTPClient ftp = new FTPClient(); @@ -148,12 +148,12 @@ public class FtpServices { } ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { - errorList.add(UtilProperties.getMessage(resource, "CommonFtpConnectionRefused", locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpConnectionRefused", locale)); } else { String username = (String) context.get("username"); String password = (String) context.get("password"); if (!ftp.login(username, password)) { - errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); } else { Boolean binaryTransfer = (Boolean) context.get("binaryTransfer"); boolean binary = (binaryTransfer == null) ? false : binaryTransfer; @@ -166,14 +166,14 @@ public class FtpServices { ftp.enterLocalPassiveMode(); } if (!ftp.retrieveFile((String) context.get("remoteFilename"), localFile)) { - errorList.add(UtilProperties.getMessage(resource, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); } } ftp.logout(); } } catch (IOException ioe) { Debug.logWarning(ioe, "[getFile] caught exception: " + ioe.getMessage(), MODULE); - errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } finally { try { if (ftp.isConnected()) { diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java index 3448dd7..a19ca3f 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java @@ -89,7 +89,7 @@ public class EmailServices { public final static String MODULE = EmailServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; /** * Basic JavaMail Service @@ -212,7 +212,7 @@ public class EmailServices { isStartTLSEnabled = EntityUtilProperties.propertyValueEqualsIgnoreCase("general", "mail.smtp.starttls.enable", "true", delegator); } } else if (sendVia == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMissingParameterSendVia", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendMissingParameterSendVia", locale)); } if (contentType == null) { @@ -315,7 +315,7 @@ public class EmailServices { } catch (MessagingException e) { Debug.logError(e, "MessagingException when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", MODULE); Debug.logError("Email message that could not be created to [" + sendTo + "] had context: " + context, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMessagingException", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendMessagingException", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } // check to see if sending mail is enabled @@ -364,13 +364,13 @@ public class EmailServices { Debug.logError(e1, MODULE); } } else { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendAddressError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendAddressError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } } catch (MessagingException e) { // message code prefix may be used by calling services to determine the cause of the failure Debug.logError(e, "[CON] Connection error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", MODULE); Debug.logError("Email message that could not be sent to [" + sendTo + "] had context: " + context, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendConnectionError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendConnectionError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } return results; } @@ -395,7 +395,7 @@ public class EmailServices { url = new URL(bodyUrl); } catch (MalformedURLException e) { Debug.logWarning(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMalformedUrl", UtilMisc.toMap("bodyUrl", bodyUrl, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendMalformedUrl", UtilMisc.toMap("bodyUrl", bodyUrl, "errorString", e.toString()), locale)); } HttpClient httpClient = new HttpClient(url, bodyUrlParameters); @@ -405,7 +405,7 @@ public class EmailServices { body = httpClient.post(); } catch (HttpClientException e) { Debug.logWarning(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendGettingError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendGettingError", UtilMisc.toMap("errorString", e.toString()), locale)); } sendMailContext.put("body", body); @@ -501,7 +501,7 @@ public class EmailServices { screenStringRenderer = new MacroScreenRenderer(visualTheme.getModelTheme(), "screen"); } catch (TemplateException | IOException e) { Debug.logError(e, "Error rendering screen for email: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } ScreenRenderer screens = new ScreenRenderer(bodyWriter, screenContext, screenStringRenderer); screens.populateContextForService(dctx, bodyParameters); @@ -512,7 +512,7 @@ public class EmailServices { screens.render(bodyScreenUri); } catch (GeneralException | IOException | SAXException | ParserConfigurationException e) { Debug.logError(e, "Error rendering screen for email: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } } @@ -570,7 +570,7 @@ public class EmailServices { } catch (GeneralException|IOException|SAXException|ParserConfigurationException |TemplateException ge) { Debug.logError(ge, "Error rendering PDF attachment for email: " + ge.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", ge.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", ge.toString()), locale)); } serviceContext.put("bodyParts", bodyParts); @@ -635,7 +635,7 @@ public class EmailServices { } } catch (Exception e) { Debug.logError(e, "Error send email:" + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonEmailSendError", UtilMisc.toMap("errorString", e.toString()), locale)); } if (ServiceUtil.isError(sendMailResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(sendMailResult)); @@ -677,9 +677,9 @@ public class EmailServices { newContext.put("sendFailureNotification", false); newContext.put("sendFrom", context.get("sendFrom")); newContext.put("sendTo", context.get("sendFrom")); - newContext.put("subject", UtilProperties.getMessage(resource, "CommonEmailSendUndeliveredMail", locale)); + newContext.put("subject", UtilProperties.getMessage(RESOURCE, "CommonEmailSendUndeliveredMail", locale)); StringBuilder sb = new StringBuilder(); - sb.append(UtilProperties.getMessage(resource, "CommonEmailDeliveryFailed", locale)); + sb.append(UtilProperties.getMessage(RESOURCE, "CommonEmailDeliveryFailed", locale)); sb.append("/n/n"); for (SMTPAddressFailedException failure : failures) { sb.append(failure.getAddress()); @@ -687,7 +687,7 @@ public class EmailServices { sb.append(failure.getMessage()); sb.append("/n/n"); } - sb.append(UtilProperties.getMessage(resource, "CommonEmailDeliveryOriginalMessage", locale)); + sb.append(UtilProperties.getMessage(RESOURCE, "CommonEmailDeliveryOriginalMessage", locale)); sb.append("/n/n"); List<Map<String, Object>> bodyParts = new LinkedList<>(); bodyParts.add(UtilMisc.<String, Object>toMap("content", sb.toString(), "type", "text/plain")); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java index 05e231f..460f6c6 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java @@ -101,7 +101,7 @@ import freemarker.template.TemplateException; public class NotificationServices { private static final String MODULE = NotificationServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; /** * This will use the {@link #prepareNotification(DispatchContext, Map) prepareNotification(DispatchContext, Map)} @@ -160,11 +160,11 @@ public class NotificationServices { result = dispatcher.runSync("sendMail", emailContext); } else { Debug.logError("Invalid email body; null is not allowed", MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailInvalidBody", locale)); + result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailInvalidBody", locale)); } } catch (GenericServiceException serviceException) { Debug.logError(serviceException, "Error sending email", MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailDeliveryError", locale)); + result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailDeliveryError", locale)); } return result; @@ -205,7 +205,7 @@ public class NotificationServices { if (templateUrl == null) { Debug.logError("Problem getting the template URL: " + templateName + " not found", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemFindingTemplate", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailProblemFindingTemplate", locale)); } // process the template with the given data and write @@ -217,14 +217,14 @@ public class NotificationServices { String notificationBody = writer.toString(); // generate the successful response - result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "CommonNotifyEmailMessageBodyGeneratedSuccessfully", locale)); + result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailMessageBodyGeneratedSuccessfully", locale)); result.put("body", notificationBody); } catch (IOException ie) { Debug.logError(ie, "Problems reading template", MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemReadingTemplate", locale)); + result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailProblemReadingTemplate", locale)); } catch (TemplateException te) { Debug.logError(te, "Problems processing template", MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemProcessingTemplate", locale)); + result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonNotifyEmailProblemProcessingTemplate", locale)); } return result; diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java b/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java index cc2be20..931a11b 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java @@ -51,7 +51,7 @@ import org.xml.sax.SAXException; public class ImageTransform { private static final String MODULE = ImageTransform.class.getName(); - public static final String resource = "CommonErrorUiLabels"; + private static final String RESOURCE = "CommonErrorUiLabels"; public ImageTransform() { } @@ -77,12 +77,12 @@ public class ImageTransform { try { bufImg = ImageIO.read(new File(fileLocation)); } catch (IllegalArgumentException e) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.input_is_null", locale) + " : " + fileLocation + " ; " + e.toString(); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.input_is_null", locale) + " : " + fileLocation + " ; " + e.toString(); Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } catch (IOException e) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.error_occurs_during_reading", locale) + " : " + fileLocation + " ; " + e.toString(); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.error_occurs_during_reading", locale) + " : " + fileLocation + " ; " + e.toString(); Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -126,7 +126,7 @@ public class ImageTransform { defaultWidth = -1; } if (defaultHeight == 0.0 || defaultWidth == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.one_default_dimension_is_null", locale) + " : defaultHeight = " + defaultHeight + " ; defaultWidth = " + defaultWidth; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.one_default_dimension_is_null", locale) + " : defaultHeight = " + defaultHeight + " ; defaultWidth = " + defaultWidth; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -137,7 +137,7 @@ public class ImageTransform { if (defaultHeight == -1) { scaleFactor = defaultWidth / imgWidth; if (scaleFactor == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -145,7 +145,7 @@ public class ImageTransform { } else if (defaultWidth == -1) { scaleFactor = defaultHeight / imgHeight; if (scaleFactor == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -153,7 +153,7 @@ public class ImageTransform { } else if (imgHeight > imgWidth) { scaleFactor = defaultHeight / imgHeight; if (scaleFactor == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -165,7 +165,7 @@ public class ImageTransform { } else { scaleFactor = defaultWidth / imgWidth; if (scaleFactor == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; @@ -177,14 +177,14 @@ public class ImageTransform { } if (scaleFactor == 0.0) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.final_scale_factor_is_null", locale) + " = " + scaleFactor; + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.final_scale_factor_is_null", locale) + " = " + scaleFactor; Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } int bufImgType; if (BufferedImage.TYPE_CUSTOM == bufImg.getType()) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.unknown_buffered_image_type", locale); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.unknown_buffered_image_type", locale); Debug.logWarning(errMsg, MODULE); // apply a type for image majority bufImgType = BufferedImage.TYPE_INT_ARGB_PRE; @@ -225,12 +225,12 @@ public class ImageTransform { try { document = UtilXml.readXmlDocument(new FileInputStream(fileFullPath), fileFullPath); } catch (ParserConfigurationException | SAXException e) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.errors_occurred_during_parsing", locale) + " ImageProperties.xml " + e.toString(); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.errors_occurred_during_parsing", locale) + " ImageProperties.xml " + e.toString(); Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, "error"); return result; } catch (IOException e) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.error_prevents_the document_from_being_fully_parsed", locale) + e.toString(); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.error_prevents_the document_from_being_fully_parsed", locale) + e.toString(); Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, "error"); return result; @@ -239,7 +239,7 @@ public class ImageTransform { try { rootElt = document.getDocumentElement(); } catch (IllegalStateException e) { - String errMsg = UtilProperties.getMessage(resource, "ImageTransform.root_element_has_not_been_set", locale) + e.toString(); + String errMsg = UtilProperties.getMessage(RESOURCE, "ImageTransform.root_element_has_not_been_set", locale) + e.toString(); Debug.logError(errMsg, MODULE); result.put(ModelService.ERROR_MESSAGE, "error"); return result; diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java index 55dd92c..089e826 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java @@ -69,7 +69,7 @@ import org.apache.tomcat.util.res.StringManager; public class LoginServices { private static final String MODULE = LoginServices.class.getName(); - public static final String resource = "SecurityextUiLabels"; + private static final String RESOURCE = "SecurityextUiLabels"; /** Login service to authenticate username and password * @return Map of results including (userLogin) GenericValue object @@ -88,7 +88,7 @@ public class LoginServices { // TODO: this should be moved to using the NEW Authenticator API if ("true".equals(EntityUtilProperties.getPropertyValue("security", "security.ldap.enable", delegator))) { if (!LdapAuthenticationServices.userLogin(ctx, context)) { - String errMsg = UtilProperties.getMessage(resource, "loginservices.ldap_authentication_failed", locale); + String errMsg = UtilProperties.getMessage(RESOURCE, "loginservices.ldap_authentication_failed", locale); if ("true".equals(EntityUtilProperties.getPropertyValue("security", "security.ldap.fail.login", delegator))) { return ServiceUtil.returnError(errMsg); } @@ -120,9 +120,9 @@ public class LoginServices { String errMsg = ""; if (UtilValidate.isEmpty(username)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.username_missing", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.username_missing", locale); } else if (UtilValidate.isEmpty(password) && UtilValidate.isEmpty(jwtToken)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.password_missing", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_missing", locale); } else { if ("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security", "username.lowercase", delegator))) { @@ -277,8 +277,8 @@ public class LoginServices { Debug.logInfo("[LoginServices.userLogin] : Password Incorrect", MODULE); // password invalid... - if (password != null) errMsg = UtilProperties.getMessage(resource,"loginservices.password_incorrect", locale); - else if (jwtToken != null) errMsg = UtilProperties.getMessage(resource,"loginservices.token_incorrect", locale); + if (password != null) errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_incorrect", locale); + else if (jwtToken != null) errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.token_incorrect", locale); // increment failed login count Long currentFailedLogins = userLogin.getLong("successiveFailedLogins"); @@ -397,19 +397,19 @@ public class LoginServices { } Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("username", username); - errMsg = UtilProperties.getMessage(resource,"loginservices.account_for_user_login_id_disabled",messageMap ,locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.account_for_user_login_id_disabled",messageMap ,locale); if (disabledDateTime != null) { messageMap = UtilMisc.<String, Object>toMap("disabledDateTime", disabledDateTime); - errMsg += " " + UtilProperties.getMessage(resource,"loginservices.since_datetime",messageMap ,locale); + errMsg += " " + UtilProperties.getMessage(RESOURCE,"loginservices.since_datetime",messageMap ,locale); } else { errMsg += "."; } if (loginDisableMinutes > 0 && reEnableTime != null) { messageMap = UtilMisc.<String, Object>toMap("reEnableTime", reEnableTime); - errMsg += " " + UtilProperties.getMessage(resource,"loginservices.will_be_reenabled",messageMap ,locale); + errMsg += " " + UtilProperties.getMessage(RESOURCE,"loginservices.will_be_reenabled",messageMap ,locale); } else { - errMsg += " " + UtilProperties.getMessage(resource,"loginservices.not_scheduled_to_be_reenabled",locale); + errMsg += " " + UtilProperties.getMessage(RESOURCE,"loginservices.not_scheduled_to_be_reenabled",locale); } } } else { @@ -433,7 +433,7 @@ public class LoginServices { //TODO: party + security information is needed; Userlogin will need to be stored } else { // userLogin record not found, user does not exist - errMsg = UtilProperties.getMessage(resource, "loginservices.user_not_found", locale); + errMsg = UtilProperties.getMessage(RESOURCE, "loginservices.user_not_found", locale); Debug.logInfo("[LoginServices.userLogin] Invalid User : '" + username + "'; " + errMsg, MODULE); } } @@ -534,33 +534,33 @@ public class LoginServices { */ private static String checkImpersonationControls(Delegator delegator, GenericValue userLogin, GenericValue userLoginToImpersonate, Locale locale) { if (userLoginToImpersonate == null) { - return UtilProperties.getMessage(resource, "loginservices.username_missing", locale); + return UtilProperties.getMessage(RESOURCE, "loginservices.username_missing", locale); } String userLoginId = userLogin.getString("userLoginId"); String userLoginIdToImpersonate = userLoginToImpersonate.getString("userLoginId"); if (UtilProperties.getPropertyAsBoolean("security", "security.disable.impersonation", true)) { - return UtilProperties.getMessage(resource, "loginevents.impersonation_disabled", locale); + return UtilProperties.getMessage(RESOURCE, "loginevents.impersonation_disabled", locale); } if (!LoginWorker.isUserLoginActive(userLoginToImpersonate)) { Map<String, Object> messageMap = UtilMisc.toMap("username", userLoginIdToImpersonate); - return UtilProperties.getMessage(resource, "loginservices.account_for_user_login_id_disabled", messageMap, locale); + return UtilProperties.getMessage(RESOURCE, "loginservices.account_for_user_login_id_disabled", messageMap, locale); } if (SecurityUtil.hasUserLoginAdminPermission(delegator, userLoginIdToImpersonate)) { - return UtilProperties.getMessage(resource, "loginevents.impersonate_notAdmin", locale); + return UtilProperties.getMessage(RESOURCE, "loginevents.impersonate_notAdmin", locale); } if (userLoginIdToImpersonate.equals(userLoginId)) { - return UtilProperties.getMessage(resource, "loginevents.impersonate_yourself", locale); + return UtilProperties.getMessage(RESOURCE, "loginevents.impersonate_yourself", locale); } //Cannot impersonate more privileged user List<String> missingNeededPermissions = SecurityUtil.hasUserLoginMorePermissionThan(delegator, userLoginId, userLoginIdToImpersonate); if (UtilValidate.isNotEmpty(missingNeededPermissions)) { String missingPermissionListString = missingNeededPermissions.stream().collect(Collectors.joining(", ")); - return UtilProperties.getMessage(resource, "loginevents.impersonate_notEnoughPermission", + return UtilProperties.getMessage(RESOURCE, "loginevents.impersonate_notEnoughPermission", UtilMisc.toMap("missingPermissions", missingPermissionListString), locale); } @@ -654,12 +654,12 @@ public class LoginServices { if (!partyId.equals(loggedInUserLogin.getString("partyId"))) { if (!security.hasEntityPermission("PARTYMGR", "_CREATE", loggedInUserLogin)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.party_with_specified_party_ID_exists_not_have_permission", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.party_with_specified_party_ID_exists_not_have_permission", locale); errorMessageList.add(errMsg); } } } else { - errMsg = UtilProperties.getMessage(resource,"loginservices.must_be_logged_in_and_permission_create_login_party_ID_exists", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.must_be_logged_in_and_permission_create_login_party_ID_exists", locale); errorMessageList.add(errMsg); } } @@ -683,13 +683,13 @@ public class LoginServices { EntityCondition condition = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.EQUALS, EntityFunction.UPPER(userLoginId)); if (UtilValidate.isNotEmpty(EntityQuery.use(delegator).from("UserLogin").where(condition).queryList())) { Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); errorMessageList.add(errMsg); } } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); errorMessageList.add(errMsg); } @@ -703,7 +703,7 @@ public class LoginServices { } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -721,7 +721,7 @@ public class LoginServices { Security security = ctx.getSecurity(); GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "loginevents.password_was_changed_with_success", locale)); + Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "loginevents.password_was_changed_with_success", locale)); // load the external auth modules -- note: this will only run once and cache the objects if (!AuthHelper.authenticatorsLoaded()) { @@ -744,7 +744,7 @@ public class LoginServices { userLoginToUpdate = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_read_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_read_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -753,7 +753,7 @@ public class LoginServices { // TODO: change this security group because we can't use permission groups defined in the applications from the framework. if (!security.hasEntityPermission("PARTYMGR", "_UPDATE", loggedInUserLogin)) { if (!userLoginId.equals(loggedInUserLogin.getString("userLoginId"))) { - errMsg = UtilProperties.getMessage(resource,"loginservices.not_have_permission_update_password_for_user_login", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.not_have_permission_update_password_for_user_login", locale); return ServiceUtil.returnError(errMsg); } if (UtilValidate.isNotEmpty(context.get("login.token"))) { @@ -785,7 +785,7 @@ public class LoginServices { } catch (AuthenticatorException e) { Debug.logError(e, e.getMessage(), MODULE); Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); return ServiceUtil.returnError(errMsg); } //result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); @@ -793,7 +793,7 @@ public class LoginServices { return result; } Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -821,7 +821,7 @@ public class LoginServices { } catch (AuthenticatorException e) { Debug.logError(e, e.getMessage(), MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } } else { @@ -835,7 +835,7 @@ public class LoginServices { createUserLoginPasswordHistory(userLoginToUpdate); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } } @@ -874,11 +874,11 @@ public class LoginServices { if (!loggedInUserLogin.isEmpty()) { // security check: userLogin partyId must equal partyId, or must have PARTYMGR_CREATE permission if (!partyId.equals(loggedInUserLogin.getString("partyId"))) { - errMsg = UtilProperties.getMessage(resource,"loginservices.party_with_party_id_exists_not_permission_create_user_login", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.party_with_party_id_exists_not_permission_create_user_login", locale); errorMessageList.add(errMsg); } } else { - errMsg = UtilProperties.getMessage(resource,"loginservices.must_logged_in_have_permission_create_user_login_exists", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.must_logged_in_have_permission_create_user_login_exists", locale); errorMessageList.add(errMsg); } } @@ -892,14 +892,14 @@ public class LoginServices { } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_read_failure", messageMap, locale); errorMessageList.add(errMsg); } if (newUserLogin != null) { if (!newUserLogin.get("partyId").equals(partyId)) { Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_with_ID_exists", messageMap, locale); errorMessageList.add(errMsg); } else { doCreate = false; @@ -927,7 +927,7 @@ public class LoginServices { } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_create_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -940,7 +940,7 @@ public class LoginServices { } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_disable_old_login_user_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_disable_old_login_user_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -970,7 +970,7 @@ public class LoginServices { // <b>security check</b>: must have PARTYMGR_UPDATE permission if (!security.hasEntityPermission("PARTYMGR", "_UPDATE", loggedInUserLogin) && !security.hasEntityPermission("SECURITY", "_UPDATE", loggedInUserLogin)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.not_permission_update_security_info_for_user_login", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.not_permission_update_security_info_for_user_login", locale); return ServiceUtil.returnError(errMsg); } @@ -980,13 +980,13 @@ public class LoginServices { userLoginToUpdate = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_read_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_read_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } if (userLoginToUpdate == null) { Map<String, String> messageMap = UtilMisc.toMap("userLoginId", userLoginId); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_userlogin_with_id_not_exist", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -1025,7 +1025,7 @@ public class LoginServices { userLoginToUpdate.store(); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.could_not_change_password_write_failure", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -1044,21 +1044,21 @@ public class LoginServices { // if this is a system account don't bother checking the passwords boolean passwordMatches = checkPassword(userLogin.getString("currentPassword"), useEncryption, currentPassword); if ((currentPassword == null) || (!passwordMatches)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.old_password_not_correct_reenter", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.old_password_not_correct_reenter", locale); errorMessageList.add(errMsg); } if (checkPassword(userLogin.getString("currentPassword"), useEncryption, newPassword)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.new_password_is_equal_to_old_password", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.new_password_is_equal_to_old_password", locale); errorMessageList.add(errMsg); } } if (UtilValidate.isEmpty(newPassword) || UtilValidate.isEmpty(newPasswordVerify)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.password_or_verify_missing", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_or_verify_missing", locale); errorMessageList.add(errMsg); } else if (!newPassword.equals(newPasswordVerify)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.password_did_not_match_verify_password", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_did_not_match_verify_password", locale); errorMessageList.add(errMsg); } @@ -1081,7 +1081,7 @@ public class LoginServices { for (GenericValue pwdHistValue : pwdHistList) { if (checkPassword(pwdHistValue.getString("currentPassword"), useEncryption, newPassword)) { Map<String, Integer> messageMap = UtilMisc.toMap("passwordChangeHistoryLimit", passwordChangeHistoryLimit); - errMsg = UtilProperties.getMessage(resource,"loginservices.password_must_be_different_from_last_passwords", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_must_be_different_from_last_passwords", messageMap, locale); errorMessageList.add(errMsg); break; } @@ -1089,7 +1089,7 @@ public class LoginServices { } catch (GenericEntityException e) { Debug.logWarning(e, "", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); - errMsg = UtilProperties.getMessage(resource,"loginevents.error_accessing_password_change_history", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginevents.error_accessing_password_change_history", messageMap, locale); } } @@ -1115,22 +1115,22 @@ public class LoginServices { Map<String, String> messageMap = UtilMisc.toMap("minPasswordLength", Integer.toString(minPasswordLength)); String passwordPatternMessage = EntityUtilProperties.getPropertyValue("security", "security.login.password.pattern.description", "loginservices.password_must_be_least_characters_long", delegator); - errMsg = UtilProperties.getMessage(resource, passwordPatternMessage, messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE, passwordPatternMessage, messageMap, locale); errorMessageList.add(errMsg); } } else { if (!(newPassword.length() >= minPasswordLength)) { Map<String, String> messageMap = UtilMisc.toMap("minPasswordLength", Integer.toString(minPasswordLength)); - errMsg = UtilProperties.getMessage(resource,"loginservices.password_must_be_least_characters_long", messageMap, locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_must_be_least_characters_long", messageMap, locale); errorMessageList.add(errMsg); } } if (newPassword.equalsIgnoreCase(userLogin.getString("userLoginId"))) { - errMsg = UtilProperties.getMessage(resource,"loginservices.password_may_not_equal_username", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_may_not_equal_username", locale); errorMessageList.add(errMsg); } if (UtilValidate.isNotEmpty(passwordHint) && (passwordHint.toUpperCase(Locale.getDefault()).indexOf(newPassword.toUpperCase(Locale.getDefault())) >= 0)) { - errMsg = UtilProperties.getMessage(resource,"loginservices.password_hint_may_not_contain_password", locale); + errMsg = UtilProperties.getMessage(RESOURCE,"loginservices.password_hint_may_not_contain_password", locale); errorMessageList.add(errMsg); } } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/preferences/PreferenceServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/preferences/PreferenceServices.java index d34f262..5976855 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/preferences/PreferenceServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/preferences/PreferenceServices.java @@ -50,7 +50,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class PreferenceServices { private static final String MODULE = PreferenceServices.class.getName(); - public static final String resource = "PrefErrorUiLabels"; + private static final String RESOURCE = "PrefErrorUiLabels"; /** * Retrieves a single user preference from persistent storage. Call with @@ -64,13 +64,13 @@ public class PreferenceServices { public static Map<String, Object> getUserPreference(DispatchContext ctx, Map<String, ?> context) { Locale locale = (Locale) context.get("locale"); if (!PreferenceWorker.isValidGetId(ctx, context)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.permissionError", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.permissionError", locale)); } Delegator delegator = ctx.getDelegator(); String userPrefTypeId = (String) context.get("userPrefTypeId"); if (UtilValidate.isEmpty(userPrefTypeId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.invalidArgument", locale)); } String userLoginId = PreferenceWorker.getUserLoginId(context, true); Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefTypeId", userPrefTypeId); @@ -87,7 +87,7 @@ public class PreferenceServices { } } catch (GeneralException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.readFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.readFailure", new Object[] { e.getMessage() }, locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -114,13 +114,13 @@ public class PreferenceServices { public static Map<String, Object> getUserPreferenceGroup(DispatchContext ctx, Map<String, ?> context) { Locale locale = (Locale) context.get("locale"); if (!PreferenceWorker.isValidGetId(ctx, context)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.permissionError", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.permissionError", locale)); } Delegator delegator = ctx.getDelegator(); String userPrefGroupTypeId = (String) context.get("userPrefGroupTypeId"); if (UtilValidate.isEmpty(userPrefGroupTypeId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.invalidArgument", locale)); } String userLoginId = PreferenceWorker.getUserLoginId(context, false); @@ -134,7 +134,7 @@ public class PreferenceServices { } } catch (GeneralException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.readFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "getPreference.readFailure", new Object[] { e.getMessage() }, locale)); } // for the 'DEFAULT' values find the related values in general properties and if found use those. Properties generalProperties = UtilProperties.getProperties("general"); @@ -168,7 +168,7 @@ public class PreferenceServices { String userPrefTypeId = (String) context.get("userPrefTypeId"); Object userPrefValue = context.get("userPrefValue"); if (UtilValidate.isEmpty(userLoginId) || UtilValidate.isEmpty(userPrefTypeId) || userPrefValue == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.invalidArgument", locale)); } String userPrefGroupTypeId = (String) context.get("userPrefGroupTypeId"); String userPrefDataType = (String) context.get("userPrefDataType"); @@ -181,7 +181,7 @@ public class PreferenceServices { delegator.createOrStore(rec); } catch (GeneralException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); } return ServiceUtil.returnSuccess(); @@ -194,7 +194,7 @@ public class PreferenceServices { String userLoginId = PreferenceWorker.getUserLoginId(context, false); String userPrefTypeId = (String) context.get("userPrefTypeId"); if (UtilValidate.isEmpty(userLoginId) || UtilValidate.isEmpty(userPrefTypeId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.invalidArgument", locale)); } try { @@ -207,7 +207,7 @@ public class PreferenceServices { } } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); } return ServiceUtil.returnSuccess(); @@ -230,7 +230,7 @@ public class PreferenceServices { Map<String, Object> userPrefMap = checkMap(context.get("userPrefMap"), String.class, Object.class); String userPrefGroupTypeId = (String) context.get("userPrefGroupTypeId"); if (UtilValidate.isEmpty(userLoginId) || UtilValidate.isEmpty(userPrefGroupTypeId) || userPrefMap == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.invalidArgument", locale)); } try { @@ -240,7 +240,7 @@ public class PreferenceServices { } } catch (GeneralException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "setPreference.writeFailure", new Object[] { e.getMessage() }, locale)); } return ServiceUtil.returnSuccess(); @@ -263,7 +263,7 @@ public class PreferenceServices { String fromUserLoginId = (String) context.get("fromUserLoginId"); String userPrefGroupTypeId = (String) context.get("userPrefGroupTypeId"); if (UtilValidate.isEmpty(userLoginId) || UtilValidate.isEmpty(userPrefGroupTypeId) || UtilValidate.isEmpty(fromUserLoginId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "copyPreference.invalidArgument", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "copyPreference.invalidArgument", locale)); } try { @@ -279,7 +279,7 @@ public class PreferenceServices { } } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "copyPreference.writeFailure", new Object[] { e.getMessage() }, locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "copyPreference.writeFailure", new Object[] { e.getMessage() }, locale)); } return ServiceUtil.returnSuccess(); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusServices.java index d261c5f..78f3c27 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusServices.java @@ -41,14 +41,14 @@ import org.apache.ofbiz.service.ServiceUtil; public class StatusServices { private static final String MODULE = StatusServices.class.getName(); - public static final String resource = "CommonUiLabels"; + private static final String RESOURCE = "CommonUiLabels"; public static Map<String, Object> getStatusItems(DispatchContext ctx, Map<String, ?> context) { Delegator delegator = ctx.getDelegator(); List<String> statusTypes = checkCollection(context.get("statusTypeIds"), String.class); Locale locale = (Locale) context.get("locale"); if (UtilValidate.isEmpty(statusTypes)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonStatusMandatory", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "CommonStatusMandatory", locale)); } List<GenericValue> statusItems = new LinkedList<>(); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java index 87f0549..dfb7208 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java @@ -65,11 +65,11 @@ import org.apache.shiro.crypto.AesCipherService; public class EntityDataServices { private static final String MODULE = EntityDataServices.class.getName(); - public static final String resource = "EntityExtUiLabels"; + private static final String RESOURCE = "EntityExtUiLabels"; public static Map<String, Object> exportDelimitedToDirectory(DispatchContext dctx, Map<String, Object> context) { Locale locale = (Locale) context.get("locale"); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtThisServiceIsNotYetImplemented", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtThisServiceIsNotYetImplemented", locale)); } public static Map<String, Object> importDelimitedFromDirectory(DispatchContext dctx, Map<String, Object> context) { @@ -80,14 +80,14 @@ public class EntityDataServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } // get the directory & delimiter String rootDirectory = (String) context.get("rootDirectory"); URL rootDirectoryUrl = UtilURL.fromResource(rootDirectory); if (rootDirectoryUrl == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtUnableToLocateRootDirectory", UtilMisc.toMap("rootDirectory", rootDirectory), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtUnableToLocateRootDirectory", UtilMisc.toMap("rootDirectory", rootDirectory), locale)); } String delimiter = (String) context.get("delimiter"); @@ -100,11 +100,11 @@ public class EntityDataServices { try { root = new File(new URI(rootDirectoryUrl.toExternalForm())); } catch (URISyntaxException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtUnableToLocateRootDirectoryURI", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtUnableToLocateRootDirectoryURI", locale)); } if (!root.exists() || !root.isDirectory() || !root.canRead()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtRootDirectoryDoesNotExists", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtRootDirectoryDoesNotExists", locale)); } // get the file list @@ -119,7 +119,7 @@ public class EntityDataServices { } } } else { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtNoFileAvailableInTheRootDirectory", UtilMisc.toMap("rootDirectory", rootDirectory), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtNoFileAvailableInTheRootDirectory", UtilMisc.toMap("rootDirectory", rootDirectory), locale)); } return ServiceUtil.returnSuccess(); @@ -133,7 +133,7 @@ public class EntityDataServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } String delimiter = (String) context.get("delimiter"); @@ -151,10 +151,10 @@ public class EntityDataServices { } catch (GeneralException e) { return ServiceUtil.returnError(e.getMessage()); } catch (FileNotFoundException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtFileNotFound", UtilMisc.toMap("fileName", file.getName()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtFileNotFound", UtilMisc.toMap("fileName", file.getName()), locale)); } catch (IOException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtProblemReadingFile", UtilMisc.toMap("fileName", file.getName()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtProblemReadingFile", UtilMisc.toMap("fileName", file.getName()), locale)); } long endTime = System.currentTimeMillis(); @@ -331,7 +331,7 @@ public class EntityDataServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } String groupName = (String) context.get("groupName"); @@ -346,7 +346,7 @@ public class EntityDataServices { modelEntities = delegator.getModelEntityMapByGroup(groupName); } catch (GenericEntityException e) { Debug.logError(e, "Error getting list of entities in group: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); } // step 1 - remove FK indices @@ -440,7 +440,7 @@ public class EntityDataServices { } } catch (GenericEntityException e) { Debug.logError(e, "Error unwrapping ByteWrapper records: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorUnwrappingRecords", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorUnwrappingRecords", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -454,7 +454,7 @@ public class EntityDataServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } String oldKey = (String) context.get("oldKey"); String newKey = (String) context.get("newKey"); @@ -505,7 +505,7 @@ public class EntityDataServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } String groupName = (String) context.get("groupName"); @@ -515,7 +515,7 @@ public class EntityDataServices { modelEntities = delegator.getModelEntityMapByGroup(groupName); } catch (GenericEntityException e) { Debug.logError(e, "Error getting list of entities in group: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); } for (ModelEntity modelEntity: modelEntities.values()) { diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/UpgradeServices.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/UpgradeServices.java index a887b69..641c57f 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/UpgradeServices.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/UpgradeServices.java @@ -48,7 +48,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class UpgradeServices { private static final String MODULE = UpgradeServices.class.getName(); - public static final String resource = "EntityExtUiLabels"; + private static final String RESOURCE = "EntityExtUiLabels"; /** @@ -76,8 +76,8 @@ public class UpgradeServices { // check permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (!security.hasPermission("ENTITY_MAINT", userLogin)) { - Debug.logError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtServicePermissionNotGranted", locale)); + Debug.logError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale), MODULE); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtServicePermissionNotGranted", locale)); } String groupName = (String) context.get("groupName"); @@ -109,7 +109,7 @@ public class UpgradeServices { dataWriter.println("SET FOREIGN_KEY_CHECKS=1;"); } catch (GenericEntityException e) { Debug.logError(e, "Error getting list of entities in group: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorGettingListOfEntityInGroup", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (FileNotFoundException | UnsupportedEncodingException e) { Debug.logError(e, e.getMessage(), MODULE); return ServiceUtil.returnError(e.getMessage()); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncServices.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncServices.java index e047168..9d55f6b 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncServices.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncServices.java @@ -69,7 +69,7 @@ import com.ibm.icu.util.Calendar; public class EntitySyncServices { private static final String MODULE = EntitySyncServices.class.getName(); - public static final String resource = "EntityExtUiLabels"; + private static final String RESOURCE = "EntityExtUiLabels"; /** * Run an Entity Sync (checks to see if other already running, etc) @@ -83,7 +83,7 @@ public class EntitySyncServices { try { esc = new EntitySyncContext(dctx, context); if ("Y".equals(esc.entitySync.get("forPullOnly"))) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtCannotDoEntitySyncPush", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtCannotDoEntitySyncPush", locale)); } esc.runPushStartRunning(); @@ -139,7 +139,7 @@ public class EntitySyncServices { if (UtilValidate.isNotEmpty(overrideDelegatorName)) { delegator = DelegatorFactory.getDelegator(overrideDelegatorName); if (delegator == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtCannotFindDelegator", UtilMisc.toMap("overrideDelegatorName", overrideDelegatorName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtCannotFindDelegator", UtilMisc.toMap("overrideDelegatorName", overrideDelegatorName), locale)); } } //LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -251,10 +251,10 @@ public class EntitySyncServices { return result; } catch (GenericEntityException e) { Debug.logError(e, "Exception saving Entity Sync Data for entitySyncId [" + entitySyncId + "]: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtExceptionSavingEntitySyncData", UtilMisc.toMap("entitySyncId", entitySyncId, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtExceptionSavingEntitySyncData", UtilMisc.toMap("entitySyncId", entitySyncId, "errorString", e.toString()), locale)); } catch (Throwable t) { Debug.logError(t, "Error saving Entity Sync Data for entitySyncId [" + entitySyncId + "]: " + t.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorSavingEntitySyncData", UtilMisc.toMap("entitySyncId", entitySyncId, "errorString", t.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorSavingEntitySyncData", UtilMisc.toMap("entitySyncId", entitySyncId, "errorString", t.toString()), locale)); } } @@ -307,7 +307,7 @@ public class EntitySyncServices { try { Map<String, Object> result = dispatcher.runSync(remotePullAndReportEntitySyncDataName, remoteCallContext); if (ServiceUtil.isError(result)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale), null, null, result); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale), null, null, result); } startDate = (Timestamp) result.get("startDate"); @@ -338,7 +338,7 @@ public class EntitySyncServices { callLocalStoreContext.put("userLogin", context.get("userLogin")); Map<String, Object> storeResult = dispatcher.runSync("storeEntitySyncData", callLocalStoreContext); if (ServiceUtil.isError(storeResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCallingService", locale), null, null, storeResult); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCallingService", locale), null, null, storeResult); } // get results for next pass @@ -353,14 +353,14 @@ public class EntitySyncServices { } } catch (GenericServiceException e) { Debug.logError(e, "Error calling service to store data locally: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCallingService", locale) + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCallingService", locale) + e.toString()); } } catch (GenericServiceException e) { Debug.logError(e, "Exception calling remote pull and report EntitySync service with name: " + remotePullAndReportEntitySyncDataName + "; " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale) + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale) + e.toString()); } catch (Throwable t) { Debug.logError(t, "Error calling remote pull and report EntitySync service with name: " + remotePullAndReportEntitySyncDataName + "; " + t.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale) + t.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCallingRemotePull", UtilMisc.toMap("remotePullAndReportEntitySyncDataName", remotePullAndReportEntitySyncDataName), locale) + t.toString()); } } @@ -382,7 +382,7 @@ public class EntitySyncServices { Debug.logInfo("Doing pullAndReportEntitySyncData for entitySyncId=" + esc.entitySyncId + ", currentRunStartTime=" + esc.currentRunStartTime + ", currentRunEndTime=" + esc.currentRunEndTime, MODULE); if ("Y".equals(esc.entitySync.get("forPushOnly"))) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtCannotDoEntitySyncPush", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtCannotDoEntitySyncPush", locale)); } // Part 1: if any results are passed, store the results for the given startDate, update EntitySync, etc @@ -541,7 +541,7 @@ public class EntitySyncServices { Debug.logError(e, MODULE); } if (xmlSyncDoc == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtEntitySyncXMLDocumentIsNotValid", UtilMisc.toMap("fileName", fileName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtEntitySyncXMLDocumentIsNotValid", UtilMisc.toMap("fileName", fileName), locale)); } List<? extends Element> syncElements = UtilXml.childElementList(xmlSyncDoc.getDocumentElement()); @@ -571,14 +571,14 @@ public class EntitySyncServices { // TODO create a response document to send back to the initial sync machine } catch (GenericServiceException gse) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtUnableToLoadXMLDocument", UtilMisc.toMap("entitySyncId", entitySyncId, "startTime", startTime, "errorString", gse.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtUnableToLoadXMLDocument", UtilMisc.toMap("entitySyncId", entitySyncId, "startTime", startTime, "errorString", gse.getMessage()), locale)); } catch (Exception e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtUnableToLoadXMLDocument", UtilMisc.toMap("entitySyncId", entitySyncId, "startTime", startTime, "errorString", e.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtUnableToLoadXMLDocument", UtilMisc.toMap("entitySyncId", entitySyncId, "startTime", startTime, "errorString", e.getMessage()), locale)); } } } } else { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtOfflineXMLFileNotFound", UtilMisc.toMap("fileName", fileName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtOfflineXMLFileNotFound", UtilMisc.toMap("fileName", fileName), locale)); } return ServiceUtil.returnSuccess(); @@ -586,7 +586,7 @@ public class EntitySyncServices { public static Map<String, Object> updateOfflineEntitySync(DispatchContext dctx, Map<String, Object> context) { Locale locale = (Locale) context.get("locale"); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtThisServiceIsNotYetImplemented", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtThisServiceIsNotYetImplemented", locale)); } /** @@ -629,7 +629,7 @@ public class EntitySyncServices { return ServiceUtil.returnSuccess(); } catch (GenericEntityException e) { Debug.logError(e, "Error cleaning out EntitySyncRemove info: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCleaningEntitySyncRemove", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityExtErrorCleaningEntitySyncRemove", UtilMisc.toMap("errorString", e.toString()), locale)); } } } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java index f948fc1..c049f74 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java @@ -51,7 +51,7 @@ public class ModelPermission implements Serializable { public boolean permissionReturnErrorOnFailure = true; public Boolean auth; - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; @Override public String toString() { @@ -74,7 +74,7 @@ public class ModelPermission implements Serializable { Security security = dctx.getSecurity(); if (userLogin == null) { Debug.logInfo("Secure service requested with no userLogin object", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorUserLoginMissing", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorUserLoginMissing", locale)); } boolean hasPermission = false; if (Debug.verboseOn()) Debug.logVerbose(" Permission : Analyse " + this.toString(), MODULE); @@ -89,10 +89,10 @@ public class ModelPermission implements Serializable { return evalPermissionService(serviceModel, dctx, context); default: Debug.logWarning("Invalid permission type [" + permissionType + "] for permission named : " + nameOrRole + " on service : " + serviceModel.name, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorInvalidPermissionType", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorInvalidPermissionType", locale)); } if (! hasPermission) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorRefused", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorRefused", locale)); } return ServiceUtil.returnSuccess(); } @@ -122,13 +122,13 @@ public class ModelPermission implements Serializable { Locale locale = (Locale) context.get("locale"); if (permissionServiceName == null) { Debug.logWarning("No ModelService found; no service name specified!", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorDefinitionProblem", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorDefinitionProblem", locale)); } try { permission = dctx.getModelService(permissionServiceName); } catch (GenericServiceException e) { Debug.logError(e, "Failed to get ModelService: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorDefinitionProblem", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorDefinitionProblem", locale)); } permission.auth = true; @@ -152,12 +152,12 @@ public class ModelPermission implements Serializable { failMessage = (String) resp.get("failMessage"); } catch (GenericServiceException e) { Debug.logError(failMessage + e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServicePermissionErrorDefinitionProblem", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorDefinitionProblem", locale)); } if (Debug.verboseOn()) Debug.logVerbose("Service permission result : hasPermission " + resp.get("hasPermission") + ", failMessage " + failMessage , MODULE); if (permissionReturnErrorOnFailure && (UtilValidate.isNotEmpty(failMessage) || ! ((Boolean) resp.get("hasPermission")).booleanValue())) { - if (UtilValidate.isEmpty(failMessage)) failMessage = UtilProperties.getMessage(resource, "ServicePermissionErrorRefused", locale); + if (UtilValidate.isEmpty(failMessage)) failMessage = UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorRefused", locale); return ServiceUtil.returnError(failMessage); } return resp; diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java index a00874c..d63c0d4 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java @@ -112,7 +112,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali public static final String SUCCESS_MESSAGE = "successMessage"; public static final String SUCCESS_MESSAGE_LIST = "successMessageList"; - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; /** The name of this service */ public String name; @@ -1006,7 +1006,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali } else { Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("hasPermission", Boolean.FALSE); - result.put("failMessage", UtilProperties.getMessage(resource, "ServicePermissionErrorDefinitionProblem", (Locale) context.get("locale"))); + result.put("failMessage", UtilProperties.getMessage(RESOURCE, "ServicePermissionErrorDefinitionProblem", (Locale) context.get("locale"))); return result; } } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java b/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java index 20d73f2..0435065 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java @@ -50,7 +50,7 @@ import org.apache.ofbiz.service.ServiceUtil; public final class EntityAutoEngine extends GenericAsyncEngine { private static final String MODULE = EntityAutoEngine.class.getName(); - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; private static final List<String> availableInvokeActionNames = UtilMisc.toList("create", "update", "delete", "expire"); public EntityAutoEngine(ServiceDispatcher dispatcher) { @@ -136,7 +136,7 @@ public final class EntityAutoEngine extends GenericAsyncEngine { } } catch (GeneralException e) { Debug.logError(e, "Error doing entity-auto operation for entity [" + modelEntity.getEntityName() + "] in service [" + modelService.name + "]: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceEntityAutoOperation", UtilMisc.toMap("entityName", modelEntity.getEntityName(), "serviceName", modelService.name,"errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceEntityAutoOperation", UtilMisc.toMap("entityName", modelEntity.getEntityName(), "serviceName", modelService.name,"errorString", e.toString()), locale)); } result.put(ModelService.SUCCESS_MESSAGE, ServiceUtil.makeSuccessMessage(result, "", "", "", "")); return result; @@ -224,14 +224,14 @@ public final class EntityAutoEngine extends GenericAsyncEngine { if (pkValue instanceof String) { StringBuffer errorDetails = new StringBuffer(); if (!UtilValidate.isValidDatabaseId((String) pkValue, errorDetails)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceParameterValueNotValid", UtilMisc.toMap("parameterName", singlePkModelParam.name,"errorDetails", errorDetails), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceParameterValueNotValid", UtilMisc.toMap("parameterName", singlePkModelParam.name,"errorDetails", errorDetails), locale)); } } } newEntity.set(singlePkModeField.getName(), pkValue); GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null); if (lookedUpValue != null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueFound", UtilMisc.toMap("pkFields", newEntity.getPkShortValueString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceValueFound", UtilMisc.toMap("pkFields", newEntity.getPkShortValueString()), locale)); } } else if (isDoublePk && doublePkPrimaryInParam != null && doublePkSecondaryOutParam != null) { /* @@ -266,7 +266,7 @@ public final class EntityAutoEngine extends GenericAsyncEngine { //with all pks present on parameters, check if the entity is not already exists. GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null); if (lookedUpValue != null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueFound", UtilMisc.toMap("pkFields", newEntity.getPkShortValueString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceValueFound", UtilMisc.toMap("pkFields", newEntity.getPkShortValueString()), locale)); } } else { /* We haven't all Pk and their are 3 or more, now check if isn't a associate entity with own sequence @@ -382,7 +382,7 @@ public final class EntityAutoEngine extends GenericAsyncEngine { GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null); if (lookedUpValue == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueNotFound", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceValueNotFound", locale)); } localContext.put("lookedUpValue", lookedUpValue); @@ -508,7 +508,7 @@ public final class EntityAutoEngine extends GenericAsyncEngine { GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null); if (lookedUpValue == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueNotFoundForRemove", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceValueNotFoundForRemove", locale)); } lookedUpValue.remove(); Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage("ServiceUiLabels", "EntityDeletedSuccessfully", UtilMisc.toMap("label", modelEntity.getTitle()), locale)); @@ -539,7 +539,7 @@ public final class EntityAutoEngine extends GenericAsyncEngine { } GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null); if (lookedUpValue == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueNotFound", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceValueNotFound", locale)); } //check if a non pk date field is present on parameters diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/job/JobServices.java b/framework/service/src/main/java/org/apache/ofbiz/service/job/JobServices.java index fcfd7eb..d40168a 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/job/JobServices.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/job/JobServices.java @@ -43,7 +43,7 @@ import org.apache.ofbiz.service.config.ServiceConfigUtil; public class JobServices { private static final String MODULE = JobServices.class.getName(); - private static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; public static Map<String, Object> cancelJob(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); @@ -62,7 +62,7 @@ public class JobServices { } } catch (GenericEntityException e) { Debug.logError(e, MODULE); - String errMsg = UtilProperties.getMessage(resource, "serviceUtil.unable_to_cancel_job", locale) + " : " + fields; + String errMsg = UtilProperties.getMessage(RESOURCE, "serviceUtil.unable_to_cancel_job", locale) + " : " + fields; return ServiceUtil.returnError(errMsg); } @@ -73,7 +73,7 @@ public class JobServices { result.put("statusId", "SERVICE_PENDING"); // To more easily see current pending jobs and possibly cancel some others return result; } - String errMsg = UtilProperties.getMessage(resource, "serviceUtil.unable_to_cancel_job", locale) + " : " + null; + String errMsg = UtilProperties.getMessage(RESOURCE, "serviceUtil.unable_to_cancel_job", locale) + " : " + null; return ServiceUtil.returnError(errMsg); } @@ -83,7 +83,7 @@ public class JobServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = ServiceUtil.getLocale(context); if (!security.hasPermission("SERVICE_INVOKE_ANY", userLogin)) { - String errMsg = UtilProperties.getMessage(resource, "serviceUtil.no_permission_to_run", locale) + "."; + String errMsg = UtilProperties.getMessage(RESOURCE, "serviceUtil.no_permission_to_run", locale) + "."; return ServiceUtil.returnError(errMsg); } @@ -99,14 +99,14 @@ public class JobServices { } } catch (GenericEntityException e) { Debug.logError(e, MODULE); - String errMsg = UtilProperties.getMessage(resource, "serviceUtil.unable_to_cancel_job_retries", locale) + " : " + fields; + String errMsg = UtilProperties.getMessage(RESOURCE, "serviceUtil.unable_to_cancel_job_retries", locale) + " : " + fields; return ServiceUtil.returnError(errMsg); } if (job != null) { return ServiceUtil.returnSuccess(); } - String errMsg = UtilProperties.getMessage(resource, "serviceUtil.unable_to_cancel_job_retries", locale) + " : " + null; + String errMsg = UtilProperties.getMessage(RESOURCE, "serviceUtil.unable_to_cancel_job_retries", locale) + " : " + null; return ServiceUtil.returnError(errMsg); } @@ -121,7 +121,7 @@ public class JobServices { if (limit == null) limit = ServiceConfigUtil.getServiceEngine().getThreadPool().getMaxThreads(); } catch (GenericConfigException e) { Debug.logWarning(e, "Exception thrown while getting service configuration: ", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceExceptionThrownWhileGettingServiceConfiguration", UtilMisc.toMap("errorString", e), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceExceptionThrownWhileGettingServiceConfiguration", UtilMisc.toMap("errorString", e), locale)); } Delegator delegator = dctx.getDelegator(); Timestamp purgeTime = Timestamp.from(Instant.now().minus(Duration.ofDays(daysToKeep))); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestPermissionServices.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestPermissionServices.java index aa33c6e..a64c1f0 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestPermissionServices.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestPermissionServices.java @@ -25,7 +25,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class ServiceEngineTestPermissionServices { private static final String MODULE = ServiceEngineTestPermissionServices.class.getName(); - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; public static Map<String, Object> genericTestService(DispatchContext dctx, Map<String, ? extends Object> context) { return ServiceUtil.returnSuccess(); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java index fd146da..fc6433a 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java @@ -40,7 +40,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class ServiceEngineTestServices { private static final String MODULE = ServiceEngineTestServices.class.getName(); - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; public static Map<String, Object> testServiceDeadLockRetry(DispatchContext dctx, Map<String, ? extends Object> context) { Locale locale = (Locale) context.get("locale"); @@ -54,17 +54,17 @@ public class ServiceEngineTestServices { Map<String, Object> threadBResult = threadBWaiter.waitForResult(); List<Object> errorList = new LinkedList<>(); if (ServiceUtil.isError(threadAResult)) { - errorList.add(UtilProperties.getMessage(resource, "ServiceTestDeadLockThreadA", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadAResult)), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockThreadA", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadAResult)), locale)); } if (ServiceUtil.isError(threadBResult)) { - errorList.add(UtilProperties.getMessage(resource, "ServiceTestDeadLockThreadB", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadBResult)), locale)); + errorList.add(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockThreadB", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadBResult)), locale)); } if (errorList.size() > 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockRetry", locale), errorList, null, null); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockRetry", locale), errorList, null, null); } } catch (Exception e) { Debug.logError(e, "Error running deadlock test services: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -94,10 +94,10 @@ public class ServiceEngineTestServices { testingTypeAOnly.store(); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running dead lock test thread A: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (InterruptedException e) { Debug.logError(e, "Wait Interrupted Exception running dead lock test thread A: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineWaitInterruptedExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineWaitInterruptedExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -126,10 +126,10 @@ public class ServiceEngineTestServices { testingTypeAOnly.store(); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running dead lock test thread B: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (InterruptedException e) { Debug.logError(e, "Wait Interrupted Exception running dead lock test thread B: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineWaitInterruptedExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineWaitInterruptedExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -155,11 +155,11 @@ public class ServiceEngineTestServices { errorList.add("Error running testServiceLockWaitTimeoutRetryWaiter: " + ServiceUtil.getErrorMessage(waiterResult)); } if (errorList.size() > 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetry", locale), errorList, null, null); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockWaitTimeoutRetry", locale), errorList, null, null); } } catch (Exception e) { Debug.logError(e, "Error running deadlock test services: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -180,10 +180,10 @@ public class ServiceEngineTestServices { Thread.sleep(4 * 1000); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running lock wait timeout test Grabber thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockWaitTimeoutRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (InterruptedException e) { Debug.logError(e, "Wait Interrupted Exception running lock wait timeout test Grabber thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -205,10 +205,10 @@ public class ServiceEngineTestServices { Debug.logInfo("In testServiceLockWaitTimeoutRetryWaiter successfully updated SVCLWTRT", MODULE); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockWaitTimeoutRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (InterruptedException e) { Debug.logError(e, "Wait Interrupted Exception running lock wait timeout test Waiter thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -246,7 +246,7 @@ public class ServiceEngineTestServices { // timeout is 5 seconds so it is longer than the tx timeout for this service, so will fail quickly; with this transaction keeping a lock on the record and that one trying to get it, bam we cause the error Map<String, Object> waiterResult = dispatcher.runSync("testServiceLockWaitTimeoutRetryCantRecoverWaiter", null, 5, true); if (ServiceUtil.isError(waiterResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryCantRecoverWaiter", locale), null, null, waiterResult); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockWaitTimeoutRetryCantRecoverWaiter", locale), null, null, waiterResult); } Debug.logInfo("In testServiceLockWaitTimeoutRetryCantRecover (grabber) successfully finished running sub-service in own transaction", MODULE); @@ -255,7 +255,7 @@ public class ServiceEngineTestServices { Debug.logError(e, errMsg, MODULE); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running lock wait timeout test main/Grabber thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -274,7 +274,7 @@ public class ServiceEngineTestServices { Debug.logInfo("In testServiceLockWaitTimeoutRetryCantRecoverWaiter successfully updated SVCLWTRTCR", MODULE); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -288,7 +288,7 @@ public class ServiceEngineTestServices { try { Map<String, Object> resultMap = dispatcher.runSync("testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent", null, 60, true); if (ServiceUtil.isError(resultMap)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper", locale), null, null, resultMap); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper", locale), null, null, resultMap); } } catch (GenericServiceException e) { String errMsg = "This is the expected error running sub-service with own tx after the parent has set rollback only, logging and ignoring: " + e.toString(); @@ -311,11 +311,11 @@ public class ServiceEngineTestServices { Map<String, Object> resultMap = dispatcher.runSync("testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService", null, 60, true); if (ServiceUtil.isError(resultMap)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParent", locale), null, null, resultMap); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParent", locale), null, null, resultMap); } } catch (Exception e) { Debug.logError(e, "Error running sub-service with own tx: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestOwnTxError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -336,7 +336,7 @@ public class ServiceEngineTestServices { dispatcher.runSync("testServiceEcaGlobalEventExecToRollback", null, 60, true); } catch (GenericServiceException e) { Debug.logError(e, "Error calling sub-service, it should return an error but not throw an exception, so something went wrong: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestSubServiceError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestSubServiceError", UtilMisc.toMap("errorString", e.toString()), locale)); } // this service doesn't actually have to do anything, just a placeholder for ECA rules, this one should commit @@ -351,7 +351,7 @@ public class ServiceEngineTestServices { testingType.store(); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -359,7 +359,7 @@ public class ServiceEngineTestServices { public static Map<String, Object> testServiceEcaGlobalEventExecToRollback(DispatchContext dctx, Map<String, ? extends Object> context) { // this service doesn't actually have to do anything, just a placeholder for ECA rules, this one should rollback Locale locale = (Locale) context.get("locale"); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestRollback", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestRollback", locale)); } public static Map<String, Object> testServiceEcaGlobalEventExecOnRollback(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); @@ -370,7 +370,7 @@ public class ServiceEngineTestServices { testingType.store(); } catch (GenericEntityException e) { Debug.logError(e, "Entity Engine Exception: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java index 072f32a..b35afe6 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java @@ -37,7 +37,7 @@ import org.apache.xmlrpc.client.XmlRpcClient; public class XmlRpcTests extends AbstractXmlRpcTestCase { private static final String MODULE = XmlRpcTests.class.getName(); - public static final String resource = "ServiceErrorUiLabels"; + private static final String RESOURCE = "ServiceErrorUiLabels"; private static String url = "http://localhost:8080/webtools/control/xmlrpc?USERNAME=admin&PASSWORD=ofbiz"; public XmlRpcTests(String name) { @@ -68,7 +68,7 @@ public class XmlRpcTests extends AbstractXmlRpcTestCase { Integer num1 = (Integer) context.get("num1"); Integer num2 = (Integer) context.get("num2"); if (UtilValidate.isEmpty(num1) || UtilValidate.isEmpty(num2)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestXmlRpcMissingParameters", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestXmlRpcMissingParameters", locale)); } Integer res = num1 + num2; response.put("resulting", res); @@ -97,9 +97,9 @@ public class XmlRpcTests extends AbstractXmlRpcTestCase { } Integer res = (Integer) result.get("resulting"); if (res == (num1 + num2)) { - result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "ServiceTestXmlRpcCalculationOK", locale) + res); + result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "ServiceTestXmlRpcCalculationOK", locale) + res); } else { - result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestXmlRpcCalculationKO", locale)); + result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestXmlRpcCalculationKO", locale)); } return result; } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index f80b07c..db27772 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -103,7 +103,7 @@ import org.xml.sax.SAXException; public class WebToolsServices { private static final String MODULE = WebToolsServices.class.getName(); - public static final String resource = "WebtoolsUiLabels"; + private static final String RESOURCE = "WebtoolsUiLabels"; public static Map<String, Object> entityImport(DispatchContext dctx, Map<String, ? extends Object> context) { GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -134,9 +134,9 @@ public class WebToolsServices { try { url = isUrl?FlexibleLocation.resolveLocation(filename):UtilURL.fromFilename(filename); } catch (MalformedURLException mue) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsInvalidFileName", UtilMisc.toMap("filename", filename, "errorString", mue.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsInvalidFileName", UtilMisc.toMap("filename", filename, "errorString", mue.getMessage()), locale)); } catch (Exception exc) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrorReadingFileName", UtilMisc.toMap("filename", filename, "errorString", exc.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsErrorReadingFileName", UtilMisc.toMap("filename", filename, "errorString", exc.getMessage()), locale)); } } @@ -146,7 +146,7 @@ public class WebToolsServices { if (UtilValidate.isNotEmpty(fmfilename) && (UtilValidate.isNotEmpty(fulltext) || url != null)) { File fmFile = new File(fmfilename); if (!fmFile.exists()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrorReadingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", "Template file not found."), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsErrorReadingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", "Template file not found."), locale)); } try { DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); @@ -168,7 +168,7 @@ public class WebToolsServices { FreeMarkerWorker.renderTemplate(fmFile.toURI().toURL().toString(), fmcontext, outWriter); fulltext = outWriter.toString(); } catch (Exception ex) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrorProcessingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", ex.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsErrorProcessingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", ex.getMessage()), locale)); } } @@ -191,18 +191,18 @@ public class WebToolsServices { } Map<String, Object> outputMap = dispatcher.runSync("parseEntityXmlFile", inputMap); if (ServiceUtil.isError(outputMap)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrorParsingFile", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(outputMap)), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsErrorParsingFile", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(outputMap)), locale)); } else { Long numberRead = (Long)outputMap.get("rowProcessed"); - messages.add(UtilProperties.getMessage(resource, "EntityImportRowProcessed", UtilMisc.toMap("numberRead", numberRead.toString()), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportRowProcessed", UtilMisc.toMap("numberRead", numberRead.toString()), locale)); } } catch (GenericServiceException gsex) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportParsingError", UtilMisc.toMap("errorString", gsex.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportParsingError", UtilMisc.toMap("errorString", gsex.getMessage()), locale)); } catch (Exception ex) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportParsingError", UtilMisc.toMap("errorString", ex.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportParsingError", UtilMisc.toMap("errorString", ex.getMessage()), locale)); } } else { - messages.add(UtilProperties.getMessage(resource, "EntityImportNoXmlFileSpecified", locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportNoXmlFileSpecified", locale)); } // send the notification @@ -269,14 +269,14 @@ public class WebToolsServices { parseEntityXmlFileArgs.put("url", furl); Map<String, Object> outputMap = dispatcher.runSync("parseEntityXmlFile", parseEntityXmlFileArgs); Long numberRead = (Long) outputMap.get("rowProcessed"); - messages.add(UtilProperties.getMessage(resource, "EntityImportNumberOfEntityToBeProcessed", UtilMisc.toMap("numberRead", numberRead.toString(), "fileName", f.getName()), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportNumberOfEntityToBeProcessed", UtilMisc.toMap("numberRead", numberRead.toString(), "fileName", f.getName()), locale)); if (deleteFiles) { - messages.add(UtilProperties.getMessage(resource, "EntityImportDeletFile", UtilMisc.toMap("fileName", f.getName()), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportDeletFile", UtilMisc.toMap("fileName", f.getName()), locale)); f.delete(); } } catch (Exception e) { unprocessedFiles.add(f); - messages.add(UtilProperties.getMessage(resource, "EntityImportFailedFile", UtilMisc.toMap("fileName", f.getName()), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportFailedFile", UtilMisc.toMap("fileName", f.getName()), locale)); } // pause in between files if (pauseLong > 0) { @@ -290,23 +290,23 @@ public class WebToolsServices { } files = unprocessedFiles; passes++; - messages.add(UtilProperties.getMessage(resource, "EntityImportPassedFile", UtilMisc.toMap("passes", passes), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportPassedFile", UtilMisc.toMap("passes", passes), locale)); Debug.logInfo("Pass " + passes + " complete", MODULE); } lastUnprocessedFilesCount=unprocessedFiles.size(); messages.add("---------------------------------------"); - messages.add(UtilProperties.getMessage(resource, "EntityImportSucceededNumberFile", UtilMisc.toMap("succeeded", (initialListSize-lastUnprocessedFilesCount), "total", initialListSize), locale)); - messages.add(UtilProperties.getMessage(resource, "EntityImportFailedNumberFile", UtilMisc.toMap("failed", lastUnprocessedFilesCount, "total", initialListSize), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportSucceededNumberFile", UtilMisc.toMap("succeeded", (initialListSize-lastUnprocessedFilesCount), "total", initialListSize), locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportFailedNumberFile", UtilMisc.toMap("failed", lastUnprocessedFilesCount, "total", initialListSize), locale)); messages.add("---------------------------------------"); - messages.add(UtilProperties.getMessage(resource, "EntityImportFailedFileList", locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportFailedFileList", locale)); for (File file: unprocessedFiles) { messages.add(file.toString()); } } else { - messages.add(UtilProperties.getMessage(resource, "EntityImportPathNotFound", locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportPathNotFound", locale)); } } else { - messages.add(UtilProperties.getMessage(resource, "EntityImportPathNotSpecified", locale)); + messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportPathNotSpecified", locale)); } // send the notification Map<String, Object> resp = UtilMisc.toMap("messages", (Object) messages); @@ -348,7 +348,7 @@ public class WebToolsServices { String helperName = delegator.getGroupHelperName(groupNameToUse); if (helperName == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportNoDataSourceSpecified", UtilMisc.toMap("groupNameToUse", groupNameToUse), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportNoDataSourceSpecified", UtilMisc.toMap("groupNameToUse", groupNameToUse), locale)); } // get the reader name URLs first @@ -431,7 +431,7 @@ public class WebToolsServices { String xmltext = (String) context.get("xmltext"); if (url == null && xmltext == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportNoXmlFileOrTextSpecified", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportNoXmlFileOrTextSpecified", locale)); } boolean onlyInserts = (String) context.get("onlyInserts") != null; boolean maintainTimeStamps = (String) context.get("maintainTimeStamps") != null; @@ -457,7 +457,7 @@ public class WebToolsServices { long numberRead = (url != null ? reader.parse(url) : reader.parse(xmltext)); rowProcessed = numberRead; } catch (Exception ex) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportParsingError", UtilMisc.toMap("errorString", ex.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportParsingError", UtilMisc.toMap("errorString", ex.toString()), locale)); } // send the notification Map<String, Object> resp = UtilMisc.<String, Object>toMap("rowProcessed", rowProcessed); @@ -488,7 +488,7 @@ public class WebToolsServices { Collection<String> ec = reader.getEntityNames(); passedEntityNames = new TreeSet<>(ec); } catch (Exception exc) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportErrorRetrievingEntityNames", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportErrorRetrievingEntityNames", locale)); } int fileNumber = 1; @@ -635,7 +635,7 @@ public class WebToolsServices { entities.add(eName); } } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportErrorRetrievingEntityNames", locale) + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportErrorRetrievingEntityNames", locale) + e.getMessage()); } String search = (String) context.get("search"); @@ -781,7 +781,7 @@ public class WebToolsServices { packagesList.add(packageMap); } } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityImportErrorRetrievingEntityNames", locale) + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EntityImportErrorRetrievingEntityNames", locale) + e.getMessage()); } resultMap.put("packagesList", packagesList); @@ -809,10 +809,10 @@ public class WebToolsServices { outdir.mkdir(); } if (!outdir.isDirectory()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFullPathIsNotADirectory", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFullPathIsNotADirectory", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); } if (!outdir.canWrite()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFullPathIsNotWriteable", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFullPathIsNotWriteable", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); } Set<String> entityNames = new TreeSet<>(); @@ -863,13 +863,13 @@ public class WebToolsServices { UtilPlist.writePlistFile(modelEntity.createEoModelMap(entityNamePrefix, datasourceName, entityNames, reader), eomodeldFullPath, curEntityName +".plist", true); } Integer entityNamesSize = entityNames.size(); - return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "WebtoolsEomodelExported", UtilMisc.toMap("entityNamesSize", entityNamesSize.toString(), "eomodeldFullPath", eomodeldFullPath), locale)); + return ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelExported", UtilMisc.toMap("entityNamesSize", entityNamesSize.toString(), "eomodeldFullPath", eomodeldFullPath), locale)); } catch (UnsupportedEncodingException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelSavingFileError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelSavingFileError", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (FileNotFoundException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFileOrDirectoryNotFound", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFileOrDirectoryNotFound", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelErrorGettingEntityNames", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelErrorGettingEntityNames", UtilMisc.toMap("errorString", e.toString()), locale)); } } @@ -888,7 +888,7 @@ public class WebToolsServices { resultMap = ServiceUtil.returnSuccess(); resultMap.put("hasPermission", true); } else { - resultMap = ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "WebtoolsPermissionError", locale)); + resultMap = ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "WebtoolsPermissionError", locale)); resultMap.put("hasPermission", false); } return resultMap; @@ -913,10 +913,10 @@ public class WebToolsServices { outdir.mkdir(); } if (!outdir.isDirectory()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFullPathIsNotADirectory", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFullPathIsNotADirectory", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); } if (!outdir.canWrite()) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFullPathIsNotWriteable", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFullPathIsNotWriteable", UtilMisc.toMap("eomodeldFullPath", eomodeldFullPath), locale)); } try { @@ -925,11 +925,11 @@ public class WebToolsServices { serviceInfo.writeServiceCallGraphEoModel(eomodeldFullPath); } catch (GeneralException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelErrorGettingEntityNames", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelErrorGettingEntityNames", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (UnsupportedEncodingException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelSavingFileError", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelSavingFileError", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (FileNotFoundException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsEomodelFileOrDirectoryNotFound", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsEomodelFileOrDirectoryNotFound", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java index 604d855..a8c333d 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java @@ -48,7 +48,7 @@ import org.xml.sax.SAXException; public class LabelManagerFactory { private static final String MODULE = LabelManagerFactory.class.getName(); - public static final String resource = "WebtoolsUiLabels"; + private static final String RESOURCE = "WebtoolsUiLabels"; public static final String keySeparator = "#"; protected static Set<String> componentNamesFound = null; diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java index 11328df..e10de22 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java @@ -44,7 +44,7 @@ import org.w3c.dom.Node; public class SaveLabelsToXmlFile { - private static final String resource = "WebtoolsUiLabels"; + private static final String RESOURCE = "WebtoolsUiLabels"; private static final String MODULE = SaveLabelsToXmlFile.class.getName(); public static Map<String, Object> saveLabelsToXmlFile(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -52,7 +52,7 @@ public class SaveLabelsToXmlFile { String fileName = (String) context.get("fileName"); if (UtilValidate.isEmpty(fileName)) { Debug.logError("labelFileName cannot be empty", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); } String key = (String) context.get("key"); String keyComment = (String) context.get("keyComment"); @@ -74,7 +74,7 @@ public class SaveLabelsToXmlFile { LabelFile labelFile = factory.getLabelFile(fileName); if (labelFile == null) { Debug.logError("Invalid file name: " + fileName, MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); } synchronized(SaveLabelsToXmlFile.class) { factory.findMatchingLabels(null, fileName, null, null, false); @@ -97,14 +97,14 @@ public class SaveLabelsToXmlFile { // Insert a new Label } else { if (UtilValidate.isNotEmpty(label)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelExisting", UtilMisc.toMap("key", key, "fileName", fileName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsLabelManagerNewLabelExisting", UtilMisc.toMap("key", key, "fileName", fileName), locale)); } else { if (UtilValidate.isEmpty(key)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmptyKey", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsLabelManagerNewLabelEmptyKey", locale)); } else { int notEmptyLabels = factory.updateLabelValue(localeNames, localeValues, localeComments, null, key, keyComment, fileName); if (notEmptyLabels == 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmpty", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsLabelManagerNewLabelEmpty", locale)); } } } @@ -159,7 +159,7 @@ public class SaveLabelsToXmlFile { } } catch (Exception e) { Debug.logError(e, "Exception during save labels to xml file:", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); } return ServiceUtil.returnSuccess(); } |
Free forum by Nabble | Edit this page |