mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-09 00:43:23 +01:00
Add error report for fields on new map.
Display error messages
This commit is contained in:
parent
e4dc4a50aa
commit
3da0eec842
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2011] [wisemapping]
|
|
||||||
*
|
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the license at
|
|
||||||
*
|
|
||||||
* http://www.wisemapping.org/license
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.wisemapping.controller;
|
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.security.Utils;
|
|
||||||
import com.wisemapping.service.MindmapService;
|
|
||||||
import com.wisemapping.view.MindMapInfoBean;
|
|
||||||
import org.springframework.validation.BindException;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class NewMindmapController
|
|
||||||
extends BaseSimpleFormController {
|
|
||||||
|
|
||||||
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
|
|
||||||
throws ServletException, WiseMappingException, IOException {
|
|
||||||
final MindMapInfoBean bean = (MindMapInfoBean) command;
|
|
||||||
|
|
||||||
final String title = bean.getTitle();
|
|
||||||
final String description = bean.getDescription();
|
|
||||||
|
|
||||||
final User user = Utils.getUser();
|
|
||||||
final MindmapService service = getMindmapService();
|
|
||||||
|
|
||||||
// The map has not been created. Create a new one ...
|
|
||||||
MindMap mindmap = new MindMap();
|
|
||||||
mindmap.setDescription(description);
|
|
||||||
mindmap.setTitle(title);
|
|
||||||
mindmap.setOwner(user);
|
|
||||||
|
|
||||||
final String xml = MindMap.getDefaultMindmapXml(title);
|
|
||||||
mindmap.setXmlStr(xml);
|
|
||||||
|
|
||||||
service.addMindmap(mindmap, user);
|
|
||||||
|
|
||||||
return new ModelAndView("redirect:editor.htm?mapId=" + mindmap.getId() + "&action=open");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,22 @@
|
|||||||
package com.wisemapping.rest;
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
|
@ -1,7 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
|
import com.wisemapping.rest.model.RestErrors;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -9,6 +29,9 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
|||||||
|
|
||||||
public class BaseController {
|
public class BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceBundleMessageSource messageSource;
|
||||||
|
|
||||||
@ExceptionHandler(IllegalArgumentException.class)
|
@ExceptionHandler(IllegalArgumentException.class)
|
||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ -22,7 +45,14 @@ public class BaseController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String handleServerErrors(@NotNull Exception ex) {
|
public String handleServerErrors(@NotNull Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
// LOGGER.error(ex.getMessage(), ex);
|
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(ValidationException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public RestErrors handleValidationErrors(@NotNull ValidationException ex) {
|
||||||
|
return new RestErrors(ex.getErrors(),messageSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,13 @@ import com.wisemapping.rest.model.RestMindmapInfo;
|
|||||||
import com.wisemapping.rest.model.RestMindmapList;
|
import com.wisemapping.rest.model.RestMindmapList;
|
||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
|
import com.wisemapping.validator.MapInfoValidator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.validation.BeanPropertyBindingResult;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
@ -154,22 +157,15 @@ public class MindmapController extends BaseController {
|
|||||||
@ResponseStatus(value = HttpStatus.CREATED)
|
@ResponseStatus(value = HttpStatus.CREATED)
|
||||||
public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
public void createMap(@RequestBody RestMindmap restMindmap, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
||||||
|
|
||||||
final String title = restMindmap.getTitle();
|
// Validate ...
|
||||||
if (title == null || title.isEmpty()) {
|
final BindingResult result = new BeanPropertyBindingResult(restMindmap, "");
|
||||||
throw new IllegalArgumentException("Map title can not be null");
|
new MapInfoValidator(mindmapService).validate(restMindmap.getDelegated(), result);
|
||||||
}
|
if (result.hasErrors()) {
|
||||||
|
throw new ValidationException(result);
|
||||||
final String description = restMindmap.getDescription();
|
|
||||||
if (description == null || description.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("Map details can not be null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some basic validations ...
|
// Some basic validations ...
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
final MindMap mindMap = mindmapService.getMindmapByTitle(title, user);
|
|
||||||
if (mindMap != null) {
|
|
||||||
throw new IllegalArgumentException("Map already exists with title '" + title + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user has not specified the xml content, add one ...
|
// If the user has not specified the xml content, add one ...
|
||||||
final MindMap delegated = restMindmap.getDelegated();
|
final MindMap delegated = restMindmap.getDelegated();
|
||||||
@ -186,7 +182,6 @@ public class MindmapController extends BaseController {
|
|||||||
// Return the new created map ...
|
// Return the new created map ...
|
||||||
response.setHeader("Location", "/service/maps/" + delegated.getId());
|
response.setHeader("Location", "/service/maps/" + delegated.getId());
|
||||||
response.setHeader("ResourceId", Integer.toString(delegated.getId()));
|
response.setHeader("ResourceId", Integer.toString(delegated.getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
||||||
@ -222,8 +217,8 @@ public class MindmapController extends BaseController {
|
|||||||
|
|
||||||
// Return the new created map ...
|
// Return the new created map ...
|
||||||
response.setHeader("Location", "/service/maps/" + clonedMap.getId());
|
response.setHeader("Location", "/service/maps/" + clonedMap.getId());
|
||||||
|
response.setHeader("ResourceId", Integer.toString(clonedMap.getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
|
public class ValidationException extends WiseMappingException{
|
||||||
|
private Errors errors;
|
||||||
|
|
||||||
|
public ValidationException(@NotNull Errors errors) {
|
||||||
|
super("Validation Exceptions");
|
||||||
|
this.errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Errors getErrors() {
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.wisemapping.rest.model;
|
||||||
|
|
||||||
|
|
||||||
|
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.springframework.context.MessageSource;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.validation.ObjectError;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "errors")
|
||||||
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||||
|
@JsonAutoDetect(
|
||||||
|
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||||
|
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
||||||
|
)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class RestErrors {
|
||||||
|
@JsonIgnore
|
||||||
|
private Errors errors;
|
||||||
|
@JsonIgnore
|
||||||
|
MessageSource messageSource;
|
||||||
|
|
||||||
|
public RestErrors() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) {
|
||||||
|
|
||||||
|
this.errors = errors;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getGlobalErrors() {
|
||||||
|
final List<String> result = new ArrayList<String>();
|
||||||
|
final List<ObjectError> globalErrors = errors.getGlobalErrors();
|
||||||
|
for (ObjectError globalError : globalErrors) {
|
||||||
|
result.add(globalError.getObjectName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalErrors(List<String> list) {
|
||||||
|
// Implemented only for XML serialization contract ...
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getFieldErrors() {
|
||||||
|
final Map<String, String> result = new HashMap<String, String>();
|
||||||
|
final List<FieldError> fieldErrors = errors.getFieldErrors();
|
||||||
|
for (FieldError fieldError : fieldErrors) {
|
||||||
|
result.put(fieldError.getField(), messageSource.getMessage(fieldError, Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldErrors(Map<String, String> fieldErrors) {
|
||||||
|
// Implemented only for XML serialization contract ...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,22 @@
|
|||||||
package com.wisemapping.rest.view;
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.rest.view;
|
||||||
|
|
||||||
import com.wisemapping.importer.ImportFormat;
|
import com.wisemapping.importer.ImportFormat;
|
||||||
import com.wisemapping.importer.Importer;
|
import com.wisemapping.importer.Importer;
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
package com.wisemapping.rest.view;
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.rest.view;
|
||||||
|
|
||||||
import com.wisemapping.exporter.ExportFormat;
|
import com.wisemapping.exporter.ExportFormat;
|
||||||
import com.wisemapping.exporter.ExportProperties;
|
import com.wisemapping.exporter.ExportProperties;
|
||||||
|
@ -24,6 +24,7 @@ import com.wisemapping.model.User;
|
|||||||
import com.wisemapping.model.Constants;
|
import com.wisemapping.model.Constants;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
import com.wisemapping.view.MindMapInfoBean;
|
import com.wisemapping.view.MindMapInfoBean;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.validation.ValidationUtils;
|
import org.springframework.validation.ValidationUtils;
|
||||||
import org.springframework.validation.Validator;
|
import org.springframework.validation.Validator;
|
||||||
@ -37,8 +38,16 @@ public class MapInfoValidator implements Validator {
|
|||||||
return clazz.equals(MindMapInfoBean.class);
|
return clazz.equals(MindMapInfoBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate(Object obj, Errors errors) {
|
public MapInfoValidator() {
|
||||||
final MindMapInfoBean map = (MindMapInfoBean) obj;
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapInfoValidator(@NotNull MindmapService service) {
|
||||||
|
this.mindmapService = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(Object obj, @NotNull Errors errors) {
|
||||||
|
final MindMap map = (MindMap) obj;
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
errors.rejectValue("map", "error.not-specified", null, "Value required.");
|
errors.rejectValue("map", "error.not-specified", null, "Value required.");
|
||||||
} else {
|
} else {
|
||||||
@ -53,9 +62,8 @@ public class MapInfoValidator implements Validator {
|
|||||||
new Object[]{Constants.MAX_MAP_NAME_LENGTH},
|
new Object[]{Constants.MAX_MAP_NAME_LENGTH},
|
||||||
"The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters.");
|
"The title must have less than " + Constants.MAX_MAP_NAME_LENGTH + " characters.");
|
||||||
} else {
|
} else {
|
||||||
// Map alredy exists ?
|
// Map already exists ?
|
||||||
final MindmapService service = this.getMindmapService();
|
final MindmapService service = this.getMindmapService();
|
||||||
|
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final User user = com.wisemapping.security.Utils.getUser();
|
||||||
final MindMap mindMap = service.getMindmapByTitle(title, user);
|
final MindMap mindMap = service.getMindmapByTitle(title, user);
|
||||||
if (mindMap != null) {
|
if (mindMap != null) {
|
||||||
|
@ -245,7 +245,7 @@ IMPORT_MINDMAP_INFO=You can import FreeMind 0.9 version maps to WiseMapping. Ple
|
|||||||
PRINT=Print
|
PRINT=Print
|
||||||
FREE_MIND_FILE=FreeMind File
|
FREE_MIND_FILE=FreeMind File
|
||||||
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
|
IMPORT_MAP_ERROR=FreeMind file could not be imported. {0}
|
||||||
MAP_TITLE_ALREADY_EXISTS=Map name already exists.
|
MAP_TITLE_ALREADY_EXISTS=A map already exists with this name.
|
||||||
EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post!
|
EMBEDDED_VIEWER=Embed a map viewer in your own web site, blog or post!
|
||||||
EMBEDDED_VIEWER_MESSAGE=Once you make your map public, you will be able to embed a mind map viewer in your own web site, blog or post just as we did it here!<br/>Try it!!, you can drag nodes, pan the map, and zoom in and out.
|
EMBEDDED_VIEWER_MESSAGE=Once you make your map public, you will be able to embed a mind map viewer in your own web site, blog or post just as we did it here!<br/>Try it!!, you can drag nodes, pan the map, and zoom in and out.
|
||||||
FREEMIND_EXPORT_IMPORT=Import and Export maps from/to FreeMind
|
FREEMIND_EXPORT_IMPORT=Import and Export maps from/to FreeMind
|
||||||
|
@ -109,18 +109,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Dialog Forms -->
|
<!-- Dialog Forms -->
|
||||||
<definition name="newMap" extends="formDialogTemplate">
|
|
||||||
<put name="title" value="NEW_MINDMAP"/>
|
|
||||||
<put name="details" value="FIELD_REQUIRED_MSG"/>
|
|
||||||
<put name="body" value="/jsp/newMap.jsp"/>
|
|
||||||
</definition>
|
|
||||||
|
|
||||||
|
|
||||||
<definition name="newMapError" extends="pageTemplate">
|
|
||||||
<put name="title" value="NEW_MINDMAP"/>
|
|
||||||
<put name="details" value="FIELD_REQUIRED_MSG"/>
|
|
||||||
<put name="body" value="/jsp/newMapError.jsp"/>
|
|
||||||
</definition>
|
|
||||||
|
|
||||||
<definition name="setting" extends="formDialogTemplate">
|
<definition name="setting" extends="formDialogTemplate">
|
||||||
<put name="title" value="SETTINGS"/>
|
<put name="title" value="SETTINGS"/>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<value>com.wisemapping.rest.model.RestMindmapInfo</value>
|
<value>com.wisemapping.rest.model.RestMindmapInfo</value>
|
||||||
<value>com.wisemapping.rest.model.RestMindmapList</value>
|
<value>com.wisemapping.rest.model.RestMindmapList</value>
|
||||||
<value>com.wisemapping.rest.model.RestUser</value>
|
<value>com.wisemapping.rest.model.RestUser</value>
|
||||||
|
<value>com.wisemapping.rest.model.RestErrors</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@ -88,4 +89,14 @@
|
|||||||
<bean id="transformViewWise" class="com.wisemapping.rest.view.ImportTransformationView">
|
<bean id="transformViewWise" class="com.wisemapping.rest.view.ImportTransformationView">
|
||||||
<constructor-arg value="application/wisemapping+xml"/>
|
<constructor-arg value="application/wisemapping+xml"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
|
<property name="basenames">
|
||||||
|
<list>
|
||||||
|
<value>messages</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -134,10 +134,6 @@
|
|||||||
<property name="mindmapService" ref="mindmapService"/>
|
<property name="mindmapService" ref="mindmapService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="newMapValidator" class="com.wisemapping.validator.MapInfoValidator">
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="importMapValidator" class="com.wisemapping.validator.ImportMapValidator">
|
<bean id="importMapValidator" class="com.wisemapping.validator.ImportMapValidator">
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
<property name="mindmapService" ref="mindmapService"/>
|
||||||
</bean>
|
</bean>
|
||||||
@ -159,19 +155,7 @@
|
|||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="newMapController" class="com.wisemapping.controller.NewMindmapController">
|
<bean id="importMapController" class="com.wisemapping.controller.ImportController">
|
||||||
<property name="sessionForm" value="false"/>
|
|
||||||
<property name="commandName" value="newMap"/>
|
|
||||||
<property name="commandClass" value="com.wisemapping.view.MindMapInfoBean"/>
|
|
||||||
<property name="validator" ref="newMapValidator"/>
|
|
||||||
<property name="formView" value="newMap"/>
|
|
||||||
<property name="errorView" value="newMapError"/>
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
<property name="userService" ref="userService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="importMapController" class="com.wisemapping.controller.ImportController">
|
|
||||||
<property name="sessionForm" value="false"/>
|
<property name="sessionForm" value="false"/>
|
||||||
<property name="commandName" value="importMap"/>
|
<property name="commandName" value="importMap"/>
|
||||||
<property name="commandClass" value="com.wisemapping.view.ImportMapBean"/>
|
<property name="commandClass" value="com.wisemapping.view.ImportMapBean"/>
|
||||||
@ -254,7 +238,6 @@
|
|||||||
<prop key="/c/embeddedView.htm">embeddedView</prop>
|
<prop key="/c/embeddedView.htm">embeddedView</prop>
|
||||||
<prop key="/c/renameMap.htm">renameMapController</prop>
|
<prop key="/c/renameMap.htm">renameMapController</prop>
|
||||||
<prop key="/c/importMap.htm">importMapController</prop>
|
<prop key="/c/importMap.htm">importMapController</prop>
|
||||||
<prop key="/c/newMap.htm">newMapController</prop>
|
|
||||||
<prop key="/c/history.htm">historyController</prop>
|
<prop key="/c/history.htm">historyController</prop>
|
||||||
<prop key="/c/installCFG.htm">homeController</prop>
|
<prop key="/c/installCFG.htm">homeController</prop>
|
||||||
</props>
|
</props>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
<%@ page session="false" contentType="text/html;charset=UTF-8" %>
|
<%@ page session="false" contentType="text/html;charset=UTF-8" %>
|
||||||
|
|
||||||
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
||||||
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>--%>
|
|
||||||
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%
|
<%
|
||||||
|
@ -161,10 +161,14 @@
|
|||||||
$("#buttons .newMap").button({
|
$("#buttons .newMap").button({
|
||||||
icons: { primary: "ui-icon-circle-plus" }
|
icons: { primary: "ui-icon-circle-plus" }
|
||||||
}).click(function() {
|
}).click(function() {
|
||||||
|
// Clean previous dialog content ...
|
||||||
|
$("#new-dialog-modal div[id='errorMessage']").text("").removeClass("ui-state-highlight");
|
||||||
|
|
||||||
$("#new-dialog-modal").dialog({
|
$("#new-dialog-modal").dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
"Create": function() {
|
"Create": function() {
|
||||||
|
|
||||||
var formData = {};
|
var formData = {};
|
||||||
$('#new-dialog-modal input').each(function(index, elem) {
|
$('#new-dialog-modal input').each(function(index, elem) {
|
||||||
formData[elem.name] = elem.value;
|
formData[elem.name] = elem.value;
|
||||||
@ -180,12 +184,37 @@
|
|||||||
var mapId = jqXHR.getResponseHeader("ResourceId");
|
var mapId = jqXHR.getResponseHeader("ResourceId");
|
||||||
window.location = "c/editor.htm?action=open&mapId=" + mapId;
|
window.location = "c/editor.htm?action=open&mapId=" + mapId;
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
alert("Unexpected error removing maps. Refresh before continue.");
|
if (jqXHR.status == 400) {
|
||||||
|
var errors = JSON.parse(jqXHR.responseText);
|
||||||
|
// Clean previous marks ....
|
||||||
|
$('#new-dialog-modal input').each(function(index, elem) {
|
||||||
|
$(elem).removeClass("ui-state-error");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark fields with errors ...
|
||||||
|
var fieldErrors = errors.fieldErrors;
|
||||||
|
if (fieldErrors) {
|
||||||
|
for (var fieldName in fieldErrors) {
|
||||||
|
// Mark the field ...
|
||||||
|
var message = fieldErrors[fieldName];
|
||||||
|
var inputField = $("#new-dialog-modal input[name='" + fieldName + "']");
|
||||||
|
$(inputField).addClass("ui-state-error");
|
||||||
|
|
||||||
|
|
||||||
|
$("#new-dialog-modal div[id='errorMessage']").text(message).addClass("ui-state-highlight");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert("Unexpected error removing maps. Refresh before continue.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel:function() {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,7 +250,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
;
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -241,7 +271,9 @@
|
|||||||
<div id="delete-dialog-modal" title="Delete maps" style="display: none">
|
<div id="delete-dialog-modal" title="Delete maps" style="display: none">
|
||||||
<p>Are you sure you want to delete maps <span></span> ?</p>
|
<p>Are you sure you want to delete maps <span></span> ?</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="new-dialog-modal" title="New" style="display: none">
|
<div id="new-dialog-modal" title="Add new map" style="display: none">
|
||||||
|
<div id="errorMessage"></div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="formLabel">
|
<td class="formLabel">
|
||||||
@ -281,7 +313,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="map-table">
|
<div id="map-table">
|
||||||
<table cellpadding="0" cellspacing="0" border="0" class="display" id="mindmapListTable">
|
<table class="display" id="mindmapListTable">
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
|
|
||||||
<h1>
|
|
||||||
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<form:form method="post" commandName="newMap">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td class="formLabel">
|
|
||||||
<span class="fieldRequired">*</span>
|
|
||||||
<spring:message code="NAME"/>
|
|
||||||
:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<form:input path="title" id="title" tabindex="1"/>
|
|
||||||
<form:errors path="title" cssClass="errorMsg"/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="formLabel">
|
|
||||||
<spring:message code="DESCRIPTION"/>
|
|
||||||
:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<form:input path="description" id="description" tabindex="2"/>
|
|
||||||
<form:errors path="description" cssClass="errorMsg"/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td> </td>
|
|
||||||
<td>
|
|
||||||
<input type="submit" value="Accept" class="btn-primary">
|
|
||||||
<c:choose>
|
|
||||||
<c:when test="${!errorView}">
|
|
||||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-secondary"
|
|
||||||
onclick="MOOdalBox.close();">
|
|
||||||
</c:when>
|
|
||||||
<c:otherwise>
|
|
||||||
<input type="button" value="<spring:message code="BACK"/>" class="btn-secondary"
|
|
||||||
onclick="window.location='mymaps.htm'">
|
|
||||||
</c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form:form>
|
|
||||||
</div>
|
|
@ -1,11 +0,0 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
|
||||||
|
|
||||||
<h1>
|
|
||||||
<spring:message code="${requestScope.title}"/>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p style="font-weight:bold;">
|
|
||||||
<spring:message code="${requestScope.details}"/>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<jsp:include page="/jsp/newMap.jsp"/>
|
|
@ -23,10 +23,6 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="../css/wisehome.css"/>
|
<link rel="stylesheet" type="text/css" href="../css/wisehome.css"/>
|
||||||
<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
||||||
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
|
||||||
<script type='text/javascript'
|
|
||||||
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
|
|
||||||
<script type='text/javascript' src='../js/mootools-more.js'></script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
import org.springframework.security.crypto.codec.Base64;
|
import org.springframework.security.crypto.codec.Base64;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
@ -111,6 +112,33 @@ public class RestMindmapTCase {
|
|||||||
assertEquals(newTitle, map.getTitle());
|
assertEquals(newTitle, map.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "ContentType-Provider-Function")
|
||||||
|
public void validateMapsCreation(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
final RestTemplate template = createTemplate();
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title = "Map to change title - " + mediaType.toString();
|
||||||
|
final URI resourceUri = addNewMap(requestHeaders, template, title);
|
||||||
|
|
||||||
|
// Try to create a map with the same title ..
|
||||||
|
final RestMindmap restMindmap = new RestMindmap();
|
||||||
|
restMindmap.setTitle(title);
|
||||||
|
restMindmap.setDescription("My Map Desc");
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<RestMindmap>(restMindmap, requestHeaders);
|
||||||
|
template.postForLocation(BASE_REST_URL + "/maps", createUserEntity);
|
||||||
|
} catch (HttpClientErrorException cause) {
|
||||||
|
final String responseBodyAsString = cause.getResponseBodyAsString();
|
||||||
|
assert(responseBodyAsString.contains("Map name already exists."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fail("Wrong response");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(dataProvider = "ContentType-Provider-Function")
|
@Test(dataProvider = "ContentType-Provider-Function")
|
||||||
public void changeMapDescription(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
public void changeMapDescription(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
Loading…
Reference in New Issue
Block a user