svn commit: r1073621 [1/2] - in /ofbiz/trunk/applications/product: config/ script/org/ofbiz/product/imagemanagement/ servicedef/ src/org/ofbiz/product/imagemanagement/ webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/imagemanagement/ webapp/catal...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1073621 [1/2] - in /ofbiz/trunk/applications/product: config/ script/org/ofbiz/product/imagemanagement/ servicedef/ src/org/ofbiz/product/imagemanagement/ webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/imagemanagement/ webapp/catal...

hansbak-2
Author: hansbak
Date: Wed Feb 23 07:06:07 2011
New Revision: 1073621

URL: http://svn.apache.org/viewvc?rev=1073621&view=rev
Log:
Add mass rename and resize functions for product images in image management

Modified:
    ofbiz/trunk/applications/product/config/ImageProperties.xml
    ofbiz/trunk/applications/product/config/ProductUiLabels.xml
    ofbiz/trunk/applications/product/config/catalog.properties
    ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml
    ofbiz/trunk/applications/product/servicedef/services.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ReplaceImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageFrame.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl
    ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageWatermark.ftl
    ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml
    ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml
    ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml

Modified: ofbiz/trunk/applications/product/config/ImageProperties.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ImageProperties.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ImageProperties.xml (original)
+++ ofbiz/trunk/applications/product/config/ImageProperties.xml Wed Feb 23 07:06:07 2011
@@ -68,7 +68,7 @@ under the License.
         <dimension name="width" value="1600"/>
     </size>
     <size name="thumbnail">
-        <dimension name="height" value="300"/>
-        <dimension name="width" value="300"/>
+        <dimension name="height" value="100"/>
+        <dimension name="width" value="100"/>
     </size>
 </imageSize>

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.xml Wed Feb 23 07:06:07 2011
@@ -24849,10 +24849,18 @@
         <value xml:lang="en">Rejected</value>
         <value xml:lang="th">ปฏิเสธ</value>
     </property>
+    <property key="Rename">
+        <value xml:lang="en">Rename</value>
+        <value xml:lang="th">เปลี่ยนชื่อ</value>
+    </property>
     <property key="Replace">
         <value xml:lang="en">Replace</value>
         <value xml:lang="th">แทนที่</value>
     </property>
+    <property key="Resize">
+        <value xml:lang="en">Resize</value>
+        <value xml:lang="th">เปลี่ยนขนาด</value>
+    </property>
     <property key="ShareImage">
         <value xml:lang="en">Share Image</value>
         <value xml:lang="th">แบ่งบันภาพ</value>

Modified: ofbiz/trunk/applications/product/config/catalog.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/catalog.properties?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/catalog.properties (original)
+++ ofbiz/trunk/applications/product/config/catalog.properties Wed Feb 23 07:06:07 2011
@@ -38,3 +38,4 @@ reactivate.product.from.receipt=Y
 # Image upload path on the image management
 image.management.path=${sys:getProperty('ofbiz.home')}/framework/images/webapp/images/products/management
 image.management.url=/images/products/management
+image.management.nameofthumbnail=-100

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml Wed Feb 23 07:06:07 2011
@@ -132,12 +132,13 @@ under the License.
             <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/>
         </entity-and>
         <if-not-empty field="contentAssocs">
-            <first-from-list entry="contentAssoc" list="contentAssocs"/>
-            <remove-value value-field="contentAssoc"/>
-            
-            <set field="removeContent.contentId" from-field="contentAssoc.contentIdTo"/>
-            <set field="removeContent.productId" from-field="parameters.productId"/>
-            <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
+            <iterate entry="contentAssoc" list="contentAssocs">
+                <remove-value value-field="contentAssoc"/>
+                
+                <set field="removeContent.contentId" from-field="contentAssoc.contentIdTo"/>
+                <set field="removeContent.productId" from-field="parameters.productId"/>
+                <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
+            </iterate>
         </if-not-empty>
         
         <make-value value-field="lookupPKMap" entity-name="ProductContent"/>
@@ -363,4 +364,50 @@ under the License.
             <remove-value value-field="contentApproval"/>
         </iterate>
     </simple-method>
+    
+    <simple-method method-name="resizeAllImageOfProduct" short-description="Resize All Image Of Product">
+        <set field="removeImageBySizeMap.productId" from-field="parameters.productId"/>
+        <set field="removeImageBySizeMap.mapKey" from-field="parameters.size"/>
+        <call-service service-name="removeImageBySize" in-map-name="removeImageBySizeMap"/>
+        
+        <entity-and entity-name="ProductContentAndInfo" list="productContentAndInfos">
+            <field-map field-name="productId" from-field="parameters.productId"/>
+            <field-map field-name="productContentTypeId" value="IMAGE"/>
+            <!--<field-map field-name="statusId" value="IM_APPROVED"/>-->
+        </entity-and>
+        <iterate list="productContentAndInfos" entry="productContentAndInfo">
+            <set field="resizeImageMap.productId" from-field="productContentAndInfo.productId"/>
+            <set field="resizeImageMap.contentId" from-field="productContentAndInfo.contentId"/>
+            <set field="resizeImageMap.dataResourceName" from-field="productContentAndInfo.drDataResourceName"/>
+            <set field="resizeImageMap.drObjectInfo" from-field="productContentAndInfo.drObjectInfo"/>
+            <set field="resizeImageMap.resizeWidth" from-field="parameters.size"/>
+            <call-service service-name="resizeImageOfProduct" in-map-name="resizeImageMap"/>
+        </iterate>
+    </simple-method>
+    
+    <simple-method method-name="removeImageBySize" short-description="Remove Image By Size">
+        <entity-condition entity-name="ProductContentAndInfo" list="productContentAndInfos">
+            <condition-list combine="and">
+                <condition-expr field-name="productId" from-field="parameters.productId"/>
+                <condition-expr field-name="productContentTypeId" value="IMAGE"/>
+                <!--<field-map field-name="statusId" value="IM_APPROVED"/>-->
+            </condition-list>
+        </entity-condition>
+        <iterate entry="productContentAndInfo" list="productContentAndInfos">
+            <entity-and list="contentAssocs" entity-name="ContentAssoc">
+                <field-map field-name="contentId" from-field="productContentAndInfo.contentId"/>
+                <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/>
+                <field-map field-name="mapKey" from-field="parameters.mapKey"/>
+            </entity-and>
+            <if-not-empty field="contentAssocs">
+                <iterate entry="contentAssoc" list="contentAssocs">
+                    <remove-value value-field="contentAssoc"/>
+                    
+                    <set field="removeContent.contentId" from-field="contentAssoc.contentIdTo"/>
+                    <set field="removeContent.productId" from-field="parameters.productId"/>
+                    <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
+                </iterate>
+            </if-not-empty>
+        </iterate>
+    </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/product/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services.xml Wed Feb 23 07:06:07 2011
@@ -1486,6 +1486,48 @@ under the License.
         <attribute mode="IN" name="productId" optional="false" type="String"/>
     </service>
     
