Author: jleroux
Date: Sun Aug 20 14:14:26 2017
New Revision: 1805558
URL:
http://svn.apache.org/viewvc?rev=1805558&view=revLog:
Fixed: LabelManager doesn't search labels in .groovy files
(OFBIZ-8153)
The logic written needs more use cases to be covered for groovy files, existing
findUiLabelMapInFile is not fit for groovy files.
Following patterns are currently used in groovy files:
1. uiLabelMap.xxxxx
2. uiLabelMap.get("xxxxx")
Thanks: Suraj Khurana
Modified:
ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java
Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java?rev=1805558&r1=1805557&r2=1805558&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java Sun Aug 20 14:14:26 2017
@@ -216,12 +216,29 @@ public class LabelReferences {
List<File> groovyFiles = FileUtil.findFiles("groovy", rootFolder + "groovyScripts", null, null);
for (File file : groovyFiles) {
String inFile = FileUtil.readString("UTF-8", file);
- findUiLabelMapInFile(inFile, file.getPath());
+ findUiLabelMapInGroovy(inFile, uiLabelMap, file.getPath());
+ findUiLabelMapInGroovy(inFile, "uiLabelMap.get(\"", file.getPath());
}
}
}
-
-
+ protected void findUiLabelMapInGroovy(String inFile, String pattern, String filePath) {
+ int pos = inFile.indexOf(pattern);
+ while (pos >= 0) {
+ String label = inFile.substring(pos + pattern.length());
+ String[] realLabel = label.split("\\P{Alpha}+");
+ String labelKey = realLabel[0];
+ int endPos = pos + labelKey.length();
+ if (endPos >= 0) {
+ if (this.labelSet.contains(labelKey)) {
+ setLabelReference(labelKey, filePath);
+ }
+ pos = endPos;
+ } else {
+ pos = pos + pattern.length();
+ }
+ pos = inFile.indexOf(pattern, pos);
+ }
+ }
protected void findUiLabelMapInFile(String inFile, String filePath) {
int pos = inFile.indexOf(uiLabelMap);
while (pos >= 0) {