From 2f52856ea189c65f1c94d0f49d441ca0de4ad160 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 16 Jun 2012 11:37:40 -0300 Subject: [PATCH] - Add custom message support --- .../java/com/wisemapping/mail/Mailer.java | 9 +- .../wisemapping/mail/NotificationService.java | 1 + .../ncontroller/MindmapController.java | 1 + .../wisemapping/rest/MindmapController.java | 3 +- .../rest/model/RestCollaborationList.java | 9 + .../wisemapping/service/MindmapService.java | 126 ++-- .../service/MindmapServiceImpl.java | 546 +++++++++--------- .../WEB-INF/classes/mail/newCollaboration.vm | 78 ++- .../src/main/webapp/jsp/mindmapShare.jsp | 62 +- 9 files changed, 437 insertions(+), 398 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java index cc0a9e3d..48dcd3c8 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java @@ -20,6 +20,7 @@ package com.wisemapping.mail; import org.apache.velocity.app.VelocityEngine; +import org.jetbrains.annotations.NotNull; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.mail.javamail.MimeMessagePreparator; @@ -53,7 +54,7 @@ public final class Mailer { } public void sendEmail(final String from, final String to, final String subject, final Map model, - final String templateMail) { + @NotNull final String templateMail) { final MimeMessagePreparator preparator = new MimeMessagePreparator() { public void prepare(MimeMessage mimeMessage) @@ -63,11 +64,7 @@ public final class Mailer { message.setFrom(from); message.setSubject(subject); - final String messageBody = - VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail, - model); - System.out.println(message); - + final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail, model); message.setText(messageBody, true); } }; 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 f46e2f18..6cbf012b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java @@ -59,6 +59,7 @@ final public class NotificationService { model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit"); model.put("baseUrl", formMail); model.put("senderMail", user.getEmail()); + model.put("message", message); mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm"); diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index 7bbd00e1..06bd9eed 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -1,3 +1,4 @@ + /* * Copyright [2011] [wisemapping] * 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 50f53120..578f1e67 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -227,9 +227,10 @@ public class MindmapController extends BaseController { // Is owner ? final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase()); if (role != CollaborationRole.OWNER) { - mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role); + mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role, restCollabs.getMessage()); } + // Remove from the list of pendings to remove ... if (collaboration != null) { collabsToRemove.remove(collaboration); } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java index 5604509a..b307a188 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java @@ -21,6 +21,7 @@ import java.util.*; public class RestCollaborationList { private List collaborations; + private String message; public RestCollaborationList() { collaborations = new ArrayList(); @@ -46,4 +47,12 @@ public class RestCollaborationList { public void setCollaborations(@NotNull List collaborations) { this.collaborations = collaborations; } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } } 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 024f170a..51ba0a5b 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -1,63 +1,63 @@ -/* -* 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.service; - -import com.wisemapping.model.*; -import com.wisemapping.exceptions.WiseMappingException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.io.IOException; - -public interface MindmapService { - - public static final String TAG_SEPARATOR = " "; - - public MindMap getMindmapById(int mindmapId); - - public MindMap getMindmapByTitle(String title, User user); - - public List getCollaborationsBy(@NotNull User user); - - public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException; - - public void addMindmap(MindMap map, User user) throws WiseMappingException; - - public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role) - throws CollaborationException; - - public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException; - - public void addTags(MindMap mindmap, String tags); - - public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException; - - public List search(MindMapCriteria criteria); - - public List getMindMapHistory(int mindmapId); - - public boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole); - - public boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); - - public void addWelcomeMindmap(User user) throws WiseMappingException; - - public void revertMapToHistory(MindMap map, int historyId) throws IOException, WiseMappingException; -} +/* +* 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.service; + +import com.wisemapping.model.*; +import com.wisemapping.exceptions.WiseMappingException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.io.IOException; + +public interface MindmapService { + + public static final String TAG_SEPARATOR = " "; + + public MindMap getMindmapById(int mindmapId); + + public MindMap getMindmapByTitle(String title, User user); + + public List getCollaborationsBy(@NotNull User user); + + public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException; + + public void addMindmap(MindMap map, User user) throws WiseMappingException; + + public 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; + + public void addTags(MindMap mindmap, String tags); + + public void removeMindmap(@NotNull final MindMap mindmap, @NotNull final User user) throws WiseMappingException; + + public List search(MindMapCriteria criteria); + + public List getMindMapHistory(int mindmapId); + + public boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole); + + public boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); + + public void addWelcomeMindmap(User user) throws WiseMappingException; + + public void revertMapToHistory(MindMap map, int historyId) throws IOException, 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 b92c97c0..0519cbfb 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -1,273 +1,273 @@ -/* -* 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.service; - -import com.wisemapping.dao.MindmapManager; -import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.mail.Mailer; -import com.wisemapping.mail.NotificationService; -import com.wisemapping.model.*; -import com.wisemapping.security.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -import java.io.IOException; -import java.util.*; - - -public class MindmapServiceImpl - implements MindmapService { - - @Autowired - private MindmapManager mindmapManager; - - @Autowired - @Qualifier("userService") - private UserService userService; - - @Autowired - private NotificationService notificationService; - - @Override - public boolean hasPermissions(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) { - final MindMap map = mindmapManager.getMindmapById(mapId); - return hasPermissions(user, map, grantedRole); - } - - @Override - public boolean hasPermissions(@Nullable User user, @Nullable MindMap map, @NotNull CollaborationRole role) { - boolean result = false; - if (map != null) { - if (map.isPublic() && role == CollaborationRole.VIEWER) { - result = true; - } else if (user != null) { - final Collaboration collaboration = map.findCollaboration(user); - if (collaboration != null) { - result = collaboration.hasPermissions(role); - } - - } - } - return result; - } - - @Override - public MindMap getMindmapByTitle(String title, User user) { - return mindmapManager.getMindmapByTitle(title, user); - } - - @Override - public MindMap getMindmapById(int mindmapId) { - return mindmapManager.getMindmapById(mindmapId); - } - - @Override - public List getCollaborationsBy(@NotNull User user) { - return mindmapManager.getMindmapUserByCollaborator(user.getId()); - } - - @Override - public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException { - if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) { - throw new WiseMappingException("The tile can not be empty"); - } - - mindmapManager.updateMindmap(mindMap, saveHistory); - } - - @Override - public List search(MindMapCriteria criteria) { - return mindmapManager.search(criteria); - } - - @Override - public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException { - // remove collaborator association - final MindMap mindMap = collaboration.getMindMap(); - final Set collaborations = mindMap.getCollaborations(); - - if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) { - throw new CollaborationException("User is the creator and must have ownership permissions"); - } - - // When you delete an object from hibernate you have to delete it from *all* collections it exists in... - mindmapManager.removeCollaboration(collaboration); - collaborations.remove(collaboration); - } - - @Override - public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException { - if (mindmap.getCreator().equals(user)) { - mindmapManager.removeMindmap(mindmap); - } else { - final Collaboration collaboration = mindmap.findCollaboration(user); - if (collaboration != null) { - this.removeCollaboration(mindmap, collaboration); - } - } - } - - @Override - public void addMindmap(@NotNull MindMap map, @NotNull User user) throws WiseMappingException { - - final String title = map.getTitle(); - - if (title == null || title.length() == 0) { - throw new IllegalArgumentException("The tile can not be empty"); - } - - if (user == null) { - throw new IllegalArgumentException("User can not be null"); - } - - final Calendar creationTime = Calendar.getInstance(); - final String username = user.getUsername(); - map.setLastModifierUser(username); - map.setCreationTime(creationTime); - map.setLastModificationTime(creationTime); - map.setCreator(user); - - // Add map creator with owner permissions ... - final User dbUser = userService.getUserBy(user.getId()); - final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map); - map.getCollaborations().add(collaboration); - - mindmapManager.addMindmap(dbUser, map); - } - - @Override - public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role) - throws CollaborationException { - - // Validate - final Collaborator owner = mindmap.getCreator(); - if (owner.getEmail().equals(email)) { - throw new CollaborationException("The user " + owner.getEmail() + " is the owner"); - } - - if (role == CollaborationRole.OWNER) { - throw new CollaborationException("Ownership can not be modified"); - - } - - final Set collaborations = mindmap.getCollaborations(); - Collaboration collaboration = getCollaborationBy(email, collaborations); - if (collaboration == null) { - final Collaborator collaborator = addCollaborator(email); - collaboration = new Collaboration(role, collaborator, mindmap); - mindmap.getCollaborations().add(collaboration); - mindmapManager.saveMindmap(mindmap); - - // Notify by email ... - final User user = Utils.getUser(); - notificationService.newCollaboration(collaboration, mindmap, user, null); - - } else if (collaboration.getRole() != role) { - // If the relationship already exists and the role changed then only update the role - collaboration.setRole(role); - mindmapManager.updateMindmap(mindmap, false); - } - } - - private Collaborator addCollaborator(String email) { - // Add a new collaborator ... - Collaborator collaborator = mindmapManager.getCollaboratorBy(email); - if (collaborator == null) { - collaborator = new Collaborator(); - collaborator.setEmail(email); - collaborator.setCreationDate(Calendar.getInstance()); - mindmapManager.addCollaborator(collaborator); - } - return collaborator; - } - - @Override - public void addTags(@NotNull MindMap mindmap, String tags) { - mindmap.setTags(tags); - mindmapManager.updateMindmap(mindmap, false); - if (tags != null && tags.length() > 0) { - final String tag[] = tags.split(TAG_SEPARATOR); - final User user = mindmap.getCreator(); - // Add new Tags to User - boolean updateUser = false; - for (String userTag : tag) { - if (!user.getTags().contains(userTag)) { - user.getTags().add(userTag); - updateUser = true; - } - } - if (updateUser) { - //update user - userService.updateUser(user); - } - } - } - - public void addWelcomeMindmap(User user) throws WiseMappingException { - final MindMap savedWelcome = getMindmapById(Constants.WELCOME_MAP_ID); - - // Is there a welcomed map configured ? - if (savedWelcome != null) { - final MindMap welcomeMap = new MindMap(); - welcomeMap.setTitle(savedWelcome.getTitle() + " " + user.getFirstname()); - welcomeMap.setDescription(savedWelcome.getDescription()); - welcomeMap.setXml(savedWelcome.getXml()); - - addMindmap(welcomeMap, user); - } - } - - public List getMindMapHistory(int mindmapId) { - return mindmapManager.getHistoryFrom(mindmapId); - } - - public void revertMapToHistory(MindMap map, int historyId) - throws IOException, WiseMappingException { - final MindMapHistory history = mindmapManager.getHistory(historyId); - map.setXml(history.getXml()); - updateMindmap(map, false); - } - - private Collaboration getCollaborationBy(String email, Set collaborations) { - Collaboration collaboration = null; - - for (Collaboration user : collaborations) { - if (user.getCollaborator().getEmail().equals(email)) { - collaboration = user; - break; - } - } - return collaboration; - } - - - public void setMindmapManager(MindmapManager mindmapManager) { - this.mindmapManager = mindmapManager; - } - - public void setUserService(UserService userService) { - this.userService = userService; - } - - public void setNotificationService(NotificationService notificationService) { - this.notificationService = notificationService; - } -} +/* +* 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.service; + +import com.wisemapping.dao.MindmapManager; +import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.mail.NotificationService; +import com.wisemapping.model.*; +import com.wisemapping.security.Utils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + +import java.io.IOException; +import java.util.*; + + +public class MindmapServiceImpl + implements MindmapService { + + @Autowired + private MindmapManager mindmapManager; + + @Autowired + @Qualifier("userService") + private UserService userService; + + @Autowired + private NotificationService notificationService; + + @Override + public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) { + final MindMap map = mindmapManager.getMindmapById(mapId); + return hasPermissions(user, map, grantedRole); + } + + @Override + public boolean hasPermissions(@Nullable User user, @Nullable MindMap map, @NotNull CollaborationRole role) { + boolean result = false; + if (map != null) { + if (map.isPublic() && role == CollaborationRole.VIEWER) { + result = true; + } else if (user != null) { + final Collaboration collaboration = map.findCollaboration(user); + if (collaboration != null) { + result = collaboration.hasPermissions(role); + } + + } + } + return result; + } + + @Override + public MindMap getMindmapByTitle(String title, User user) { + return mindmapManager.getMindmapByTitle(title, user); + } + + @Override + public MindMap getMindmapById(int mindmapId) { + return mindmapManager.getMindmapById(mindmapId); + } + + @Override + public List getCollaborationsBy(@NotNull User user) { + return mindmapManager.getMindmapUserByCollaborator(user.getId()); + } + + @Override + public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException { + if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) { + throw new WiseMappingException("The tile can not be empty"); + } + + mindmapManager.updateMindmap(mindMap, saveHistory); + } + + @Override + public List search(MindMapCriteria criteria) { + return mindmapManager.search(criteria); + } + + @Override + public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException { + // remove collaborator association + final MindMap mindMap = collaboration.getMindMap(); + final Set collaborations = mindMap.getCollaborations(); + + if (mindMap.getCreator().getEmail().equals(collaboration.getCollaborator().getEmail())) { + throw new CollaborationException("User is the creator and must have ownership permissions"); + } + + // When you delete an object from hibernate you have to delete it from *all* collections it exists in... + mindmapManager.removeCollaboration(collaboration); + collaborations.remove(collaboration); + } + + @Override + public void removeMindmap(@NotNull MindMap mindmap, @NotNull User user) throws WiseMappingException { + if (mindmap.getCreator().equals(user)) { + mindmapManager.removeMindmap(mindmap); + } else { + final Collaboration collaboration = mindmap.findCollaboration(user); + if (collaboration != null) { + this.removeCollaboration(mindmap, collaboration); + } + } + } + + @Override + public void addMindmap(@NotNull MindMap map, @NotNull User user) throws WiseMappingException { + + final String title = map.getTitle(); + + if (title == null || title.length() == 0) { + throw new IllegalArgumentException("The tile can not be empty"); + } + + //noinspection ConstantConditions + if (user == null) { + throw new IllegalArgumentException("User can not be null"); + } + + final Calendar creationTime = Calendar.getInstance(); + final String username = user.getUsername(); + map.setLastModifierUser(username); + map.setCreationTime(creationTime); + map.setLastModificationTime(creationTime); + map.setCreator(user); + + // Add map creator with owner permissions ... + final User dbUser = userService.getUserBy(user.getId()); + final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map); + map.getCollaborations().add(collaboration); + + mindmapManager.addMindmap(dbUser, map); + } + + @Override + public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role, @Nullable String message) + throws CollaborationException { + + // Validate + final Collaborator owner = mindmap.getCreator(); + if (owner.getEmail().equals(email)) { + throw new CollaborationException("The user " + owner.getEmail() + " is the owner"); + } + + if (role == CollaborationRole.OWNER) { + throw new CollaborationException("Ownership can not be modified"); + + } + + final Set collaborations = mindmap.getCollaborations(); + Collaboration collaboration = getCollaborationBy(email, collaborations); + if (collaboration == null) { + final Collaborator collaborator = addCollaborator(email); + collaboration = new Collaboration(role, collaborator, mindmap); + mindmap.getCollaborations().add(collaboration); + mindmapManager.saveMindmap(mindmap); + + // Notify by email ... + final User user = Utils.getUser(); + notificationService.newCollaboration(collaboration, mindmap, user, message); + + } else if (collaboration.getRole() != role) { + // If the relationship already exists and the role changed then only update the role + collaboration.setRole(role); + mindmapManager.updateMindmap(mindmap, false); + } + } + + private Collaborator addCollaborator(String email) { + // Add a new collaborator ... + Collaborator collaborator = mindmapManager.getCollaboratorBy(email); + if (collaborator == null) { + collaborator = new Collaborator(); + collaborator.setEmail(email); + collaborator.setCreationDate(Calendar.getInstance()); + mindmapManager.addCollaborator(collaborator); + } + return collaborator; + } + + @Override + public void addTags(@NotNull MindMap mindmap, String tags) { + mindmap.setTags(tags); + mindmapManager.updateMindmap(mindmap, false); + if (tags != null && tags.length() > 0) { + final String tag[] = tags.split(TAG_SEPARATOR); + final User user = mindmap.getCreator(); + // Add new Tags to User + boolean updateUser = false; + for (String userTag : tag) { + if (!user.getTags().contains(userTag)) { + user.getTags().add(userTag); + updateUser = true; + } + } + if (updateUser) { + //update user + userService.updateUser(user); + } + } + } + + public void addWelcomeMindmap(User user) throws WiseMappingException { + final MindMap savedWelcome = getMindmapById(Constants.WELCOME_MAP_ID); + + // Is there a welcomed map configured ? + if (savedWelcome != null) { + final MindMap welcomeMap = new MindMap(); + welcomeMap.setTitle(savedWelcome.getTitle() + " " + user.getFirstname()); + welcomeMap.setDescription(savedWelcome.getDescription()); + welcomeMap.setXml(savedWelcome.getXml()); + + addMindmap(welcomeMap, user); + } + } + + public List getMindMapHistory(int mindmapId) { + return mindmapManager.getHistoryFrom(mindmapId); + } + + public void revertMapToHistory(MindMap map, int historyId) + throws IOException, WiseMappingException { + final MindMapHistory history = mindmapManager.getHistory(historyId); + map.setXml(history.getXml()); + updateMindmap(map, false); + } + + private Collaboration getCollaborationBy(String email, Set collaborations) { + Collaboration collaboration = null; + + for (Collaboration user : collaborations) { + if (user.getCollaborator().getEmail().equals(email)) { + collaboration = user; + break; + } + } + return collaboration; + } + + + public void setMindmapManager(MindmapManager mindmapManager) { + this.mindmapManager = mindmapManager; + } + + public void setUserService(UserService userService) { + this.userService = userService; + } + + public void setNotificationService(NotificationService notificationService) { + this.notificationService = notificationService; + } +} 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 c1181a40..b9532973 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 @@ -1,41 +1,39 @@ - - -
-
- - - - - - - -
- - WiseMapping Log - - - I've shared - ${mindmap.title} mindmap with you. -
-
-
- #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. -

- + + +
+
+ + + + + + + +
+ + WiseMapping Log + + + I've shared + ${mindmap.title} mindmap with you. +
+
+
+ #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. +

+ \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp b/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp index 9c03adf1..471e5aa5 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapShare.jsp @@ -13,13 +13,26 @@ } #collabEmails { - float: left; width: 300px; + display: inline-block; + vertical-align: middle; + margin-bottom: 0; } #roleBtn { - float: left; - margin: 0px 10px; + margin: 0 10px; + display: inline-block; + vertical-align: middle; + } + + #addBtn { + display: inline-block; + vertical-align: middle; + } + + #collabMessage { + display: block; + width: 100%; } @@ -38,25 +51,43 @@
-

Add People:

- +
-
- Can edit - - - +

Add People:

+ + + + + +
+
+

Notify people via email - Add message

+
-
+