Add welcome message on creation ...

This commit is contained in:
Paulo Gustavo Veiga 2012-07-13 21:07:51 -03:00
parent 86fca31251
commit b05e25b43f
7 changed files with 108 additions and 21 deletions

View File

@ -25,4 +25,10 @@ public class WiseMappingException
{ {
super(str); super(str);
} }
public WiseMappingException(String str,Exception e)
{
super(str);
initCause(e);
}
} }

View File

@ -20,14 +20,10 @@ package com.wisemapping.model;
public class Constants { public class Constants {
public static int WELCOME_MAP_ID =49 ;
public static final int MAX_MAP_NAME_LENGTH = 512; public static final int MAX_MAP_NAME_LENGTH = 512;
public static final int MAX_MAP_DESCRIPTION_LENGTH = 512; public static final int MAX_MAP_DESCRIPTION_LENGTH = 512;
public static final int MAX_USER_USERNAME_LENGTH = 255; public static final int MAX_USER_USERNAME_LENGTH = 255;
public static final int MAX_USER_LASTNAME_LENGTH = 255; public static final int MAX_USER_LASTNAME_LENGTH = 255;
public static final int MAX_USER_FIRSTNAME_LENGTH = 255; public static final int MAX_USER_FIRSTNAME_LENGTH = 255;
public static final int MAX_USER_PASSWORD_LENGTH = 255; public static final int MAX_USER_PASSWORD_LENGTH = 255;
public static final int MAX_COMMENT_LENGTH = 512;
public static final int MAX_SUBJECT_LENGTH = 100;
public static final int MAX_TAGS_LENGTH=1014;
} }

View File

@ -57,8 +57,6 @@ public interface MindmapService {
boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole); boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
void addWelcomeMindmap(User user) throws WiseMappingException;
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; MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException;

View File

@ -219,20 +219,7 @@ public class MindmapServiceImpl
} }
} }
@Override
public void addWelcomeMindmap(User user) throws WiseMappingException {
final MindMap savedWelcome = findMindmapById(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);
}
}
@Override @Override
public List<MindMapHistory> findMindmapHistory(int mindmapId) { public List<MindMapHistory> findMindmapHistory(int mindmapId) {

View File

@ -23,10 +23,17 @@ import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.mail.NotificationService; import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.AccessAuditory; import com.wisemapping.model.AccessAuditory;
import com.wisemapping.model.Collaborator; import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
public class UserServiceImpl public class UserServiceImpl
@ -34,6 +41,8 @@ public class UserServiceImpl
private UserManager userManager; private UserManager userManager;
private MindmapService mindmapService; private MindmapService mindmapService;
private NotificationService notificationService; private NotificationService notificationService;
private MessageSource messageSource;
@Override @Override
public void activateAccount(long code) public void activateAccount(long code)
@ -119,7 +128,8 @@ public class UserServiceImpl
} }
//create welcome map //create welcome map
mindmapService.addWelcomeMindmap(user); final MindMap mindMap = buildWelcomeMindmap(user.getFirstname());
mindmapService.addMindmap(mindMap, user);
// Send registration email. // Send registration email.
if (emailConfirmEnabled) { if (emailConfirmEnabled) {
@ -132,6 +142,29 @@ public class UserServiceImpl
return user; return user;
} }
private MindMap buildWelcomeMindmap(@NotNull String username) throws WiseMappingException {
//To change body of created methods use File | Settings | File Templates.
final Locale locale = LocaleContextHolder.getLocale();
MindMap result = new MindMap();
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
InputStream resourceAsStream = contextClassLoader.getResourceAsStream("samples/welcome_" + locale.toString() + ".xml");
if (resourceAsStream == null) {
resourceAsStream = contextClassLoader.getResourceAsStream("samples/welcome_en.xml");
}
try {
final byte[] bytes = IOUtils.toByteArray(resourceAsStream);
result.setXml(bytes);
result.setTitle(messageSource.getMessage("WELCOME", null, locale) + " " + username);
result.setDescription("");
} catch (IOException e) {
throw new WiseMappingException("Could not be loaded", e);
}
return result;
}
@Override @Override
public void changePassword(@NotNull User user) { public void changePassword(@NotNull User user) {
notificationService.passwordChanged(user); notificationService.passwordChanged(user);
@ -169,4 +202,8 @@ public class UserServiceImpl
public void setNotificationService(NotificationService notificationService) { public void setNotificationService(NotificationService notificationService) {
this.notificationService = notificationService; this.notificationService = notificationService;
} }
public void setMessageSource(@NotNull MessageSource messageSource) {
this.messageSource = messageSource;
}
} }