+    <service name="resizeAllImageOfProduct" engine="simple"
+        location="component://product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml" invoke="resizeAllImageOfProduct" auth="true">
+        <description>Resize All Image Of Product.</description>
+        <attribute name="productId" mode="IN" type="String" optional="false"/>
+        <attribute name="size" mode="IN" type="String" optional="false"/>
+    </service>
+    
+    <service name="resizeImageOfProduct" engine="java"
+        location="org.ofbiz.product.imagemanagement.ImageManagementServices" invoke="resizeImageOfProduct" auth="true">
+        <description>Resize Image Of Product.</description>
+        <attribute name="productId" mode="IN" type="String" optional="false"/>
+        <attribute name="contentId" mode="IN" type="String" optional="false"/>
+        <attribute name="dataResourceName" mode="IN" type="String" optional="false"/>
+        <attribute name="drObjectInfo" mode="IN" type="String" optional="false"/>
+        <attribute name="resizeWidth" mode="IN" type="String" optional="false"/>
+    </service>
+    
+    <service name="removeImageBySize" engine="simple"
+        location="component://product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml" invoke="removeImageBySize" auth="true">
+        <description>Remove Image By Size.</description>
+        <attribute name="productId" mode="IN" type="String" optional="false"/>
+        <attribute name="mapKey" mode="IN" type="String" optional="false"/>
+    </service>
+    
+    <service name="replaceImageToExistImage" engine="java"
+        location="org.ofbiz.product.imagemanagement.ReplaceImage" invoke="replaceImageToExistImage" auth="true">
+        <description>Resize Image Of Product.</description>
+        <attribute name="productId" mode="IN" type="String" optional="false"/>
+        <attribute name="contentIdExist" mode="IN" type="String" optional="false"/>
+        <attribute name="contentIdReplace" mode="IN" type="String" optional="false"/>
+        <attribute name="dataResourceNameExist" mode="IN" type="String" optional="false"/>
+        <attribute name="dataResourceNameReplace" mode="IN" type="String" optional="false"/>
+    </service>
+    
+    <service name="renameImage" engine="java"
+        location="org.ofbiz.product.imagemanagement.ImageManagementServices" invoke="renameImage" auth="true">
+        <description>Rename Image.</description>
+        <attribute name="productId" mode="IN" type="String" optional="false"/>
+        <attribute name="contentId" mode="IN" type="String" optional="false"/>
+        <attribute name="drDataResourceName" mode="IN" type="String" optional="false"/>
+    </service>
+    
     <!-- Best Selling Category Services -->
     <service name="loadBestSellingCategory" engine="simple"
         location="component://product/script/org/ofbiz/product/category/CategoryServices.xml" invoke="loadBestSellingCategory" auth="true">

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java Wed Feb 23 07:06:07 2011
@@ -50,6 +50,7 @@ public class CropImage {
     throws IOException, JDOMException {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String nameOfThumb = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail"), context);
         
         String productId = (String) context.get("productId");
         String imageName = (String) context.get("imageName");
@@ -84,7 +85,7 @@ public class CropImage {
             String contentIdThumb = (String) contentThumbResult.get("contentId");
             String contentId = (String) contentResult.get("contentId");
             String filenameToUse = (String) contentResult.get("contentId") + ".jpg";
-            String filenameTouseThumb = (String) contentThumbResult.get("contentId") + ".jpg";
+            String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg";
             
             String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
             String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
@@ -116,6 +117,7 @@ public class CropImage {
             createContentAssocMap.put("contentId", contentId);
             createContentAssocMap.put("contentIdTo", contentIdThumb);
             createContentAssocMap.put("userLogin", userLogin);
+            createContentAssocMap.put("mapKey", "100");
             try {
                 dispatcher.runSync("createContentAssoc", createContentAssocMap);
             } catch (GenericServiceException e) {

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java Wed Feb 23 07:06:07 2011
@@ -72,6 +72,7 @@ public class FrameImage {
         Delegator delegator = dctx.getDelegator();
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
         String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
+        String nameOfThumb = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail"), context);
         
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String productId = (String) context.get("productId");
@@ -90,10 +91,10 @@ public class FrameImage {
                     "ProductImageWidthAndHeightRequired", locale));
             result.putAll(context);
         }
-
+        
         String frameContentId = (String) context.get("frameContentId");
         String frameDataResourceId = (String) context.get("frameDataResourceId");
-
+        
         String frameImageName = null;
         try {
             GenericValue contentDataResourceView = delegator.findByPrimaryKey("ContentDataResourceView", UtilMisc.toMap("contentId", frameContentId, "drDataResourceId", frameDataResourceId));
@@ -103,7 +104,7 @@ public class FrameImage {
             result = ServiceUtil.returnError(e.getMessage());
             result.putAll(context);
         }
-
+        
         if (UtilValidate.isNotEmpty(imageName)) {
             
             // Image Frame
@@ -147,7 +148,7 @@ public class FrameImage {
             String contentIdThumb = (String) contentThumbResult.get("contentId");
             String contentId = (String) contentResult.get("contentId");
             String filenameToUse = (String) contentResult.get("contentId") + ".jpg";
-            String filenameTouseThumb = (String) contentThumbResult.get("contentId") + ".jpg";
+            String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg";
             
             Image newImg1 = bufImg1.getScaledInstance((int) width, (int) height , Image.SCALE_SMOOTH);
             Image newImg2 = bufImg2.getScaledInstance((int) width , (int) height , Image.SCALE_SMOOTH);
@@ -172,6 +173,7 @@ public class FrameImage {
             createContentAssocMap.put("contentId", contentId);
             createContentAssocMap.put("contentIdTo", contentIdThumb);
             createContentAssocMap.put("userLogin", userLogin);
+            createContentAssocMap.put("mapKey", "100");
             try {
                 dispatcher.runSync("createContentAssoc", createContentAssocMap);
             } catch (GenericServiceException e) {
@@ -242,7 +244,7 @@ public class FrameImage {
         
         return( bufferedImage );
     }
-
+    
     public static String uploadFrame(HttpServletRequest request, HttpServletResponse response) {
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         HttpSession session = request.getSession();
@@ -267,7 +269,7 @@ public class FrameImage {
             request.setAttribute("_ERROR_MESSAGE_", "The selected image type is incorrect, please select the image type *.PNG to upload.");
             return "error";
         }
-
+        
         String contentId = null;
         String dataResourceId = null;
         try {
@@ -289,7 +291,7 @@ public class FrameImage {
             RandomAccessFile out = new RandomAccessFile(file, "rw");
             out.write(imageData.array());
             out.close();
-
+            
             //create dataResource
             Map<String, Object> dataResourceCtx = FastMap.newInstance();
             dataResourceCtx.put("objectInfo", imageServerUrl + imagePath);
@@ -318,15 +320,26 @@ public class FrameImage {
         request.setAttribute("_EVENT_MESSAGE_", "Upload frame image successful.");
         return "success";
     }
+    
     public static String previewFrameImage(HttpServletRequest request, HttpServletResponse response) throws IOException, JDOMException {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
         HttpSession session = request.getSession();
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
-
+        
         String productId = request.getParameter("productId");
         String imageName = request.getParameter("imageName");
         
+        String dirPath = "/preview/";
+        File dir = new File(imageServerPath + dirPath);
+        if (!dir.exists()) {
+            boolean createDir = dir.mkdir();
+            if (!createDir) {
+                request.setAttribute("_ERROR_MESSAGE_", "Cannot create directory.");
+                return "error";
+            }
+        }
+        
         if (UtilValidate.isEmpty(request.getParameter("frameContentId")) || UtilValidate.isEmpty(request.getParameter("frameDataResourceId"))) {
             request.setAttribute("_ERROR_MESSAGE_", "Required frame image content ID or dataResource ID parameters. Please upload new frame image or choose the exist frame.");
             return "error";
@@ -351,7 +364,7 @@ public class FrameImage {
             return "error";
         }
         if (UtilValidate.isNotEmpty(imageName)) {
-            File file = new File(imageServerPath + "/previewImage.jpg");
+            File file = new File(imageServerPath + "/preview/" +"/previewImage.jpg");
             file.delete();
             // Image Frame
             BufferedImage bufImg1 = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + imageName));
@@ -363,16 +376,16 @@ public class FrameImage {
             } else {
                 bufImgType = bufImg1.getType();
             }
-
+            
             int width = Integer.parseInt(request.getParameter("imageWidth"));
             int height= Integer.parseInt(request.getParameter("imageHeight"));
-
+            
             Image newImg1 = bufImg1.getScaledInstance((int) width, (int) height , Image.SCALE_SMOOTH);
             Image newImg2 = bufImg2.getScaledInstance((int) width , (int) height , Image.SCALE_SMOOTH);
             BufferedImage bufNewImg = combineBufferedImage(newImg1, newImg2, bufImgType);
             String mimeType = imageName.substring(imageName.lastIndexOf(".") + 1);
-            ImageIO.write((RenderedImage) bufNewImg, mimeType, new File(imageServerPath + "/previewImage.jpg"));
-
+            ImageIO.write((RenderedImage) bufNewImg, mimeType, new File(imageServerPath + "/preview/" + "/previewImage.jpg"));
+            
         }
          else{
              String errMsg = "Please select Image.";
@@ -381,6 +394,7 @@ public class FrameImage {
         }
         return "success";
     }
+    
     public static String chooseFrameImage(HttpServletRequest request, HttpServletResponse response) {
         HttpSession session = request.getSession();
         if(UtilValidate.isEmpty(request.getParameter("frameContentId"))) {
@@ -408,10 +422,11 @@ public class FrameImage {
         session.setAttribute("frameDataResourceId", frameDataResourceId);
         return "success";
     }
+    
     public static String deleteFrameImage(HttpServletRequest request, HttpServletResponse response) {
         Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
-        File file = new File(imageServerPath + "/previewImage.jpg");
+        File file = new File(imageServerPath + "/preview/" + "/previewImage.jpg");
         if (file.exists()) {
             file.delete();
         }

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=1073621&r1=1073620&r2=1073621&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 Wed Feb 23 07:06:07 2011
@@ -77,13 +77,13 @@ import org.ofbiz.webapp.event.EventHandl
  * Product Services
  */
 public class ImageManagementServices {
-
+    
     public static final String module = ImageManagementServices.class.getName();
     public static final String resource = "ProductErrorUiLabels";
     private static List<Map<String,Object>> josonMap = null;
     private static int imageCount = 0;
     private static String imagePath;
-
+    
     public static Map<String, Object> addMultipleuploadForProduct(DispatchContext dctx, Map<String, ? extends Object> context)
     throws IOException, JDOMException {
         
@@ -271,6 +271,7 @@ public class ImageManagementServices {
             createContentAssocMap.put("contentId", contentId);
             createContentAssocMap.put("contentIdTo", contentIdThumb);
             createContentAssocMap.put("userLogin", userLogin);
+            createContentAssocMap.put("mapKey", "100");
             try {
                 dispatcher.runSync("createContentAssoc", createContentAssocMap);
             } catch (GenericServiceException e) {
@@ -521,6 +522,7 @@ public class ImageManagementServices {
         //FIXME can be removed ?
         // String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
+        String nameOfThumb = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail"), context);
         
         // Create content for thumbnail
         Map<String, Object> contentThumb = FastMap.newInstance();
@@ -565,7 +567,7 @@ public class ImageManagementServices {
             filenameToUseThumb += "." + extensionThumb.getString("fileExtensionId");
         }*/
         //String uploadFileName = (String) context.get("_uploadedFile_fileName");
-        String filenameToUseThumb = imageName.substring(0 , imageName.indexOf(".")) + "_Thumbnail";
+        String filenameToUseThumb = imageName.substring(0 , imageName.indexOf(".")) + nameOfThumb;
         String fileContentType = (String) context.get("_uploadedFile_contentType");
         if (fileContentType.equals("image/pjpeg")) {
             fileContentType = "image/jpeg";
@@ -628,8 +630,8 @@ public class ImageManagementServices {
         Map<String, Object> result = FastMap.newInstance();
         
         /* DIMENSIONS from ImageProperties */
-        defaultHeight = 300;
-        defaultWidth = 300;
+        defaultHeight = 100;
+        defaultWidth = 100;
         
         /* SCALE FACTOR */
         // find the right Scale Factor related to the Image Dimensions
@@ -873,5 +875,247 @@ public class ImageManagementServices {
         file = new File(filePath + "(" + imageCount + ")." + type);
         return checkExistsImage(file);
     }
-
+    
+    public static Map<String, Object> resizeImage(BufferedImage bufImg, double imgHeight, double imgWidth, double resizeHeight, double resizeWidth) {
+        
+        /* VARIABLES */
+        BufferedImage bufNewImg;
+        double defaultHeight, defaultWidth, scaleFactor;
+        Map<String, Object> result = FastMap.newInstance();
+        
+        /* DIMENSIONS from ImageProperties */
+        defaultHeight = resizeHeight;
+        defaultWidth = resizeWidth;
+        
+        /* SCALE FACTOR */
+        // find the right Scale Factor related to the Image Dimensions
+        if (imgHeight > imgWidth) {
+            scaleFactor = defaultHeight / imgHeight;
+            
+            // get scaleFactor from the smallest width
+            if (defaultWidth < (imgWidth * scaleFactor)) {
+                scaleFactor = defaultWidth / imgWidth;
+            }
+        } else {
+            scaleFactor = defaultWidth / imgWidth;
+            // get scaleFactor from the smallest height
+            if (defaultHeight < (imgHeight * scaleFactor)) {
+                scaleFactor = defaultHeight / imgHeight;
+            }
+        }
+        
+        int bufImgType;
+        if (BufferedImage.TYPE_CUSTOM == bufImg.getType()) {
+            // apply a type for image majority
+            bufImgType = BufferedImage.TYPE_INT_ARGB_PRE;
+        } else {
+            bufImgType = bufImg.getType();
+        }
+        
+        // scale original image with new size
+        Image newImg = bufImg.getScaledInstance((int) (imgWidth * scaleFactor), (int) (imgHeight * scaleFactor), Image.SCALE_SMOOTH);
+        
+        bufNewImg = ImageTransform.toBufferedImage(newImg, bufImgType);
+        
+        result.put("bufferedImage", bufNewImg);
+        result.put("scaleFactor", scaleFactor);
+        return result;
+    }
+    
+    public static Map<String, Object> resizeImageOfProduct(DispatchContext dctx, Map<String, ? extends Object> context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        Delegator delegator = dctx.getDelegator();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
+        String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
+        String productId = (String) context.get("productId");
+        String contentId = (String) context.get("contentId");
+        String dataResourceName = (String) context.get("dataResourceName");
+        String drObjectInfo = (String) context.get("drObjectInfo");
+        String width = (String) context.get("resizeWidth");
+        int resizeWidth = Integer.parseInt(width);
+        int resizeHeight = resizeWidth;
+        
+        try {
+            BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceName));
+            double imgHeight = bufImg.getHeight();
+            double imgWidth = bufImg.getWidth();
+            String filenameToUse = dataResourceName.substring(0, dataResourceName.length() - 4) + "-" + resizeWidth + ".jpg";
+            
+            if (dataResourceName.length() > 3) {
+                String mimeType = dataResourceName.substring(dataResourceName.length() - 3, dataResourceName.length());
+                if (mimeType.equals("jpg")) {
+                    Map<String, Object> resultResize = ImageManagementServices.resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth);
+                    ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameToUse));
+                    
+                    Map<String, Object> contentThumb = FastMap.newInstance();
+                    contentThumb.put("contentTypeId", "DOCUMENT");
+                    contentThumb.put("userLogin", userLogin);
+                    Map<String, Object> contentThumbResult = FastMap.newInstance();
+                    try {
+                        contentThumbResult = dispatcher.runSync("createContent", contentThumb);
+                    } catch (GenericServiceException e) {
+                        Debug.logError(e, module);
+                        return ServiceUtil.returnError(e.getMessage());
+                    }
+                    
+                    String contentIdThumb = (String) contentThumbResult.get("contentId");
+                    String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameToUse;
+                    ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlThumb, contentIdThumb, "image/jpeg");
+                    
+                    Map<String, Object> createContentAssocMap = FastMap.newInstance();
+                    createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL");
+                    createContentAssocMap.put("contentId", contentId);
+                    createContentAssocMap.put("contentIdTo", contentIdThumb);
+                    createContentAssocMap.put("userLogin", userLogin);
+                    createContentAssocMap.put("mapKey", width);
+                    try {
+                        dispatcher.runSync("createContentAssoc", createContentAssocMap);
+                    } catch (GenericServiceException e) {
+                        Debug.logError(e, module);
+                        return ServiceUtil.returnError(e.getMessage());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
+        }
+        String successMsg = "Resize images successful";
+        return ServiceUtil.returnSuccess(successMsg);
+    }
+    
+    public static Map<String, Object> renameImage(DispatchContext dctx, Map<String, ? extends Object> context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        Delegator delegator = dctx.getDelegator();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
+        String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
+        String productId = (String) context.get("productId");
+        String contentId = (String) context.get("contentId");
+        String filenameToUse = (String) context.get("drDataResourceName");
+        String mimeType = filenameToUse.substring(filenameToUse.length() - 3, filenameToUse.length());
+        String imageUrl = imageServerUrl + "/" + productId + "/" + filenameToUse;
+        
+        try {
+            if (mimeType.equals("jpg")) {
+                List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "contentId", contentId, "productContentTypeId", "IMAGE"));
+                GenericValue productContent = EntityUtil.getFirst(productContentList);
+                String dataResourceName = (String) productContent.get("drDataResourceName");
+                
+                BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceName));
+                ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + filenameToUse));
+                
+                File file = new File(imageServerPath + "/" + productId + "/" + dataResourceName);
+                file.delete();
+                
+                Map<String, Object> contentUp = FastMap.newInstance();
+                contentUp.put("contentId", contentId);
+                contentUp.put("contentName", filenameToUse);
+                contentUp.put("userLogin", userLogin);
+                try {
+                    dispatcher.runSync("updateContent", contentUp);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+                GenericValue content = null;
+                try {
+                    content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+                if (content != null) {
+                    GenericValue dataResource = null;
+                    try {
+                        dataResource = content.getRelatedOne("DataResource");
+                    } catch (GenericEntityException e) {
+                        Debug.logError(e, module);
+                        return ServiceUtil.returnError(e.getMessage());
+                    }
+                    
+                    if (dataResource != null) {
+                        Map<String, Object> dataResourceCtx = FastMap.newInstance();
+                        dataResourceCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
+                        dataResourceCtx.put("objectInfo", imageUrl);
+                        dataResourceCtx.put("dataResourceName", filenameToUse);
+                        dataResourceCtx.put("userLogin", userLogin);
+                        try {
+                            dispatcher.runSync("updateDataResource", dataResourceCtx);
+                        } catch (GenericServiceException e) {
+                            Debug.logError(e, module);
+                            return ServiceUtil.returnError(e.getMessage());
+                        }
+                    }
+                }
+                
+                List<GenericValue> contentAssocList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL"));
+                if (contentAssocList.size() > 0) {
+                    for (int i = 0; i < contentAssocList.size(); i++) {
+                        GenericValue contentAssoc = (GenericValue) contentAssocList.get(i);
+                        
+                        List<GenericValue> dataResourceAssocList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssoc.get("contentIdTo")));
+                        GenericValue dataResourceAssoc = EntityUtil.getFirst(dataResourceAssocList);
+                        
+                        String drDataResourceNameAssoc = (String) dataResourceAssoc.get("drDataResourceName");
+                        String filenameToUseAssoc = filenameToUse.substring(0, filenameToUse.length() - 4) + "-" + contentAssoc.get("mapKey") + ".jpg";
+                        String imageUrlAssoc = imageServerUrl + "/" + productId + "/" + filenameToUseAssoc;
+                        
+                        BufferedImage bufImgAssoc = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + drDataResourceNameAssoc));
+                        ImageIO.write((RenderedImage) bufImgAssoc, "jpg", new File(imageServerPath + "/" + productId + "/" + filenameToUseAssoc));
+                        
+                        File fileAssoc = new File(imageServerPath + "/" + productId + "/" + drDataResourceNameAssoc);
+                        fileAssoc.delete();
+                        
+                        Map<String, Object> contentAssocMap = FastMap.newInstance();
+                        contentAssocMap.put("contentId", contentAssoc.get("contentIdTo"));
+                        contentAssocMap.put("contentName", filenameToUseAssoc);
+                        contentAssocMap.put("userLogin", userLogin);
+                        try {
+                            dispatcher.runSync("updateContent", contentAssocMap);
+                        } catch (GenericServiceException e) {
+                            Debug.logError(e, module);
+                            return ServiceUtil.returnError(e.getMessage());
+                        }
+                        GenericValue contentAssocUp = null;
+                        try {
+                            contentAssocUp = delegator.findOne("Content", UtilMisc.toMap("contentId", contentAssoc.get("contentIdTo")), false);
+                        } catch (GenericEntityException e) {
+                            Debug.logError(e, module);
+                            return ServiceUtil.returnError(e.getMessage());
+                        }
+                        if (contentAssocUp != null) {
+                            GenericValue dataResourceAssocUp = null;
+                            try {
+                                dataResourceAssocUp = contentAssocUp.getRelatedOne("DataResource");
+                            } catch (GenericEntityException e) {
+                                Debug.logError(e, module);
+                                return ServiceUtil.returnError(e.getMessage());
+                            }
+                            
+                            if (dataResourceAssocUp != null) {
+                                Map<String, Object> dataResourceAssocMap = FastMap.newInstance();
+                                dataResourceAssocMap.put("dataResourceId", dataResourceAssocUp.getString("dataResourceId"));
+                                dataResourceAssocMap.put("objectInfo", imageUrlAssoc);
+                                dataResourceAssocMap.put("dataResourceName", filenameToUseAssoc);
+                                dataResourceAssocMap.put("userLogin", userLogin);
+                                try {
+                                    dispatcher.runSync("updateDataResource", dataResourceAssocMap);
+                                } catch (GenericServiceException e) {
+                                    Debug.logError(e, module);
+                                    return ServiceUtil.returnError(e.getMessage());
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
+        }
+        String successMsg = "Rename image successfully.";
+        return ServiceUtil.returnSuccess(successMsg);
+    }
 }
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ReplaceImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ReplaceImage.java?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ReplaceImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ReplaceImage.java Wed Feb 23 07:06:07 2011
@@ -18,6 +18,8 @@
  *******************************************************************************/
 package org.ofbiz.product.imagemanagement;
 
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -27,6 +29,7 @@ import java.net.URL;
 import java.util.List;
 import java.util.Map;
 
+import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -42,72 +45,80 @@ import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
-
-import watermarker.exception.WatermarkerException;
-import watermarker.impl.DefaultWatermarker;
-import watermarker.model.WatermarkerSettings;
+import org.ofbiz.service.ServiceUtil;
 
 public class ReplaceImage{
 
     public static final String module = ReplaceImage.class.getName();
     public static final String resource = "ProductErrorUiLabels";
 
-    public static String replaceImageToExistImage(HttpServletRequest request, HttpServletResponse response) throws MalformedURLException, FileNotFoundException, WatermarkerException, GenericEntityException, GenericServiceException {
-        Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
+    public static Map<String, Object> replaceImageToExistImage(DispatchContext dctx, Map<String, ? extends Object> context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        Delegator delegator = dctx.getDelegator();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
-        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
-        Delegator delegator = (Delegator) request.getAttribute("delegator");
-        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-        String productId = request.getParameter("productId");
-        String imageName = request.getParameter("imageName");
-        String contentIdExist = request.getParameter("contentIdExist");
-        String contentIdReplace = request.getParameter("contentIdReplace");
-        if (UtilValidate.isNotEmpty(imageName)) {
+        String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
+        String productId = (String) context.get("productId");
+        String contentIdExist = (String) context.get("contentIdExist");
+        String contentIdReplace = (String) context.get("contentIdReplace");
+        String dataResourceNameExist = (String) context.get("dataResourceNameExist");
+        String dataResourceNameReplace = (String) context.get("dataResourceNameReplace");
+        
+        if (UtilValidate.isNotEmpty(dataResourceNameExist)) {
             if (UtilValidate.isNotEmpty(contentIdReplace)) {
                 if (contentIdExist.equals(contentIdReplace)) {
                     String errMsg = "Cannot replace because both images are the same image.";
-                    request.setAttribute("_ERROR_MESSAGE_", errMsg);
-                    return "error";
+                    Debug.logError(errMsg, module);
+                    return ServiceUtil.returnError(errMsg);
                 }
             }
             else{
                 String errMsg = "Please choose image to replace.";
-                request.setAttribute("_ERROR_MESSAGE_", errMsg);
-                return "error";
+                Debug.logError(errMsg, module);
+                return ServiceUtil.returnError(errMsg);
             }
         }
         else{
             String errMsg = "Please choose replacement image.";
-            request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            return "error";
+            Debug.logError(errMsg, module);
+            return ServiceUtil.returnError(errMsg);
         }
         
         try {
-            File file = new File(imageServerPath + "/" + productId + "/" + imageName);
-            file.delete();
-            
-            URL imageUrl = new URL("file:" + imageServerPath + "/" + productId + "/" + contentIdReplace + ".jpg");
-            File outputImageFile = new File(imageServerPath + "/" + productId + "/" + imageName);
-            OutputStream outputStream = new FileOutputStream(outputImageFile);
-            WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
-            new DefaultWatermarker().watermark(imageUrl, " ", outputStream, watermarkerSettings);
-            
-            List<GenericValue> contentAssocExistList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL"));
-            GenericValue contentAssocExist = EntityUtil.getFirst(contentAssocExistList);
+            BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceNameReplace));
+            ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist));
             
             List<GenericValue> contentAssocReplaceList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL"));
-            GenericValue contentAssocReplace = EntityUtil.getFirst(contentAssocReplaceList);
-            
-            URL imageThumbnailUrl = new URL("file:" + imageServerPath + "/" + productId + "/" + contentAssocReplace.get("contentIdTo") + ".jpg");
-            File outputImageThumbnailFile = new File(imageServerPath + "/" + productId + "/" + contentAssocExist.get("contentIdTo") + ".jpg");
-            OutputStream outputStreamThumbnail = new FileOutputStream(outputImageThumbnailFile);
-            new DefaultWatermarker().watermark(imageThumbnailUrl, " ", outputStreamThumbnail, watermarkerSettings);
+            if (contentAssocReplaceList.size() > 0) {
+                for (int i = 0; i < contentAssocReplaceList.size(); i++) {
+                    GenericValue contentAssocReplace = (GenericValue) contentAssocReplaceList.get(i);
+                    
+                    List<GenericValue> dataResourceAssocReplaceList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssocReplace.get("contentIdTo")));
+                    GenericValue dataResourceAssocReplace = EntityUtil.getFirst(dataResourceAssocReplaceList);
+                    
+                    List<GenericValue> contentAssocExistList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL", "mapKey", contentAssocReplace.get("mapKey")));
+                    GenericValue contentAssocExist = EntityUtil.getFirst(contentAssocExistList);
+                    
+                    List<GenericValue> dataResourceAssocExistList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssocExist.get("contentIdTo")));
+                    GenericValue dataResourceAssocExist = EntityUtil.getFirst(dataResourceAssocExistList);
+                    
+                    if (UtilValidate.isNotEmpty(dataResourceAssocExist)) {
+                        BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName")));
+                        ImageIO.write((RenderedImage) bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceAssocExist.get("drDataResourceName")));
+                    }
+                    else{
+                        BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName")));
+                        ImageIO.write((RenderedImage) bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist.substring(0, dataResourceNameExist.length() - 4) + "-" + contentAssocReplace.get("mapKey") + ".jpg"));
+                    }
+                }
+            }
             
             List<GenericValue> productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "contentId", contentIdReplace, "productContentTypeId", "IMAGE"));
             GenericValue productContent = EntityUtil.getFirst(productContentList);
-
+            
             if (productContent != null) {
                 Map<String, Object> productContentCtx = FastMap.newInstance();
                 productContentCtx.put("productId", productId);
@@ -117,15 +128,13 @@ public class ReplaceImage{
                 productContentCtx.put("userLogin", userLogin);
                 dispatcher.runSync("removeProductContentAndImageFile", productContentCtx);
             }
-        } catch (WatermarkerException e) {
+        } catch (Exception e) {
             String errMsg = "Cannot replace image.";
-            request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            Debug.logError(e, errMsg, module);
-            return "error";
+            Debug.logError(errMsg, module);
+            return ServiceUtil.returnError(errMsg);
         }
-        String eventMsg = "Replace image successfully.";
-        request.setAttribute("_EVENT_MESSAGE_", eventMsg);
-        return "success";
+        String successMsg = "Replace image successfully.";
+        return ServiceUtil.returnSuccess(successMsg);
     }
 
 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java Wed Feb 23 07:06:07 2011
@@ -51,11 +51,11 @@ public class RotateImage {
     throws IOException, JDOMException {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String nameOfThumb = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail"), context);
         
         String productId = (String) context.get("productId");
         String imageName = (String) context.get("imageName");
         String angle = (String) context.get("angle");
-
         
         if (UtilValidate.isNotEmpty(imageName)) {
             Map<String, Object> contentCtx = FastMap.newInstance();
@@ -83,7 +83,7 @@ public class RotateImage {
             String contentIdThumb = (String) contentThumbResult.get("contentId");
             String contentId = (String) contentResult.get("contentId");
             String filenameToUse = (String) contentResult.get("contentId") + ".jpg";
-            String filenameTouseThumb = (String) contentThumbResult.get("contentId") + ".jpg";
+            String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg";
             
             String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
             String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
@@ -124,6 +124,7 @@ public class RotateImage {
             createContentAssocMap.put("contentId", contentId);
             createContentAssocMap.put("contentIdTo", contentIdThumb);
             createContentAssocMap.put("userLogin", userLogin);
+            createContentAssocMap.put("mapKey", "100");
             try {
                 dispatcher.runSync("createContentAssoc", createContentAssocMap);
             } catch (GenericServiceException e) {

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java Wed Feb 23 07:06:07 2011
@@ -66,6 +66,7 @@ public class WatermarkImage{
         Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
         String imageServerUrl = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.url"), context);
+        String nameOfThumb = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail"), context);
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
         String watermarkText = null;
@@ -81,7 +82,7 @@ public class WatermarkImage{
         String fontColor = request.getParameter("colorWatermark");
         String fontSize = request.getParameter("sizeWatermark");
         
-        File file = new File(imageServerPath + "/previewImage" + count  + ".jpg");
+        File file = new File(imageServerPath + "/preview/" + "/previewImage" + count  + ".jpg");
         file.delete();
         try {
             if (UtilValidate.isNotEmpty(imageName)) {
@@ -91,7 +92,7 @@ public class WatermarkImage{
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
-
+            
             if (UtilValidate.isNotEmpty(text)) {
                 watermarkText = text;
             } else {
@@ -99,9 +100,9 @@ public class WatermarkImage{
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
-
+            
             WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
-
+            
             if (UtilValidate.isNotEmpty(fontColor)) {
                 Color graphicsColor = setFontColor(fontColor);
                 watermarkerSettings.setGraphicsColor(graphicsColor);
@@ -110,7 +111,7 @@ public class WatermarkImage{
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
-
+            
             DecimalFormat decimalFormat = new DecimalFormat();
             decimalFormat.applyPattern("0.00");
             if (UtilValidate.isNotEmpty(fontSize)) {
@@ -123,7 +124,7 @@ public class WatermarkImage{
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
-
+            
             WatermarkSettings position = new WatermarkSettings();
             if (UtilValidate.isNotEmpty(x) && UtilValidate.isNotEmpty(y)) {
                 BigDecimal positionX = new BigDecimal(decimalFormat.format(Float.parseFloat(x)));
@@ -136,14 +137,14 @@ public class WatermarkImage{
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
-
+            
             AlphaComposite alphaComposite = null;
             if (UtilValidate.isNotEmpty(opacity)) {
                 BigDecimal opa = new BigDecimal(opacity);
                 alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opa.floatValue());
                 watermarkerSettings.setAlphaComposite(alphaComposite);
             }
-
+            
             if (UtilValidate.isNotEmpty(imageUrl)) {
                 
                 Map<String, Object> contentCtx = FastMap.newInstance();
@@ -157,7 +158,7 @@ public class WatermarkImage{
                     request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
                 return "error";
                 }
-
+                
                 Map<String, Object> contentThumb = FastMap.newInstance();
                 contentThumb.put("contentTypeId", "DOCUMENT");
                 contentThumb.put("userLogin", userLogin);
@@ -168,45 +169,46 @@ public class WatermarkImage{
                     Debug.logError(e, module);
                     return e.getMessage();
                 }
-
+                
                 String contentIdThumb = (String) contentThumbResult.get("contentId");
                 String contentId = (String) contentResult.get("contentId");
                 String filenameToUse = (String) contentResult.get("contentId") + ".jpg";
-                String filenameTouseThumb = (String) contentThumbResult.get("contentId") + ".jpg";
+                String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg";
                 File outputImageFile = new File(imageServerPath + "/" + productId + "/" + filenameToUse);
                 OutputStream outputStream = new FileOutputStream(outputImageFile);
-
+                
                 // *** Actual call to Watermarker#watermark(...) ***
                 new DefaultWatermarker().watermark(imageUrl, watermarkText, outputStream, watermarkerSettings);
-
+                
                 String imageUrlResource = imageServerUrl + "/" + productId + "/" + filenameToUse;
-
+                
                 BufferedImage bufNewImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + filenameToUse));
-
+                
                 double imgHeight = bufNewImg.getHeight();
                 double imgWidth = bufNewImg.getWidth();
                 String mimeType = imageName.substring(imageName.lastIndexOf(".") + 1);
-
+                
                 Map<String, Object> resultResize = ImageManagementServices.resizeImageThumbnail(bufNewImg, imgHeight, imgWidth);
                 ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameTouseThumb));
-
+                
                 String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameTouseThumb;
-
+                
                 createContentAndDataResourceWaterMark(request, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg");
                 createContentAndDataResourceWaterMark(request, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg");
-
+                
                 Map<String, Object> createContentAssocMap = FastMap.newInstance();
                 createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL");
                 createContentAssocMap.put("contentId", contentId);
                 createContentAssocMap.put("contentIdTo", contentIdThumb);
                 createContentAssocMap.put("userLogin", userLogin);
+                createContentAssocMap.put("mapKey", "100");
                 try {
                     dispatcher.runSync("createContentAssoc", createContentAssocMap);
                 } catch (GenericServiceException e) {
                     Debug.logError(e, module);
                     return e.getMessage();
                 }
-
+                
                 Map<String, Object> productContentCtx = FastMap.newInstance();
                 productContentCtx.put("productId", productId);
                 productContentCtx.put("productContentTypeId", "IMAGE");
@@ -241,21 +243,21 @@ public class WatermarkImage{
         request.setAttribute("_EVENT_MESSAGE_", eventMsg);
         return "success";
     }
-
+    
     public static Map<String, Object> createContentAndDataResourceWaterMark(HttpServletRequest request, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String mimeTypeId){
         Map<String, Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         Delegator delegator = (Delegator) request.getAttribute("delegator");
-
+        
         Map<String, Object> dataResourceCtx = FastMap.newInstance();
-
+        
         dataResourceCtx.put("objectInfo", imageUrl);
         dataResourceCtx.put("dataResourceName", filenameToUse);
         dataResourceCtx.put("userLogin", userLogin);
         dataResourceCtx.put("dataResourceTypeId", "IMAGE_OBJECT");
         dataResourceCtx.put("mimeTypeId", mimeTypeId);
         dataResourceCtx.put("isPublic", "Y");
-
+        
         Map<String, Object> dataResourceResult = FastMap.newInstance();
         try {
             dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
@@ -263,7 +265,7 @@ public class WatermarkImage{
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
-
+        
         Map<String, Object> contentUp = FastMap.newInstance();
         contentUp.put("contentId", contentId);
         contentUp.put("dataResourceId", dataResourceResult.get("dataResourceId"));
@@ -275,7 +277,7 @@ public class WatermarkImage{
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
-
+        
         GenericValue content = null;
         try {
             content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
@@ -283,7 +285,7 @@ public class WatermarkImage{
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
-
+        
         if (content != null) {
             GenericValue dataResource = null;
             try {
@@ -292,7 +294,7 @@ public class WatermarkImage{
                 Debug.logError(e, module);
                 return ServiceUtil.returnError(e.getMessage());
             }
-
+            
             if (dataResource != null) {
                 dataResourceCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
                 try {
@@ -305,6 +307,7 @@ public class WatermarkImage{
         }
         return result;
     }
+    
     public static String setPreviewWaterMark(HttpServletRequest request, HttpServletResponse response) {
         Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
@@ -319,13 +322,23 @@ public class WatermarkImage{
         String fontColor = request.getParameter("fontColor");
         String fontSize = request.getParameter("fontSize");
         
+        String dirPath = "/preview/";
+        File dir = new File(imageServerPath + dirPath);
+        if (!dir.exists()) {
+            boolean createDir = dir.mkdir();
+            if (!createDir) {
+                request.setAttribute("_ERROR_MESSAGE_", "Cannot create directory.");
+                return "error";
+            }
+        }
+        
         BigDecimal opa = new BigDecimal(opacity);
         DecimalFormat decimalFormat = new DecimalFormat();
         decimalFormat.applyPattern("0.00");
         BigDecimal positionX = new BigDecimal(decimalFormat.format(Float.parseFloat(x)));
         BigDecimal positionY = new BigDecimal(decimalFormat.format(Float.parseFloat(y)));
         BigDecimal picWidth = new BigDecimal(decimalFormat.format(Float.parseFloat(width)));
-        File file = new File(imageServerPath + "/previewImage" + count  + ".jpg");
+        File file = new File(imageServerPath + "/preview/" + "/previewImage" + count  + ".jpg");
         file.delete();
         BigDecimal widthBase = new BigDecimal(600.00);
         Integer currentPic = Integer.parseInt(count);
@@ -343,11 +356,11 @@ public class WatermarkImage{
         watermarkerSettings.setAlphaComposite(alphaComposite);
         try {
            URL imageUrl = new URL("file:" + imageServerPath + "/" + productId + "/" + imageName);
-           File outputImageFile = new File(imageServerPath + "/previewImage" + nextPic + ".jpg");
+           File outputImageFile = new File(imageServerPath + "/preview/" + "/previewImage" + nextPic + ".jpg");
            OutputStream outputStream = new FileOutputStream(outputImageFile);
-
+          
            new DefaultWatermarker().watermark(imageUrl, text, outputStream, watermarkerSettings);
-
+          
         } catch (Exception e) {
             String errMsg = "Error from setPreviewWaterMark";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -355,16 +368,17 @@ public class WatermarkImage{
         }
         return "success";
     }
+    
     public static String deletePreviewWatermarkImage(HttpServletRequest request, HttpServletResponse response) {
         Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
         String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context);
         String count = request.getParameter("count");
-        File file = new File(imageServerPath + "/previewImage" + count  + ".jpg");
+        File file = new File(imageServerPath + "/preview/" + "/previewImage" + count  + ".jpg");
         file.delete();
-
+        
         return "success";
     }
-
+    
     private static Color setFontColor(String color) {
         Color graphicsColor = null;
         if (color.equals("TEXT_BLACK")) {
@@ -384,7 +398,7 @@ public class WatermarkImage{
         }
         return graphicsColor;
     }
-
+    
     private static Font setFontSize(String fontSize, BigDecimal multiply) {
         Font graphicsFont = null;
         BigDecimal baseSize = null;

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageFrame.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageFrame.groovy?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageFrame.groovy (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageFrame.groovy Wed Feb 23 07:06:07 2011
@@ -18,16 +18,21 @@
  */
 
 import javax.servlet.http.HttpSession;
+import org.ofbiz.base.util.UtilValidate;
 
-frameContentId = parameters.get("frameContentId");
-frameDataResourceId = parameters.get("frameDataResourceId");
-if ((session != null) && (frameContentId == null) && (frameDataResourceId == null)) {
+frameContentId = null;
+frameDataResourceId = null;
+
+if (UtilValidate.isNotEmpty(session.getAttribute("frameContentId")) && UtilValidate.isNotEmpty(session.getAttribute("frameDataResourceId"))) {
     frameContentId = session.getAttribute("frameContentId");
     frameDataResourceId = session.getAttribute("frameDataResourceId");
+} else {
+    frameContentId = parameters.get("frameContentId");
+    frameDataResourceId = parameters.get("frameDataResourceId");
 }
 
 context.frameContentId = frameContentId;
 context.frameDataResourceId = frameDataResourceId;
 
 session.removeAttribute("frameContentId");
-session.removeAttribute("frameDataResourceId");
+session.removeAttribute("frameDataResourceId");
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Wed Feb 23 07:06:07 2011
@@ -2834,7 +2834,7 @@ under the License.
     </request-map>
      <request-map uri="replaceImageToExistImage">
         <security https="true" auth="true"/>
-        <event type="java" path="org.ofbiz.product.imagemanagement.ReplaceImage" invoke="replaceImageToExistImage"/>
+        <event type="service" path="" invoke="replaceImageToExistImage"/>
         <response name="success" type="view" value="ListImageReplace"/>
         <response name="error" type="view" value="ListImageReplace"/>
     </request-map>
@@ -2968,6 +2968,36 @@ under the License.
         <security https="true" auth="true"/>
         <response name="success" type="view" value="ListImageRemove"/>
     </request-map>
+    <request-map uri="ImageResize">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="ImageResize"/>
+    </request-map>
+    <request-map uri="resizeAllImageOfProduct">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="resizeAllImageOfProduct"/>
+        <response name="success" type="view" value="ImageResize"/>
+        <response name="error" type="view" value="ImageResize"/>
+    </request-map>
+    <request-map uri="removeImageBySize">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="removeImageBySize"/>
+        <response name="success" type="view" value="ImageResize"/>
+        <response name="error" type="view" value="ImageResize"/>
+    </request-map>
+    <request-map uri="ImageRename">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="ImageRename"/>
+    </request-map>
+    <request-map uri="ListImageRename">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="ListImageRename"/>
+    </request-map>
+    <request-map uri="renameImage">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="renameImage"/>
+        <response name="success" type="view" value="ListImageRename"/>
+        <response name="error" type="view" value="ListImageRename"/>
+    </request-map>
 
    <!-- ================ Lookup Requests ================= -->
     <request-map uri="LookupContent"><security auth="true" https="true"/><response name="success" type="view" value="LookupContent"/></request-map>
@@ -3235,5 +3265,8 @@ under the License.
     <view-map name="LookupImageFrame" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#LookupImageFrame"/>
     <view-map name="ImageRemove" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageRemove"/>
     <view-map name="ListImageRemove" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ListImageRemove"/>
+    <view-map name="ImageResize" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageResize"/>
+    <view-map name="ImageRename" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageRename"/>
+    <view-map name="ListImageRename" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ListImageRename"/>
     <!-- end of view mappings -->
 </site-conf>

Modified: ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl Wed Feb 23 07:06:07 2011
@@ -29,48 +29,47 @@ under the License.
         <#list productContentAndInfos as productContentAndInfo>
             <#assign contentAssocs  = delegator.findByAnd("ContentAssoc",Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", productContentAndInfo.contentId?if_exists, "contentAssocTypeId", "IMAGE_THUMBNAIL"))/>
             <#if contentAssocs?has_content>
-                <#list contentAssocs as contentAssoc>
-                    <#assign ImageContent = delegator.findByPrimaryKey("Content", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo))?if_exists>
-                    <#assign contentDataResourceView = delegator.findByPrimaryKey("ContentDataResourceView", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo, "drDataResourceId", ImageContent.dataResourceId))?if_exists>
-                    <#assign contentName  = productContentAndInfo.contentName>
-                    <#if imageIndex < 5>
-                        <td style="vertical-align:bottom">
-                            <table>
-                                <tbody>
-                                    <tr valign="middle">
-                                        <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> -->
-                                        <td align="center"><a href="<@ofbizContentUrl>${(productContentAndInfo.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td>
-                                    </tr>
-                                    <tr valign="middle">
-                                        <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}&amp;seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> -->
-                                        <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td>
-                                    </tr>
-                                    <br/>
-                                </tbody>
-                            </table>
-                        </td>
-                        <#assign imageIndex = imageIndex+1>
-                    <#else>
-                        <#assign imageIndex = 0>
-                        <tr></tr>
-                        <td style="vertical-align:bottom">
-                            <table>
-                                <tbody>
-                                    <tr valign="middle">
-                                        <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> -->
-                                        <td align="center"><a href="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td>
-                                    </tr>
-                                    <tr valign="middle">
-                                        <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}&amp;seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> -->
-                                        <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td>
-                                    </tr>
-                                    <br/>
-                                </tbody>
-                            </table>
-                        </td>
-                        <#assign imageIndex = imageIndex+1>
-                    </#if>
-                </#list>
+                <#assign contentAssoc = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(contentAssocs) />
+                <#assign ImageContent = delegator.findByPrimaryKey("Content", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo))?if_exists>
+                <#assign contentDataResourceView = delegator.findByPrimaryKey("ContentDataResourceView", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo, "drDataResourceId", ImageContent.dataResourceId))?if_exists>
+                <#assign contentName  = productContentAndInfo.contentName>
+                <#if imageIndex < 5>
+                    <td style="vertical-align:bottom">
+                        <table>
+                            <tbody>
+                                <tr valign="middle">
+                                    <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> -->
+                                    <td align="center"><a href="<@ofbizContentUrl>${(productContentAndInfo.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td>
+                                </tr>
+                                <tr valign="middle">
+                                    <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}&amp;seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> -->
+                                    <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td>
+                                </tr>
+                                <br/>
+                            </tbody>
+                        </table>
+                    </td>
+                    <#assign imageIndex = imageIndex+1>
+                <#else>
+                    <#assign imageIndex = 0>
+                    <tr></tr>
+                    <td style="vertical-align:bottom">
+                        <table>
+                            <tbody>
+                                <tr valign="middle">
+                                    <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> -->
+                                    <td align="center"><a href="<@ofbizContentUrl>${(productContentAndInfo.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td>
+                                </tr>
+                                <tr valign="middle">
+                                    <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}&amp;seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> -->
+                                    <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&amp;dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td>
+                                </tr>
+                                <br/>
+                            </tbody>
+                        </table>
+                    </td>
+                    <#assign imageIndex = imageIndex+1>
+                </#if>
             </#if>
         </#list>
     </#if>

Modified: ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageWatermark.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageWatermark.ftl?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageWatermark.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageWatermark.ftl Wed Feb 23 07:06:07 2011
@@ -85,7 +85,7 @@ under the License.
        var imageData = {productId : productId, imageName : imageName, text : text, opacity : opacity, x : pointX, y : pointY,
                            width : width, count : previewCount, fontColor : fontColor, fontSize : fontSize};
        jQuery.post("setPreviewWaterMark", imageData, function() {
-           var path = imageServerUrl + "/previewImage" + next + ".jpg";
+           var path = imageServerUrl + "/preview/" + "/previewImage" + next + ".jpg";
            jQuery('td.img-src img').attr('src', path);
            jQuery('#ImageWatermarking_previewCount').attr('value', next);
        });

Modified: ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml?rev=1073621&r1=1073620&r2=1073621&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml Wed Feb 23 07:06:07 2011
@@ -476,7 +476,7 @@ under the License.
     </menu>
 
      <menu name="ImageManagementTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml" selected-menuitem-context-field-name="userTabButtonImage">
-        <menu-item name="main" title="${uiLabelMap.main}">
+        <menu-item name="main" title="${uiLabelMap.Main}">
             <condition>
                 <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/>
             </condition>
@@ -539,6 +539,22 @@ under the License.
                 <parameter param-name="productId"/>
             </link>
         </menu-item>
+        <menu-item name="ImageRename" title="${uiLabelMap.Rename}">
+            <condition>
+                <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/>
+            </condition>
+            <link target="ListImageRename">
+                <parameter param-name="productId"/>
+            </link>
+        </menu-item>
+        <menu-item name="ImageResize" title="${uiLabelMap.Resize}">
+            <condition>
+                <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/>
+            </condition>
+            <link target="ImageResize">
+                <parameter param-name="productId"/>
+            </link>
+        </menu-item>
         <menu-item name="ImageRemove" title="${uiLabelMap.Remove}">
             <condition>
                 <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/>