You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2026/04/18 16:39:26 UTC

(ofbiz-framework) branch release24.09 updated (b034fc3392 -> f31511788c)

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

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


    from b034fc3392 Bump com.gradle.common-custom-user-data-gradle-plugin
     new cc85d8eccc Fixed: Update StartupCommandUtil to fix warning messages for usage of deprecated methods in the org.apache.commons.cli library
     new afd2c1a294 Fixed: Replace deprecated StringUtils methods with native string operations to resolve compilation warnings
     new ec2b92e48f Fixed: Update CSVFormat usage to resolve compilation warnings
     new 65c1769811 Fixed: Remove deprecated use of AccessController in AuthHelper to resolve compilation warnings
     new e381c45ed8 Fixed: Update context data handling in OFBizDynamicThresholdFilter to resolve compilation warnings
     new 548440099c Improved: getFields() in AcroFields has been deprecated (OFBIZ-13312)
     new f31511788c Fixed: Update import statement for GroovyTestCase to resolve compilation warnings

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ofbiz/accounting/invoice/InvoiceServices.java  |  2 +-
 .../ofbiz/content/survey/PdfSurveyServices.java    | 46 +++++++++---------
 .../apache/ofbiz/party/party/PartyServices.java    |  2 +-
 .../base/log4j/OFBizDynamicThresholdFilter.java    |  5 +-
 .../java/org/apache/ofbiz/base/util/UtilCodec.java |  3 +-
 .../ofbiz/base/util/string/UelFunctions.java       |  4 +-
 .../ofbiz/common/authentication/AuthHelper.java    | 19 +++-----
 .../org/apache/ofbiz/security/SecuredUpload.java   |  2 +-
 .../ofbiz/base/start/StartupCommandUtil.java       | 54 +++++++++++-----------
 .../ofbiz/testtools/GroovyScriptTestCase.java      |  2 +-
 .../apache/ofbiz/webtools/WebToolsServices.java    |  3 +-
 11 files changed, 71 insertions(+), 71 deletions(-)


(ofbiz-framework) 03/07: Fixed: Update CSVFormat usage to resolve compilation warnings

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ec2b92e48f1757f385b35e77c5c27b59d570bb7e
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Thu Apr 16 12:07:58 2026 +0200

    Fixed: Update CSVFormat usage to resolve compilation warnings
    
    (cherry picked from commit b73a14c2fd63e485d12f4bfb762aeae4104fc63d)
---
 .../main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java  | 2 +-
 .../party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java | 2 +-
 .../security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
