Fix error handling for Import Operation.
Remove some old icons
This commit is contained in:
@@ -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)
|
||||
|
@@ -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.");
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,10 @@ import java.util.*;
|
||||
public class RestErrors {
|
||||
@JsonIgnore
|
||||
private Errors errors;
|
||||
|
||||
@JsonIgnore
|
||||
private List<String> 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<String> getGlobalErrors() {
|
||||
public RestErrors(@NotNull String errorMsg) {
|
||||
globalErrors.add(errorMsg);
|
||||
}
|
||||
|
||||
private List<String> processGlobalErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final List<ObjectError> globalErrors = errors.getGlobalErrors();
|
||||
for (ObjectError globalError : globalErrors) {
|
||||
@@ -49,6 +58,10 @@ public class RestErrors {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getGlobalErrors() {
|
||||
return globalErrors;
|
||||
}
|
||||
|
||||
public void setGlobalErrors(List<String> list) {
|
||||
// Implemented only for XML serialization contract ...
|
||||
}
|
||||
|
Reference in New Issue
Block a user