From 71762ff629e4a5fb1804cda4116ede481546ab1d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 13 Nov 2012 13:44:33 -0300 Subject: [PATCH] Add more debug. --- .../exceptions/ClientException.java | 4 ++ .../MultipleSessionsOpenException.java | 4 +- .../com/wisemapping/rest/BaseController.java | 2 +- .../wisemapping/rest/model/RestErrors.java | 39 +++++++++++++++---- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java index 484c1557..65d91222 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java @@ -28,4 +28,8 @@ abstract public class ClientException extends WiseMappingException { public Severity getSeverity() { return this.severity; } + + public String getTechInfo() { + return getMessage(); + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java index 6d92a7e0..70be4572 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java @@ -25,9 +25,9 @@ public class MultipleSessionsOpenException { public static final String MSG_KEY = "MINDMAP_OUTDATED_BY_YOU"; - public MultipleSessionsOpenException(@NotNull String msg) + public MultipleSessionsOpenException(@NotNull String techInfo) { - super(msg,Severity.INFO); + super(techInfo,Severity.INFO); } @NotNull diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java index 37d7ec87..d2a7fc26 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -108,6 +108,6 @@ public class BaseController { @ResponseStatus(HttpStatus.BAD_REQUEST) public RestErrors handleClientErrors(@NotNull ClientException ex) { final Locale locale = LocaleContextHolder.getLocale(); - return new RestErrors(ex.getMessage(messageSource, locale),ex.getSeverity()); + return new RestErrors(ex.getMessage(messageSource, locale),ex.getSeverity(),ex.getTechInfo()); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java index d94b9e0b..792bb23f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java @@ -23,6 +23,7 @@ import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.validation.Errors; @@ -56,6 +57,10 @@ public class RestErrors { @JsonIgnore Severity gSeverity; + @Nullable + @JsonIgnore + private String _debugInfo; + public RestErrors() { } @@ -64,17 +69,23 @@ public class RestErrors { this.errors = errors; this.messageSource = messageSource; - this.gErrors = this.processGlobalErrors(errors, messageSource); + this.gErrors = this.processGlobalErrors(errors); this.gSeverity = Severity.WARNING; } public RestErrors(@NotNull String errorMsg, @NotNull Severity severity) { - gErrors = new ArrayList(); - gErrors.add(errorMsg); + + this(errorMsg, severity, null); + } + + public RestErrors(@NotNull String errorMsg, @NotNull Severity severity, @Nullable String debugInfo) { + this._debugInfo = debugInfo; + this.gErrors = new ArrayList(); + this.gErrors.add(errorMsg); this.gSeverity = severity; } - private List processGlobalErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) { + private List processGlobalErrors(@NotNull Errors errors) { final List result = new ArrayList(); final List globalErrors = errors.getGlobalErrors(); for (ObjectError globalError : globalErrors) { @@ -83,10 +94,6 @@ public class RestErrors { return result; } - public List getGlobalErrors() { - return gErrors; - } - public void setGlobalErrors(List list) { // Implemented only for XML serialization contract ... } @@ -111,7 +118,23 @@ public class RestErrors { // Implemented only for XML serialization contract ... } + public void setDebugInfo(@Nullable String debugInfo) { + // Implemented only for XML serialization contract ... + } + + + @Nullable public String getGlobalSeverity() { return this.gSeverity.toString(); } + + @Nullable + public String getDebugInfo() { + return _debugInfo; + } + + public List getGlobalErrors() { + return gErrors; + } + }