index 17e2b71f7c..b536017115 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
@@ -3674,7 +3674,7 @@ public class InvoiceServices {
         String encoding = System.getProperty("file.encoding");
         String csvString = Charset.forName(encoding).decode(fileBytes).toString();
         Builder csvFormatBuilder = Builder.create().setHeader();
-        CSVFormat fmt = csvFormatBuilder.build();
+        CSVFormat fmt = csvFormatBuilder.get();
         List<String> errMsgs = new LinkedList<>();
         List<String> newErrMsgs;
         String lastInvoiceId = null;
diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
index 5b2ea3147e..93f9555d03 100644
--- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
+++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
@@ -2297,7 +2297,7 @@ public class PartyServices {
         String encoding = System.getProperty("file.encoding");
         String csvString = Charset.forName(encoding).decode(fileBytes).toString();
         Builder csvFormatBuilder = Builder.create().setHeader();
-        CSVFormat fmt = csvFormatBuilder.build();
+        CSVFormat fmt = csvFormatBuilder.get();
         List<String> errMsgs = new LinkedList<>();
         List<String> newErrMsgs = new LinkedList<>();
         String lastPartyId = null;        // last partyId read from the csv file
diff --git a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
index decaf8cd0b..5b711676be 100644
--- a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
+++ b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
@@ -919,7 +919,7 @@ public class SecuredUpload {
 
         // cf. https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVFormat.html
         if (!content.contains("</svg>")) {
-            try (CSVParser parser = new CSVParser(in, cvsFormat)) {
+            try (CSVParser parser = cvsFormat.parse(in)) {
                 parser.getRecords();
             }
         } else {


(ofbiz-framework) 04/07: Fixed: Remove deprecated use of AccessController in AuthHelper to resolve compilation warnings

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 65c17698111894ff27d047ad6f5e4093297b9933
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Thu Apr 16 12:20:20 2026 +0200

    Fixed: Remove deprecated use of AccessController in AuthHelper to resolve compilation warnings
    
    (cherry picked from commit 451c4141649237dfd1d65d0fe9ae90eb545578bb)
---
 .../ofbiz/common/authentication/AuthHelper.java       | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java b/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java
index bb585357d0..62daa5a1cf 100644
--- a/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java
+++ b/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java
@@ -19,8 +19,6 @@
 
 package org.apache.ofbiz.common.authentication;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -129,15 +127,12 @@ public final class AuthHelper {
      * non-secure source.
      */
     private static ClassLoader getContextClassLoader() {
-        return AccessController.doPrivileged(
-                (PrivilegedAction<ClassLoader>) () -> {
-                    ClassLoader cl = null;
-                    try {
-                        cl = Thread.currentThread().getContextClassLoader();
-                    } catch (SecurityException e) {
-                        Debug.logError(e, e.getMessage(), MODULE);
-                    }
-                    return cl;
-                });
+        ClassLoader cl = null;
+        try {
+            cl = Thread.currentThread().getContextClassLoader();
+        } catch (SecurityException e) {
+            Debug.logError(e, e.getMessage(), MODULE);
+        }
+        return cl;
     }
 }


(ofbiz-framework) 06/07: Improved: getFields() in AcroFields has been deprecated (OFBIZ-13312)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 548440099c0c5543f26e5b062672a783407b7f06
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Wed Nov 12 20:13:37 2025 +0100

    Improved: getFields() in AcroFields has been deprecated (OFBIZ-13312)
    
    After moving from lowagie to openPDF (OFBIZ-13300),
    getFields() in AcroFields is deprecated.
    
    Contrary to what I wrote in OFBIZ-13306, it's not related to
    "Upgrade java version to 21"
    
    This fixes it (present only in PdfSurveyServices class).
    
    I have also improved pdfStamper.close() missing in 2 places
    (almost fixed but OFBIZ-13300 was not backported, better to keep things simple).
    In one case I added it, in the other I used try-with-ressource.
    
    I also put a comment about openpdf:1.3.43 being the last version with
    com.lowagie.text embedded that is used (only) by PdfSurveyServices class.
    
    Also some formatting
    
    (cherry picked from commit 8e492c2163dacbbbfe8cbc5f8704b5816a603e15)
---
 .../ofbiz/content/survey/PdfSurveyServices.java    | 46 +++++++++++-----------
 1 file changed, 23 insertions(+), 23 deletions(-)

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 68418e3488..ab6872cfa4 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
@@ -88,7 +88,7 @@ public class PdfSurveyServices {
             PdfReader pdfReader = new PdfReader(byteBuffer.array());
             PdfStamper pdfStamper = new PdfStamper(pdfReader, os);
             AcroFields acroFields = pdfStamper.getAcroFields();
-            Map<String, Object> acroFieldMap = UtilGenerics.cast(acroFields.getFields());
+            Map<String, Object> acroFieldMap = UtilGenerics.cast(acroFields.getAllFields());
 
             String contentId = (String) context.get("contentId");
             GenericValue survey = null;
@@ -107,6 +107,7 @@ public class PdfSurveyServices {
                     UtilMisc.<String, Object>toMap("description", "From AcroForm in Content [" + contentId + "] for Survey [" + surveyId
                             + "]", "userLogin", userLogin));
             if (ServiceUtil.isError(createCategoryResultMap)) {
+                pdfStamper.close();
                 return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createCategoryResultMap));
             }
             String surveyQuestionCategoryId = (String) createCategoryResultMap.get("surveyQuestionCategoryId");
@@ -234,15 +235,15 @@ public class PdfSurveyServices {
             String surveyId = (String) context.get("surveyId");
             surveyResponseId = (String) context.get("surveyResponseId");
             if (UtilValidate.isNotEmpty(surveyResponseId)) {
-                GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId",
-                        surveyResponseId).queryOne();
+                GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse")
+                        .where("surveyResponseId", surveyResponseId).queryOne();
                 if (surveyResponse != null) {
                     surveyId = surveyResponse.getString("surveyId");
                 }
             } else {
                 surveyResponseId = delegator.getNextSeqId("SurveyResponse");
-                GenericValue surveyResponse = delegator.makeValue("SurveyResponse", UtilMisc.toMap("surveyResponseId",
-                        surveyResponseId, "surveyId", surveyId, "partyId", partyId));
+                GenericValue surveyResponse = delegator.makeValue("SurveyResponse",
+                        UtilMisc.toMap("surveyResponseId", surveyResponseId, "surveyId", surveyId, "partyId", partyId));
                 surveyResponse.set("responseDate", UtilDateTime.nowTimestamp());
                 surveyResponse.set("lastModifiedDate", UtilDateTime.nowTimestamp());
                 surveyResponse.create();
@@ -253,24 +254,23 @@ public class PdfSurveyServices {
             PdfReader r = new PdfReader(byteBuffer.array());
             PdfStamper s = new PdfStamper(r, os);
             AcroFields fs = s.getAcroFields();
-            Map<String, Object> hm = UtilGenerics.cast(fs.getFields());
+            Map<String, Object> hm = UtilGenerics.cast(fs.getAllFields());
             s.setFormFlattening(true);
             for (String fieldName : hm.keySet()) {
-                //AcroFields.Item item = fs.getFieldItem(fieldName);
+                // AcroFields.Item item = fs.getFieldItem(fieldName);
                 String value = fs.getField(fieldName);
                 GenericValue surveyQuestionAndAppl = EntityQuery.use(delegator).from("SurveyQuestionAndAppl")
-                        .where("surveyId", surveyId,
-                                "externalFieldRef", fieldName)
-                        .queryFirst();
+                        .where("surveyId", surveyId, "externalFieldRef", fieldName).queryFirst();
                 if (surveyQuestionAndAppl == null) {
-                    Debug.logInfo("No question found for surveyId:" + surveyId + " and externalFieldRef:" + fieldName, MODULE);
+                    Debug.logInfo("No question found for surveyId:" + surveyId + " and externalFieldRef:" + fieldName,
+                            MODULE);
                     continue;
                 }
 
                 String surveyQuestionId = (String) surveyQuestionAndAppl.get("surveyQuestionId");
                 String surveyQuestionTypeId = (String) surveyQuestionAndAppl.get("surveyQuestionTypeId");
-                GenericValue surveyResponseAnswer = delegator.makeValue("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId",
-                        surveyResponseId, "surveyQuestionId", surveyQuestionId));
+                GenericValue surveyResponseAnswer = delegator.makeValue("SurveyResponseAnswer",
+                        UtilMisc.toMap("surveyResponseId", surveyResponseId, "surveyQuestionId", surveyQuestionId));
                 if (surveyQuestionTypeId == null || "TEXT_SHORT".equals(surveyQuestionTypeId)) {
                     surveyResponseAnswer.set("textResponse", value);
                 }
@@ -290,17 +290,17 @@ public class PdfSurveyServices {
     }
 
     /**
+     * @throws GeneralException if getInputByteBuffer fails
      */
-    public static Map<String, Object> getAcroFieldsFromPdf(DispatchContext dctx, Map<String, ? extends Object> context) {
+    public static Map<String, Object> getAcroFieldsFromPdf(DispatchContext dctx, Map<String, ? extends Object> context) throws GeneralException {
         Map<String, Object> acroFieldMap = new HashMap<>();
-        try {
-            ByteArrayOutputStream os = new ByteArrayOutputStream();
-            Delegator delegator = dctx.getDelegator();
-            ByteBuffer byteBuffer = getInputByteBuffer(context, delegator);
-            PdfReader r = new PdfReader(byteBuffer.array());
-            PdfStamper s = new PdfStamper(r, os);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        Delegator delegator = dctx.getDelegator();
+        ByteBuffer byteBuffer = getInputByteBuffer(context, delegator);
+        try (PdfReader r = new PdfReader(byteBuffer.array());
+                PdfStamper s = new PdfStamper(r, os)) {
             AcroFields fs = s.getAcroFields();
-            Map<String, Object> map = UtilGenerics.cast(fs.getFields());
+            Map<String, Object> map = UtilGenerics.cast(fs.getAllFields());
             s.setFormFlattening(true);
 
             for (String fieldName : map.keySet()) {
@@ -308,7 +308,7 @@ public class PdfSurveyServices {
                 acroFieldMap.put(fieldName, parmValue);
             }
 
-        } catch (DocumentException | GeneralException | IOException e) {
+        } catch (DocumentException | IOException e) {
             Debug.logError(e, MODULE);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -330,7 +330,7 @@ public class PdfSurveyServices {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             PdfStamper s = new PdfStamper(r, baos);
             AcroFields fs = s.getAcroFields();
-            Map<String, Object> map = UtilGenerics.cast(fs.getFields());
+            Map<String, Object> map = UtilGenerics.cast(fs.getAllFields());
             s.setFormFlattening(true);
 
             for (String fieldName : map.keySet()) {


(ofbiz-framework) 02/07: Fixed: Replace deprecated StringUtils methods with native string operations to resolve compilation warnings

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit afd2c1a29418e5fd28d6cc1e1c401990f1e51b6d
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Thu Apr 16 12:00:21 2026 +0200

    Fixed: Replace deprecated StringUtils methods with native string operations to resolve compilation warnings
    
    (cherry picked from commit 685c1940e13f697063a7a7573f3cd2d768d774ca)
---
 .../base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java      | 3 ++-
 .../src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java | 4 ++--
 .../src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java     | 3 +--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java
index 2c7fae4427..cf07507adf 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java
@@ -459,7 +459,8 @@ public class UtilCodec {
 
         // check for js events
         String onEvent = "on" + StringUtils.substringBetween(value, " on", "=");
-        if (JS_EVENT_LIST.stream().anyMatch(str -> StringUtils.containsIgnoreCase(str, onEvent))
+        String onEventLower = onEvent.toLowerCase(Locale.ROOT);
+        if (JS_EVENT_LIST.stream().anyMatch(s -> s.toLowerCase(Locale.ROOT).contains(onEventLower))
                 || value.contains("seekSegmentTime")) {
             String issueMsg = null;
             if (locale.equals(new Locale("test"))) { // labels are not available in testClasses Gradle task
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
index 520f911b3b..7a79af415e 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java
@@ -43,7 +43,6 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.ofbiz.base.location.FlexibleLocation;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.FileUtil;
@@ -290,7 +289,8 @@ public class UelFunctions {
 
     public static String replaceFirst(String str1, String str2, String str3) {
         if (null == str1) return null;
-        return StringUtils.replaceOnce(str1, str2, str3);
+        int idx = str1.indexOf(str2);
+        return idx < 0 ? str1 : str1.substring(0, idx) + str3 + str1.substring(idx + str2.length());
     }
 
     public static boolean startsWith(String str1, String str2) {
diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java
index aa00b03bba..84a60eec73 100644
--- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java
+++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java
@@ -48,7 +48,6 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.ofbiz.base.location.FlexibleLocation;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
@@ -809,7 +808,7 @@ public class WebToolsServices {
                         entityMap.put("title", entity.getTitle());
                         entityMap.put("description", entityDescription);
                         String entityLocation = entity.getLocation();
-                        entityLocation = StringUtils.replaceOnce(entityLocation, System.getProperty("ofbiz.home") + "/", "");
+                        entityLocation = entityLocation.replace(System.getProperty("ofbiz.home") + "/", "");
                         entityMap.put("location", entityLocation);
                         entityMap.put("javaNameList", javaNameList);
                         entityMap.put("relationsList", relationsList);


(ofbiz-framework) 05/07: Fixed: Update context data handling in OFBizDynamicThresholdFilter to resolve compilation warnings

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e381c45ed86d37aee1022dbccae54d1074f7bd4f
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Thu Apr 16 13:07:56 2026 +0200

    Fixed: Update context data handling in OFBizDynamicThresholdFilter to resolve compilation warnings
    
    (cherry picked from commit c3085df0cd8a9b0d70296ecf1f4b7836e7b30695)
---
 .../org/apache/ofbiz/base/log4j/OFBizDynamicThresholdFilter.java     | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/log4j/OFBizDynamicThresholdFilter.java b/framework/base/src/main/java/org/apache/ofbiz/base/log4j/OFBizDynamicThresholdFilter.java
index 091b411cc8..5e8e56075d 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/log4j/OFBizDynamicThresholdFilter.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/log4j/OFBizDynamicThresholdFilter.java
@@ -34,7 +34,9 @@ import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginElement;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.filter.AbstractFilter;
+import org.apache.logging.log4j.core.impl.ContextDataFactory;
 import org.apache.logging.log4j.core.impl.ContextDataInjectorFactory;
+import org.apache.logging.log4j.util.StringMap;
 import org.apache.logging.log4j.core.util.KeyValuePair;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.util.PerformanceSensitive;
@@ -150,7 +152,8 @@ public final class OFBizDynamicThresholdFilter extends AbstractFilter {
     }
 
     private ReadOnlyStringMap currentContextData() {
-        return injector.rawContextData();
+        StringMap contextData = ContextDataFactory.createContextData();
+        return injector.injectContextData(null, contextData);
     }
 
     @Override


(ofbiz-framework) 07/07: Fixed: Update import statement for GroovyTestCase to resolve compilation warnings

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f31511788c75d16c8404d2bb4927451875e3e26d
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Sat Apr 18 18:25:10 2026 +0200

    Fixed: Update import statement for GroovyTestCase to resolve compilation warnings
---
 .../src/main/java/org/apache/ofbiz/testtools/GroovyScriptTestCase.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/framework/testtools/src/main/java/org/apache/ofbiz/testtools/GroovyScriptTestCase.java b/framework/testtools/src/main/java/org/apache/ofbiz/testtools/GroovyScriptTestCase.java
index 5b8b689b7b..8ae84b5345 100644
--- a/framework/testtools/src/main/java/org/apache/ofbiz/testtools/GroovyScriptTestCase.java
+++ b/framework/testtools/src/main/java/org/apache/ofbiz/testtools/GroovyScriptTestCase.java
@@ -18,7 +18,7 @@
  *******************************************************************************/
 package org.apache.ofbiz.testtools;
 
-import groovy.util.GroovyTestCase;
+import groovy.test.GroovyTestCase;
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.security.Security;
 import org.apache.ofbiz.service.LocalDispatcher;


(ofbiz-framework) 01/07: Fixed: Update StartupCommandUtil to fix warning messages for usage of deprecated methods in the org.apache.commons.cli library

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cc85d8eccc0df67b86e9e1377816972511ef0f9a
Author: Jacopo Cappellato <ja...@gmail.com>
AuthorDate: Thu Apr 16 11:43:50 2026 +0200

    Fixed: Update StartupCommandUtil to fix warning messages for usage of deprecated methods in the org.apache.commons.cli library
    
    (cherry picked from commit 644e4d32c687674d92c08bf43bac94a1fffbae96)
---
 .../ofbiz/base/start/StartupCommandUtil.java       | 54 +++++++++++-----------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
index 3dc81b88b1..ba003d17bc 100644
--- a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
+++ b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
@@ -18,10 +18,7 @@
  *******************************************************************************/
 package org.apache.ofbiz.base.start;
 
-import java.io.OutputStreamWriter;
 import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -33,7 +30,8 @@ import java.util.stream.Collectors;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.help.HelpFormatter;
+import org.apache.commons.cli.help.TextHelpAppendable;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionGroup;
 import org.apache.commons.cli.Options;
@@ -82,7 +80,7 @@ public final class StartupCommandUtil {
             .longOpt(StartupOption.HELP.getName())
             .desc("Prints this help screen to the user")
             .hasArg(false)
-            .build();
+            .get();
     private static final Option LOAD_DATA = Option.builder("l")
             .longOpt(StartupOption.LOAD_DATA.getName())
             .desc("Creates tables/load data e.g:"
@@ -122,29 +120,29 @@ public final class StartupCommandUtil {
             .valueSeparator('=')
             .optionalArg(true)
             .argName("key=value")
-            .build();
+            .get();
     private static final Option PORTOFFSET = Option.builder("o")
             .longOpt(StartupOption.PORTOFFSET.getName())
             .desc("Offsets all default ports for OFBiz")
             .hasArg()
             .argName("offset")
             .optionalArg(false)
-            .build();
+            .get();
     private static final Option SHUTDOWN = Option.builder("d")
             .longOpt(StartupOption.SHUTDOWN.getName())
             .desc("Shutdown OFBiz")
             .hasArg(false)
-            .build();
+            .get();
     private static final Option START = Option.builder("u")
             .longOpt(StartupOption.START.getName())
             .desc("Start OFBiz")
             .hasArg(false)
-            .build();
+            .get();
     private static final Option STATUS = Option.builder("s")
             .longOpt(StartupOption.STATUS.getName())
             .desc("Gives the status of OFBiz")
             .hasArg(false)
-            .build();
+            .get();
     private static final Option TEST = Option.builder("t")
             .longOpt(StartupOption.TEST.getName())
             .desc("Runs the selected test or all if none selected e.g.: "
@@ -159,7 +157,7 @@ public final class StartupCommandUtil {
             .valueSeparator('=')
             .optionalArg(true)
             .argName("key=value")
-            .build();
+            .get();
 
     static List<StartupCommand> parseOfbizCommands(final String[] args) throws StartupException {
         CommandLine commandLine = null;
@@ -174,21 +172,25 @@ public final class StartupCommandUtil {
     }
 
     static void printOfbizStartupHelp(final PrintStream printStream) {
-        HelpFormatter formatter = new HelpFormatter();
-        formatter.printHelp(
-                new PrintWriter(new OutputStreamWriter(printStream, StandardCharsets.UTF_8), true),
-                HelpFormatter.DEFAULT_WIDTH + 6,
-                "ofbiz|ofbizDebug|ofbizBackground",
-                System.lineSeparator() + "Executes OFBiz command e.g. start, shutdown, check status, etc",
-                getOfbizStartupOptions(),
-                HelpFormatter.DEFAULT_LEFT_PAD,
-                HelpFormatter.DEFAULT_DESC_PAD,
-                "note: Only one command can execute at a time. Portoffset may be appended."
-                    + System.lineSeparator()
-                    + "Also a command must be invoked separately for each argument e.g."
-                    + System.lineSeparator()
-                    + "gradlew \"ofbiz --test component=somecomp --test case=somecase\"",
-                true);
+        HelpFormatter.Builder builder = HelpFormatter.builder();
+        builder.setShowSince(false);
+        builder.setHelpAppendable(new TextHelpAppendable(printStream));
+        HelpFormatter formatter = builder.get();
+        try {
+            formatter.printHelp(
+                    "ofbiz|ofbizDebug|ofbizBackground",
+                    System.lineSeparator() + "Executes OFBiz command e.g. start, shutdown, check status, etc",
+                    getOfbizStartupOptions(),
+                    "note: Only one command can execute at a time. Portoffset may be appended."
+                        + System.lineSeparator()
+                        + "Also a command must be invoked separately for each argument e.g."
+                        + System.lineSeparator()
+                        + "gradlew \"ofbiz --test component=somecomp --test case=somecase\"",
+                    true);
+        } catch (Exception e) {
+            // In case of any exception during help printing, print a simple help message without formatting
+            printStream.println("Usage: ofbiz|ofbizDebug|ofbizBackground [options]");
+        }
     }
 
     static void highlightAndPrintErrorMessage(String errorMessage) {