Fix toolbar title bug
Add properties peer user.
This commit is contained in:
@@ -21,6 +21,7 @@ package com.wisemapping.rest;
|
||||
import com.wisemapping.rest.model.RestErrors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
public class BaseController {
|
||||
|
||||
@Qualifier("messageSource")
|
||||
@Autowired
|
||||
private ResourceBundleMessageSource messageSource;
|
||||
|
||||
@@ -36,6 +38,7 @@ public class BaseController {
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public RestErrors handleClientErrors(@NotNull IllegalArgumentException ex) {
|
||||
ex.printStackTrace();
|
||||
return new RestErrors(ex.getMessage());
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ public class MindmapController extends BaseController {
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborationsBy(user);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
|
||||
final List<MindMap> mindmaps = new ArrayList<MindMap>();
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
@@ -125,7 +125,7 @@ public class MindmapController extends BaseController {
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.findMindmapById(id);
|
||||
final MindMap mindmap = mindmapService.findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Validate arguments ...
|
||||
@@ -133,17 +133,20 @@ public class MindmapController extends BaseController {
|
||||
if (properties == null) {
|
||||
throw new IllegalArgumentException("Map properties can not be null");
|
||||
}
|
||||
mindMap.setProperties(properties);
|
||||
|
||||
// Update collaboration properties ...
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user);
|
||||
collaborationProperties.setMindmapProperties(properties);
|
||||
|
||||
// Validate content ...
|
||||
final String xml = restMindmap.getXml();
|
||||
if (xml == null) {
|
||||
throw new IllegalArgumentException("Map xml can not be null");
|
||||
}
|
||||
mindMap.setXmlStr(xml);
|
||||
mindmap.setXmlStr(xml);
|
||||
|
||||
// Update map ...
|
||||
saveMindmap(minor, mindMap, user);
|
||||
saveMindmap(minor, mindmap, user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,41 +156,43 @@ public class MindmapController extends BaseController {
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void update(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.findMindmapById(id);
|
||||
final MindMap mindmap = mindmapService.findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Update document properties ...
|
||||
final String properties = restMindmap.getProperties();
|
||||
if (properties != null) {
|
||||
mindMap.setProperties(properties);
|
||||
}
|
||||
final String xml = restMindmap.getXml();
|
||||
if (xml != null) {
|
||||
mindMap.setXmlStr(xml);
|
||||
mindmap.setXmlStr(xml);
|
||||
}
|
||||
|
||||
// Update title ...
|
||||
final String title = restMindmap.getTitle();
|
||||
if (title != null && !title.equals(mindMap.getTitle())) {
|
||||
if (title != null && !title.equals(mindmap.getTitle())) {
|
||||
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
||||
throw buildValidationException("title", "You already have a map with this title");
|
||||
}
|
||||
mindMap.setTitle(title);
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
|
||||
// Update description ...
|
||||
final String description = restMindmap.getDescription();
|
||||
if (description != null) {
|
||||
mindMap.setDescription(description);
|
||||
mindmap.setDescription(description);
|
||||
}
|
||||
|
||||
final String tags = restMindmap.getTags();
|
||||
if (tags != null) {
|
||||
mindMap.setTags(tags);
|
||||
mindmap.setTags(tags);
|
||||
}
|
||||
|
||||
// Update document properties ...
|
||||
final String properties = restMindmap.getProperties();
|
||||
if (properties != null) {
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user);
|
||||
collaborationProperties.setMindmapProperties(properties);
|
||||
}
|
||||
|
||||
// Update map ...
|
||||
saveMindmap(minor, mindMap, user);
|
||||
saveMindmap(minor, mindmap, user);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -46,6 +46,7 @@ public class RestErrors {
|
||||
}
|
||||
|
||||
public RestErrors(@NotNull String errorMsg) {
|
||||
globalErrors = new ArrayList<String>();
|
||||
globalErrors.add(errorMsg);
|
||||
}
|
||||
|
||||
@@ -68,9 +69,11 @@ public class RestErrors {
|
||||
|
||||
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));
|
||||
if (errors != null) {
|
||||
final List<FieldError> fieldErrors = errors.getFieldErrors();
|
||||
for (FieldError fieldError : fieldErrors) {
|
||||
result.put(fieldError.getField(), messageSource.getMessage(fieldError, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -2,9 +2,8 @@ package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.security.Utils;
|
||||
import org.codehaus.jackson.annotate.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -32,22 +31,28 @@ public class RestMindmap {
|
||||
private MindMap mindmap;
|
||||
@JsonIgnore
|
||||
static private SimpleDateFormat sdf;
|
||||
private String properties;
|
||||
|
||||
static {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public RestMindmap() {
|
||||
public RestMindmap() throws WiseMappingException {
|
||||
this(new MindMap(), null);
|
||||
|
||||
}
|
||||
|
||||
public RestMindmap(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) {
|
||||
public RestMindmap(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) throws WiseMappingException {
|
||||
this.mindmap = mindmap;
|
||||
this.collaborator = collaborator;
|
||||
if (collaborator != null) {
|
||||
final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(collaborator);
|
||||
this.properties = collaborationProperties.getMindmapProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getCreationTime() {
|
||||
final Calendar creationTime = mindmap.getCreationTime();
|
||||
String result = null;
|
||||
@@ -139,8 +144,8 @@ public class RestMindmap {
|
||||
}
|
||||
|
||||
|
||||
public void setProperties(String properties) {
|
||||
mindmap.setProperties(properties);
|
||||
public void setProperties(@Nullable String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void setLastModificationTime(final String value) {
|
||||
@@ -150,7 +155,7 @@ public class RestMindmap {
|
||||
}
|
||||
|
||||
public String getProperties() {
|
||||
return mindmap.getProperties();
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean getStarred() {
|
||||
|
Reference in New Issue
Block a user