[ofbiz-framework] branch trunk updated: Improved: Convert ImageManagementServices.xml minilang to groovy (OFBIZ-11604)

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

[ofbiz-framework] branch trunk updated: Improved: Convert ImageManagementServices.xml minilang to groovy (OFBIZ-11604)

mbrohl
This is an automated email from the ASF dual-hosted git repository.

mbrohl pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new bcb76eb  Improved: Convert ImageManagementServices.xml minilang to groovy (OFBIZ-11604)
bcb76eb is described below

commit bcb76eb607168308834d8782378e5ee798f5d91e
Author: Sebastian Berg <[hidden email]>
AuthorDate: Mon Feb 8 11:33:47 2021 +0100

    Improved: Convert ImageManagementServices.xml minilang to groovy (OFBIZ-11604)
---
 .../imagemanagement/ImageManagementServices.groovy | 482 ++++++++++++++++++++
 .../imagemanagement/ImageManagementServices.xml    | 490 ---------------------
 applications/product/servicedef/services.xml       |  40 +-
 3 files changed, 502 insertions(+), 510 deletions(-)

diff --git a/applications/product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy b/applications/product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy
new file mode 100644
index 0000000..9837e33
--- /dev/null
+++ b/applications/product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy
@@ -0,0 +1,482 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.sql.Timestamp
+
+import org.apache.ofbiz.base.util.ScriptUtil
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilProperties
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.service.ServiceUtil
+
+/**
+ * Method to upload multiple images for product
+ * @return
+ */
+def uploadProductImages() {
+    Map result = success()
+    Map serviceResult = [:]
+    Map addAdditionalViewForProductMap = parameters
+    if (parameters._additionalImageOne_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageOne
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageOne_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageOne_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageTwo_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageTwo
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageTwo_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageTwo_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageThree_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageThree
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageThree_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageThree_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageFour_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageFour
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageFour_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageFour_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageFive_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageFive
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageFive_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageFive_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageSix_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageSix
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageSix_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageSix_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageSeven_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageSeven
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageSeven_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageSeven_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageEight_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageEight
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageEight_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageEight_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageNine_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageNine
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageNine_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageNine_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    if (parameters._additionalImageTen_fileName) {
+        addAdditionalViewForProductMap.productId = parameters.productId
+        addAdditionalViewForProductMap.imageResize = parameters.imageResize
+        addAdditionalViewForProductMap.uploadedFile = parameters.additionalImageTen
+        addAdditionalViewForProductMap.productContentTypeId = "IMAGE"
+        addAdditionalViewForProductMap._uploadedFile_fileName = parameters._additionalImageTen_fileName
+        addAdditionalViewForProductMap._uploadedFile_contentType = parameters._additionalImageTen_contentType
+        serviceResult = run service: "addMultipleuploadForProduct", with: addAdditionalViewForProductMap
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+        addAdditionalViewForProductMap.clear()
+    }
+    result.productId = parameters.productId
+    return result
+}
+
+/**
+ * Remove Content From Product and Image File
+ * @return
+ */
+def removeProductContentAndImageFile() {
+    Map removeContent
+    Map serviceResult = [:]
+    List checkDefaultImage = from("ProductContent").where(productId: parameters.productId, contentId: parameters.contentId,
+        productContentTypeId: "DEFAULT_IMAGE").queryList()
+    if (!checkDefaultImage) {
+        List contentAssocs = from("ContentAssoc").where(contentId: parameters.contentId, contentAssocTypeId: "IMAGE_THUMBNAIL").queryList()
+        if (contentAssocs) {
+            for (GenericValue contentAssoc : contentAssocs) {
+                contentAssoc.remove()
+                removeContent = [contentId: contentAssoc.contentIdTo, productId: parameters.productId]
+                serviceResult = run service: "removeProductContentForImageManagement", with: removeContent
+                if (!ServiceUtil.isSuccess(serviceResult)) {
+                    return error(serviceResult.errorMessage)
+                }
+            }
+        }
+        GenericValue lookedUpValue = from("ProductContent").where(parameters).queryOne()
+        lookedUpValue.remove()
+        removeContent = [contentId: parameters.contentId, productId: parameters.productId]
+        serviceResult = run service: "removeProductContentForImageManagement", with: removeContent
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+    } else {
+        String errorMessage = UtilProperties.getMessage("ProductErrorUiLabels", "ImageManagementErrorRmoveDefaultImage", locale)
+        logError("Cannot remove image contentId ${parameters.contentId}")
+        return error(errorMessage)
+    }
+    return success()
+}
+
+/**
+ * Remove Content From Product
+ * @return
+ */
+def removeProductContentForImageManagement() {
+    Map serviceResult = [:]
+    List contentRoles = from("ContentRole").where(contentId: parameters.contentId).queryList()
+    if (contentRoles) {
+        contentRoles.get(0).remove()
+    }
+    List contentApprovals = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER").queryList()
+    for (GenericValue contentApproval : contentApprovals) {
+        contentApproval.remove()
+    }
+    List contentKeywords = from("ContentKeyword").where(contentId: parameters.contentId).queryList()
+    for (GenericValue contentKeyword : contentKeywords) {
+        contentKeyword.remove()
+    }
+    GenericValue content = from("Content").where(contentId: parameters.contentId).queryOne()
+    Map removeContentPKMap = [contentId: parameters.contentId]
+    serviceResult = run service: "removeContent", with: removeContentPKMap
+    if (!ServiceUtil.isSuccess(serviceResult)) {
+        return error(serviceResult.errorMessage)
+    }
+
+    String dataResourceId = content.dataResourceId
+    List dataResourceRoles = from("DataResourceRole").where(dataResourceId: dataResourceId).queryList()
+    if (dataResourceRoles) {
+        dataResourceRoles.get(0).remove()
+    }
+    GenericValue dataResource = from("DataResource").where(dataResourceId: dataResourceId).queryOne()
+    Map removeImageFile = [productId: parameters.productId, contentId: parameters.contentId, objectInfo: dataResource.objectInfo,
+        dataResourceName: dataResource.dataResourceName]
+    serviceResult = run service: "removeImageFileForImageManagement", with: removeImageFile
+    if (!ServiceUtil.isSuccess(serviceResult)) {
+        return error(serviceResult.errorMessage)
+    }
+
+    Map removeDataResourcePKMap = [dataResourceId: dataResourceId]
+    serviceResult = run service: "removeDataResource", with: removeDataResourcePKMap
+    if (!ServiceUtil.isSuccess(serviceResult)) {
+        return error(serviceResult.errorMessage)
+    }
+    return success()
+}
+
+/**
+ * Set Image Detail
+ * @return
+ */
+def setImageDetail() {
+    GenericValue productContent = from("ProductContent").where(parameters).queryOne()
+    productContent.sequenceNum = parameters.sequenceNum
+    productContent.store()
+    if (parameters.sequenceNum) {
+        ScriptUtil.executeScript("component://product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy", null, context)
+        productContent.sequenceNum = parameters.sequenceNum
+        productContent.store()
+    }
+    // set caption
+    GenericValue content = from("Content").where(parameters).queryOne()
+    content.description = parameters.description
+    content.store()
+
+    if (content.statusId == "IM_APPROVED") {
+        GenericValue dataResource = from("DataResource").where(dataResourceId: content.dataResourceId).queryOne()
+        dataResource.isPublic = parameters.drIsPublic
+        dataResource.store()
+    }
+    return success()
+}
+
+/**
+ * Update Status Image Management
+ * @return
+ */
+def updateStatusImageManagement() {
+    Timestamp nowTimestamp = UtilDateTime.nowTimestamp()
+    String checkStatusVal = parameters.checkStatusId
+    List statusId = StringUtil.split(checkStatusVal, "/")
+    if (statusId) {
+        parameters.checkStatusId = statusId.get(0)
+    }
+    String autoApproveImage = UtilProperties.getPropertyValue("catalog.properties", "image.management.autoApproveImage")
+    String multipleApproval = UtilProperties.getPropertyValue("catalog.properties", "image.management.multipleApproval")
+    if (autoApproveImage == "Y") {
+        List contentApprovals = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER").queryList()
+        for (GenericValue contentApproval : contentApprovals) {
+            contentApproval.approvalStatusId = parameters.checkStatusId
+            contentApproval.store()
+        }
+    } else {
+        GenericValue contentApproval = from("ContentApproval").where(partyId: userLogin.partyId, contentId: parameters.contentId,
+            roleTypeId: "IMAGEAPPROVER").queryFirst()
+        contentApproval.approvalStatusId = parameters.checkStatusId
+        contentApproval.store()
+    }
+    if (parameters.checkStatusId == "IM_REJECTED") {
+        List checkRejects = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER").queryList()
+        for (GenericValue checkReject : checkRejects) {
+            checkReject.statusId = "IM_REJECTED"
+            checkReject.store()
+        }
+        GenericValue content = from("Content").where(parameters).queryOne()
+        content.statusId = "IM_REJECTED"
+        content.createdByUserLogin = userLogin.userLoginId
+        content.store()
+    } else {
+        if (parameters.checkStatusId == "IM_APPROVED") {
+            if (multipleApproval == "Y") {
+                Long countParty = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER").queryCount()
+                if (countParty == (Long) 1) {
+                    GenericValue content = from("Content").where(parameters).queryOne()
+                    content.statusId = "IM_APPROVED"
+                    content.store()
+
+                    GenericValue productContent = from("ProductContent").where(contentId: parameters.contentId, productContentTypeId: "IMAGE")
+                        .queryFirst()
+                    productContent.purchaseFromDate = nowTimestamp
+                    productContent.store()
+                } else {
+                    Long countApprove = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER",
+                        approvalStatusId: "IM_APPROVED").queryCount()
+                    if (countApprove >= (Long) 2) {
+                        GenericValue content = from("Content").where(parameters).queryOne()
+                        content.statusId = "IM_APPROVED"
+                        content.store()
+
+                        GenericValue productContent = from("ProductContent").where(contentId: parameters.contentId, productContentTypeId: "IMAGE")
+                            .queryFirst()
+                        productContent.purchaseFromDate = nowTimestamp
+                        productContent.store()
+
+                        List checkApproveList = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER")
+                            .queryList()
+                        for (GenericValue checkApprove : checkApproveList) {
+                            checkApprove.approvalStatusId = "IM_APPROVED"
+                            checkApprove.store()
+                        }
+                    }
+                }
+            } else {
+                GenericValue content = from("Content").where(parameters).queryOne()
+                content.statusId = "IM_APPROVED"
+                content.store()
+
+                GenericValue productContent = from("ProductContent").where(contentId: parameters.contentId, productContentTypeId: "IMAGE").queryFirst()
+                productContent.purchaseFromDate = nowTimestamp
+                productContent.store()
+
+                List checkApproveList = from("ContentApproval").where(contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER").queryList()
+                for (GenericValue checkApprove : checkApproveList) {
+                    checkApprove.approvalStatusId = "IM_APPROVED"
+                    checkApprove.store()
+                }
+            }
+        }
+    }
+    return success()
+}
+
+/**
+ * Add Rejected Reason Image Management
+ * @return
+ */
+def addRejectedReasonImageManagement() {
+    Timestamp nowTimestamp = UtilDateTime.nowTimestamp()
+    GenericValue content = from("Content").where(parameters).queryOne()
+    if (parameters.description) {
+        if (parameters.description == "RETAKE_PHOTO") {
+            content.description = "Re-take Photo"
+        }
+        if (parameters.description == "REMOVE_LOGO") {
+            content.description = "Remove Logo"
+        }
+        if (parameters.description == "OTHER") {
+            content.description = "Other"
+        }
+    } else {
+        content.description = "Other"
+    }
+    content.store()
+    GenericValue productContent = from("ProductContent").where(contentId: parameters.contentId, productContentTypeId: "IMAGE").queryFirst()
+    productContent.thruDate = nowTimestamp
+    productContent.store()
+    return success()
+}
+
+/**
+ * Create Content Approval of Image
+ * @return
+ */
+def createImageContentApproval() {
+    Timestamp nowTimestamp = UtilDateTime.nowTimestamp()
+    List partyRoles = from("PartyRole").where(roleTypeId: "IMAGEAPPROVER").queryList()
+    for (GenericValue partyRole : partyRoles) {
+        Map contentApproval = [partyId: partyRole.partyId, contentId: parameters.contentId, roleTypeId: "IMAGEAPPROVER",
+            approvalDate: nowTimestamp, approvalStatusId: "IM_PENDING"]
+        Map serviceResult = run service: "createContentApproval", with: contentApproval
+        if (!ServiceUtil.isSuccess(serviceResult)) {
+            return error(serviceResult.errorMessage)
+        }
+    }
+    return success()
+}
+
+/**
+ * Remove Content Approval of Image
+ * @return
+ */
+def removeImageContentApproval() {
+    List contentApprovals = from("ContentApproval").where(partyId: parameters.partyId, roleTypeId: "IMAGEAPPROVER").queryList()
+    for (GenericValue contentApproval : contentApprovals) {
+        contentApproval.remove()
+    }
+    return success()
+}
+
+/**
+ * Resize Images
+ * @return
+ */
+def resizeImages() {
+    Map serviceResult = [:]
+    if (parameters.resizeOption == "resizeAllImages") {
+        List productContentAndInfos = from("ProductContentAndInfo").where(productId: parameters.productId, productContentTypeId: "IMAGE").queryList()
+        // <field-map field-name="statusId" value="IM_APPROVED"/>
+        for (GenericValue productContentAndInfo : productContentAndInfos) {
+            Map resizeImageMap = [productId: productContentAndInfo.productId, dataResourceName: productContentAndInfo.drDataResourceName,
+                resizeWidth: parameters.size]
+            serviceResult = run service: "resizeImageOfProduct", with: resizeImageMap
+            if (!ServiceUtil.isSuccess(serviceResult)) {
+                return error(serviceResult.errorMessage)
+            }
+        }
+    }
+    if (parameters.resizeOption == "createNewThumbnail") {
+        Map removeImageBySizeMap = [productId: parameters.productId, mapKey: parameters.size]
+        run service: "removeImageBySize", with: removeImageBySizeMap
+
+        List productContentAndInfos = from("ProductContentAndInfo").where(productId: parameters.productId, productContentTypeId: "IMAGE").queryList()
+        // <field-map field-name="statusId" value="IM_APPROVED"/>
+        for (GenericValue productContentAndInfo : productContentAndInfos) {
+            Map createNewImageThumbnailMap = [productId: productContentAndInfo.productId, contentId: productContentAndInfo.contentId,
+                dataResourceName: productContentAndInfo.drDataResourceName, drObjectInfo: productContentAndInfo.drObjectInfo, sizeWidth: parameters.size]
+            serviceResult = run service: "createNewImageThumbnail", with: createNewImageThumbnailMap
+            if (!ServiceUtil.isSuccess(serviceResult)) {
+                return error(serviceResult.errorMessage)
+            }
+        }
+    }
+    return success()
+}
+
+/**
+ * Remove Image By Size
+ * @return
+ */
+def removeImageBySize() {
+    List productContentAndInfos = from("ProductContentAndInfo").where(productId: parameters.productId, productContentTypeId: "IMAGE").queryList()
+    // <field-map field-name="statusId" value="IM_APPROVED"/>
+    for (GenericValue productContentAndInfo : productContentAndInfos) {
+        List contentAssocs = from("ContentAssoc").where(contentId: productContentAndInfo.contentId, contentAssocTypeId: "IMAGE_THUMBNAIL",
+            mapKey: parameters.mapKey).queryList()
+        if (contentAssocs) {
+            for (GenericValue contentAssoc : contentAssocs) {
+                contentAssoc.remove()
+                Map removeContent = [contentId: contentAssoc.contentIdTo, productId: parameters.productId]
+                Map serviceResult = run service: "removeProductContentForImageManagement", with: removeContent
+                if (!ServiceUtil.isSuccess(serviceResult)) {
+                    return error(serviceResult.errorMessage)
+                }
+            }
+        }
+    }
+    return success()
+}
diff --git a/applications/product/minilang/product/imagemanagement/ImageManagementServices.xml b/applications/product/minilang/product/imagemanagement/ImageManagementServices.xml
deleted file mode 100644
index 436c64d..0000000
--- a/applications/product/minilang/product/imagemanagement/ImageManagementServices.xml
+++ /dev/null
@@ -1,490 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
-    
-    <simple-method method-name="uploadProductImages" short-description="Method to upload multiple images for product">
-        <set-service-fields service-name="addMultipleuploadForProduct" map="parameters" to-map="addAdditionalViewForProductMap"/>
-        <if-not-empty field="parameters._additionalImageOne_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageOne"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageOne_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageOne_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageTwo_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageTwo"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageTwo_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageTwo_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageThree_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageThree"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageThree_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageThree_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageFour_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageFour"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageFour_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageFour_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageFive_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageFive"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageFive_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageFive_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageSix_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageSix"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageSix_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageSix_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageSeven_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageSeven"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-           <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageSeven_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageSeven_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageEight_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageEight"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageEight_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageEight_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageNine_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageNine"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageNine_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageNine_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <if-not-empty field="parameters._additionalImageTen_fileName">
-            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
-            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
-            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageTen"/>
-            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageTen_fileName"/>
-            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageTen_contentType"/>
-            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
-            <clear-field field="addAdditionalViewForProductMap"/>
-        </if-not-empty>
-        <field-to-result field="parameters.productId" result-name="productId"/>
-    </simple-method>
-  
-    <simple-method method-name="removeProductContentAndImageFile" short-description="Remove Content From Product and Image File">
-        <entity-and entity-name="ProductContent" list="checkDefaultImage">
-            <field-map field-name="productId" from-field="parameters.productId"/>
-            <field-map field-name="contentId" from-field="parameters.contentId"/>
-            <field-map field-name="productContentTypeId" value="DEFAULT_IMAGE"/>
-        </entity-and>
-        <if-empty field="checkDefaultImage">
-            <entity-and entity-name="ContentAssoc" list="contentAssocs">
-                <field-map field-name="contentId" from-field="parameters.contentId"/>
-                <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/>
-            </entity-and>
-            <if-not-empty field="contentAssocs">
-                <iterate list="contentAssocs" entry="contentAssoc">
-                    <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 entity-name="ProductContent" value-field="lookupPKMap"/>
-            <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-            <find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
-            <remove-value value-field="lookedUpValue"/>
-            <set field="removeContent.contentId" from-field="parameters.contentId"/>
-            <set field="removeContent.productId" from-field="parameters.productId"/>
-            <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
-        <else>
-            <add-error>
-                <fail-property resource="ProductErrorUiLabels" property="ImageManagementErrorRmoveDefaultImage"/>
-            </add-error>
-            <log level="error" message="Cannot remove image contentId ${parameters.contentId}"/>
-            <check-errors/>
-        </else>
-        </if-empty>
-    </simple-method>
-    
-    <simple-method method-name="removeProductContentForImageManagement" short-description="Remove Content From Product">
-        <entity-and entity-name="ContentRole" list="contentRoles" >
-           <field-map field-name="contentId" from-field="parameters.contentId"/>
-        </entity-and>
-        <if-not-empty field="contentRoles">
-            <remove-value value-field="contentRoles[0]"/>
-        </if-not-empty>
-        
-        <entity-condition entity-name="ContentApproval" list="contentApprovals">
-            <condition-list combine="and">
-                <condition-expr field-name="contentId" from-field="parameters.contentId"/>
-                <condition-expr field-name="roleTypeId" value="IMAGEAPPROVER"/>
-            </condition-list>
-        </entity-condition>
-        <iterate list="contentApprovals" entry="contentApproval">
-            <remove-value value-field="contentApproval"/>
-        </iterate>
-        
-        <entity-and entity-name="ContentKeyword" list="contentKeywords">
-            <field-map field-name="contentId" from-field="parameters.contentId"/>
-        </entity-and>
-        <iterate list="contentKeywords" entry="contentKeyword">
-            <remove-value value-field="contentKeyword"/>
-        </iterate>
-        
-        <entity-one entity-name="Content" value-field="content">
-            <field-map field-name="contentId" from-field="parameters.contentId"/>
-        </entity-one>
-        <set field="removeContentPKMap.contentId" from-field="parameters.contentId"/>
-        <set-service-fields service-name="removeContent" map="removeContentPKMap" to-map="removeContentMap"/>
-        <call-service service-name="removeContent" in-map-name="removeContentMap"/>
-        
-        <set field="dataResourceId" from-field="content.dataResourceId"/>
-        <entity-and entity-name="DataResourceRole" list="dataResourceRoles" >
-            <field-map field-name="dataResourceId" from-field="dataResourceId"/>
-        </entity-and>
-        <if-not-empty field="dataResourceRoles">
-            <remove-value value-field="dataResourceRoles[0]"/>
-        </if-not-empty>
-        
-        <entity-one entity-name="DataResource" value-field="dataResource">
-            <field-map field-name="dataResourceId" from-field="dataResourceId"/>
-        </entity-one>
-        <set field="removeImageFile.productId" from-field="parameters.productId"/>
-        <set field="removeImageFile.contentId" from-field="parameters.contentId"/>
-        <set field="removeImageFile.objectInfo" from-field="dataResource.objectInfo"/>
-        <set field="removeImageFile.dataResourceName" from-field="dataResource.dataResourceName"/>
-        <set-service-fields service-name="removeImageFileForImageManagement" map="removeImageFile" to-map="removeImageFileMap"/>
-        <call-service service-name="removeImageFileForImageManagement" in-map-name="removeImageFileMap"/>
-        
-        <set field="removeDataResourcePKMap.dataResourceId" from-field="dataResourceId"/>
-        <set-service-fields service-name="removeDataResource" map="removeDataResourcePKMap" to-map="removeDataResourceMap"/>
-        <call-service service-name="removeDataResource" in-map-name="removeDataResourceMap"/>
-    </simple-method>
-    
-    <simple-method method-name="setImageDetail" short-description="Set Image Detail">
-        <entity-one entity-name="ProductContent" value-field="productContent"/>
-        <set field="productContent.sequenceNum" from-field="parameters.sequenceNum" type="Long"/>
-        <store-value value-field="productContent"/>
-        <if-not-empty field="parameters.sequenceNum">
-            <script location="component://product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy"/>
-            <set field="productContent.sequenceNum" from-field="parameters.sequenceNum" type="Long"/>
-            <store-value value-field="productContent"/>
-        </if-not-empty>
-        
-        <!-- set caption -->
-        <entity-one entity-name="Content" value-field="content"/>
-        <set field="content.description" from-field="parameters.description"/>
-        <store-value value-field="content"/>
-        
-        <if-compare field="content.statusId" operator="equals" value="IM_APPROVED">
-            <entity-one entity-name="DataResource" value-field="dataResource">
-                <field-map field-name="dataResourceId" from-field="content.dataResourceId"/>
-            </entity-one>
-            <set field="dataResource.isPublic" from-field="parameters.drIsPublic"/>
-            <store-value value-field="dataResource"/>
-        </if-compare>
-    </simple-method>
-    
-    <simple-method method-name="updateStatusImageManagement" short-description="Update Status Image Management">
-        <now-timestamp field="nowTimestamp"/>
-        <set field="parameters.checkStatusId" value="${groovy: import org.apache.ofbiz.base.util.StringUtil;
-        checkStatusVal = parameters.checkStatusId;
-        statusId = StringUtil.split(checkStatusVal, &quot;/&quot;);
-        if (statusId) return statusId[0];
-        }"/>
-        
-        <property-to-field resource="catalog.properties" property="image.management.autoApproveImage" field="autoApproveImage"/>
-        <property-to-field resource="catalog.properties" property="image.management.multipleApproval" field="multipleApproval"/>
-        <if-compare field="autoApproveImage" operator="equals" value="Y">
-            <entity-and entity-name="ContentApproval" list="contentApprovals">
-                <field-map field-name="contentId" from-field="parameters.contentId"/>
-                <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
-            </entity-and>
-            <iterate list="contentApprovals" entry="contentApproval">
-                <set field="contentApproval.approvalStatusId" from-field="parameters.checkStatusId"/>
-                <store-value value-field="contentApproval"/>
-            </iterate>
-        <else>
-            <entity-and entity-name="ContentApproval" list="contentApprovals">
-                <field-map field-name="partyId" from-field="userLogin.partyId"/>
-                <field-map field-name="contentId" from-field="parameters.contentId"/>
-                <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
-            </entity-and>
-            <first-from-list list="contentApprovals" entry="contentApproval"/>
-            <set field="contentApproval.approvalStatusId" from-field="parameters.checkStatusId"/>
-            <store-value value-field="contentApproval"/>
-        </else>
-        </if-compare>
-        
-        <if-compare field="parameters.checkStatusId" operator="equals" value="IM_REJECTED">
-            <entity-condition entity-name="ContentApproval" list="checkRejects">
-                <condition-list combine="and">
-                    <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                    <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                </condition-list>
-            </entity-condition>
-            <iterate list="checkRejects" entry="checkReject">
-                <set field="checkReject.statusId" value="IM_REJECTED"/>
-                <store-value value-field="checkReject"/>
-            </iterate>
-            <entity-one entity-name="Content" value-field="content"/>
-            <set field="content.statusId" value="IM_REJECTED"/>
-            <set field="content.createdByUserLogin" from-field="userLogin.userLoginId"/>
-            <store-value value-field="content"/>
-        <else>
-            <if-compare field="parameters.checkStatusId" operator="equals" value="IM_APPROVED">
-                <if-compare field="multipleApproval" operator="equals" value="Y">
-                    <entity-count entity-name="ContentApproval" count-field="countParty">
-                        <condition-list combine="and">
-                            <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                            <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                        </condition-list>
-                    </entity-count>
-                    <if-compare field="countParty" operator="equals" value="1">
-                        <entity-one entity-name="Content" value-field="content"/>
-                        <set field="content.statusId" value="IM_APPROVED"/>
-                        <store-value value-field="content"/>
-                        
-                        <entity-and entity-name="ProductContent" list="productContents">
-                            <field-map field-name="contentId" from-field="parameters.contentId"/>
-                            <field-map field-name="productContentTypeId" value="IMAGE"/>
-                        </entity-and>
-                        <first-from-list list="productContents" entry="productContent"/>
-                        <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
-                        <store-value value-field="productContent"/>
-                    <else>
-                        <entity-count entity-name="ContentApproval" count-field="countApprove">
-                             <condition-list combine="and">
-                                <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                                <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                                <condition-expr field-name="approvalStatusId" operator="equals" value="IM_APPROVED"/>
-                            </condition-list>
-                        </entity-count>
-                        <if-compare field="countApprove" operator="greater-equals" value="2">
-                            <entity-one entity-name="Content" value-field="content"/>
-                            <set field="content.statusId" value="IM_APPROVED"/>
-                            <store-value value-field="content"/>
-                            
-                            <entity-and entity-name="ProductContent" list="productContents">
-                                <field-map field-name="contentId" from-field="parameters.contentId"/>
-                                <field-map field-name="productContentTypeId" value="IMAGE"/>
-                            </entity-and>
-                            <first-from-list list="productContents" entry="productContent"/>
-                            <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
-                            <store-value value-field="productContent"/>
-                            
-                            <entity-condition entity-name="ContentApproval" list="checkApproveList">
-                                <condition-list combine="and">
-                                    <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                                    <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                                </condition-list>
-                            </entity-condition>
-                            <iterate list="checkApproveList" entry="checkApprove">
-                                <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
-                                <store-value value-field="checkApprove"/>
-                            </iterate>
-                        </if-compare>
-                    </else>
-                    </if-compare>
-                <else>
-                    <entity-one entity-name="Content" value-field="content"/>
-                    <set field="content.statusId" value="IM_APPROVED"/>
-                    <store-value value-field="content"/>
-                    
-                    <entity-and entity-name="ProductContent" list="productContents">
-                        <field-map field-name="contentId" from-field="parameters.contentId"/>
-                        <field-map field-name="productContentTypeId" value="IMAGE"/>
-                    </entity-and>
-                    <first-from-list list="productContents" entry="productContent"/>
-                    <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
-                    <store-value value-field="productContent"/>
-                    
-                    <entity-condition entity-name="ContentApproval" list="checkApproveList">
-                        <condition-list combine="and">
-                            <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                            <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                        </condition-list>
-                    </entity-condition>
-                    <iterate list="checkApproveList" entry="checkApprove">
-                        <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
-                        <store-value value-field="checkApprove"/>
-                    </iterate>
-                </else>
-                </if-compare>
-            </if-compare>
-        </else>
-        </if-compare>
-    </simple-method>
-    
-    <simple-method method-name="addRejectedReasonImageManagement" short-description="Add Rejected Reason Image Management">
-        <now-timestamp field="nowTimestam"/>
-        <entity-one entity-name="Content" value-field="content"/>
-        <if-not-empty field="parameters.description">
-            <if-compare field="parameters.description" value="RETAKE_PHOTO" operator="equals">
-                <set field="content.description" value="Re-take Photo"/>
-            </if-compare>
-            <if-compare field="parameters.description" value="REMOVE_LOGO" operator="equals">
-                <set field="content.description" value="Remove Logo"/>
-            </if-compare>
-            <if-compare field="parameters.description" value="OTHER" operator="equals">
-                <set field="content.description" value="Other"/>
-            </if-compare>
-            <else>
-                <set field="content.description" value="Other"/>
-            </else>
-        </if-not-empty>
-        <store-value value-field="content"/>
-        
-        <entity-and entity-name="ProductContent" list="productContents">
-            <field-map field-name="contentId" from-field="parameters.contentId"/>
-            <field-map field-name="productContentTypeId" value="IMAGE"/>
-        </entity-and>
-        <first-from-list list="productContents" entry="productContent"/>
-        <set field="productContent.thruDate" from-field="nowTimestam"/>
-        <store-value value-field="productContent"/>
-    </simple-method>
-    
-    <simple-method method-name="createImageContentApproval" short-description="Create Content Approval of Image">
-        <now-timestamp field="nowTimestam"/>
-        <entity-and entity-name="PartyRole" list="partyRoles">
-            <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
-        </entity-and>
-        <iterate list="partyRoles" entry="partyRole">
-            <set field="contentApproval.partyId" from-field="partyRole.partyId"/>
-            <set field="contentApproval.contentId" from-field="parameters.contentId"/>
-            <set field="contentApproval.roleTypeId" value="IMAGEAPPROVER"/>
-            <set field="contentApproval.approvalDate" from-field="nowTimestam"/>
-            <set field="contentApproval.approvalStatusId" value="IM_PENDING"/>
-            <call-service service-name="createContentApproval" in-map-name="contentApproval"/>
-        </iterate>
-    </simple-method>
-    
-    <simple-method method-name="removeImageContentApproval" short-description="Remove Content Approval of Image">
-        <entity-and entity-name="ContentApproval" list="contentApprovals">
-            <field-map field-name="partyId" from-field="parameters.partyId"/>
-            <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
-        </entity-and>
-        <iterate list="contentApprovals" entry="contentApproval">
-            <remove-value value-field="contentApproval"/>
-        </iterate>
-    </simple-method>
-    
-    <simple-method method-name="resizeImages" short-description="Resize Images">
-        <if-compare field="parameters.resizeOption" operator="equals" value="resizeAllImages">
-            <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.dataResourceName" from-field="productContentAndInfo.drDataResourceName"/>
-                <set field="resizeImageMap.resizeWidth" from-field="parameters.size"/>
-                <call-service service-name="resizeImageOfProduct" in-map-name="resizeImageMap"/>
-            </iterate>
-        </if-compare>
-        <if-compare field="parameters.resizeOption" operator="equals" value="createNewThumbnail">
-            <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="createNewImageThumbnailMap.productId" from-field="productContentAndInfo.productId"/>
-                <set field="createNewImageThumbnailMap.contentId" from-field="productContentAndInfo.contentId"/>
-                <set field="createNewImageThumbnailMap.dataResourceName" from-field="productContentAndInfo.drDataResourceName"/>
-                <set field="createNewImageThumbnailMap.drObjectInfo" from-field="productContentAndInfo.drObjectInfo"/>
-                <set field="createNewImageThumbnailMap.sizeWidth" from-field="parameters.size"/>
-                <call-service service-name="createNewImageThumbnail" in-map-name="createNewImageThumbnailMap"/>
-            </iterate>
-        </if-compare>
-    </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 list="productContentAndInfos" entry="productContentAndInfo">
-            <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 list="contentAssocs" entry="contentAssoc">
-                    <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>
diff --git a/applications/product/servicedef/services.xml b/applications/product/servicedef/services.xml
index fe60e1f..bdfee10 100644
--- a/applications/product/servicedef/services.xml
+++ b/applications/product/servicedef/services.xml
@@ -1387,8 +1387,8 @@ under the License.
         <override name="productId" optional="false"/>
     </service>
 
