/** {@inheritDoc} */ @Override public void sendAccountActivationMail(User recipient) { VelocityContext veloContext = new VelocityContext(); ResourceBundle mailBoundle = ResourceBundle.getBundle(MAIL_MESSAGES_TEMPLATES_PATH, recipient.getLanguage().getLocale()); String appName = mailBoundle.getString("application_name"); veloContext.put("application_name", appName); veloContext.put( "account_activation_subject", MessageFormat.format(mailBoundle.getString("account_activation.subject"), appName)); veloContext.put("account_activation_img_path", applicationUrl + ACCOUNT_ACTIVATION_IMG_PATH); veloContext.put( "greeting", MessageFormat.format(mailBoundle.getString("greeting"), recipient.getUserName())); veloContext.put( "account_activation_content_part1", MessageFormat.format( mailBoundle.getString("account_activation.content.part1"), applicationUrl, appName)); veloContext.put( "account_activation_content_part2", mailBoundle.getString("account_activation.content.part2")); veloContext.put( "account_activation_content_part3", MessageFormat.format( mailBoundle.getString("account_activation.content.part3"), applicationUrl + ACTIVATE_ACCOUNT_URL_PATTERN + "/" + recipient.getUuid())); veloContext.put( "account_activation_content_part4", mailBoundle.getString("account_activation.content.part4")); veloContext.put( "account_activation_content_part5", mailBoundle.getString("account_activation.content.part5")); veloContext.put("wish", MessageFormat.format(mailBoundle.getString("wish"), appName)); Template veloTemp = velocityEngine.getTemplate(ACCOUNT_ACTIVATION_HTML_TEMPLATE_PATH, "UTF-8"); StringWriter sw = new StringWriter(); veloTemp.merge(veloContext, sw); logger.debug("account activation mail's body {}", sw.toString()); try { mailSender.sendEmail( recipient.getEmail(), MessageFormat.format(mailBoundle.getString("account_activation.subject"), appName), sw.toString(), true); } catch (MailingException e) { logger.error("Failed to sent activation email message to user " + recipient.getUserName(), e); } if (sw != null) { try { sw.close(); } catch (IOException e) { logger.warn("Some error occurred in I/O while StringWriter closing", e); } } }
/** {@inheritDoc} */ @Override public Set<String> getNamesOfHubsAvailableToUser(User user) { Set<String> publicHubs = new LinkedHashSet<String>(); for (Hub hub : hubDao.getAllPublicHubs()) { publicHubs.add(hub.getName()); } List<String> ownHubs = new ArrayList<String>(); for (Hub hub : hubDao.getHubsOfUser(user.getUserName())) { ownHubs.add(hub.getName()); } publicHubs.addAll(ownHubs); return publicHubs; }