Author: deepak
Date: Tue May 16 17:02:22 2017 New Revision: 1795340 URL: http://svn.apache.org/viewvc?rev=1795340&view=rev Log: Improved: Remove hard-coded success/error message variables set in service output (OFBIZ-9303) Thanks Devanshu Vyas for your contribution. Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1795340&r1=1795339&r2=1795340&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java Tue May 16 17:02:22 2017 @@ -5976,7 +5976,7 @@ public class OrderServices { } result.put("totalQuantity", totalQuantity); if (UtilValidate.isNotEmpty(message)) { - result.put("successMessage", message); + result.put(ModelService.SUCCESS_MESSAGE, message); } return result; } @@ -6039,7 +6039,7 @@ public class OrderServices { } } if (UtilValidate.isNotEmpty(message)) { - result.put("successMessage", message); + result.put(ModelService.SUCCESS_MESSAGE, message); } } } else { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java?rev=1795340&r1=1795339&r2=1795340&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/image/ScaleImage.java Tue May 16 17:02:22 2017 @@ -39,6 +39,7 @@ import org.apache.ofbiz.base.util.string import org.apache.ofbiz.common.image.ImageTransform; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.util.EntityUtilProperties; +import org.apache.ofbiz.service.ModelService; import org.apache.ofbiz.service.ServiceUtil; /** @@ -96,7 +97,7 @@ public class ScaleImage { } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_parse", locale) + " : ImageProperties.xml"; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -152,7 +153,7 @@ public class ScaleImage { if (imgHeight == 0.0 || imgWidth == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.one_current_image_dimension_is_null", locale) + " : imgHeight = " + imgHeight + " ; imgWidth = " + imgWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -215,12 +216,12 @@ public class ScaleImage { } catch (IllegalArgumentException e) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.one_parameter_is_null", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } catch (IOException e) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.error_occurs_during_writing", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -241,7 +242,7 @@ public class ScaleImage { } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_scale_original_image", locale) + " : " + filenameToUse; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return ServiceUtil.returnError(errMsg); } } @@ -276,7 +277,7 @@ public class ScaleImage { } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_parse", locale) + " : ImageProperties.xml"; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -330,7 +331,7 @@ public class ScaleImage { if (imgHeight == 0.0 || imgWidth == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.one_current_image_dimension_is_null", locale) + " : imgHeight = " + imgHeight + " ; imgWidth = " + imgWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -377,12 +378,12 @@ public class ScaleImage { } catch (IllegalArgumentException e) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.one_parameter_is_null", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } catch (IOException e) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.error_occurs_during_writing", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -401,7 +402,7 @@ public class ScaleImage { } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_scale_original_image", locale) + " : " + filenameToUse; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return ServiceUtil.returnError(errMsg); } } Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1795340&r1=1795339&r2=1795340&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java Tue May 16 17:02:22 2017 @@ -53,6 +53,7 @@ import org.apache.ofbiz.entity.util.Enti import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ModelService; import org.apache.ofbiz.service.ServiceUtil; /** @@ -327,7 +328,7 @@ public class ImageManagementServices { } else { String errMsg = UtilProperties.getMessage(resourceError, "ScaleImage.unable_to_parse", locale) + " : ImageProperties.xml"; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -352,7 +353,7 @@ public class ImageManagementServices { if (imgHeight == 0.0 || imgWidth == 0.0) { String errMsg = UtilProperties.getMessage(resourceError, "ScaleImage.one_current_image_dimension_is_null", locale) + " : imgHeight = " + imgHeight + " ; imgWidth = " + imgWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -384,12 +385,12 @@ public class ImageManagementServices { } catch (IllegalArgumentException e) { String errMsg = UtilProperties.getMessage(resourceError, "ScaleImage.one_parameter_is_null", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } catch (IOException e) { String errMsg = UtilProperties.getMessage(resourceError, "ScaleImage.error_occurs_during_writing", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -408,7 +409,7 @@ public class ImageManagementServices { } else { String errMsg = UtilProperties.getMessage(resourceError, "ScaleImage.unable_to_scale_original_image", locale) + " : " + filenameToUse; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return ServiceUtil.returnError(errMsg); } } Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java?rev=1795340&r1=1795339&r2=1795340&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java Tue May 16 17:02:22 2017 @@ -36,6 +36,7 @@ import javax.xml.parsers.ParserConfigura import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.service.ModelService; import org.xml.sax.SAXException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -78,12 +79,12 @@ public class ImageTransform { } catch (IllegalArgumentException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.input_is_null", locale) + " : " + fileLocation + " ; " + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + 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(); Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -127,7 +128,7 @@ public class ImageTransform { if (defaultHeight == 0.0 || defaultWidth == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.one_default_dimension_is_null", locale) + " : defaultHeight = " + defaultHeight + " ; defaultWidth = " + defaultWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } @@ -138,7 +139,7 @@ public class ImageTransform { if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } } else if (defaultWidth == -1) { @@ -146,7 +147,7 @@ public class ImageTransform { if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } } else if (imgHeight > imgWidth) { @@ -154,7 +155,7 @@ public class ImageTransform { if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.height_scale_factor_is_null", locale) + " (defaultHeight = " + defaultHeight + "; imgHeight = " + imgHeight; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } // get scaleFactor from the smallest width @@ -166,7 +167,7 @@ public class ImageTransform { if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.width_scale_factor_is_null", locale) + " (defaultWidth = " + defaultWidth + "; imgWidth = " + imgWidth; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } // get scaleFactor from the smallest height @@ -178,7 +179,7 @@ public class ImageTransform { if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.final_scale_factor_is_null", locale) + " = " + scaleFactor; Debug.logError(errMsg, module); - result.put("errorMessage", errMsg); + result.put(ModelService.ERROR_MESSAGE, errMsg); return result; } int bufImgType; @@ -226,17 +227,17 @@ public class ImageTransform { } catch (ParserConfigurationException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.errors_occurred_during_parsing", locale) + " ImageProperties.xml " + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", "error"); + result.put(ModelService.ERROR_MESSAGE, "error"); return result; } catch (SAXException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.errors_occurred_during_parsing", locale) + " ImageProperties.xml " + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", "error"); + 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(); Debug.logError(errMsg, module); - result.put("errorMessage", "error"); + result.put(ModelService.ERROR_MESSAGE, "error"); return result; } // set Root Element @@ -245,7 +246,7 @@ public class ImageTransform { } catch (IllegalStateException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.root_element_has_not_been_set", locale) + e.toString(); Debug.logError(errMsg, module); - result.put("errorMessage", "error"); + result.put(ModelService.ERROR_MESSAGE, "error"); return result; } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java?rev=1795340&r1=1795339&r2=1795340&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java Tue May 16 17:02:22 2017 @@ -112,22 +112,22 @@ public final class EntityAutoEngine exte switch (modelService.invoke) { case "create": result = invokeCreate(dctx, parameters, modelService, modelEntity, allPksInOnly, pkFieldNameOutOnly); - result.put("successMessage", UtilProperties.getMessage("ServiceUiLabels", "EntityCreatedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); + result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage("ServiceUiLabels", "EntityCreatedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); break; case "update": result = invokeUpdate(dctx, parameters, modelService, modelEntity, allPksInOnly); - result.put("successMessage", UtilProperties.getMessage("ServiceUiLabels", "EntityUpdatedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); + result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage("ServiceUiLabels", "EntityUpdatedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); break; case "delete": result = invokeDelete(dctx, parameters, modelService, modelEntity, allPksInOnly); - result.put("successMessage", UtilProperties.getMessage("ServiceUiLabels", "EntityDeletedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); + result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage("ServiceUiLabels", "EntityDeletedSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); break; case "expire": result = invokeExpire(dctx, parameters, modelService, modelEntity, allPksInOnly); if (ServiceUtil.isSuccess(result)) { result = invokeUpdate(dctx, parameters, modelService, modelEntity, allPksInOnly); } - result.put("successMessage", UtilProperties.getMessage("ServiceUiLabels", "EntityExpiredSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); + result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage("ServiceUiLabels", "EntityExpiredSuccessfully", UtilMisc.toMap("entityName", modelEntity.getEntityName()), locale)); break; default: break; |
Free forum by Nabble | Edit this page |