OK no problems with me, I'll change that. I must say I did no like the property 
either.

Jacques


Le 07/09/2016 à 09:56, Jacopo Cappellato a écrit :
On Wed, Sep 7, 2016 at 9:23 AM, Jacques Le Roux <
[email protected]> wrote:

...

2. So I created a private static final String: private static final String
getResourceRegex = "ServiceUtil\\.getResource\\(\\)"
    But this did not work. I got

    2016-09-07 08:27:32,489 |ttp-nio-8443-exec-10 |ScriptUtil
       |W| Error running script at location
    [component://webtools/groovyScripts/labelmanager/LabelManager.groovy]:
java.lang.ArrayIndexOutOfBoundsException: 1
    java.lang.ArrayIndexOutOfBoundsException: 1  at
    org.apache.ofbiz.webtools.labelmanager.LabelReferences.getL
abelsFromJavaFiles(LabelReferences.java:196) ~[ofbiz.jar:?]


Without further digging into this issue, I would prefer the following tweak:

Index:
framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java
===================================================================
---
framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java
(revision
1759552)
+++
framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java
(working
copy)
@@ -60,7 +60,7 @@
      private static final String uiLabelMap = "uiLabelMap.";
      private static final String formFieldTitle = "FormFieldTitle_";
      private static final String getMessage = "UtilProperties.getMessage(";
-    private static final String getResourceRegex =
UtilProperties.getPropertyValue("webtools", "getResourceRegex");
+    private static final String getResourceRegex =
"ServiceUtil\\.getResource\\(\\)";
      private static final String getResource = "ServiceUtil.getResource  ";

      protected Map<String, Map<String, Integer>> references = new
TreeMap<String, Map<String, Integer>>();
@@ -185,6 +185,8 @@
          for (String rootFolder : this.rootFolders) {
              List<File> javaFiles = FileUtil.findFiles("java", rootFolder +
"src", null, null);
              for (File javaFile : javaFiles) {
+                // do not parse this file
+                if ("LabelReferences.java".equals(javaFile.getName()))
continue;
                  String inFile = FileUtil.readString("UTF-8", javaFile);
                  inFile = inFile.replaceAll(getResourceRegex, getResource);
                  int pos = inFile.indexOf(getMessage);


In this way, we will not need an additional configuration file and the
ugliness will be self contained in the LabelReference class.

Jacopo


Reply via email to