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

mridulpathak 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 09aee9791f Fixed: Survey PDF services read any server file named in 
the pdfFileNameIn parameter (OFBIZ-13690)
09aee9791f is described below

commit 09aee9791fe197f98172cd1c76532931cd4b5b15
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Oct 16 16:51:37 2026 +0530

    Fixed: Survey PDF services read any server file named in the pdfFileNameIn 
parameter (OFBIZ-13690)
    
    - Removed the pdfFileNameIn parameter from the survey PDF services, the 
BuildSurveyResponseFromPdf form and its label, so a PDF can only be given as an 
inputByteBuffer or a contentId.
    - Removed the unused pdfFileNameOut handling in 
setAcroFieldsFromSurveyResponse.
    - buildSurveyFromPdf and buildSurveyResponseFromPdf now require a logged-in 
user with the content manager CREATE permission.
---
 applications/content/config/ContentUiLabels.xml    | 15 --------------
 .../content/servicedef/services_survey.xml         | 11 ++++------
 .../ofbiz/content/survey/PdfSurveyServices.java    | 24 ++--------------------
 applications/content/widget/survey/SurveyForms.xml |  2 --
 4 files changed, 6 insertions(+), 46 deletions(-)

diff --git a/applications/content/config/ContentUiLabels.xml 
b/applications/content/config/ContentUiLabels.xml
index 3aceaf1e91..02ec9f445c 100644
--- a/applications/content/config/ContentUiLabels.xml
+++ b/applications/content/config/ContentUiLabels.xml
@@ -5001,21 +5001,6 @@
         <value xml:lang="zh">路径别名到</value>
         <value xml:lang="zh-TW">路徑別名到</value>
     </property>
-    <property key="FormFieldTitle_pdfFileNameIn">
-        <value xml:lang="ar">اسم ملف Pdf الداخل</value>
-        <value xml:lang="da">Pdf fil navn ind</value>
-        <value xml:lang="de">PDF Dateiname Eingang</value>
-        <value xml:lang="en">Pdf File Name In</value>
-        <value xml:lang="fr">Nom de fichier PDF inclus</value>
-        <value xml:lang="it">Nome File Pdf Ingresso</value>
-        <value xml:lang="ja">PDFファイル名</value>
-        <value xml:lang="pt">Nome do arquivo PDF em</value>
-        <value xml:lang="ro">Nume Fisier Pdf Intrare</value>
-        <value xml:lang="th">ชื่อในไฟล์ Pdf</value>
-        <value xml:lang="vi">Tên tập tin PDF tại</value>
-        <value xml:lang="zh">PDF文件名在</value>
-        <value xml:lang="zh-TW">PDF檔案名在</value>
-    </property>
     <property key="FormFieldTitle_privilegeEnumId">
         <value xml:lang="ar">تعريف تعداد الأفضلية</value>
         <value xml:lang="da">Privilegie numerisk ID</value>
diff --git a/applications/content/servicedef/services_survey.xml 
b/applications/content/servicedef/services_survey.xml
index 3138859ce4..62363f0e98 100644
--- a/applications/content/servicedef/services_survey.xml
+++ b/applications/content/servicedef/services_survey.xml
@@ -278,9 +278,9 @@ under the License.
     </service>
 
     <service name="buildSurveyFromPdf" engine="java"
-            location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="buildSurveyFromPdf" auth="false">
+            location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="buildSurveyFromPdf" auth="true">
         <description>Create a Survey and related entities from 
AcroForm</description>
-        <attribute name="pdfFileNameIn" type="String" mode="IN" 
optional="true"/>
+        <permission-service service-name="contentManagerPermission" 
main-action="CREATE"/>
         <attribute name="contentId" type="String" mode="IN" optional="true"/>
         <attribute name="inputByteBuffer" type="java.nio.ByteBuffer" mode="IN" 
optional="true"/>
         <attribute name="surveyName" type="String" mode="IN" optional="true"/>
@@ -288,9 +288,9 @@ under the License.
     </service>
 
     <service name="buildSurveyResponseFromPdf" engine="java"  
transaction-timeout="7200"
-            location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="buildSurveyResponseFromPdf" auth="false">
+            location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="buildSurveyResponseFromPdf" auth="true">
         <description>Create a Survey and related entities from 
AcroForm</description>
-        <attribute name="pdfFileNameIn" type="String" mode="IN" 
optional="true"/>
+        <permission-service service-name="contentManagerPermission" 
main-action="CREATE"/>
         <attribute name="contentId" type="String" mode="IN" optional="true"/>
         <attribute name="inputByteBuffer" type="java.nio.ByteBuffer" mode="IN" 
optional="true"/>
         <attribute name="surveyId" type="String" mode="IN" optional="true"/>
