Skip to content

Commit c910e41

Browse files
committed
Improved: Don't need to show files names in UI messages (OFBIZ-12884)
We don't need to show files paths in UI messages. It does not help users, rather confuse them. Also in log, we give enough information, ie the file and method used. Also removes all useless "this." in SimpleMethod class Conflicts handled by hand in SimpleMethod.java
1 parent 93f8a58 commit c910e41

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangRuntimeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public String getMessage() {
4141
StringBuilder sb = new StringBuilder(super.getMessage());
4242
if (this.element != null) {
4343
SimpleMethod method = this.element.getSimpleMethod();
44-
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
44+
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
4545
sb.append(", Element = <").append(this.element.getTagName()).append(">");
4646
sb.append(", Line ").append(this.element.getLineNumber());
4747
}

framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
* (see <a href="http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html" target="_blank">ServiceLoader</a>)
7676
* </li>
7777
* </ul>
78-
*
78+
*
7979
* @see <a href="https://cwiki.apache.org/confluence/display/OFBIZ/Mini+Language+-+minilang+-+simple-method+-+Reference">Mini-language Reference</a>
8080
*/
8181
public final class SimpleMethod extends MiniLangElement {
@@ -584,8 +584,7 @@ public String exec(MethodContext methodContext) throws MiniLangException {
584584
}
585585
// rollback here passing beganTransaction to either rollback, or set rollback only
586586
try {
587-
TransactionUtil.rollback(beganTransaction, "Error in simple-method [" + getShortDescription() + "]: "
588-
+ summaryErrorStringBuffer, null);
587+
TransactionUtil.rollback(beganTransaction, summaryErrorStringBuffer.toString(), null);
589588
} catch (GenericTransactionException e) {
590589
String errMsg = "Error trying to rollback transaction, could not process method: " + e.getMessage();
591590
if (methodContext.isTraceOn()) {
@@ -723,14 +722,9 @@ public String getServiceSuccessMessageName() {
723722
}
724723

725724
public String getShortDescription() {
726-
if (fromLocation.contains("file:") && fromLocation.contains("Events.xml")) {
727-
return getFileName() + "#" + getMethodName();
728-
} else {
729-
return shortDescription + " [" + fromLocation + "#" + methodName + "]";
730-
}
725+
return shortDescription + " [" + getFileName() + "#" + methodName + "]";
731726
}
732727

733-
734728
@Override
735729
public SimpleMethod getSimpleMethod() {
736730
return this;

framework/minilang/src/main/java/org/apache/ofbiz/minilang/ValidationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public ValidationException(String str, SimpleMethod method, Element element) {
3939
public String getMessage() {
4040
StringBuilder sb = new StringBuilder(super.getMessage());
4141
if (method != null) {
42-
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
42+
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
4343
}
4444
if (element != null) {
4545
sb.append(", Element = <").append(element.getTagName()).append(">");

framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Break.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public BreakElementException() {
5656
public String getMessage() {
5757
StringBuilder sb = new StringBuilder(super.getMessage());
5858
SimpleMethod method = getSimpleMethod();
59-
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
59+
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
6060
sb.append(", Element = <break>, Line ").append(getLineNumber());
6161
return sb.toString();
6262
}

framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Continue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public ContinueElementException() {
5656
public String getMessage() {
5757
StringBuilder sb = new StringBuilder(super.getMessage());
5858
SimpleMethod method = getSimpleMethod();
59-
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
59+
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
6060
sb.append(", Element = <continue>, Line ").append(getLineNumber());
6161
return sb.toString();
6262
}

0 commit comments

Comments
 (0)