Mercurial > lada > lada-server
diff src/main/java/de/intevation/lada/util/rest/Response.java @ 539:deb3fec601ed
Use multivalued map for errors and warnings to be able to store more than one
error/warning per item.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 24 Feb 2015 14:56:46 +0100 |
parents | 8751d2135364 |
children | 3ec358698b4d |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/util/rest/Response.java Tue Feb 24 10:58:06 2015 +0100 +++ b/src/main/java/de/intevation/lada/util/rest/Response.java Tue Feb 24 14:56:46 2015 +0100 @@ -11,6 +11,9 @@ import java.util.HashMap; import java.util.Map; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; + /** * Response object storing information about success, warnings, errors and @@ -25,8 +28,8 @@ private Boolean success; private String message; private Object data; - private Map<String, String> errors; - private Map<String, String> warnings; + private MultivaluedMap<String, Integer> errors; + private MultivaluedMap<String, Integer> warnings; private Boolean readonly; private int totalCount; @@ -41,8 +44,8 @@ this.success = success; this.message = Integer.toString(code); this.data = data; - this.errors = new HashMap<String, String>(); - this.warnings = new HashMap<String, String>(); + this.errors = new MultivaluedHashMap<String, Integer>(); + this.warnings = new MultivaluedHashMap<String, Integer>(); this.readonly = Boolean.FALSE; this.totalCount = 0; } @@ -58,8 +61,8 @@ this.success = success; this.message = Integer.toString(code); this.data = data; - this.errors = new HashMap<String, String>(); - this.warnings = new HashMap<String, String>(); + this.errors = new MultivaluedHashMap<String, Integer>(); + this.warnings = new MultivaluedHashMap<String, Integer>(); this.readonly = Boolean.FALSE; this.totalCount = totalCount; } @@ -88,20 +91,22 @@ this.data = data; } - public Map<String, String> getErrors() { + public MultivaluedMap<String, Integer> getErrors() { return errors; } - public void setErrors(Map<String, Integer> errors) { - this.errors = this.convertCodes(errors); + public void setErrors(MultivaluedMap<String, Integer> errors) { + this.errors.putAll(errors); +// this.errors = this.convertCodes(errors); } - public Map<String, String> getWarnings() { + public MultivaluedMap<String, Integer> getWarnings() { return warnings; } - public void setWarnings(Map<String, Integer> warnings) { - this.warnings = this.convertCodes(warnings); + public void setWarnings(MultivaluedMap<String, Integer> warnings) { + this.warnings.putAll(warnings); + //this.warnings = this.convertCodes(warnings); } public Boolean getReadonly() { @@ -126,6 +131,7 @@ this.totalCount = totalCount; } + @SuppressWarnings("unused") private HashMap<String, String> convertCodes(Map<String, Integer> codes) { HashMap<String, String> converted = new HashMap<String, String>(); if (codes == null || codes.isEmpty()) {