diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index 8ceff27e..9b284c9c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -25,7 +25,7 @@ import java.util.List; public interface MindmapManager { - Collaborator getCollaboratorBy(@NotNull String email); + Collaborator findCollaborator(@NotNull String email); Collaborator findCollaborator(long id); @@ -62,4 +62,6 @@ public interface MindmapManager { public List getHistoryFrom(int mindmapId); public MindMapHistory getHistory(int historyId); + + void updateCollaboration(@NotNull Collaboration collaboration); } diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 5e41a76e..7ccfe2b0 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -35,7 +35,7 @@ public class MindmapManagerImpl implements MindmapManager { @Override - public Collaborator getCollaboratorBy(final String email) { + public Collaborator findCollaborator(@NotNull final String email) { final Collaborator collaborator; final List collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email); if (collaborators != null && !collaborators.isEmpty()) { @@ -69,6 +69,11 @@ public class MindmapManagerImpl return getHibernateTemplate().get(MindMapHistory.class, historyId); } + @Override + public void updateCollaboration(@NotNull Collaboration collaboration) { + getHibernateTemplate().save(collaboration); + } + @Override public List search(MindMapCriteria criteria, int maxResult) { final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class); @@ -138,7 +143,7 @@ public class MindmapManagerImpl } @Override - public void addCollaborator(Collaborator collaborator) { + public void addCollaborator(@NotNull Collaborator collaborator) { assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!"; getHibernateTemplate().save(collaborator); } diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java index 68bd41e5..7303bc1f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java @@ -60,6 +60,7 @@ final public class NotificationService { model.put("baseUrl", formMail); model.put("senderMail", user.getEmail()); model.put("message", message); + model.put("supportEmail", mailer.getSupportEmail()); mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm"); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java index 39451cc4..11a580cf 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -222,12 +222,12 @@ public class MindMap { } public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException { - final CollaborationProperties collaborationProperties = getCollaborationProperties(collaborator); + final CollaborationProperties collaborationProperties = findCollaborationProperties(collaborator); collaborationProperties.setStarred(value); } @NotNull - public CollaborationProperties getCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException { + public CollaborationProperties findCollaborationProperties(@NotNull Collaborator collaborator) throws WiseMappingException { if (collaborator == null) { throw new IllegalStateException("Collaborator can not be null"); } 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 cc692e02..6e2195f6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -54,7 +54,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"}) @ResponseBody - public ModelAndView retrieve(@PathVariable int id) throws IOException { + public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException { final User user = Utils.getUser(); final MindMap mindMap = mindmapService.findMindmapById(id); final RestMindmap map = new RestMindmap(mindMap, user); @@ -64,7 +64,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/wisemapping+xml"}, params = {"download=wxml"}) @ResponseBody - public ModelAndView retrieveAsWise(@PathVariable int id) throws IOException { + public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException { final MindMap mindMap = mindmapService.findMindmapById(id); final Map values = new HashMap(); @@ -116,14 +116,14 @@ public class MindmapController extends BaseController { @RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateRevertMindmap(@PathVariable int id, @PathVariable int hid) throws IOException, WiseMappingException { + public void updateRevertMindmap(@PathVariable int id, @PathVariable int hid) throws WiseMappingException { final MindMap mindmap = mindmapService.findMindmapById(id); mindmapService.revertChange(mindmap, hid); } @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 { + public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException { final MindMap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); @@ -135,7 +135,7 @@ public class MindmapController extends BaseController { } // Update collaboration properties ... - final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user); + final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user); collaborationProperties.setMindmapProperties(properties); // Validate content ... @@ -187,7 +187,7 @@ public class MindmapController extends BaseController { // Update document properties ... final String properties = restMindmap.getProperties(); if (properties != null) { - final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(user); + final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user); collaborationProperties.setMindmapProperties(properties); } @@ -307,12 +307,17 @@ public class MindmapController extends BaseController { @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException { - final MindMap mindMap = mindmapService.findMindmapById(id); + final MindMap mindmap = mindmapService.findMindmapById(id); final User user = Utils.getUser(); // Update map status ... - mindMap.setStarred(user, Boolean.parseBoolean(value)); - saveMindmap(true, mindMap, user); + final boolean starred = Boolean.parseBoolean(value); + final Collaboration collaboration = mindmap.findCollaboration(user); + if (collaboration == null) { + throw new WiseMappingException("No enough permissions."); + } + collaboration.getCollaborationProperties().setStarred(starred); + mindmapService.updateCollaboration(user, collaboration); } @RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}") @@ -425,7 +430,7 @@ public class MindmapController extends BaseController { mindmapService.updateMindmap(mindMap, !minor); } - private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException { + private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws WiseMappingException { final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), ""); result.rejectValue(fieldName, "error.not-specified", null, message); return new ValidationException(result); diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java index 5321882f..26601b56 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java @@ -3,7 +3,6 @@ package com.wisemapping.rest.model; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.*; -import com.wisemapping.security.Utils; import org.codehaus.jackson.annotate.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,7 +46,7 @@ public class RestMindmap { this.mindmap = mindmap; this.collaborator = collaborator; if (collaborator != null) { - final CollaborationProperties collaborationProperties = mindmap.getCollaborationProperties(collaborator); + final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(collaborator); this.properties = collaborationProperties.getMindmapProperties(); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java index 9fda352e..ff38c5f5 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -28,38 +28,40 @@ import java.io.IOException; public interface MindmapService { - public static final String TAG_SEPARATOR = " "; + static final String TAG_SEPARATOR = " "; - public MindMap findMindmapById(int mindmapId); + MindMap findMindmapById(int mindmapId); - public MindMap getMindmapByTitle(String title, User user); + MindMap getMindmapByTitle(String title, User user); - public List findCollaborations(@NotNull User user); + List findCollaborations(@NotNull User user); - public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException; + void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException; - public void addMindmap(MindMap map, User user) throws WiseMappingException; + void addMindmap(MindMap map, User user) throws WiseMappingException; - public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) + void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) throws CollaborationException; - public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException; + void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException; - public void addTags(@NotNull MindMap mindmap, String tags); + void addTags(@NotNull MindMap mindmap, String tags); - public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException; + void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException; - public List search(MindMapCriteria criteria); + List search(MindMapCriteria criteria); - public List findMindmapHistory(int mindmapId); + List findMindmapHistory(int mindmapId); - public boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole); + boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole); - public boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); + boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); - public void addWelcomeMindmap(User user) throws WiseMappingException; + void addWelcomeMindmap(User user) throws WiseMappingException; - public void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException; + void revertChange(@NotNull MindMap map, int historyId) throws WiseMappingException; MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException; + + void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index f0aa8d38..451628a8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -187,7 +187,7 @@ public class MindmapServiceImpl private Collaborator addCollaborator(String email) { // Add a new collaborator ... - Collaborator collaborator = mindmapManager.getCollaboratorBy(email); + Collaborator collaborator = mindmapManager.findCollaborator(email); if (collaborator == null) { collaborator = new Collaborator(); collaborator.setEmail(email); @@ -219,6 +219,7 @@ public class MindmapServiceImpl } } + @Override public void addWelcomeMindmap(User user) throws WiseMappingException { final MindMap savedWelcome = findMindmapById(Constants.WELCOME_MAP_ID); @@ -233,10 +234,12 @@ public class MindmapServiceImpl } } + @Override public List findMindmapHistory(int mindmapId) { return mindmapManager.getHistoryFrom(mindmapId); } + @Override public void revertChange(@NotNull MindMap mindmap, int historyId) throws WiseMappingException { final MindMapHistory history = mindmapManager.getHistory(historyId); @@ -261,6 +264,14 @@ public class MindmapServiceImpl return result; } + @Override + public void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException { + if (collaborator.equals(collaboration.getCollaborator())) { + throw new WiseMappingException("No enough permissions for this operation."); + } + mindmapManager.updateCollaboration(collaboration); + } + private Collaboration getCollaborationBy(String email, Set collaborations) { Collaboration collaboration = null; diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index 0ecc46e9..59466d6e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -125,7 +125,7 @@ public class MindMapBean { } public String getProperties() throws WiseMappingException { - final CollaborationProperties collaboration = this.mindmap.getCollaborationProperties(collaborator); + final CollaborationProperties collaboration = this.mindmap.findCollaborationProperties(collaborator); return collaboration.getMindmapProperties(); } diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/newCollaboration.vm b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/newCollaboration.vm index b9532973..b693065c 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/newCollaboration.vm +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/newCollaboration.vm @@ -23,17 +23,19 @@
+

Message from ${senderMail}:

#if($message )
${message}
#end

Click to open: ${mindmap.title}

+

Do you have a WiseMapping account ?. Don't worry, you can create an account for free.

Important: Do not reply this email. If - you need to contact mindmap sender, you can send an email clicking here. + you need further help or have any concerns regarding your account, contact us to here.

\ No newline at end of file