From 6f923656ee2c1b5668b22f18777c5c38026f05e3 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 7 Jun 2012 19:45:22 -0300 Subject: [PATCH] Fix error handling for Import Operation. Remove some old icons --- .../com/wisemapping/rest/BaseController.java | 5 +- .../wisemapping/rest/MindmapController.java | 10 +- .../wisemapping/rest/model/RestErrors.java | 15 +- wise-webapp/src/main/webapp/images/info.png | Bin 778 -> 0 bytes wise-webapp/src/main/webapp/images/key.png | Bin 612 -> 0 bytes wise-webapp/src/main/webapp/js/mymaps.js | 4 + .../main/webapp/jsp/dialogFullTemplate.jsp | 4 +- .../src/main/webapp/jsp/mindmapImport.jsp | 9 +- .../src/main/webapp/jsp/mindmapList.jsp | 16 ++ .../src/main/webapp/jsp/mindmapShare.jsp | 208 ++++++++++++++++-- 10 files changed, 243 insertions(+), 28 deletions(-) delete mode 100644 wise-webapp/src/main/webapp/images/info.png delete mode 100644 wise-webapp/src/main/webapp/images/key.png 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 0fe7672b..9ef6acc4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -35,9 +35,8 @@ public class BaseController { @ExceptionHandler(IllegalArgumentException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody - public String handleClientErrors(@NotNull Exception ex) { - ex.printStackTrace(); - return ex.getMessage(); + public RestErrors handleClientErrors(@NotNull IllegalArgumentException ex) { + return new RestErrors(ex.getMessage()); } @ExceptionHandler(Exception.class) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 3267beb2..693c1eb7 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -76,7 +76,6 @@ public class MindmapController extends BaseController { return new ModelAndView("transformViewWise", values); } - @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"}) @ResponseBody public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException { @@ -105,6 +104,14 @@ public class MindmapController extends BaseController { return new ModelAndView("mapsView", "list", restMindmapList); } + + @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"}) + public ModelAndView retrieveHistory(@PathVariable int id) throws IOException { + final User user = com.wisemapping.security.Utils.getUser(); + + return null; + } + @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException { @@ -302,6 +309,7 @@ public class MindmapController extends BaseController { final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml); mindMap = importer.importMap(title, "", stream); } catch (ImporterException e) { + // @Todo: This should be an illegal argument exception. Review the all the other cases. throw buildValidationException("xml", "The selected file does not seems to be a valid Freemind or WiseMapping file. Contact support in case the problem persists."); } 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 b07ae67b..a544afad 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 @@ -27,6 +27,10 @@ import java.util.*; public class RestErrors { @JsonIgnore private Errors errors; + + @JsonIgnore + private List globalErrors; + @JsonIgnore MessageSource messageSource; @@ -38,9 +42,14 @@ public class RestErrors { this.errors = errors; this.messageSource = messageSource; + this.globalErrors = this.processGlobalErrors(errors, messageSource); } - public List getGlobalErrors() { + public RestErrors(@NotNull String errorMsg) { + globalErrors.add(errorMsg); + } + + private List processGlobalErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) { final List result = new ArrayList(); final List globalErrors = errors.getGlobalErrors(); for (ObjectError globalError : globalErrors) { @@ -49,6 +58,10 @@ public class RestErrors { return result; } + public List getGlobalErrors() { + return globalErrors; + } + public void setGlobalErrors(List list) { // Implemented only for XML serialization contract ... } diff --git a/wise-webapp/src/main/webapp/images/info.png b/wise-webapp/src/main/webapp/images/info.png deleted file mode 100644 index 12cd1aef900803abba99b26920337ec01ad5c267..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 778 zcmV+l1NHogP)BVme|mWaqy4$_pJm?y9KM{-*hp?1+Ey3e-CEDooTa!B;e(Q>TSF?bj>5At13y1p zriN3w3x~5SfZj{@J4M{kp{?=M_Lh2bV+5LH)Q)5W!-ePA$RgE1@5f1cyHki0Y}JyVEYZF(LD$xXlt$7A5CgE@ zpV-&l%vf;=5kZ2-2gi@Y6J&=cuwt>!vJ^#(&n|LcZyUzi6Duj$$hJ1s*HD-#;k-w@ zpdrwAuoDG_N2bvb07G$Zk*?Hc)JLtW4yqOnic_$zO7NZ#l>Fm){;fE?b$IbOaX2fe z0la4g0Dfw2xk7Wi7NapVD8YMPCZu?A1QCK*67dgsvRKBLFtrM>?$%&_lD1882mzdO zWPdw5KWw6IT`m1b_8=lS5jt8D3=RDa=&jWzR-)S@56WMslZ~mKu1)-wpXB>rNBQ>N zU#K`#1B&v|_AQK;7I~B}OdGiUT9LX>f0xm6<;LeP!=vFjPsUQF*wCJ*dO)4YBypgdiuF!=i@6Zyi7F|q#K zz?tlSZULa@t1D?$e;f@b36&N!V2mjOHw|*nmX^MrbE*gmZ6|p*GkKoxa?X?hD9M+@sRvFH{EqYA??u6x z2pu{uGnrwz*>rh zfvUA@7b#acN?M*mBG3rQV?e^+0R5m3YXWyRZL5Bt@3vAw{9JaEW$}=f4bXO52yBH{ z;G~ZN|GLn>k~{On3Swd-Sy(gFkOdyw-RP%&exwl01RJRp))TI*SsngruhZksQ*NT%!X?K0000 - + - -
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp index 1c4abaeb..71a32392 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapImport.jsp @@ -72,7 +72,14 @@ inputField.parent().addClass('error'); } } - + var globalErrors = errors.globalErrors; + if (globalErrors) { + for (var error in globalErrors) { + // Mark the field with errors ... + $("#dialogMainForm").find(".errorMessage").text(error).addClass("alert alert-error"); + inputField.parent().addClass('error'); + } + } } else { console.log(errorThrown); console.log(jqXHR); diff --git a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp index 2bf136cf..9f10d618 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp @@ -279,6 +279,22 @@
+ + + + diff --git a/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp b/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp index c759c973..adb8aba1 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp @@ -1,39 +1,209 @@ <%@ include file="/jsp/init.jsp" %> -

Who has access

+

Who has access:

- - - - - - - - +
NameEmailAction
-
-
- -
+
+
+

Add People:

+ + + +