View File

@ -0,0 +1,53 @@
<map name="welcome" version="tango">
<topic central="true" text="Welcome To WiseMapping" id="1" fontStyle=";;#eeeeee;;;" bgColor="#0a0a08">
<topic position="179,-130" order="0" id="11" fontStyle=";;#444444;;;" bgColor="#250be3" brColor="#080559">
<text><![CDATA[Easy to use Try it Now!]]></text>
<topic position="294,-156" order="0" id="12" fontStyle=";;#444444;;italic;">
<text><![CDATA[Double Click To Create new Topics!]]></text>
</topic>
<topic position="305,-126" order="1" text="Start typing to edit the text" id="13"
fontStyle=";;#444444;;italic;"/>
<topic position="287,-100" order="2" text="Drag map to move" id="14" fontStyle=";;#444444;;italic;"/>
</topic>
<topic position="-172,-39" order="1" text="Web Tool" id="22" fontStyle=";;#444444;;;" bgColor="#add1f7">
<topic position="-256,-78" order="0" text="Shortcuts" id="26" fontStyle=";;#444444;;;"/>
<topic position="-280,-52" order="1" text="No plugin required" id="24" fontStyle=";;#444444;;;">
<icon id="conn_disconnect"/>
</topic>
<topic position="-265,-26" order="2" text="Collaborate" id="23" fontStyle=";;#444444;;;">
<icon id="people_group"/>
</topic>
<topic position="-249,0" order="3" text="Share" id="25" fontStyle=";;#444444;;;"/>
</topic>
<topic position="185,-35" order="2" text="Mind Mapping" id="6" fontStyle=";;#444444;;;" bgColor="#edabff">
<topic position="303,-74" order="0" text="Share with Colleagues" id="7" fontStyle=";;#444444;;;"/>
<topic position="275,-48" order="1" text="Online" id="8" fontStyle=";;#444444;;;"/>
<topic position="299,-22" order="2" text="Anyplace, Anytime" id="9" fontStyle=";;#444444;;;"/>
<topic position="277,4" order="3" text="Free!!!" id="10" fontStyle=";;#444444;;;"/>
</topic>
<topic position="-189,52" order="3" text="Productivity" id="2" fontStyle=";;#444444;;;" bgColor="#d9b518">
<icon id="chart_bar"/>
<topic position="-310,26" order="0" text="Share your ideas" id="3" fontStyle=";;#444444;;;">
<icon id="bulb_light_on"/>
</topic>
<topic position="-299,52" order="1" text="Brainstorming" id="4" fontStyle=";;#444444;;;"/>
<topic position="-283,78" order="2" text="Visual " id="5" fontStyle=";;#444444;;;"/>
</topic>
<topic position="171,96" order="4" text="Features" id="15" fontStyle=";;#444444;;;">
<topic position="267,31" order="0" text="Links to Sites" id="16" fontStyle=";6;#444444;;;">
<link url="http://www.digg.com" type="url"/>
</topic>
<topic position="246,57" order="1" text="Fonts" id="17" fontStyle=";;#444444;;;"/>
<topic position="256,83" order="2" text="Topic Color" id="18" fontStyle=";;#444444;;;"/>
<topic position="252,135" order="4" text="Icons" id="20" fontStyle=";;#444444;;;">
<icon id="object_rainbow"/>
</topic>
<topic position="273,161" order="5" text="History Changes" id="21" fontStyle=";;#444444;;;">
<icon id="arrowc_turn_left"/>
</topic>
<topic position="260,109" order="3" text="Topic Shapes" shape="line" id="19" fontStyle=";;#444444;;;"/>
</topic>
</topic>
<relationship srcTopicId="26" destTopicId="11" lineType="3" srcCtrlPoint="96,-81" destCtrlPoint="-167,-40"
endArrow="true" startArrow="false"/>
</map>

View File

@ -15,6 +15,8 @@
<property name="userManager" ref="userManager"/> <property name="userManager" ref="userManager"/>
<property name="mindmapService" ref="mindMapServiceTarget"/> <property name="mindmapService" ref="mindMapServiceTarget"/>
<property name="notificationService" ref="notificationService"/> <property name="notificationService" ref="notificationService"/>
<property name="messageSource" ref="messageSource"/>
</bean> </bean>
<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
@ -77,4 +79,12 @@
<property name="mailer" ref="mailer"/> <property name="mailer" ref="mailer"/>
</bean> </bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
</beans> </beans>