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

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


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 2bd92780d7 Fixed: error in creating category image content. 
(OFBIZ-12011) (#1695)
2bd92780d7 is described below

commit 2bd92780d7e19bddfe48cba3594226d12ced4ba2
Author: Rehan Khan <[email protected]>
AuthorDate: Fri Sep 11 18:52:48 2026 +0530

    Fixed: error in creating category image content. (OFBIZ-12011) (#1695)
    
    Fixed: error in creating category image content
    (OFBIZ-12011)
    
    Explanation : the root cause was essentially a combination of incorrect
    parameter/field handling and missing ID propagation between the services
    involved in the category image upload process.
    
    The fix ensures that the uploaded image is correctly received, its data
    resource is maintained, the generated content remains identifiable, and
    any service failure is properly surfaced
    
    Thanks:
    Aakash Jain for reporting the issue.
    Rehan Khan for providing the fix.
---
 applications/product/servicedef/services.xml       |  1 +
 .../category/CategoryContentServicesScript.groovy  | 24 +++++++++++++++++-----
 .../product/widget/catalog/CategoryForms.xml       |  2 +-
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/applications/product/servicedef/services.xml 
b/applications/product/servicedef/services.xml
index fddd781c8e..e2011d8b93 100644
--- a/applications/product/servicedef/services.xml
+++ b/applications/product/servicedef/services.xml
@@ -993,6 +993,7 @@ under the License.
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <auto-attributes include="nonpk" mode="IN" entity-name="Content" 
optional="true"/>
         <attribute name="dataResourceTypeId" type="String" mode="IN" 
optional="true"/>
+        <override name="contentId" mode="INOUT" optional="true"/>
         <override name="prodCatContentTypeId" optional="false"/>
     </service>
     <service name="updateDownloadContentForCategory" 
default-entity-name="ProductCategoryContent" engine="groovy"
diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryContentServicesScript.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryContentServicesScript.groovy
index 8093e5c722..c04f1f2818 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryContentServicesScript.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryContentServicesScript.groovy
@@ -24,6 +24,7 @@ import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.entity.GenericValue
 import org.apache.ofbiz.entity.util.EntityUtil
 import org.apache.ofbiz.service.ModelService
+import org.apache.ofbiz.service.ServiceUtil
 
 /**
  * Create Content For Product Category
@@ -176,23 +177,36 @@ Map createDownloadContentForCategory() {
         uploadedFile: parameters.uploadedFile
     ]
     Map creDatRes = run service: 'createDataResource', with: data
+    if (!ServiceUtil.isSuccess(creDatRes)) {
+        return creDatRes
+    }
     parameters.dataResourceId = creDatRes.dataResourceId
     // create attach upload to data resource
     Map attachMap = 
dispatcher.getDispatchContext().makeValidContext('attachUploadToDataResource', 
ModelService.IN_PARAM, parameters)
-    attachMap = [
+    attachMap.putAll([
         uploadedFile: parameters.uploadedFile,
         _uploadedFile_fileName: parameters._uploadedFile_fileName,
         _uploadedFile_contentType: parameters._uploadedFile_contentType
-    ]
-    run service: 'attachUploadToDataResource', with: attachMap
+    ])
+    Map attachResult = run service: 'attachUploadToDataResource', with: 
attachMap
+    if (!ServiceUtil.isSuccess(attachResult)) {
+        return attachResult
+    }
     // create content from dataResource
     Map contentMap = 
dispatcher.getDispatchContext().makeValidContext('createContentFromDataResource',
 ModelService.IN_PARAM, parameters)
     contentMap.contentTypeId = 'DOCUMENT'
     Map creConRes = run service: 'createContentFromDataResource', with: 
contentMap
+    if (!ServiceUtil.isSuccess(creConRes)) {
+        return creConRes
+    }
     createCategoryContent.contentId = creConRes.contentId
 
-    createCategoryContent.contentId = parameters.contentId
-    run service: 'createCategoryContent', with: createCategoryContent
+    Map createCategoryResult = run service: 'createCategoryContent', with: 
createCategoryContent
+    if (!ServiceUtil.isSuccess(creConRes)) {
+        return createCategoryResult
+    }
+    createCategoryResult.contentId = creConRes.contentId
+    return createCategoryResult
 }
 
 /**
diff --git a/applications/product/widget/catalog/CategoryForms.xml 
b/applications/product/widget/catalog/CategoryForms.xml
index bb948e0783..502983f827 100644
--- a/applications/product/widget/catalog/CategoryForms.xml
+++ b/applications/product/widget/catalog/CategoryForms.xml
@@ -299,7 +299,7 @@ under the License.
                 <parameter param-name="contentId"/>
             </hyperlink>
         </field>
-        <field name="imageData" 
title="${uiLabelMap.ProductFile}"><file/></field>
+        <field name="uploadedFile" 
title="${uiLabelMap.ProductFile}"><file/></field>
         <field name="fileDataResourceId"><hidden/></field>
         <field name="productCategoryId"><hidden/></field>
         <field name="prodCatContentTypeId"><hidden/></field>

Reply via email to