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 2015/02/21 10:47:34 UTC

svn commit: r1661313 - in /ofbiz/branches/release12.04/applications/product: config/ 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/acti...

Author: ashish
Date: Sat Feb 21 09:47:33 2015
New Revision: 1661313

URL: http://svn.apache.org/r1661313
Log:
Applied bug fix from trunk r1661307.
=======================================================================
Applied patch from jira issue - OFBIZ-6088 - There should not need to setup SystemProperty data on each tenant for specifying path to store tenant images.
Thanks Arun for creating the issue and thanks for providing the patch for the same.
=======================================================================

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

Modified: ofbiz/branches/release12.04/applications/product/config/catalog.properties
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/config/catalog.properties?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/config/catalog.properties (original)
+++ ofbiz/branches/release12.04/applications/product/config/catalog.properties Sat Feb 21 09:47:33 2015
@@ -21,10 +21,10 @@
 
 
 # -- Image upload path on the server
-image.server.path=${sys:getProperty('ofbiz.home')}/framework/images/webapp/images
+image.server.path=${sys:getProperty('ofbiz.home')}/framework/images/webapp/images/${tenantId}
 
 # -- The prefix to put on auto-generated image urls (can be relative or absolute, whatever you want)
-image.url.prefix=/images
+image.url.prefix=/images/${tenantId}
 image.filename.format=${location}/${id}/${type}
 image.filename.additionalviewsize.format=${location}/${id}/${viewtype}/${sizetype}
 

Modified: ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/image/ScaleImage.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/image/ScaleImage.java?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/image/ScaleImage.java (original)
+++ ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/image/ScaleImage.java Sat Feb 21 09:47:33 2015
@@ -110,8 +110,13 @@ public class ScaleImage {
         index = filenameToUse.lastIndexOf(".");
         String imgExtension = filenameToUse.substring(index + 1);
         // paths
-        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"));
+        Map<String, Object>imageContext = FastMap.newInstance();
+        imageContext.putAll(context);
+        imageContext.put("tenantId",((Delegator)context.get("delegator")).getDelegatorTenantId());
+        String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", (Delegator)context.get("delegator")), imageContext);
+        String imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", (Delegator)context.get("delegator")), imageContext);
+        imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+        imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
         
         FlexibleStringExpander filenameExpander;
         String fileLocation = null;
@@ -286,9 +291,15 @@ public class ScaleImage {
         String imgName = filenameToUse.substring(0, index - 1);
         String imgExtension = filenameToUse.substring(index + 1);
         // paths
-        String mainFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-        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"));
+        Map<String, Object>imageContext = FastMap.newInstance();
+        imageContext.putAll(context);
+        imageContext.put("tenantId",((Delegator)context.get("delegator")).getDelegatorTenantId());
+        String mainFilenameFormat = EntityUtilProperties.getPropertyValue("catalog", "image.filename.format", (Delegator) context.get("delegator"));
+
+        String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", (Delegator)context.get("delegator")), imageContext);
+        String imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",(Delegator)context.get("delegator")), imageContext);
+        imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+        imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 
         String id = null;
         String type = null;

Modified: ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductServices.java Sat Feb 21 09:47:33 2015
@@ -984,9 +984,16 @@ public class ProductServices {
         Locale locale = (Locale) context.get("locale");
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
-            String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.additionalviewsize.format");
-            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator);
+            Map<String, Object>imageContext = FastMap.newInstance();
+            imageContext.putAll(context);
+            imageContext.put("delegator", delegator);
+            imageContext.put("tenantId",delegator.getDelegatorTenantId());
+            String imageFilenameFormat = EntityUtilProperties.getPropertyValue("catalog", "image.filename.additionalviewsize.format", delegator);
+
+            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), imageContext);
+            String imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator), imageContext);
+            imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+            imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 
             FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat);
             String viewNumber = String.valueOf(productContentTypeId.charAt(productContentTypeId.length() - 1));