-    <service name="multipleUploadProductImages" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="uploadProductImages" auth="true">
+    <service name="multipleUploadProductImages" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="uploadProductImages" auth="true">
         <description>Multiple upload Images For Product</description>
         <permission-service service-name="genericContentPermission" main-action="CREATE"/>
         <attribute name="productId" type="String" mode="INOUT" optional="false"/>
@@ -1425,15 +1425,15 @@ under the License.
         <attribute name="_additionalImageTen_contentType" type="String" mode="IN" optional="true"/>
     </service>
 
-    <service name="removeProductContentAndImageFile" default-entity-name="ProductContent" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="removeProductContentAndImageFile" auth="true">
+    <service name="removeProductContentAndImageFile" default-entity-name="ProductContent" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="removeProductContentAndImageFile" auth="true">
         <description>Remove Content From Product and File Image</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
 
-    <service name="removeProductContentForImageManagement" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="removeProductContentForImageManagement" auth="true">
+    <service name="removeProductContentForImageManagement" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="removeProductContentForImageManagement" auth="true">
         <description>Delete Product Content Relationship Entity</description>
         <attribute mode="IN" name="contentId" optional="false" type="String"/>
         <attribute mode="IN" name="productId" optional="false" type="String"/>
@@ -1484,8 +1484,8 @@ under the License.
         <attribute mode="IN" name="angle" optional="false" type="String"/>
     </service>
 