@@ -301,7 +301,6 @@ under the License.
     <service name="getAcroFieldsFromPdf" engine="java"
             location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="getAcroFieldsFromPdf" auth="false">
         <description>Get fields from AcroForm</description>
-        <attribute name="pdfFileNameIn" type="String" mode="IN" 
optional="true"/>
         <attribute name="contentId" type="String" mode="IN" optional="true"/>
         <attribute name="inputByteBuffer" type="java.nio.ByteBuffer" mode="IN" 
optional="true"/>
         <attribute name="acroFieldMap" type="Map" mode="OUT" optional="false"/>
@@ -310,7 +309,6 @@ under the License.
     <service name="setAcroFieldsFromSurveyResponse" engine="java"
             location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="setAcroFieldsFromSurveyResponse" auth="false">
         <description>Get fields from AcroForm</description>
-        <attribute name="pdfFileNameIn" type="String" mode="IN" 
optional="true"/>
         <attribute name="contentId" type="String" mode="IN" optional="true"/>
         <attribute name="inputByteBuffer" type="java.nio.ByteBuffer" mode="IN" 
optional="true"/>
         <attribute name="surveyResponseId" type="String" mode="IN" 
optional="false">
@@ -324,7 +322,6 @@ under the License.
     <service name="setAcroFields" engine="java"
             location="org.apache.ofbiz.content.survey.PdfSurveyServices" 
invoke="setAcroFields" auth="false">
         <description>Get fields from AcroForm</description>
-        <attribute name="pdfFileNameIn" type="String" mode="IN" 
optional="true"/>
         <attribute name="contentId" type="String" mode="IN" optional="true"/>
         <attribute name="inputByteBuffer" type="java.nio.ByteBuffer" mode="IN" 
optional="true"/>
         <attribute name="acroFieldMap" type="Map" mode="IN" optional="false">
diff --git 
a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
 
b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
index b67c7c3843..16f217359f 100644
--- 
a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
+++ 
b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
@@ -19,8 +19,6 @@
 package org.apache.ofbiz.content.survey;
 
 import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.sql.Timestamp;
@@ -555,15 +553,9 @@ public class PdfSurveyServices {
             if (ServiceUtil.isError(map)) {
                 return 
ServiceUtil.returnError(ServiceUtil.getErrorMessage(map));
             }
-            String pdfFileNameOut = (String) context.get("pdfFileNameOut");
             ByteBuffer outByteBuffer = (ByteBuffer) map.get("outByteBuffer");
             results.put("outByteBuffer", outByteBuffer);
-            if (UtilValidate.isNotEmpty(pdfFileNameOut)) {
-                FileOutputStream fos = new FileOutputStream(pdfFileNameOut);
-                fos.write(outByteBuffer.array());
-                fos.close();
-            }
-        } catch (IOException | GenericServiceException e) {
+        } catch (GenericServiceException e) {
             Debug.logError(e, "Error generating PDF: " + e.toString(), MODULE);
             return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, 
"ContentPDFGeneratingError",
                     UtilMisc.toMap("errorString", e.toString()), locale));
@@ -576,20 +568,8 @@ public class PdfSurveyServices {
         ByteBuffer inputByteBuffer = (ByteBuffer) 
context.get("inputByteBuffer");
 
         if (inputByteBuffer == null) {
-            String pdfFileNameIn = (String) context.get("pdfFileNameIn");
             String contentId = (String) context.get("contentId");
-            if (UtilValidate.isNotEmpty(pdfFileNameIn)) {
-                try (FileInputStream fis = new FileInputStream(pdfFileNameIn)) 
{
-                    int c;
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                    while ((c = fis.read()) != -1) {
-                        baos.write(c);
-                    }
-                    inputByteBuffer = ByteBuffer.wrap(baos.toByteArray());
-                } catch (IOException e) {
-                    throw(new GeneralException(e.getMessage()));
-                }
-            } else if (UtilValidate.isNotEmpty(contentId)) {
+            if (UtilValidate.isNotEmpty(contentId)) {
                 try {
                     Locale locale = (Locale) context.get("locale");
                     String https = (String) context.get("https");
diff --git a/applications/content/widget/survey/SurveyForms.xml 
b/applications/content/widget/survey/SurveyForms.xml
index 94bf01a667..d635f7fb91 100644
--- a/applications/content/widget/survey/SurveyForms.xml
+++ b/applications/content/widget/survey/SurveyForms.xml
@@ -89,8 +89,6 @@ under the License.
         header-row-style="header-row" default-table-style="basic-table">
         <field name="surveyId" map-name="parameters"><hidden/></field>
         <field name="surveyResponseId" 
map-name="surveyResponse"><hidden/></field>
-        <field name="pdfFileNameIn" map-name="empty"><text/></field>
-
         <field name="contentId" map-name="empty" 
title="${uiLabelMap.ContentPDF}">
             <lookup target-form-name="LookupContent"/>
         </field>

Reply via email to