Le 06/09/2016 à 19:03, Jacopo Cappellato a écrit :
On Tue, Sep 6, 2016 at 6:38 PM, <[email protected]> wrote:
Author: jleroux
Date: Tue Sep 6 16:38:14 2016
New Revision: 1759457
URL: http://svn.apache.org/viewvc?rev=1759457&view=rev
Log:
...
* Moreover the string can't be in the LabelReferences.java file, to avoid
side effects
Hi Jacques,
what are the side effects?
Thanks,
Jacopo
Hi Jacopo,
Good question, it has tortured me a moment, please try yourself you will see
(kidding, see below ;))
I initially thought about 2 places to put the replacing regexp string:
1. I began directly in code to test: inFile =
inFile.replaceAll("ServiceUtil\\.getResource\\(\\)", getResource);
This worked, and I decided to follow the pattern already used: a private
member
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.getLabelsFromJavaFiles(LabelReferences.java:196)
~[ofbiz.jar:?]
I wondered about doubling backslashes (which made not sense but with Java
regexp and backslashes ...), when doing got the same error. And by
investigating I found that using a member had a side effect during the
parsing.
If you use
if (args.length > 1) {
if (searchString.equals(args[1].trim())) {
setLabelReference(labelKey,
javaFile.getPath());
}
} else {
Debug.log("searchString = " + searchString);
Debug.log("args[0] = " + args[0]);
}
You will see the culprit:
2016-09-07 09:17:32,873 |http-nio-8443-exec-7 |LabelManagerFactory
|I| Current file : AccountingEntityLabels.xml
2016-09-07 09:17:33,903 |http-nio-8443-exec-7 |NoModule |F|
searchString = "InvoiceItemType.description.PITM_DISCOUNT_ADJ"
2016-09-07 09:17:33,903 |http-nio-8443-exec-7 |NoModule |F|
args[0] = ";
private static final String getResourceRegex =
"ServiceUtil\\.getResource\\(\\
That's also how I discovered we are considering entity description labels as
not used when they are automatically by widget and even overriding
some in data files
BTW there are sometimes better English labels descriptions in data files.
They should be used in labels and translations, 2 Jiras to create...
HTH
Jacques