Author: ashish
Date: Sat Feb 21 09:38:51 2015
New Revision: 1661310

URL: http://svn.apache.org/r1661310
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/release14.12/applications/product/config/catalog.properties
    
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/image/ScaleImage.java
    
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductServices.java
    
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
    
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
    
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
    
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
    
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
    
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy

Modified: 
ofbiz/branches/release14.12/applications/product/config/catalog.properties
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/config/catalog.properties?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/product/config/catalog.properties 
(original)
+++ ofbiz/branches/release14.12/applications/product/config/catalog.properties 
Sat Feb 21 09:38:51 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/release14.12/applications/product/src/org/ofbiz/product/image/ScaleImage.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/image/ScaleImage.java?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/image/ScaleImage.java
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/image/ScaleImage.java
 Sat Feb 21 09:38:51 2015
@@ -106,9 +106,14 @@ 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;
         String type = null;
@@ -282,10 +287,15 @@ public class ScaleImage {
         String imgName = filenameToUse.substring(0, index - 1);
         String imgExtension = filenameToUse.substring(index + 1);
         // paths
+        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")), context);
-        String imageUrlPrefix = 
EntityUtilProperties.getPropertyValue("catalog", 
"image.url.prefix",(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;
         if (viewType.toLowerCase().contains("main")) {

Modified: 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductServices.java
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductServices.java
 Sat Feb 21 09:38:51 2015
@@ -975,10 +975,16 @@ public class ProductServices {
         Locale locale = (Locale) context.get("locale");
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
+            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), context);
-            String imageUrlPrefix = 
EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", 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));
             String viewType = "additional" + viewNumber;
@@ -1068,9 +1074,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);
@@ -1269,10 +1272,15 @@ public class ProductServices {
         Locale locale = (Locale) context.get("locale");
 
         if (UtilValidate.isNotEmpty(context.get("_uploadedFile_fileName"))) {
+            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), context);
-            String imageUrlPrefix = 
EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix", 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);
             String fileLocation = 
filenameExpander.expandString(UtilMisc.toMap("location", "products", "type", 
"promo", "id", id));

Modified: 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
 Sat Feb 21 09:38:51 2015
@@ -501,8 +501,12 @@ public class ProductUtilServices {
         String errMsg = null;
 
         if (UtilValidate.isEmpty(pattern)) {
+            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 = 
EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",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/release14.12/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
 Sat Feb 21 09:38:51 2015
@@ -36,9 +36,12 @@ context.primaryParentCategory = primaryP
 
 
 // make the image file formats
+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/release14.12/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
 Sat Feb 21 09:38:51 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/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageUpload.groovy
 Sat Feb 21 09:38:51 2015
@@ -27,9 +27,12 @@ import org.ofbiz.entity.condition.*
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
 
 // make the image file formats
+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/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy
 Sat Feb 21 09:38:51 2015
@@ -44,9 +44,12 @@ if (productContentList) {
 }
 
 // make the image file formats
+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/release14.12/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy?rev=1661310&r1=1661309&r2=1661310&view=diff
==============================================================================
--- 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy
 (original)
+++ 
ofbiz/branches/release14.12/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy
 Sat Feb 21 09:38:51 2015
@@ -26,9 +26,12 @@ import org.ofbiz.product.image.ScaleImag
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString();
 
 // make the image file formats
+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;


Reply via email to