-    <service name="setImageDetail" engine="simple" default-entity-name="ProductContent"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="setImageDetail" auth="true">
+    <service name="setImageDetail" engine="groovy" default-entity-name="ProductContent"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="setImageDetail" auth="true">
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <attribute name="sequenceNum" mode="IN" type="Integer" optional="true"/>
@@ -1493,30 +1493,30 @@ under the License.
         <attribute name="description" mode="IN" type="String" optional="true"/>
     </service>
 
-    <service name="updateStatusImageManagement" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="updateStatusImageManagement" auth="true">
+    <service name="updateStatusImageManagement" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="updateStatusImageManagement" auth="true">
         <attribute name="contentId" mode="IN" type="String" optional="false"/>
         <attribute name="checkStatusId" mode="IN" type="String" optional="true"/>
     </service>
 
-    <service name="addRejectedReasonImageManagement" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="addRejectedReasonImageManagement" auth="true">
+    <service name="addRejectedReasonImageManagement" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="addRejectedReasonImageManagement" auth="true">
         <attribute name="contentId" mode="IN" type="String" optional="false"/>
         <attribute name="description" mode="IN" type="String" optional="true"/>
     </service>
 
-    <service name="createImageContentApproval" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="createImageContentApproval" auth="true">
+    <service name="createImageContentApproval" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="createImageContentApproval" auth="true">
         <attribute name="contentId" mode="IN" type="String" optional="false"/>
     </service>
 
-    <service name="removeImageContentApproval" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="removeImageContentApproval" auth="true">
+    <service name="removeImageContentApproval" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="removeImageContentApproval" auth="true">
         <attribute name="partyId" mode="IN" type="String" optional="false"/>
     </service>
 
-    <service name="resizeImages" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="resizeImages" auth="true">
+    <service name="resizeImages" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" invoke="resizeImages" auth="true">
         <description>Resize Images.</description>
         <attribute name="resizeOption" mode="IN" type="String" optional="false"/>
         <attribute name="productId" mode="IN" type="String" optional="false"/>
@@ -1541,8 +1541,8 @@ under the License.
         <attribute name="sizeWidth" mode="IN" type="String" optional="false"/>
     </service>
 
-    <service name="removeImageBySize" engine="simple"
-        location="component://product/minilang/product/imagemanagement/ImageManagementServices.xml" invoke="removeImageBySize" auth="true">
+    <service name="removeImageBySize" engine="groovy"
+        location="component://product/groovyScripts/product/imagemanagement/ImageManagementServices.groovy" 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"/>