Add more debug.

This commit is contained in:
Paulo Gustavo Veiga 2012-11-13 13:44:33 -03:00
parent 00fd168489
commit 71762ff629
4 changed files with 38 additions and 11 deletions

View File

@ -28,4 +28,8 @@ abstract public class ClientException extends WiseMappingException {
public Severity getSeverity() { public Severity getSeverity() {
return this.severity; return this.severity;
} }
public String getTechInfo() {
return getMessage();
}
} }

View File

@ -25,9 +25,9 @@ public class MultipleSessionsOpenException
{ {
public static final String MSG_KEY = "MINDMAP_OUTDATED_BY_YOU"; 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 @NotNull

View File

@ -108,6 +108,6 @@ public class BaseController {
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
public RestErrors handleClientErrors(@NotNull ClientException ex) { public RestErrors handleClientErrors(@NotNull ClientException ex) {
final Locale locale = LocaleContextHolder.getLocale(); 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());
} }
} }

View File

@ -23,6 +23,7 @@ import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
@ -56,6 +57,10 @@ public class RestErrors {
@JsonIgnore @JsonIgnore
Severity gSeverity; Severity gSeverity;
@Nullable
@JsonIgnore
private String _debugInfo;
public RestErrors() { public RestErrors() {
} }
@ -64,17 +69,23 @@ public class RestErrors {
this.errors = errors; this.errors = errors;
this.messageSource = messageSource; this.messageSource = messageSource;
this.gErrors = this.processGlobalErrors(errors, messageSource); this.gErrors = this.processGlobalErrors(errors);
this.gSeverity = Severity.WARNING; this.gSeverity = Severity.WARNING;
} }
public RestErrors(@NotNull String errorMsg, @NotNull Severity severity) { public RestErrors(@NotNull String errorMsg, @NotNull Severity severity) {
gErrors = new ArrayList<String>();
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<String>();
this.gErrors.add(errorMsg);
this.gSeverity = severity; this.gSeverity = severity;
} }
private List<String> processGlobalErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) { private List<String> processGlobalErrors(@NotNull Errors errors) {
final List<String> result = new ArrayList<String>(); final List<String> result = new ArrayList<String>();
final List<ObjectError> globalErrors = errors.getGlobalErrors(); final List<ObjectError> globalErrors = errors.getGlobalErrors();
for (ObjectError globalError : globalErrors) { for (ObjectError globalError : globalErrors) {
@ -83,10 +94,6 @@ public class RestErrors {
return result; return result;
} }
public List<String> getGlobalErrors() {
return gErrors;
}
public void setGlobalErrors(List<String> list) { public void setGlobalErrors(List<String> list) {
// Implemented only for XML serialization contract ... // Implemented only for XML serialization contract ...
} }
@ -111,7 +118,23 @@ public class RestErrors {
// Implemented only for XML serialization contract ... // Implemented only for XML serialization contract ...
} }
public void setDebugInfo(@Nullable String debugInfo) {
// Implemented only for XML serialization contract ...
}
@Nullable
public String getGlobalSeverity() { public String getGlobalSeverity() {
return this.gSeverity.toString(); return this.gSeverity.toString();
} }
@Nullable
public String getDebugInfo() {
return _debugInfo;
}
public List<String> getGlobalErrors() {
return gErrors;
}
} }