You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2015/12/20 22:07:27 UTC
svn commit: r1721066 - in /ofbiz/trunk/applications:
content/servicedef/services_data.xml
product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
Author: jleroux
Date: Sun Dec 20 21:07:27 2015
New Revision: 1721066
URL: http://svn.apache.org/viewvc?rev=1721066&view=rev
Log:
A slightly modified patch from Supachai Chaima-ngua for <<Upload product image does not work.>> https://issues.apache.org/jira/browse/OFBIZ-6769
Upload product image dose not working because "updateDataResource" require out parameter name 'dataResourceId' but the service doesn't return by using entity-auto engine and upload image function need delegator but do not sent to upload image function.
jleroux: this was due to recent r1716271 so no needs to backport. The changes in ImageManagementServices were not operationally needed (it worked as is) but indeed better for a method like scaleImageMangementInAllSize to rely on DispatchContext rather than service context when called from a service. Since it's not a service I changed the scaleImageMangementInAllSize method to private. I also removed the useless "ImageManagementServices." prefix.
Modified:
ofbiz/trunk/applications/content/servicedef/services_data.xml
ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
Modified: ofbiz/trunk/applications/content/servicedef/services_data.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_data.xml?rev=1721066&r1=1721065&r2=1721066&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_data.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_data.xml Sun Dec 20 21:07:27 2015
@@ -52,7 +52,7 @@
<description>Update a DataResource</description>
<permission-service service-name="genericDataResourcePermission" main-action="UPDATE"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
- <attribute name="dataResourceId" type="String" mode="INOUT" optional="false"/>
+ <attribute name="dataResourceId" type="String" mode="IN" optional="false"/>
<override name="objectInfo" allow-html="any"/>
<override name="dataResourceName" allow-html="any"/>
</service>
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1721066&r1=1721065&r2=1721066&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Sun Dec 20 21:07:27 2015
@@ -202,7 +202,7 @@ public class ImageManagementServices {
Map<String, Object> resultResize = new HashMap<String, Object>();
try {
- resultResize.putAll(ImageManagementServices.scaleImageMangementInAllSize(context, imageName, sizeType, productId));
+ resultResize.putAll(scaleImageMangementInAllSize(dctx, context, imageName, sizeType, productId));
} catch (IOException e) {
String errMsg = "Scale additional image in all different sizes is impossible : " + e.toString();
Debug.logError(e, errMsg, module);
@@ -296,7 +296,7 @@ public class ImageManagementServices {
return ServiceUtil.returnSuccess();
}
- public static Map<String, Object> scaleImageMangementInAllSize(Map<String, ? extends Object> context, String filenameToUse, String resizeType, String productId)
+ private static Map<String, Object> scaleImageMangementInAllSize(DispatchContext dctx, Map<String, ? extends Object> context, String filenameToUse, String resizeType, String productId)
throws IllegalArgumentException, ImagingOpException, IOException, JDOMException {
/* VARIABLES */
@@ -577,7 +577,7 @@ public class ImageManagementServices {
Map<String, Object> resultResizeThumb = new HashMap<String, Object>();
try {
- resultResizeThumb.putAll(ImageManagementServices.scaleImageMangementInAllSize(context, filenameToUseThumb, "thumbnail", productId));
+ resultResizeThumb.putAll(scaleImageMangementInAllSize(dctx, context, filenameToUseThumb, "thumbnail", productId));
} catch (IOException e) {
String errMsg = "Scale additional image in all different sizes is impossible : " + e.toString();
Debug.logError(e, errMsg, module);
@@ -721,7 +721,7 @@ public class ImageManagementServices {
if (dataResourceName.length() > 3) {
String mimeType = dataResourceName.substring(dataResourceName.length() - 3, dataResourceName.length());
- Map<String, Object> resultResize = ImageManagementServices.resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth);
+ Map<String, Object> resultResize = resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth);
ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameToUse));
Map<String, Object> contentThumb = new HashMap<String, Object>();
@@ -737,7 +737,7 @@ public class ImageManagementServices {
String contentIdThumb = (String) contentThumbResult.get("contentId");
String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameToUse;
- ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlThumb, contentIdThumb, "image/jpeg");
+ createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlThumb, contentIdThumb, "image/jpeg");
Map<String, Object> createContentAssocMap = new HashMap<String, Object>();
createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL");
@@ -761,7 +761,7 @@ public class ImageManagementServices {
}
public static Map<String, Object> resizeImageOfProduct(DispatchContext dctx, Map<String, ? extends Object> context) {
- Delegator delegator = dctx.getDelegator();
+ Delegator delegator = dctx.getDelegator();
String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context);
String productId = (String) context.get("productId");
String dataResourceName = (String) context.get("dataResourceName");
@@ -775,7 +775,7 @@ public class ImageManagementServices {
double imgWidth = bufImg.getWidth();
String filenameToUse = dataResourceName;
String mimeType = dataResourceName.substring(dataResourceName.length() - 3, dataResourceName.length());
- Map<String, Object> resultResize = ImageManagementServices.resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth);
+ Map<String, Object> resultResize = resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth);
ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameToUse));
} catch (Exception e) {
Debug.logError(e, module);