Skip to content

Commit

Permalink
Improved: Don't need to show files names in UI messages (OFBIZ-12884)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JacquesLeRoux committed Feb 2, 2024
1 parent 79242f6 commit 279bb92
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getMessage() {
StringBuilder sb = new StringBuilder(super.getMessage());
if (this.element != null) {
SimpleMethod method = this.element.getSimpleMethod();
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
sb.append(", Element = <").append(this.element.getTagName()).append(">");
sb.append(", Line ").append(this.element.getLineNumber());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ public String exec(MethodContext methodContext) throws MiniLangException {
}
// rollback here passing beganTransaction to either rollback, or set rollback only
try {
TransactionUtil.rollback(beganTransaction, "Error in simple-method [" + this.getShortDescription() + "]: "
+ summaryErrorStringBuffer, null);
TransactionUtil.rollback(beganTransaction, summaryErrorStringBuffer.toString(), null);
} catch (GenericTransactionException e) {
String errMsg = "Error trying to rollback transaction, could not process method: " + e.getMessage();
if (methodContext.isTraceOn()) {
Expand All @@ -643,7 +642,7 @@ public String exec(MethodContext methodContext) throws MiniLangException {

@Override
public void gatherArtifactInfo(ArtifactInfoContext aic) {
for (MethodOperation methodOp : this.methodOperations) {
for (MethodOperation methodOp : methodOperations) {
methodOp.gatherArtifactInfo(aic);
}
}
Expand All @@ -663,101 +662,102 @@ public Set<String> getAllServiceNamesCalled() throws MiniLangException {
}

public String getDefaultErrorCode() {
return this.defaultErrorCode;
return defaultErrorCode;
}

public String getDefaultSuccessCode() {
return this.defaultSuccessCode;
return defaultSuccessCode;
}

public String getEventErrorMessageListName() {
return this.eventErrorMessageListName;
return eventErrorMessageListName;
}

public String getEventErrorMessageName() {
return this.eventErrorMessageName;
return eventErrorMessageName;
}

public String getEventEventMessageListName() {
return this.eventEventMessageListName;
return eventEventMessageListName;
}

public String getEventEventMessageName() {
return this.eventEventMessageName;
return eventEventMessageName;
}

// event fields
public String getEventRequestName() {
return this.eventRequestName;
return eventRequestName;
}

public String getEventResponseCodeName() {
return this.eventResponseCodeName;
return eventResponseCodeName;
}

public String getEventSessionName() {
return this.eventSessionName;
return eventSessionName;
}

public String getFileName() {
return this.fromLocation.substring(this.fromLocation.lastIndexOf("/") + 1);
return fromLocation.substring(fromLocation.lastIndexOf("/") + 1);
}

public String getFromLocation() {
return this.fromLocation;
return fromLocation;
}

public String getLocationAndName() {
return this.fromLocation + "#" + this.methodName;
return fromLocation + "#" + methodName;
}

public boolean getLoginRequired() {
return this.loginRequired;
return loginRequired;
}

public String getMethodName() {
return this.methodName;
return methodName;
}

public List<MethodOperation> getMethodOperations() {
return this.methodOperations;
return methodOperations;
}

public String getServiceErrorMessageListName() {
return this.serviceErrorMessageListName;
return serviceErrorMessageListName;
}

public String getServiceErrorMessageMapName() {
return this.serviceErrorMessageMapName;
return serviceErrorMessageMapName;
}

public String getServiceErrorMessageName() {
return this.serviceErrorMessageName;
return serviceErrorMessageName;
}

public String getServiceResponseMessageName() {
return this.serviceResponseMessageName;
return serviceResponseMessageName;
}

public String getServiceSuccessMessageListName() {
return this.serviceSuccessMessageListName;
return serviceSuccessMessageListName;
}

public String getServiceSuccessMessageName() {
return this.serviceSuccessMessageName;
return serviceSuccessMessageName;
}

public String getShortDescription() {
return this.shortDescription + " [" + this.fromLocation + "#" + this.methodName + "]";
return shortDescription + " [" + getFileName() + "#" + methodName + "]";
}


@Override
public SimpleMethod getSimpleMethod() {
return this;
}

public boolean getUseTransaction() {
return this.useTransaction;
return useTransaction;
}

private String returnError(MethodContext methodContext, String errorMsg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ValidationException(String str, SimpleMethod method, Element element) {
public String getMessage() {
StringBuilder sb = new StringBuilder(super.getMessage());
if (method != null) {
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
}
if (element != null) {
sb.append(", Element = <").append(element.getTagName()).append(">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public BreakElementException() {
public String getMessage() {
StringBuilder sb = new StringBuilder(super.getMessage());
SimpleMethod method = getSimpleMethod();
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
sb.append(", Element = <break>, Line ").append(getLineNumber());
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ContinueElementException() {
public String getMessage() {
StringBuilder sb = new StringBuilder(super.getMessage());
SimpleMethod method = getSimpleMethod();
sb.append(" Method = ").append(method.getMethodName()).append(", File = ").append(method.getFromLocation());
sb.append(", File#Method = ").append(method.getFileName()).append("#").append(method.getMethodName());
sb.append(", Element = <continue>, Line ").append(getLineNumber());
return sb.toString();
}
Expand Down

0 comments on commit 279bb92

Please sign in to comment.