You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2014/08/16 15:12:34 UTC

svn commit: r1618354 - in /ofbiz/trunk/applications/product: src/org/ofbiz/product/image/ src/org/ofbiz/product/product/ webapp/catalog/WEB-INF/actions/category/ webapp/catalog/WEB-INF/actions/config/ webapp/catalog/WEB-INF/actions/imagemanagement/ web...

Author: ashish
Date: Sat Aug 16 13:12:34 2014
New Revision: 1618354

URL: http://svn.apache.org/r1618354
Log:
Applied patch from jira issue - OFBIZ-5455 - images not stored in SystemProperty location. Thanks Pierre for reporting the issue and thanks to ofbiz.us team for providing the fix. 

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java Sat Aug 16 13:12:34 2014
@@ -38,6 +38,8 @@ import org.ofbiz.base.util.UtilPropertie
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.common.image.ImageTransform;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.service.ServiceUtil;
 
 /**
@@ -104,8 +106,8 @@ public class ScaleImage {
         index = filenameToUse.lastIndexOf(".");
         String imgExtension = filenameToUse.substring(index + 1);
         // paths
-        String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-        String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+        String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", (Delegator)context.get("delegator")), context);
+        String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", (Delegator)context.get("delegator"));
         
         FlexibleStringExpander filenameExpander;
         String fileLocation = null;
@@ -281,8 +283,8 @@ public class ScaleImage {
         String imgExtension = filenameToUse.substring(index + 1);
         // paths
         String mainFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-        String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-        String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+        String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", (Delegator)context.get("delegator")), context);
+        String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",(Delegator)context.get("delegator"));
 
         String id = null;
         String type = null;

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Sat Aug 16 13:12:34 2014
@@ -55,6 +55,7 @@ import org.ofbiz.entity.condition.Entity
 import org.ofbiz.entity.condition.EntityJoinOperator;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.product.catalog.CatalogWorker;
 import org.ofbiz.product.category.CategoryWorker;
 import org.ofbiz.product.image.ScaleImage;
@@ -983,8 +984,8 @@ public class ProductServices {
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
             String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.additionalviewsize.format");
-            String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-            String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator);
 
             FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat);
             String viewNumber = String.valueOf(productContentTypeId.charAt(productContentTypeId.length() - 1));
@@ -1075,7 +1076,10 @@ public class ProductServices {
             /* scale Image in different sizes */
             Map<String, Object> resultResize = FastMap.newInstance();
             try {
-                resultResize.putAll(ScaleImage.scaleImageInAllSize(context, filenameToUse, "additional", viewNumber));
+                Map<String, Object>imageContext = FastMap.newInstance();
+                imageContext.putAll(context);
+                imageContext.put("delegator", delegator);
+                resultResize.putAll(ScaleImage.scaleImageInAllSize(imageContext, filenameToUse, "additional", viewNumber));
             } catch (IOException e) {
                 Debug.logError(e, "Scale additional image in all different sizes is impossible : " + e.toString(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
@@ -1274,8 +1278,8 @@ public class ProductServices {
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
             String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-            String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-            String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path",delegator), context);
+            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator);
 
             FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat);
             String id = productPromoId + "_Image_" + productPromoContentTypeId.charAt(productPromoContentTypeId.length() - 1);

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Sat Aug 16 13:12:34 2014
@@ -45,6 +45,7 @@ import org.ofbiz.entity.model.ModelEntit
 import org.ofbiz.entity.model.ModelKeyMap;
 import org.ofbiz.entity.util.EntityListIterator;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -494,7 +495,7 @@ public class ProductUtilServices {
 
         if (UtilValidate.isEmpty(pattern)) {
             String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-            String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
             pattern = imageUrlPrefix + "/" + imageFilenameFormat;
         }
 

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy Sat Aug 16 13:12:34 2014
@@ -19,6 +19,7 @@
 
 import org.ofbiz.base.util.*
 import org.ofbiz.base.util.string.*
+import org.ofbiz.entity.util.EntityUtilProperties
 
 if (productCategory) {
     context.productCategoryType = productCategory.getRelatedOne("ProductCategoryType", false);
@@ -36,8 +37,8 @@ context.primaryParentCategory = primaryP
 
 // make the image file formats
 imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy Sat Aug 16 13:12:34 2014
@@ -20,12 +20,13 @@
 import org.ofbiz.base.util.*
 import org.ofbiz.base.util.string.*
 import org.ofbiz.entity.*
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.widget.html.*
 
 // make the image file formats
 imageFilenameFormat = "configitems/${configItemId}";
-imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy Sat Aug 16 13:12:34 2014
@@ -20,6 +20,7 @@
 import org.ofbiz.entity.*;
 import org.ofbiz.base.util.*;
 import org.ofbiz.base.util.string.*;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.product.image.ScaleImage;
 import org.ofbiz.entity.condition.*
 
@@ -27,8 +28,8 @@ context.nowTimestampString = UtilDateTim
 
 // make the image file formats
 imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
-imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix');
+imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;
@@ -126,6 +127,7 @@ if (fileType) {
 
             // call scaleImageInAllSize
             if (fileType.equals("original")) {
+                context.delegator = delegator;
                 result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0");
 
                 if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) {

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy Sat Aug 16 13:12:34 2014
@@ -26,6 +26,7 @@ import javax.imageio.ImageIO;
 
 import org.ofbiz.entity.*;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.base.util.*;
 import org.ofbiz.base.util.string.*;
 import org.ofbiz.product.image.ScaleImage;
@@ -44,8 +45,8 @@ if (productContentList) {
 
 // make the image file formats
 imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
-imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix');
+imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;
@@ -164,6 +165,7 @@ if (fileType) {
 
             // call scaleImageInAllSize
             if (fileType.equals("original")) {
+                context.delegator = delegator;
                 result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0");
 
                 if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) {

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy?rev=1618354&r1=1618353&r2=1618354&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy Sat Aug 16 13:12:34 2014
@@ -20,14 +20,15 @@
 import org.ofbiz.entity.*;
 import org.ofbiz.base.util.*;
 import org.ofbiz.base.util.string.*;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.product.image.ScaleImage;
 
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
 
 // make the image file formats
 imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
-imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
-imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix');
+imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
+imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;
@@ -143,6 +144,7 @@ if (fileType) {
 
             // call scaleImageInAllSize
             if (fileType.equals("original")) {
+                context.delegator = delegator;
                 result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0");
 
                 if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) {