Author: sletellier Date: 2011-06-30 16:22:30 +0200 (Thu, 30 Jun 2011) New Revision: 112 Url: http://chorem.org/repositories/revision/vradi/112 Log: - Send request email - Add link to user preference Added: trunk/vradi-web/src/main/java/org/chorem/vradi/EmailType.java Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java trunk/vradi-web/src/main/java/org/chorem/vradi/actions/OptionsAction.java trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SendInvitationAction.java trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties trunk/vradi-web/src/main/webapp/WEB-INF/jsp/inc/header.jsp trunk/vradi-web/src/main/webapp/WEB-INF/jsp/showInvitation.jsp trunk/vradi-web/src/main/webapp/WEB-INF/jsp/userInfo.jsp Added: trunk/vradi-web/src/main/java/org/chorem/vradi/EmailType.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/EmailType.java (rev 0) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/EmailType.java 2011-06-30 14:22:30 UTC (rev 112) @@ -0,0 +1,71 @@ +package org.chorem.vradi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.services.managers.MailingManager; +import org.nuiton.i18n.I18n; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import static org.nuiton.i18n.I18n.n_; + +public enum EmailType { + + THESAURUS_NEW_CHILD(n_("vradi.template.thesaurus.new.child")), + THESAURUS_RENAMED(n_("vradi.template.thesaurus.renamed")), + WEBHARVEST(n_("vradi.template.webHarvest")), + RSS(n_("vradi.template.rss")), + REQUEST(n_("vradi.template.request")); + + protected static final Log log = LogFactory.getLog(EmailType.class); + public static final String TITLE_PREFIX = ".title"; + private String key; + + EmailType(String key) { + this.key = key; + } + + public boolean sendEmailToAdmins(VradiUser user, String comment, String... args) { + List<String> adminEmail = VradiWebConfig.getAdminEmail(); + return sendEmail(adminEmail, user, comment, args); + } + + /** + * We consider that i18n is created for key with login and more in args + * + * @param user ask to send msg + * @param comment commentaire à ajouter + * @param args to add in message + * @return true if send + */ + public boolean sendEmail(Collection<String> recipients, VradiUser user, String comment, String... args) { + String title = I18n._(key + TITLE_PREFIX); + + List<String> argsList = new ArrayList<String>(); + argsList.add(user.getLogin()); + argsList.add(comment); + argsList.addAll(Arrays.asList(args)); + + String msg = I18n._(key, argsList.toArray(new String[argsList.size()])); + for (String recipient : recipients) { + try { + MailingManager.postMail(VradiWebConfig.getConfig(), recipient, title, false, msg); + if (log.isDebugEnabled()) { + log.debug("Mail is sent from '" + user.getLogin() + + "' to '" + recipient + "' with title '" + + title + "' and body : " + msg); + } + } catch (Exception eee) { + log.error("Failed to send email from '" + user.getLogin() + + "' to '" + recipient + "' with title '" + + title + "' and body : " + msg, eee); + return false; + } + } + return true; + } +} \ No newline at end of file Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java 2011-06-30 14:22:30 UTC (rev 112) @@ -69,22 +69,6 @@ } /** - * Envoi un mail a chaque recipient avec comme contenu du mail mailContent. - * Le senders est une adresse on les reponses ne sont pas possible - * (vradi-noresponse@vradi.chorem.org) - * - * @param recipient - * @param mailContent - */ - public static void sendEmail(Set<String> recipient, String mailContent) { - String sender = "vradi-noresponse@vradi.chorem.org"; - String subject = "Vradi invitation"; - for (String email : recipient) { - // FIXME poussin 20110601 implanter l'envoi d'email - } - } - - /** * Converti le rst dans le format demande * @param resultType * @param rst Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/OptionsAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/OptionsAction.java 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/OptionsAction.java 2011-06-30 14:22:30 UTC (rev 112) @@ -1,17 +1,10 @@ package org.chorem.vradi.actions; import org.apache.commons.lang.StringUtils; -import org.chorem.vradi.VradiWebConfig; -import org.chorem.vradi.entities.VradiUser; -import org.chorem.vradi.services.managers.MailingManager; +import org.chorem.vradi.EmailType; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import static org.nuiton.i18n.I18n._; - /** * Action used for vradi web options page * @@ -90,22 +83,22 @@ boolean sent = true; if (!StringUtils.isEmpty(thesaurusNewChildName)) { // User propose new thesaurus child - sent &= EmailType.THESAURUS_NEW_CHILD.sendEmail(getUser(), comment, thesaurusPath, thesaurusNewChildName); + sent &= EmailType.THESAURUS_NEW_CHILD.sendEmailToAdmins(getUser(), comment, thesaurusPath, thesaurusNewChildName); } if (!StringUtils.isEmpty(thesaurusRenamed)) { // User propose to rename thesaurus - sent &= EmailType.THESAURUS_RENAMED.sendEmail(getUser(), comment, thesaurusPath, thesaurusName, thesaurusRenamed); + sent &= EmailType.THESAURUS_RENAMED.sendEmailToAdmins(getUser(), comment, thesaurusPath, thesaurusName, thesaurusRenamed); } if (webHarvestScript != null) { // Upload file String uri = getVradiSession().getFileService().uploadWebHarvestScript(webHarvestScript); // User propose to add a webharvest script - sent &= EmailType.WEBHARVEST.sendEmail(getUser(), comment, uri); + sent &= EmailType.WEBHARVEST.sendEmailToAdmins(getUser(), comment, uri); } if (!StringUtils.isEmpty(rssUrl)) { // User propose to add an rss - sent &= EmailType.RSS.sendEmail(getUser(), comment, rssUrl); + sent &= EmailType.RSS.sendEmailToAdmins(getUser(), comment, rssUrl); } if (sent) { @@ -115,54 +108,4 @@ } } - public enum EmailType { - THESAURUS_NEW_CHILD("vradi.template.thesaurus.new.child"), - THESAURUS_RENAMED("vradi.template.thesaurus.renamed"), - WEBHARVEST("vradi.template.webHarvest"), - RSS("vradi.template.rss"); - - public static final String TITLE_PREFIX = ".title"; - private String key; - - EmailType(String key) { - this.key = key; - } - - /** - * We consider that i18n is created for key with login and more in args - * - * @param user ask to send msg - * @param comment commentaire à ajouter - * @param args to add in message - * @return true if send - */ - public boolean sendEmail(VradiUser user, String comment, String... args) { - String title = _(key + TITLE_PREFIX); - - List<String> argsList = new ArrayList<String>(); - argsList.add(user.getLogin()); - argsList.add(comment); - argsList.addAll(Arrays.asList(args)); - - String msg = _(key, argsList.toArray(new String[argsList.size()])); - - List<String> adminEmail = VradiWebConfig.getAdminEmail(); - for (String recipient : adminEmail) { - try { - MailingManager.postMail(VradiWebConfig.getConfig(), recipient, title, false, msg); - if (log.isDebugEnabled()) { - log.debug("Mail is sent from '" + user.getLogin() + - "' to '" + recipient + "' with title '" + - title + "' and body : " + msg); - } - } catch (Exception eee) { - log.error("Failed to send email from '" + user.getLogin() + - "' to '" + recipient + "' with title '" + - title + "' and body : " + msg, eee); - return false; - } - } - return true; - } - } } Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SendInvitationAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SendInvitationAction.java 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SendInvitationAction.java 2011-06-30 14:22:30 UTC (rev 112) @@ -9,6 +9,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.EmailType; import org.chorem.vradi.VradiWebConfig; import org.chorem.vradi.VradiWebHelper; import org.chorem.vradi.entities.FormNote; @@ -181,25 +182,8 @@ log.error(String.format("Url forged for invitation is to long for some navigator '%s'", url)); } - StringBuilder mailContent = new StringBuilder(); - mailContent.append("Bonjour,\n"); - mailContent.append("\n"); - mailContent.append("Ceci est une invitation pour participer à la creation\n"); - mailContent.append("commune d'information sur un formulaire Vradi.\n"); - mailContent.append("\n"); - mailContent.append("Cette invitation provient de:\n"); - mailContent.append(sender.getInfo()); - mailContent.append("\n\n"); - mailContent.append("Avec le message:\n"); - mailContent.append(message); - mailContent.append("\n\n"); - mailContent.append("Pour répondre à cette demande veuillez aller sur la page:\n"); - mailContent.append(url); - mailContent.append("\n\n"); - mailContent.append("Cordialement,"); + EmailType.REQUEST.sendEmail(recipient, sender, message, url, sender.getInfo()); - VradiWebHelper.sendEmail(recipient, mailContent.toString()); - return result; } Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties =================================================================== --- trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-06-30 14:22:30 UTC (rev 112) @@ -89,3 +89,5 @@ vradi.showInvitation.accept=Accept vradi.showInvitation.reject=Reject vradi.showInvitation.noReceived=Do not receved other request from this person +vradi.noEmail=No email +vradi.userPreference=User preference Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties =================================================================== --- trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-06-30 14:22:30 UTC (rev 112) @@ -40,6 +40,7 @@ vradi.login.title=Connection vradi.logout.submit=Déconnection vradi.new.formNote=Nouvelle réponse +vradi.noEmail=Pas d'email vradi.options=Options vradi.options.comment=Commentaires vradi.options.rssUrl=Ajout d'un flux RSS @@ -73,7 +74,7 @@ vradi.seekingPartners.title=Recherche de partenaires vradi.send=Envoyer vradi.sendInvitation.count=Nombre d'invitations envoyés -vradi.sendInvitation.title=Envoie d'invitation +vradi.sendInvitation.title=Envoi d'invitation vradi.show=Afficher vradi.showInvitation.accept=Accepter vradi.showInvitation.from=L'invitation provient de \: @@ -83,17 +84,20 @@ vradi.showInvitation.requestMsg=Le message de l'invitation est \: vradi.showInvitation.title=Visualisation de l'invitation vradi.summary=Résumé -vradi.template.rss=L'utilisateur %1$s à fait la demande d'ajout du flux RSS '%3$s' avec le commentaire suivant \: %2$s +vradi.template.request=Bonjour,\n\nCeci est une invitation pour participer à la creation commune d'information sur un formulaire Vradi.\n\nCette invitation provient de\:\n%4$s\n\nAvec le message\:\n%2$s\n\nPour répondre à cette demande veuillez aller sur la page\:'%3$s'\n"\n\nCordialement. +vradi.template.request.title=[Vradi web] Vradi invitation +vradi.template.rss=L'utilisateur %1$s à fait la demande d'ajout du flux RSS '%3$s' avec le commentaire suivant \: \n%2$s vradi.template.rss.title=[Vradi web] Demande d'ajout d'un flux RSS -vradi.template.thesaurus.new.child=L'utilisateur %1$s à fait la demande d'ajout d'un thesaurus pour le chemin '%3$s' qui aura pour nom '%4$s' avec le commentaire suivant \: %2$s +vradi.template.thesaurus.new.child=L'utilisateur %1$s à fait la demande d'ajout d'un thesaurus pour le chemin '%3$s' qui aura pour nom '%4$s' avec le commentaire suivant \: \n%2$s vradi.template.thesaurus.new.child.title=[Vradi web] Demande d'ajout d'un thesaurus -vradi.template.thesaurus.renamed=L'utilisateur %1$s à fait la demande de renomage d'un thesaurus pour le chemin '%3$s' qui avais le nom '%4$s' avec pour nouveau nom '%5$s' avec le commentaire suivant \: %2$s +vradi.template.thesaurus.renamed=L'utilisateur %1$s à fait la demande de renomage d'un thesaurus pour le chemin '%3$s' qui avais le nom '%4$s' avec pour nouveau nom '%5$s' avec le commentaire suivant \: \n%2$s vradi.template.thesaurus.renamed.title=[Vradi web] Demande de renomage d'un thesaurus -vradi.template.webHarvest=L'utilisateur %1$s à fait la demande d'ajout du script webHarvest disponible à l'adresse '%3$s' avec le commentaire suivant \: %2$s +vradi.template.webHarvest=L'utilisateur %1$s à fait la demande d'ajout du script webHarvest disponible à l'adresse '%3$s' avec le commentaire suivant \: \n%2$s vradi.template.webHarvest.title=[Vradi web] Demande d'ajout d'un script webHarvest vradi.thesaurus.path=Chemin du descripteur \: vradi.thesaurus.thesaurusNewChildName=Nom du nouveau fils pour le descripteur séléctionné vradi.thesaurus.thesaurusRenamed=Nouveau nom du descripteur séléctionné vradi.title=Vradi Web -vradi.user.noinfo= +vradi.user.noinfo=Pas d'info +vradi.userPreference=Préférence de l'utilisateur vradi.userPreference.info=Text complémentaire à envoyer en plus de l'abstract lors de la demande Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/inc/header.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/inc/header.jsp 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/inc/header.jsp 2011-06-30 14:22:30 UTC (rev 112) @@ -10,6 +10,9 @@ VradiSession vradiSession = VradiSession.getVradiSession(session); VradiUser user = vradiSession.getUser(); ActionContext.getContext().put("logged", user != null); + if (user != null) { + ActionContext.getContext().put("userId", user.getWikittyId()); + } String requestURI = request.getRequestURI(); boolean isSearchView = requestURI.contains("searchView"); @@ -17,6 +20,9 @@ boolean isOption = requestURI.contains("option"); ActionContext.getContext().put("isNotOptionPage", !isOption); + + boolean isNotUserPreferencePage = requestURI.contains("userPreference"); + ActionContext.getContext().put("isNotUserPreferencePage", !isNotUserPreferencePage); %> <div id="titlePanel"> <h1><s:text name="vradi.title" /></h1> @@ -29,6 +35,12 @@ <s:text name="vradi.options"/> </s:a> </s:if> + <s:if test="isNotUserPreferencePage"> + <s:a id="options" + href="/userPreference/%{userId}.action"> + <s:text name="vradi.userPreference"/> + </s:a> + </s:if> <s:if test="isNotSearchViewPage"> <s:a id="searchLink" action="searchView"> Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/showInvitation.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/showInvitation.jsp 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/showInvitation.jsp 2011-06-30 14:22:30 UTC (rev 112) @@ -40,8 +40,11 @@ <form id="partnersForm" action="/fragment/userInfo.action"> <s:select size="5" name="userId" list="partners" listKey="wikittyId" listValue="login"/> + <s:set id="showText"> + <s:text name="vradi.show"/> + </s:set> <sj:submit id="partnersSubmit" - value="Show" + value="%{showText}" targets="partnersInfo" indicator="indicator-partnersInfo" button="true" buttonIcon="ui-icon-gear"/> </form> Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/userInfo.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/userInfo.jsp 2011-06-30 13:14:25 UTC (rev 111) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/userInfo.jsp 2011-06-30 14:22:30 UTC (rev 112) @@ -5,8 +5,8 @@ --%> <%@page import="org.chorem.vradi.actions.RestoreUserAction"%> -<%@page import="com.opensymphony.xwork2.ActionContext"%> <%@page import="org.chorem.vradi.entities.VradiUser"%> +<%@ page import="static org.nuiton.i18n.I18n._" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> @@ -14,7 +14,7 @@ <% RestoreUserAction action = RestoreUserAction.getAction(); VradiUser user = action.getUser(); -String email = "no email"; +String email = _("vrado.noEmail"); String info = action.getInfoHtml(); if (user != null) { email = user.getLogin();