diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java
index 7ccf6f32..1604b531 100644
--- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java
+++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java
@@ -36,8 +36,7 @@ public class UserManagerImpl
private PasswordEncoder passwordEncoder;
- public void setEncoder(PasswordEncoder passwordEncoder)
- {
+ public void setEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
@@ -47,14 +46,12 @@ public class UserManagerImpl
@Override
- public User getUserBy(final String email) {
- final User user;
- final List users = getHibernateTemplate().find("from com.wisemapping.model.User colaborator where email=?", email);
+ public User getUserBy(@NotNull final String email) {
+ User user = null;
+ final List users = getHibernateTemplate().find("from com.wisemapping.model.User colaborator where email=?", email);
if (users != null && !users.isEmpty()) {
assert users.size() == 1 : "More than one user with the same email!";
- user = (User) users.get(0);
- } else {
- user = null;
+ user = users.get(0);
}
return user;
}
@@ -100,13 +97,13 @@ public class UserManagerImpl
@Override
public void createUser(User user) {
assert user != null : "Trying to store a null user";
- user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
+ user.setPassword(passwordEncoder.encodePassword(user.getPassword(), null));
getHibernateTemplate().saveOrUpdate(user);
}
@Override
public User createUser(@NotNull User user, @NotNull Collaborator col) {
- user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
+ user.setPassword(passwordEncoder.encodePassword(user.getPassword(), null));
assert user != null : "Trying to store a null user";
final Set set = col.getCollaborations();
@@ -139,7 +136,7 @@ public class UserManagerImpl
public void updateUser(User user) {
assert user != null : "user is null";
- user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
+ user.setPassword(passwordEncoder.encodePassword(user.getPassword(), null));
getHibernateTemplate().update(user);
}
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 b02214c7..cc0a9e3d 100644
--- a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java
+++ b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java
@@ -39,19 +39,16 @@ public final class Mailer {
//~ Methods ..............................................................................................
- public Mailer(String registrationEmail, String siteEmail)
- {
+ public Mailer(String registrationEmail, String siteEmail) {
this.registrationEmail = registrationEmail;
this.siteEmail = siteEmail;
}
- public String getRegistrationEmail()
- {
+ public String getRegistrationEmail() {
return registrationEmail;
}
- public String getSiteEmail()
- {
+ public String getSiteEmail() {
return siteEmail;
}
@@ -66,11 +63,12 @@ public final class Mailer {
message.setFrom(from);
message.setSubject(subject);
- final String text =
+ final String messageBody =
VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/mail/" + templateMail,
model);
+ System.out.println(message);
- message.setText(text, true);
+ 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
new file mode 100644
index 00000000..c48201ae
--- /dev/null
+++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java
@@ -0,0 +1,83 @@
+/*
+* 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.mail;
+
+import com.wisemapping.model.Collaboration;
+import com.wisemapping.model.MindMap;
+import com.wisemapping.model.User;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.HashMap;
+import java.util.Map;
+
+final public class NotificationService {
+
+
+ @Autowired
+ private Mailer mailer;
+ private String baseUrl;
+
+ public NotificationService() {
+
+ }
+
+ public void newCollaboration(@NotNull Collaboration collaboration, @NotNull MindMap mindmap, @NotNull User user, @Nullable String message) {
+
+ try {
+ // Sent collaboration email ...
+ final String formMail = mailer.getSiteEmail();
+
+ // Is the user already registered user ?.
+ final String collabEmail = collaboration.getCollaborator().getEmail();
+
+ // Build the subject ...
+ final String subject = user.getFullName() + " has shared a mindmap with you";
+
+ // Fill template properties ...
+ final Map model = new HashMap();
+ model.put("mindmap", mindmap);
+ model.put("message", "message");
+ model.put("ownerName", user.getFirstname());
+ model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
+ model.put("baseUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
+
+ mailer.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
+ } catch (Exception e) {
+ handleException(e);
+ }
+
+ }
+
+ private void handleException(Exception e) {
+ e.printStackTrace();
+ }
+
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl;
+ }
+
+ public void setMailer(Mailer mailer) {
+ this.mailer = mailer;
+ }
+
+
+}
+
diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java
index eafd4ec0..13e6b97a 100644
--- a/wise-webapp/src/main/java/com/wisemapping/model/User.java
+++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java
@@ -45,6 +45,10 @@ public class User
return tags;
}
+ public String getFullName() {
+ return this.getFirstname() + " " + this.getLastname();
+ }
+
public String getFirstname() {
return firstname;
}
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 8cf7ecb8..50f53120 100644
--- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java
+++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java
@@ -238,7 +238,7 @@ public class MindmapController extends BaseController {
// Remove all collaborations that no applies anymore ..
for (final Collaboration collaboration : collabsToRemove) {
- mindmapService.removeCollaboration(collaboration);
+ mindmapService.removeCollaboration(mindMap, collaboration);
}
}
diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java
index 63902ccb..65d91af7 100755
--- a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java
+++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java
@@ -25,6 +25,8 @@ import com.wisemapping.exceptions.UnexpectedArgumentException;
import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService;
import org.aopalliance.intercept.MethodInvocation;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public abstract class BaseSecurityAdvice {
private MindmapService mindmapService = null;
@@ -47,9 +49,9 @@ public abstract class BaseSecurityAdvice {
}
}
- protected abstract boolean isAllowed(User user, MindMap map);
+ protected abstract boolean isAllowed(@Nullable User user, MindMap map);
- protected abstract boolean isAllowed(User user, int mapId);
+ protected abstract boolean isAllowed(@Nullable User user, int mapId);
protected MindmapService getMindmapService() {
return mindmapService;
diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java
index dd3083f8..116f58aa 100755
--- a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java
+++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java
@@ -25,6 +25,7 @@ import com.wisemapping.model.MindMap;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class UpdateSecurityAdvise
extends BaseSecurityAdvice
@@ -35,7 +36,7 @@ public class UpdateSecurityAdvise
return methodInvocation.proceed();
}
- protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) {
+ protected boolean isAllowed(@Nullable User user, @NotNull MindMap map) {
boolean result;
if (map.getCreator() == null) {
// This means that the map is new and is an add operation.
@@ -46,7 +47,7 @@ public class UpdateSecurityAdvise
return result;
}
- protected boolean isAllowed(User user, int mapId) {
+ protected boolean isAllowed(@Nullable User user, int mapId) {
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
}
}
diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java
index 14df1e16..c5fddfce 100755
--- a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java
+++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java
@@ -34,11 +34,11 @@ public class ViewBaseSecurityAdvise
return methodInvocation.proceed();
}
- protected boolean isAllowed(User user, MindMap map) {
+ protected boolean isAllowed(@NotNull User user, MindMap map) {
return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER);
}
- protected boolean isAllowed(User user, int mapId) {
+ protected boolean isAllowed(@NotNull User user, int mapId) {
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER);
}
}
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 f62a3249..024f170a 100755
--- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java
+++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java
@@ -21,6 +21,7 @@ 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;
@@ -42,7 +43,7 @@ public interface MindmapService {
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
throws CollaborationException;
- public void removeCollaboration(@NotNull Collaboration collaboration) throws CollaborationException;
+ public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException;
public void addTags(MindMap mindmap, String tags);
@@ -52,9 +53,9 @@ public interface MindmapService {
public List getMindMapHistory(int mindmapId);
- public boolean hasPermissions(User user, MindMap map, CollaborationRole allowedRole);
+ public boolean hasPermissions(@Nullable User user, MindMap map, CollaborationRole allowedRole);
- public boolean hasPermissions(User user, int mapId, CollaborationRole allowedRole);
+ public boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
public void addWelcomeMindmap(User user) 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 90bab924..b92c97c0 100755
--- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java
+++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java
@@ -21,9 +21,13 @@ 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.*;
@@ -32,9 +36,15 @@ import java.util.*;
public class MindmapServiceImpl
implements MindmapService {
+ @Autowired
private MindmapManager mindmapManager;
+
+ @Autowired
+ @Qualifier("userService")
private UserService userService;
- private Mailer mailer;
+
+ @Autowired
+ private NotificationService notificationService;
@Override
public boolean hasPermissions(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) {
@@ -89,7 +99,7 @@ public class MindmapServiceImpl
}
@Override
- public void removeCollaboration(@NotNull Collaboration collaboration) throws CollaborationException {
+ public void removeCollaboration(@NotNull MindMap mindmap, @NotNull Collaboration collaboration) throws CollaborationException {
// remove collaborator association
final MindMap mindMap = collaboration.getMindMap();
final Set collaborations = mindMap.getCollaborations();
@@ -110,7 +120,7 @@ public class MindmapServiceImpl
} else {
final Collaboration collaboration = mindmap.findCollaboration(user);
if (collaboration != null) {
- this.removeCollaboration(collaboration);
+ this.removeCollaboration(mindmap, collaboration);
}
}
}
@@ -166,16 +176,9 @@ public class MindmapServiceImpl
mindmap.getCollaborations().add(collaboration);
mindmapManager.saveMindmap(mindmap);
- try {
- // Sent collaboration email ...
- final Map model = new HashMap();
- model.put("role", role);
- model.put("map", mindmap);
- model.put("message", "message");
- mailer.sendEmail(mailer.getSiteEmail(), email, "Collaboration", model, "newColaborator.vm");
- } catch (Exception e) {
- e.printStackTrace();
- }
+ // 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
@@ -264,7 +267,7 @@ public class MindmapServiceImpl
this.userService = userService;
}
- public void setMailer(Mailer mailer) {
- this.mailer = mailer;
+ public void setNotificationService(NotificationService notificationService) {
+ this.notificationService = notificationService;
}
}
diff --git a/wise-webapp/src/main/webapp/WEB-INF/app.properties b/wise-webapp/src/main/webapp/WEB-INF/app.properties
index 1022c535..204712c4 100755
--- a/wise-webapp/src/main/webapp/WEB-INF/app.properties
+++ b/wise-webapp/src/main/webapp/WEB-INF/app.properties
@@ -24,33 +24,21 @@ database.password=
#------------------------
# Plain SMTP Server Configuration
#------------------------
-#mail.smtp.socketFactory.class=javax.net.DefaultSocketFactory
-#mail.smtp.socketFactory.port=25
-#mail.smtp.auth = false
-#mail.host=localhost
-#mail.user=
-#mail.password=
#------------------------
# SSL SMTP Server Configuration
#------------------------
-# mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
-#mail.smtp.socketFactory.port=465
-#mail.smtp.auth = false
-#mail.host=localhost
-#mail.user=
-#mail.password=
#------------------------
# GMAIL SMTP Configuration
#------------------------
-mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
-mail.smtp.socketFactory.port=587
-mail.smtp.auth = true
-mail.host=smtp.gmail.com
-mail.user=example@gmail.com
-mail.password=
+mail.smtp.port=587
+mail.smtp.host=smtp.gmail.com
+mail.username=pveiga@gmail.com
+mail.password=p0w3rwdgg
+mail.smtp.auth=true
mail.smtp.starttls.enable=true
+mail.smtp.quitwait=false
#------------------------
# Domain address
diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties
index fd586b37..e415a7a2 100644
--- a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties
+++ b/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties
@@ -1,6 +1,6 @@
log4j.rootLogger=WARN, stdout, R
log4j.logger.com.wisemapping=WARN,stdout,R
-log4j.logger.org.springframework=DEBUG,stdout,R
+log4j.logger.org.springframework=WARN,stdout,R
log4j.logger.org.codehaus.jackson=WARN,stdout,R
log4j.additivity.org.hibernate.SQL=false
diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/activationAccountMail.vm b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/activationAccountMail.vm
index 6c8b0d75..f53ea2d6 100644
--- a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/activationAccountMail.vm
+++ b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/activationAccountMail.vm
@@ -1,22 +1,41 @@
-Welcome to WiseMapping!
-
- Your account has been activated.
- First Name: ${user.firstname}
- Last Name: ${user.lastname}
- Username: ${user.username}
-
-
- Thank you for using WiseMapping.
-
-
- For questions or concerns regarding your account, send us an email to support@wisemapping.com.
-
-
-Best regards,
-WiseMapping Team
-WiseMapping Site
-
+
+
+
+ Click to open:
+
+
Google Docs makes it easy to create, store and share online documents, spreadsheets and presentations.
+
+
+
+
\ No newline at end of file
diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/confirmationMail.vm b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/confirmationMail.vm
index be44896c..0600d055 100644
--- a/wise-webapp/src/main/webapp/WEB-INF/classes/mail/confirmationMail.vm
+++ b/wise-webapp/src/main/webapp/WEB-INF/classes/mail/confirmationMail.vm
@@ -1,24 +1,29 @@
Welcome to WiseMapping!
+
- To active your account and verify your e-mail address, please click on the following link.
+ To active your account and verify your e-mail address, please click on the following link.
- ${emailcheck}
+${emailcheck}
- If you have received this mail by error, you do not need to take any action to cancel the account. The account will not be activated, and you will not receive any futher emails.
+ If you have received this mail by error, you do not need to take any action to cancel the account. The account will
+ not be activated, and you will not receive any futher emails.
+
- If clicking the link above does not work, copy and paste the URL in a new browser window instead.
+ If clicking the link above does not work, copy and paste the URL in a new browser window instead.
+
- For questions or concerns regarding your account, send us an email to support@wisemapping.com.
+ For questions or concerns regarding your account, send us an email to support@wisemapping.com.
+
-Cheers,
-The WiseMapping Team.
-WiseMapping Site
+ Cheers,
+ The WiseMapping Team.
+ WiseMapping Site
-
\ No newline at end of file
+