@@ -1077,9 +1084,6 @@ public class ProductServices {
             /* scale Image in different sizes */
             Map<String, Object> resultResize = FastMap.newInstance();
             try {
-                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);
@@ -1278,9 +1282,15 @@ public class ProductServices {
         Locale locale = (Locale) context.get("locale");
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
-            String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path",delegator), context);
-            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator);
+            Map<String, Object>imageContext = FastMap.newInstance();
+            imageContext.putAll(context);
+            imageContext.put("tenantId",delegator.getDelegatorTenantId());
+            String imageFilenameFormat = EntityUtilProperties.getPropertyValue("catalog", "image.filename.format", delegator);
+
+            String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path",delegator), imageContext);
+            String imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", delegator), imageContext);
+            imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+            imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 
             FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat);
             String id = productPromoId + "_Image_" + productPromoContentTypeId.charAt(productPromoContentTypeId.length() - 1);

Modified: ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original)
+++ ofbiz/branches/release12.04/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Sat Feb 21 09:47:33 2015
@@ -494,8 +494,12 @@ public class ProductUtilServices {
         String errMsg = null;
 
         if (UtilValidate.isEmpty(pattern)) {
-            String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
-            String imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
+            Map<String, Object>imageContext = FastMap.newInstance();
+            imageContext.putAll(context);
+            imageContext.put("tenantId",delegator.getDelegatorTenantId());
+            String imageFilenameFormat = EntityUtilProperties.getPropertyValue("catalog", "image.filename.format", delegator);
+            String imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), imageContext);
+            imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
             pattern = imageUrlPrefix + "/" + imageFilenameFormat;
         }
 

Modified: ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy (original)
+++ ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy Sat Feb 21 09:47:33 2015
@@ -36,9 +36,12 @@ context.primaryParentCategory = primaryP
 
 
 // make the image file formats
-imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
+context.tenantId = delegator.getDelegatorTenantId();
+imageFilenameFormat = EntityUtilProperties.getPropertyValue("catalog", "image.filename.format", delegator);
 imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
+imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context);
+imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy (original)
+++ ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy Sat Feb 21 09:47:33 2015
@@ -24,9 +24,12 @@ import org.ofbiz.entity.util.EntityUtilP
 import org.ofbiz.widget.html.*
 
 // make the image file formats
+context.tenantId = delegator.getDelegatorTenantId();
 imageFilenameFormat = "configitems/${configItemId}";
 imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-imageUrlPrefix = EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator);
+imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context);
+imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy (original)
+++ ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy Sat Feb 21 09:47:33 2015
@@ -27,9 +27,12 @@ import org.ofbiz.entity.condition.*
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
 
 // make the image file formats
-imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
+context.tenantId = delegator.getDelegatorTenantId();
+imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator);
 imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
+imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context);
+imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy (original)
+++ ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy Sat Feb 21 09:47:33 2015
@@ -44,9 +44,12 @@ if (productContentList) {
 }
 
 // make the image file formats
-imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
+context.tenantId = delegator.getDelegatorTenantId();
+imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator);
 imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
+imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context);
+imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;

Modified: ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy?rev=1661313&r1=1661312&r2=1661313&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy (original)
+++ ofbiz/branches/release12.04/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy Sat Feb 21 09:47:33 2015
@@ -26,9 +26,12 @@ import org.ofbiz.product.image.ScaleImag
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
 
 // make the image file formats
-imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format');
+context.tenantId = delegator.getDelegatorTenantId();
+imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator);
 imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context);
-imageUrlPrefix = EntityUtilProperties.getPropertyValue('catalog', 'image.url.prefix',delegator);
+imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context);
+imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath;
+imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix;
 context.imageFilenameFormat = imageFilenameFormat;
 context.imageServerPath = imageServerPath;
 context.imageUrlPrefix = imageUrlPrefix;