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 b7c86d97..8040ec71 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java @@ -21,6 +21,7 @@ package com.wisemapping.mail; import com.wisemapping.model.Collaboration; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; +import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; @@ -137,16 +138,17 @@ final public class NotificationService { } public void sendRegistrationEmail(@NotNull User user) { - try { - final Map model = new HashMap(); - model.put("user", user); - final String activationUrl = "http://wisemapping.com/c/activation?code=" + user.getActivationCode(); - model.put("emailcheck", activationUrl); - mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), "Welcome to Wisemapping!", model, - "confirmationMail.vm"); - } catch (Exception e) { - handleException(e); - } + throw new UnsupportedOperationException("Not implemented yet"); +// try { +// final Map model = new HashMap(); +// model.put("user", user); +// final String activationUrl = "http://wisemapping.com/c/activation?code=" + user.getActivationCode(); +// model.put("emailcheck", activationUrl); +// mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), "Welcome to Wisemapping!", model, +// "confirmationMail.vm"); +// } catch (Exception e) { +// handleException(e); +// } } public void reportMindmapEditorError(@NotNull MindMap mindmap, @NotNull User user, @NotNull String userAgent, @Nullable String jsErrorMsg) { @@ -198,11 +200,8 @@ final public class NotificationService { e.printStackTrace(pw); retValue = sw.toString(); } finally { - try { - if (pw != null) pw.close(); - if (sw != null) sw.close(); - } catch (IOException ignore) { - } + IOUtils.closeQuietly(pw); + IOUtils.closeQuietly(sw); } return retValue; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java index ec94c9d1..7251061b 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java @@ -26,15 +26,16 @@ import com.wisemapping.model.Collaborator; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; import org.apache.commons.io.IOUtils; +import org.apache.velocity.app.VelocityEngine; import org.jetbrains.annotations.NotNull; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.ui.velocity.VelocityEngineUtils; import java.io.IOException; import java.io.InputStream; -import java.util.Calendar; -import java.util.Locale; -import java.util.UUID; +import java.io.UnsupportedEncodingException; +import java.util.*; public class UserServiceImpl implements UserService { @@ -42,6 +43,7 @@ public class UserServiceImpl private MindmapService mindmapService; private NotificationService notificationService; private MessageSource messageSource; + private VelocityEngine velocityEngine; @Override @@ -131,6 +133,7 @@ public class UserServiceImpl final MindMap mindMap = buildWelcomeMindmap(user.getFirstname()); mindmapService.addMindmap(mindMap, user); + // Send registration email. if (emailConfirmEnabled) { notificationService.sendRegistrationEmail(user); @@ -142,24 +145,27 @@ public class UserServiceImpl return user; } - private MindMap buildWelcomeMindmap(@NotNull String firstName) throws WiseMappingException { + public MindMap buildWelcomeMindmap(@NotNull String firstName) { //To change body of created methods use File | Settings | File Templates. - final Locale locale = LocaleContextHolder.getLocale(); - MindMap result = new MindMap(); + Locale locale = LocaleContextHolder.getLocale(); + + // @TODO: Remove this once is translated + locale = Locale.ENGLISH; + MindMap result = new MindMap(); + final Map model = new HashMap(); + model.put("messages", messageSource); + model.put("noArgs", new Object[]{}); + model.put("locale", locale); + + final String mapXml = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "/samples/tutorial.vm", model); - 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.setXmlStr(mapXml); result.setTitle(messageSource.getMessage("WELCOME", null, locale) + " " + firstName); result.setDescription(""); } catch (IOException e) { - throw new WiseMappingException("Could not be loaded", e); + e.printStackTrace(); } return result; @@ -201,4 +207,8 @@ public class UserServiceImpl public void setMessageSource(@NotNull MessageSource messageSource) { this.messageSource = messageSource; } + + public void setVelocityEngine(VelocityEngine velocityEngine) { + this.velocityEngine = velocityEngine; + } } diff --git a/wise-webapp/src/main/resources/samples/tutorial.vm b/wise-webapp/src/main/resources/samples/tutorial.vm new file mode 100644 index 00000000..0b6ba308 --- /dev/null +++ b/wise-webapp/src/main/resources/samples/tutorial.vm @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wise-webapp/src/main/resources/samples/welcome_en.xml b/wise-webapp/src/main/resources/samples/welcome_en.xml deleted file mode 100644 index a95074be..00000000 --- a/wise-webapp/src/main/resources/samples/welcome_en.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties index 6c26983c..6e04ac36 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties @@ -210,5 +210,17 @@ COPY_AND_PASTE_TOPICS=Copy and Page Topics MULTIPLE_LINES=Add multiple text lines TERM_OF_USE=Terms and Conditions - +# Properties used on the tutorial mindmap .... +TUTORIAL.MULTIPLE_TEXT_STYLES=Multitple Text Styles +TUTORIAL.DIFFERENT_SHAPES=Different Shapes +TUTORIAL.FANCY_ICONS=Fancy Icons +TUTORIAL.MOVE_WITH_ARROWS=Move Between Topics\nWith The Arrows +TUTORIAL.START_TYPING_TO_EDIT_TEXT=Start Typing to Edit Text +TUTORIAL.CTRL_TO_ADD_CHILD=Press Ctrl/Meta+Enter to Add Child Topic +TUTORIAL.ENTER_TO_ADD_SIBLING=Press Enter to Add a Sibling Topic +TUTORIAL.MORE_KEY_TIPS=More ... ?. Click on shortcuts above +TUTORIAL.DOUBLE_CLICK_TO_ADD=Double Click on the Canvas to Create Topics +TUTORIAL.DRAG_AND_DROP_TO_POSITION=Drag and Drop Topics Position +TUTORIAL.DOUBLE_CLICK_TO_EDIT_TEXT=Double Click on a Topic to Edit the Text +TUTORIAL.ADD_NOTES=Add Notes diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml index 3d015d26..d6ac02cb 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml @@ -16,7 +16,7 @@ - +