Author: solomax Date: Tue Nov 15 03:24:44 2016 New Revision: 1769713 URL: http://svn.apache.org/viewvc?rev=1769713&view=rev Log: [OPENMEETINGS-1488] date/time is being formatted according to recipient locale
Modified: openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java Modified: openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java Tue Nov 15 03:24:44 2016 @@ -18,6 +18,8 @@ */ package org.apache.openmeetings; +import java.util.Locale; + import javax.servlet.ServletContext; import org.apache.openmeetings.db.entity.room.Invitation; @@ -34,6 +36,7 @@ public interface IApplication { String getOmString(long id); String getOmString(long id, long languageId); String getOmString(String key, long languageId); + String getOmString(String key, final Locale loc); String getOmContactsLink(); String getOmInvitationLink(Invitation i); String urlForActivatePage(PageParameters pp); Modified: openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java Tue Nov 15 03:24:44 2016 @@ -18,7 +18,13 @@ */ package org.apache.openmeetings; +import java.util.Locale; + +import org.apache.openmeetings.db.entity.user.User; + public interface IWebSession { long getOmLanguage(); void setLanguage(long languageId); + Locale getLocale(); + Locale getLocale(User u); } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java Tue Nov 15 03:24:44 2016 @@ -46,6 +46,7 @@ import org.apache.openmeetings.db.entity import org.apache.openmeetings.db.entity.room.Room; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.util.TimezoneUtil; +import org.apache.openmeetings.service.mail.template.subject.AbstractSubjectEmailTemplate; import org.apache.openmeetings.service.mail.template.subject.AppointmentReminderTemplate; import org.apache.wicket.util.string.Strings; import org.red5.logging.Red5LoggerFactory; @@ -100,7 +101,7 @@ public class AppointmentLogic { String smsSubject = generateSMSSubject(langDao.getString(1158L, langId), a); - AppointmentReminderTemplate t = AppointmentReminderTemplate.get(langId, a, tz); + AbstractSubjectEmailTemplate t = AppointmentReminderTemplate.get(u, a, tz); invitationManager.sendInvitationLink(inv, MessageType.Create, t.getSubject(), t.getEmail(), false); invitationManager.sendInvitationReminderSMS(u.getAddress().getPhone(), smsSubject, langId); Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java Tue Nov 15 03:24:44 2016 @@ -21,6 +21,8 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAULT_LANG_KEY; +import java.util.Locale; + import org.apache.openmeetings.IWebSession; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.db.dao.label.LabelDao; @@ -33,7 +35,7 @@ import org.apache.wicket.protocol.http.W public abstract class AbstractTemplatePanel extends Panel { private static final long serialVersionUID = 1L; public static final String COMP_ID = "template"; - protected long langId; + protected final Locale locale; public static <T> T getBean(Class<T> clazz) { return ensureApplication().getOmBean(clazz); @@ -43,13 +45,18 @@ public abstract class AbstractTemplatePa return (IWebSession)WebSession.get(); } - public AbstractTemplatePanel(Long langId) { + private static Locale getDefault() { + long langId = getBean(ConfigurationDao.class).getConfValue(CONFIG_DEFAULT_LANG_KEY, Long.class, "1"); + return LabelDao.languages.get(langId); + } + + public AbstractTemplatePanel(Locale locale) { super(COMP_ID); - this.langId = langId == null ? getBean(ConfigurationDao.class).getConfValue(CONFIG_DEFAULT_LANG_KEY, Long.class, "1") : langId; - add(new TransparentWebMarkupContainer("container").add(AttributeAppender.append("dir", FormatHelper.isRtlLanguage(LabelDao.languages.get(langId).toLanguageTag()) ? "rtl" : "ltr"))); + this.locale = locale == null ? getDefault() : locale; + add(new TransparentWebMarkupContainer("container").add(AttributeAppender.append("dir", FormatHelper.isRtlLanguage(this.locale.toLanguageTag()) ? "rtl" : "ltr"))); } - public static String getString(long id, long languageId) { - return ensureApplication().getOmString(id, languageId); + public static String getString(String id, Locale locale) { + return ensureApplication().getOmString(id, locale); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java Tue Nov 15 03:24:44 2016 @@ -27,7 +27,7 @@ public class FeedbackTemplate extends Ab private static final long serialVersionUID = 1L; public FeedbackTemplate(String username, String email, String message) { - super(getOmSession().getOmLanguage()); + super(getOmSession().getLocale()); add(new Label("appname", getBean(ConfigurationDao.class).getAppName())); add(new Label("username", username)); add(new Label("email", email)); Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,6 +20,9 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; + +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.core.util.string.ComponentRenderer; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; @@ -28,26 +31,26 @@ import org.apache.wicket.markup.html.lin public class InvitationTemplate extends AbstractTemplatePanel { private static final long serialVersionUID = 1L; - private InvitationTemplate(Long langId, String invitorName, String message, String link) { - super(langId); + private InvitationTemplate(Locale locale, String invitorName, String message, String link) { + super(locale); - add(new Label("titleLbl", getString(500, langId))); - add(new Label("userLbl", getString(501, langId))); + add(new Label("titleLbl", getString("500", locale))); + add(new Label("userLbl", getString("501", locale))); add(new Label("user", invitorName)); - add(new Label("messageLbl", getString(502, langId))); + add(new Label("messageLbl", getString("502", locale))); add(new Label("message", message).setEscapeModelStrings(false)); add(new WebMarkupContainer("links") - .add(new Label("comment_for_link1", getString(503, langId))) - .add(new ExternalLink("invitation_link1", link).add(new Label("clickMe", getString(504, langId)))) - .add(new Label("comment_for_link2", getString(505, langId))) + .add(new Label("comment_for_link1", getString("503", locale))) + .add(new ExternalLink("invitation_link1", link).add(new Label("clickMe", getString("504", locale)))) + .add(new Label("comment_for_link2", getString("505", locale))) .add(new Label("invitation_link2", link)) .setVisible(link != null) ); } - - public static String getEmail(Long langId, String invitorName, String message, String link) { - ensureApplication(langId); - return ComponentRenderer.renderComponent(new InvitationTemplate(langId, invitorName, message, link)).toString(); + + public static String getEmail(User invitee, String invitorName, String message, String link) { + ensureApplication(invitee.getLanguageId()); + return ComponentRenderer.renderComponent(new InvitationTemplate(getOmSession().getLocale(invitee), invitorName, message, link)).toString(); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java Tue Nov 15 03:24:44 2016 @@ -18,8 +18,6 @@ */ package org.apache.openmeetings.service.mail.template; -import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; - import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.html.basic.Label; @@ -28,14 +26,6 @@ public class OmTextLabel extends Label { private static final long serialVersionUID = 1L; private static final String WICKET_VISIBLE = ":visible"; - public OmTextLabel(String id, long key, long langId) { - this(id, "" + key, langId); - } - - public OmTextLabel(String id, String key, long langId) { - this(id, ensureApplication().getOmString(key, langId)); - } - public OmTextLabel(String id, String label) { super(id, label); setRenderBodyOnly(true); Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java Tue Nov 15 03:24:44 2016 @@ -27,15 +27,15 @@ public class RegisterUserTemplate extend private static final long serialVersionUID = 1L; public RegisterUserTemplate(String username, String email, String verification_url) { - super(getOmSession().getOmLanguage()); - add(new Label("registrationLbl", getString(506, langId))); + super(getOmSession().getLocale()); + add(new Label("registrationLbl", getString("506", locale))); add(new Label("username", username)); add(new Label("email", email)); WebMarkupContainer verification = new WebMarkupContainer("verification"); add(verification.add(new Label("verification_url2", verification_url)) .add(new ExternalLink("verification_url1", verification_url)) .setVisible(verification_url != null)); - add(new Label("groupLbl", getString(511, langId))); + add(new Label("groupLbl", getString("511", locale))); } public static String getEmail(String username, String email, String verification_url) { Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java Tue Nov 15 03:24:44 2016 @@ -26,15 +26,15 @@ public class RequestContactConfirmTempla private static final long serialVersionUID = 1L; public RequestContactConfirmTemplate(UserContact contact) { - super(contact.getOwner().getLanguageId()); - add(new Label("hi", getString(1192, langId))); + super(getOmSession().getLocale(contact.getOwner())); + add(new Label("hi", getString("1192", locale))); add(new Label("firstName", contact.getOwner().getFirstname())); add(new Label("lastName", contact.getOwner().getLastname())); add(new Label("addedFirstName", contact.getContact().getFirstname())); add(new Label("addedLastName", contact.getContact().getLastname())); - add(new Label("confirmed", getString(1198, langId))); + add(new Label("confirmed", getString("1198", locale))); } - + public static String getEmail(UserContact contact) { return ComponentRenderer.renderComponent(new RequestContactConfirmTemplate(contact)).toString(); } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java Tue Nov 15 03:24:44 2016 @@ -29,17 +29,17 @@ public class RequestContactTemplate exte private static final long serialVersionUID = 1L; public RequestContactTemplate(User userToAdd, User user) { - super(userToAdd.getLanguageId()); - add(new Label("hi", getString(1192, langId))); + super(getOmSession().getLocale(userToAdd)); + add(new Label("hi", getString("1192", locale))); add(new Label("addedFirstName", userToAdd.getFirstname())); add(new Label("addedLastName", userToAdd.getLastname())); add(new Label("firstName", user.getFirstname())); add(new Label("lastName", user.getLastname())); - add(new Label("likeToAdd", getString(1193, langId))); - add(new Label("check", getString(1194, langId))); - add(new ExternalLink("link", ensureApplication().getOmContactsLink()).add(new Label("contactList", getString(1196, langId)))); + add(new Label("likeToAdd", getString("1193", locale))); + add(new Label("check", getString("1194", locale))); + add(new ExternalLink("link", ensureApplication().getOmContactsLink()).add(new Label("contactList", getString("1196", locale)))); } - + public static String getEmail(User userToAdd, User user) { return ComponentRenderer.renderComponent(new RequestContactTemplate(userToAdd, user)).toString(); } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java Tue Nov 15 03:24:44 2016 @@ -26,7 +26,7 @@ public class ResetPasswordTemplate exten private static final long serialVersionUID = 1L; public ResetPasswordTemplate(String link) { - super(getOmSession().getOmLanguage()); + super(getOmSession().getLocale()); add(new ExternalLink("reset_link1", link)); add(new Label("reset_link2", link)); } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java Tue Nov 15 03:24:44 2016 @@ -18,13 +18,18 @@ */ package org.apache.openmeetings.service.mail.template.subject; +import static org.apache.commons.lang3.time.FastDateFormat.MEDIUM; +import static org.apache.commons.lang3.time.FastDateFormat.SHORT; + +import java.util.Date; +import java.util.Locale; import java.util.TimeZone; +import org.apache.commons.lang3.time.FastDateFormat; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.service.mail.template.AbstractTemplatePanel; import org.apache.openmeetings.service.mail.template.DashOmTextLabel; import org.apache.openmeetings.service.mail.template.OmTextLabel; -import org.apache.openmeetings.util.CalendarPatterns; import org.apache.wicket.core.util.string.ComponentRenderer; import org.apache.wicket.markup.html.panel.Fragment; @@ -34,42 +39,53 @@ public abstract class AbstractSubjectEma protected TimeZone tz; private String email = null; private String subject = null; + private boolean created = false; - - public AbstractSubjectEmailTemplate(Long langId, Appointment a, TimeZone tz) { - super(langId); + public AbstractSubjectEmailTemplate(Locale locale, Appointment a, TimeZone tz) { + super(locale); this.a = a; this.tz = tz; } - abstract void omInit(); - - @Override - protected void onInitialize() { - super.onInitialize(); - omInit(); + AbstractSubjectEmailTemplate create() { email = ComponentRenderer.renderComponent(this).toString(); subject = ComponentRenderer.renderComponent(getSubjectFragment()).toString(); + created = true; + return this; } - public final String getEmail() { - return email; + abstract String getPrefix(); + + protected String format(Date d) { + return format(d, MEDIUM); } - abstract String getPrefix(); + protected String format(Date d, int fmt) { + return FastDateFormat.getDateTimeInstance(fmt, fmt, tz, locale).format(d); + } Fragment getSubjectFragment() { Fragment f = new Fragment(COMP_ID, "subject", this); f.add(new OmTextLabel("prefix", getPrefix()) , new OmTextLabel("title", a.getTitle()) - , new OmTextLabel("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz)) + , new OmTextLabel("start", format(a.getStart(), SHORT)) , new DashOmTextLabel("dash") - , new OmTextLabel("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz)) + , new OmTextLabel("end", format(a.getEnd(), SHORT)) ); return f; } + public final String getEmail() { + if (!created) { + throw new RuntimeException("Not created!!"); + } + return email; + } + public final String getSubject() { + if (!created) { + throw new RuntimeException("Not created!!"); + } return subject; } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,10 +20,11 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; import java.util.TimeZone; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.util.CalendarPatterns; +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.util.string.Strings; @@ -31,32 +32,33 @@ import org.apache.wicket.util.string.Str public class AppointmentReminderTemplate extends AbstractSubjectEmailTemplate { private static final long serialVersionUID = 1L; - private AppointmentReminderTemplate(Long langId, Appointment a, TimeZone tz) { - super(langId, a, tz); + private AppointmentReminderTemplate(Locale locale, Appointment a, TimeZone tz) { + super(locale, a, tz); } @Override - void omInit() { - add(new Label("titleLbl", getString(1158L, langId))); + protected void onInitialize() { + super.onInitialize(); + add(new Label("titleLbl", getString("1158", locale))); add(new Label("title", a.getTitle())); add(new WebMarkupContainer("descContainer") - .add(new Label("descLbl", getString(1152L, langId))) + .add(new Label("descLbl", getString("1152", locale))) .add(new Label("desc", a.getDescription()).setEscapeModelStrings(false)) .setVisible(!Strings.isEmpty(a.getDescription())) ); - add(new Label("startLbl", getString(1153L, langId))); - add(new Label("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz))); - add(new Label("endLbl", getString(1154L, langId))); - add(new Label("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz))); + add(new Label("startLbl", getString("1153", locale))); + add(new Label("start", format(a.getStart()))); + add(new Label("endLbl", getString("1154", locale))); + add(new Label("end", format(a.getEnd()))); } - public static AppointmentReminderTemplate get(Long langId, Appointment a, TimeZone tz) { - ensureApplication(langId); - return new AppointmentReminderTemplate(langId, a, tz); + public static AbstractSubjectEmailTemplate get(User u, Appointment a, TimeZone tz) { + ensureApplication(u.getLanguageId()); + return new AppointmentReminderTemplate(getOmSession().getLocale(u), a, tz).create(); } @Override String getPrefix() { - return ensureApplication().getOmString(1158, langId); + return ensureApplication().getOmString("1158", locale); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,10 +20,11 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; import java.util.TimeZone; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.util.CalendarPatterns; +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.util.string.Strings; @@ -32,35 +33,36 @@ public class CanceledAppointmentTemplate private static final long serialVersionUID = 1L; private final String invitorName; - private CanceledAppointmentTemplate(Long langId, Appointment a, TimeZone tz, String invitorName) { - super(langId, a, tz); + private CanceledAppointmentTemplate(Locale locale, Appointment a, TimeZone tz, String invitorName) { + super(locale, a, tz); this.invitorName = invitorName; } @Override - void omInit() { - add(new Label("titleLbl", getString(1157L, langId))); + protected void onInitialize() { + super.onInitialize(); + add(new Label("titleLbl", getString("1157", locale))); add(new Label("title", a.getTitle())); add(new WebMarkupContainer("descContainer") - .add(new Label("descLbl", getString(1152L, langId))) + .add(new Label("descLbl", getString("1152", locale))) .add(new Label("desc", a.getDescription()).setEscapeModelStrings(false)) .setVisible(!Strings.isEmpty(a.getDescription())) ); - add(new Label("startLbl", getString(1153L, langId))); - add(new Label("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz))); - add(new Label("endLbl", getString(1154L, langId))); - add(new Label("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz))); - add(new Label("invitorLbl", getString(1156L, langId))); + add(new Label("startLbl", getString("1153", locale))); + add(new Label("start", format(a.getStart()))); + add(new Label("endLbl", getString("1154", locale))); + add(new Label("end", format(a.getEnd()))); + add(new Label("invitorLbl", getString("1156", locale))); add(new Label("invitor", invitorName)); } - public static CanceledAppointmentTemplate get(Long langId, Appointment a, TimeZone tz, String invitorName) { - ensureApplication(langId); - return new CanceledAppointmentTemplate(langId, a, tz, invitorName); + public static AbstractSubjectEmailTemplate get(User u, Appointment a, TimeZone tz, String invitorName) { + ensureApplication(u.getLanguageId()); + return new CanceledAppointmentTemplate(getOmSession().getLocale(u), a, tz, invitorName).create(); } @Override String getPrefix() { - return ensureApplication().getOmString(1157, langId); + return ensureApplication().getOmString("1157", locale); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CreatedAppointmentTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,10 +20,11 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; import java.util.TimeZone; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.util.CalendarPatterns; +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.util.string.Strings; @@ -32,35 +33,36 @@ public class CreatedAppointmentTemplate private static final long serialVersionUID = 1L; private final String invitorName; - private CreatedAppointmentTemplate(Long langId, Appointment a, TimeZone tz, String invitorName) { - super(langId, a, tz); + private CreatedAppointmentTemplate(Locale locale, Appointment a, TimeZone tz, String invitorName) { + super(locale, a, tz); this.invitorName = invitorName; } @Override - void omInit() { - add(new Label("titleLbl", getString(1151L, langId))); + protected void onInitialize() { + super.onInitialize(); + add(new Label("titleLbl", getString("1151", locale))); add(new Label("title", a.getTitle())); add(new WebMarkupContainer("descContainer") - .add(new Label("descLbl", getString(1152L, langId))) + .add(new Label("descLbl", getString("1152", locale))) .add(new Label("desc", a.getDescription()).setEscapeModelStrings(false)) .setVisible(!Strings.isEmpty(a.getDescription())) ); - add(new Label("startLbl", getString(1153L, langId))); - add(new Label("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz))); - add(new Label("endLbl", getString(1154L, langId))); - add(new Label("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz))); - add(new Label("invitorLbl", getString(1156L, langId))); + add(new Label("startLbl", getString("1153", locale))); + add(new Label("start", format(a.getStart()))); + add(new Label("endLbl", getString("1154", locale))); + add(new Label("end", format(a.getEnd()))); + add(new Label("invitorLbl", getString("1156", locale))); add(new Label("invitor", invitorName)); } - public static CreatedAppointmentTemplate get(Long langId, Appointment a, TimeZone tz, String invitorName) { - ensureApplication(langId); - return new CreatedAppointmentTemplate(langId, a, tz, invitorName); + public static AbstractSubjectEmailTemplate get(User u, Appointment a, TimeZone tz, String invitorName) { + ensureApplication(u.getLanguageId()); + return new CreatedAppointmentTemplate(getOmSession().getLocale(u), a, tz, invitorName).create(); } @Override String getPrefix() { - return ensureApplication().getOmString(1151, langId); + return ensureApplication().getOmString("1151", locale); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/UpdatedAppointmentTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,10 +20,11 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; import java.util.TimeZone; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.util.CalendarPatterns; +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.util.string.Strings; @@ -32,35 +33,36 @@ public class UpdatedAppointmentTemplate private static final long serialVersionUID = 1L; private final String invitorName; - private UpdatedAppointmentTemplate(Long langId, Appointment a, TimeZone tz, String invitorName) { - super(langId, a, tz); + private UpdatedAppointmentTemplate(Locale locale, Appointment a, TimeZone tz, String invitorName) { + super(locale, a, tz); this.invitorName = invitorName; } @Override - void omInit() { - add(new Label("titleLbl", getString(1155L, langId))); + protected void onInitialize() { + super.onInitialize(); + add(new Label("titleLbl", getString("1155", locale))); add(new Label("title", a.getTitle())); add(new WebMarkupContainer("descContainer") - .add(new Label("descLbl", getString(1152L, langId))) + .add(new Label("descLbl", getString("1152", locale))) .add(new Label("desc", a.getDescription()).setEscapeModelStrings(false)) .setVisible(!Strings.isEmpty(a.getDescription())) ); - add(new Label("startLbl", getString(1153L, langId))); - add(new Label("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz))); - add(new Label("endLbl", getString(1154L, langId))); - add(new Label("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz))); - add(new Label("invitorLbl", getString(1156L, langId))); + add(new Label("startLbl", getString("1153", locale))); + add(new Label("start", format(a.getStart()))); + add(new Label("endLbl", getString("1154", locale))); + add(new Label("end", format(a.getEnd()))); + add(new Label("invitorLbl", getString("1156", locale))); add(new Label("invitor", invitorName)); } - public static UpdatedAppointmentTemplate get(Long langId, Appointment a, TimeZone tz, String invitorName) { - ensureApplication(langId); - return new UpdatedAppointmentTemplate(langId, a, tz, invitorName); + public static AbstractSubjectEmailTemplate get(User u, Appointment a, TimeZone tz, String invitorName) { + ensureApplication(u.getLanguageId()); + return new UpdatedAppointmentTemplate(getOmSession().getLocale(u), a, tz, invitorName).create(); } @Override String getPrefix() { - return ensureApplication().getOmString(1155, langId); + return ensureApplication().getOmString("1155", locale); } } Modified: openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java Tue Nov 15 03:24:44 2016 @@ -84,19 +84,18 @@ public class InvitationManager implement private void sendInvitionLink(Appointment a, MeetingMember mm, MessageType type, boolean ical) throws Exception { User owner = a.getOwner(); String invitorName = owner.getFirstname() + " " + owner.getLastname(); - Long langId = mm.getUser().getLanguageId(); TimeZone tz = timezoneUtil.getTimeZone(mm.getUser()); AbstractSubjectEmailTemplate t = null; switch (type) { case Cancel: - t = CanceledAppointmentTemplate.get(langId, a, tz, invitorName); + t = CanceledAppointmentTemplate.get(mm.getUser(), a, tz, invitorName); break; case Create: - t = CreatedAppointmentTemplate.get(langId, a, tz, invitorName); + t = CreatedAppointmentTemplate.get(mm.getUser(), a, tz, invitorName); break; case Update: default: - t = UpdatedAppointmentTemplate.get(langId, a, tz, invitorName); + t = UpdatedAppointmentTemplate.get(mm.getUser(), a, tz, invitorName); break; } @@ -113,7 +112,7 @@ public class InvitationManager implement User owner = i.getInvitedBy(); String invitorName = owner.getFirstname() + " " + owner.getLastname(); - String template = InvitationTemplate.getEmail(i.getInvitee().getLanguageId(), invitorName, message, invitation_link); + String template = InvitationTemplate.getEmail(i.getInvitee(), invitorName, message, invitation_link); String email = i.getInvitee().getAddress().getEmail(); String replyToEmail = owner.getAddress().getEmail(); Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java Tue Nov 15 03:24:44 2016 @@ -490,4 +490,9 @@ public class Application extends Authent public String getOmString(String key, long languageId) { return getString(key, languageId); } + + @Override + public String getOmString(String key, final Locale loc) { + return getString(key, loc, false); + } } Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java (original) +++ openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java Tue Nov 15 03:24:44 2016 @@ -22,6 +22,7 @@ import static java.text.DateFormat.SHORT import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOARD_SHOW_MYROOMS_KEY; import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOARD_SHOW_RSS_KEY; import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAULT_LANG_KEY; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.apache.openmeetings.web.app.Application.getAuthenticationStrategy; import static org.apache.openmeetings.web.app.Application.getBean; import static org.apache.openmeetings.web.app.Application.getClientByKeys; @@ -29,6 +30,7 @@ import static org.apache.openmeetings.we import static org.apache.openmeetings.web.app.Application.isInvaldSession; import static org.apache.openmeetings.web.app.Application.removeInvalidSession; import static org.apache.openmeetings.web.app.Application.removeOnlineUser; +import static org.red5.logging.Red5LoggerFactory.getLogger; import java.util.Arrays; import java.util.Calendar; @@ -79,6 +81,7 @@ import org.apache.wicket.authroles.autho import org.apache.wicket.request.Request; import org.apache.wicket.util.string.StringValue; import org.apache.wicket.util.string.Strings; +import org.slf4j.Logger; import org.wicketstuff.dashboard.Dashboard; import org.wicketstuff.dashboard.Widget; import org.wicketstuff.dashboard.WidgetFactory; @@ -86,6 +89,7 @@ import org.wicketstuff.dashboard.web.Das public class WebSession extends AbstractAuthenticatedWebSession implements IWebSession { private static final long serialVersionUID = 1L; + private static final Logger log = getLogger(WebSession.class, webAppRootKey); public static final int MILLIS_IN_MINUTE = 60000; public static final String ISO8601_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ssZ"; public static final List<String> AVAILABLE_TIMEZONES = Arrays.asList(TimeZone.getAvailableIDs()); @@ -255,6 +259,21 @@ public class WebSession extends Abstract return false; } + public Locale getLocale(User u) { + Long langId = u.getLanguageId(); + Locale locale = langId == 3 ? Locale.GERMANY : LabelDao.languages.get(langId); + try { + Locale.Builder builder = new Locale.Builder().setLanguage(locale.getLanguage()); + if (u.getAddress() != null && u.getAddress().getCountry() != null) { + builder.setRegion(u.getAddress().getCountry()); + } + locale = builder.build(); + } catch (Exception e) { + log.error("Unexpected Error whilw constructing locale for the user", e.getMessage()); + } + return locale; + } + private void setUser(User u, Set<Right> rights) { String _sid = SID; Long _recordingId = recordingId; @@ -292,8 +311,7 @@ public class WebSession extends Abstract externalType = u.getExternalType(); tz = getBean(TimezoneUtil.class).getTimeZone(u); ISO8601FORMAT = FastDateFormat.getInstance(ISO8601_FORMAT_STRING, tz); - setLocale(languageId == 3 ? Locale.GERMANY : LabelDao.languages.get(languageId)); - //FIXMW locale need to be set by User language first + setLocale(getLocale(u)); sdf = FastDateFormat.getDateTimeInstance(SHORT, SHORT, getLocale()); } Modified: openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java Tue Nov 15 03:24:44 2016 @@ -18,6 +18,8 @@ */ package org.apache.openmeetings; +import java.util.Locale; + import javax.servlet.ServletContext; import org.apache.openmeetings.db.entity.room.Client; @@ -35,6 +37,7 @@ public interface IApplication { String getOmString(long id); String getOmString(long id, long languageId); String getOmString(String key, long languageId); + String getOmString(String key, final Locale loc); Client updateClient(Client rcl); String getOmContactsLink(); String getOmInvitationLink(Invitation i); Modified: openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/IWebSession.java Tue Nov 15 03:24:44 2016 @@ -18,7 +18,13 @@ */ package org.apache.openmeetings; +import java.util.Locale; + +import org.apache.openmeetings.db.entity.user.User; + public interface IWebSession { long getOmLanguage(); void setLanguage(long languageId); + Locale getLocale(); + Locale getLocale(User u); } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/AppointmentLogic.java Tue Nov 15 03:24:44 2016 @@ -46,6 +46,7 @@ import org.apache.openmeetings.db.entity import org.apache.openmeetings.db.entity.room.Room; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.util.TimezoneUtil; +import org.apache.openmeetings.service.mail.template.subject.AbstractSubjectEmailTemplate; import org.apache.openmeetings.service.mail.template.subject.AppointmentReminderTemplate; import org.apache.wicket.util.string.Strings; import org.red5.logging.Red5LoggerFactory; @@ -100,7 +101,7 @@ public class AppointmentLogic { String smsSubject = generateSMSSubject(langDao.getString(1158L, langId), a); - AppointmentReminderTemplate t = AppointmentReminderTemplate.get(langId, a, tz); + AbstractSubjectEmailTemplate t = AppointmentReminderTemplate.get(u, a, tz); invitationManager.sendInvitationLink(inv, MessageType.Create, t.getSubject(), t.getEmail(), false); invitationManager.sendInvitationReminderSMS(u.getAddress().getPhone(), smsSubject, langId); Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/AbstractTemplatePanel.java Tue Nov 15 03:24:44 2016 @@ -21,6 +21,8 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAULT_LANG_KEY; +import java.util.Locale; + import org.apache.openmeetings.IWebSession; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.db.dao.label.LabelDao; @@ -33,7 +35,7 @@ import org.apache.wicket.protocol.http.W public abstract class AbstractTemplatePanel extends Panel { private static final long serialVersionUID = 1L; public static final String COMP_ID = "template"; - protected long langId; + protected final Locale locale; public static <T> T getBean(Class<T> clazz) { return ensureApplication().getOmBean(clazz); @@ -43,13 +45,18 @@ public abstract class AbstractTemplatePa return (IWebSession)WebSession.get(); } - public AbstractTemplatePanel(Long langId) { + private static Locale getDefault() { + long langId = getBean(ConfigurationDao.class).getConfValue(CONFIG_DEFAULT_LANG_KEY, Long.class, "1"); + return LabelDao.languages.get(langId); + } + + public AbstractTemplatePanel(Locale locale) { super(COMP_ID); - this.langId = langId == null ? getBean(ConfigurationDao.class).getConfValue(CONFIG_DEFAULT_LANG_KEY, Long.class, "1") : langId; - add(new TransparentWebMarkupContainer("container").add(AttributeAppender.append("dir", FormatHelper.isRtlLanguage(LabelDao.languages.get(langId).toLanguageTag()) ? "rtl" : "ltr"))); + this.locale = locale == null ? getDefault() : locale; + add(new TransparentWebMarkupContainer("container").add(AttributeAppender.append("dir", FormatHelper.isRtlLanguage(this.locale.toLanguageTag()) ? "rtl" : "ltr"))); } - public static String getString(long id, long languageId) { - return ensureApplication().getOmString(id, languageId); + public static String getString(String id, Locale locale) { + return ensureApplication().getOmString(id, locale); } } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/FeedbackTemplate.java Tue Nov 15 03:24:44 2016 @@ -27,7 +27,7 @@ public class FeedbackTemplate extends Ab private static final long serialVersionUID = 1L; public FeedbackTemplate(String username, String email, String message) { - super(getOmSession().getOmLanguage()); + super(getOmSession().getLocale()); add(new Label("appname", getBean(ConfigurationDao.class).getAppName())); add(new Label("username", username)); add(new Label("email", email)); Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/InvitationTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,6 +20,9 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; + +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.core.util.string.ComponentRenderer; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; @@ -28,26 +31,26 @@ import org.apache.wicket.markup.html.lin public class InvitationTemplate extends AbstractTemplatePanel { private static final long serialVersionUID = 1L; - private InvitationTemplate(Long langId, String invitorName, String message, String link) { - super(langId); + private InvitationTemplate(Locale locale, String invitorName, String message, String link) { + super(locale); - add(new Label("titleLbl", getString(500, langId))); - add(new Label("userLbl", getString(501, langId))); + add(new Label("titleLbl", getString("500", locale))); + add(new Label("userLbl", getString("501", locale))); add(new Label("user", invitorName)); - add(new Label("messageLbl", getString(502, langId))); + add(new Label("messageLbl", getString("502", locale))); add(new Label("message", message).setEscapeModelStrings(false)); add(new WebMarkupContainer("links") - .add(new Label("comment_for_link1", getString(503, langId))) - .add(new ExternalLink("invitation_link1", link).add(new Label("clickMe", getString(504, langId)))) - .add(new Label("comment_for_link2", getString(505, langId))) + .add(new Label("comment_for_link1", getString("503", locale))) + .add(new ExternalLink("invitation_link1", link).add(new Label("clickMe", getString("504", locale)))) + .add(new Label("comment_for_link2", getString("505", locale))) .add(new Label("invitation_link2", link)) .setVisible(link != null) ); } - - public static String getEmail(Long langId, String invitorName, String message, String link) { - ensureApplication(langId); - return ComponentRenderer.renderComponent(new InvitationTemplate(langId, invitorName, message, link)).toString(); + + public static String getEmail(User invitee, String invitorName, String message, String link) { + ensureApplication(invitee.getLanguageId()); + return ComponentRenderer.renderComponent(new InvitationTemplate(getOmSession().getLocale(invitee), invitorName, message, link)).toString(); } } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/OmTextLabel.java Tue Nov 15 03:24:44 2016 @@ -18,8 +18,6 @@ */ package org.apache.openmeetings.service.mail.template; -import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; - import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.html.basic.Label; @@ -28,14 +26,6 @@ public class OmTextLabel extends Label { private static final long serialVersionUID = 1L; private static final String WICKET_VISIBLE = ":visible"; - public OmTextLabel(String id, long key, long langId) { - this(id, "" + key, langId); - } - - public OmTextLabel(String id, String key, long langId) { - this(id, ensureApplication().getOmString(key, langId)); - } - public OmTextLabel(String id, String label) { super(id, label); setRenderBodyOnly(true); Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RegisterUserTemplate.java Tue Nov 15 03:24:44 2016 @@ -27,15 +27,15 @@ public class RegisterUserTemplate extend private static final long serialVersionUID = 1L; public RegisterUserTemplate(String username, String email, String verification_url) { - super(getOmSession().getOmLanguage()); - add(new Label("registrationLbl", getString(506, langId))); + super(getOmSession().getLocale()); + add(new Label("registrationLbl", getString("506", locale))); add(new Label("username", username)); add(new Label("email", email)); WebMarkupContainer verification = new WebMarkupContainer("verification"); add(verification.add(new Label("verification_url2", verification_url)) .add(new ExternalLink("verification_url1", verification_url)) .setVisible(verification_url != null)); - add(new Label("groupLbl", getString(511, langId))); + add(new Label("groupLbl", getString("511", locale))); } public static String getEmail(String username, String email, String verification_url) { Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactConfirmTemplate.java Tue Nov 15 03:24:44 2016 @@ -26,15 +26,15 @@ public class RequestContactConfirmTempla private static final long serialVersionUID = 1L; public RequestContactConfirmTemplate(UserContact contact) { - super(contact.getOwner().getLanguageId()); - add(new Label("hi", getString(1192, langId))); + super(getOmSession().getLocale(contact.getOwner())); + add(new Label("hi", getString("1192", locale))); add(new Label("firstName", contact.getOwner().getFirstname())); add(new Label("lastName", contact.getOwner().getLastname())); add(new Label("addedFirstName", contact.getContact().getFirstname())); add(new Label("addedLastName", contact.getContact().getLastname())); - add(new Label("confirmed", getString(1198, langId))); + add(new Label("confirmed", getString("1198", locale))); } - + public static String getEmail(UserContact contact) { return ComponentRenderer.renderComponent(new RequestContactConfirmTemplate(contact)).toString(); } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/RequestContactTemplate.java Tue Nov 15 03:24:44 2016 @@ -29,17 +29,17 @@ public class RequestContactTemplate exte private static final long serialVersionUID = 1L; public RequestContactTemplate(User userToAdd, User user) { - super(userToAdd.getLanguageId()); - add(new Label("hi", getString(1192, langId))); + super(getOmSession().getLocale(userToAdd)); + add(new Label("hi", getString("1192", locale))); add(new Label("addedFirstName", userToAdd.getFirstname())); add(new Label("addedLastName", userToAdd.getLastname())); add(new Label("firstName", user.getFirstname())); add(new Label("lastName", user.getLastname())); - add(new Label("likeToAdd", getString(1193, langId))); - add(new Label("check", getString(1194, langId))); - add(new ExternalLink("link", ensureApplication().getOmContactsLink()).add(new Label("contactList", getString(1196, langId)))); + add(new Label("likeToAdd", getString("1193", locale))); + add(new Label("check", getString("1194", locale))); + add(new ExternalLink("link", ensureApplication().getOmContactsLink()).add(new Label("contactList", getString("1196", locale)))); } - + public static String getEmail(User userToAdd, User user) { return ComponentRenderer.renderComponent(new RequestContactTemplate(userToAdd, user)).toString(); } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/ResetPasswordTemplate.java Tue Nov 15 03:24:44 2016 @@ -26,7 +26,7 @@ public class ResetPasswordTemplate exten private static final long serialVersionUID = 1L; public ResetPasswordTemplate(String link) { - super(getOmSession().getOmLanguage()); + super(getOmSession().getLocale()); add(new ExternalLink("reset_link1", link)); add(new Label("reset_link2", link)); } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AbstractSubjectEmailTemplate.java Tue Nov 15 03:24:44 2016 @@ -18,13 +18,18 @@ */ package org.apache.openmeetings.service.mail.template.subject; +import static org.apache.commons.lang3.time.FastDateFormat.MEDIUM; +import static org.apache.commons.lang3.time.FastDateFormat.SHORT; + +import java.util.Date; +import java.util.Locale; import java.util.TimeZone; +import org.apache.commons.lang3.time.FastDateFormat; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.service.mail.template.AbstractTemplatePanel; import org.apache.openmeetings.service.mail.template.DashOmTextLabel; import org.apache.openmeetings.service.mail.template.OmTextLabel; -import org.apache.openmeetings.util.CalendarPatterns; import org.apache.wicket.core.util.string.ComponentRenderer; import org.apache.wicket.markup.html.panel.Fragment; @@ -34,42 +39,53 @@ public abstract class AbstractSubjectEma protected TimeZone tz; private String email = null; private String subject = null; + private boolean created = false; - - public AbstractSubjectEmailTemplate(Long langId, Appointment a, TimeZone tz) { - super(langId); + public AbstractSubjectEmailTemplate(Locale locale, Appointment a, TimeZone tz) { + super(locale); this.a = a; this.tz = tz; } - abstract void omInit(); - - @Override - protected void onInitialize() { - super.onInitialize(); - omInit(); + AbstractSubjectEmailTemplate create() { email = ComponentRenderer.renderComponent(this).toString(); subject = ComponentRenderer.renderComponent(getSubjectFragment()).toString(); + created = true; + return this; } - public final String getEmail() { - return email; + abstract String getPrefix(); + + protected String format(Date d) { + return format(d, MEDIUM); } - abstract String getPrefix(); + protected String format(Date d, int fmt) { + return FastDateFormat.getDateTimeInstance(fmt, fmt, tz, locale).format(d); + } Fragment getSubjectFragment() { Fragment f = new Fragment(COMP_ID, "subject", this); f.add(new OmTextLabel("prefix", getPrefix()) , new OmTextLabel("title", a.getTitle()) - , new OmTextLabel("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz)) + , new OmTextLabel("start", format(a.getStart(), SHORT)) , new DashOmTextLabel("dash") - , new OmTextLabel("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz)) + , new OmTextLabel("end", format(a.getEnd(), SHORT)) ); return f; } + public final String getEmail() { + if (!created) { + throw new RuntimeException("Not created!!"); + } + return email; + } + public final String getSubject() { + if (!created) { + throw new RuntimeException("Not created!!"); + } return subject; } } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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 Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/AppointmentReminderTemplate.java Tue Nov 15 03:24:44 2016 @@ -20,10 +20,11 @@ package org.apache.openmeetings.service. import static org.apache.openmeetings.db.util.ApplicationHelper.ensureApplication; +import java.util.Locale; import java.util.TimeZone; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.util.CalendarPatterns; +import org.apache.openmeetings.db.entity.user.User; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.util.string.Strings; @@ -31,32 +32,33 @@ import org.apache.wicket.util.string.Str public class AppointmentReminderTemplate extends AbstractSubjectEmailTemplate { private static final long serialVersionUID = 1L; - private AppointmentReminderTemplate(Long langId, Appointment a, TimeZone tz) { - super(langId, a, tz); + private AppointmentReminderTemplate(Locale locale, Appointment a, TimeZone tz) { + super(locale, a, tz); } @Override - void omInit() { - add(new Label("titleLbl", getString(1158L, langId))); + protected void onInitialize() { + super.onInitialize(); + add(new Label("titleLbl", getString("1158", locale))); add(new Label("title", a.getTitle())); add(new WebMarkupContainer("descContainer") - .add(new Label("descLbl", getString(1152L, langId))) + .add(new Label("descLbl", getString("1152", locale))) .add(new Label("desc", a.getDescription()).setEscapeModelStrings(false)) .setVisible(!Strings.isEmpty(a.getDescription())) ); - add(new Label("startLbl", getString(1153L, langId))); - add(new Label("start", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getStart(), tz))); - add(new Label("endLbl", getString(1154L, langId))); - add(new Label("end", CalendarPatterns.getDateWithTimeByMiliSecondsAndTimeZone(a.getEnd(), tz))); + add(new Label("startLbl", getString("1153", locale))); + add(new Label("start", format(a.getStart()))); + add(new Label("endLbl", getString("1154", locale))); + add(new Label("end", format(a.getEnd()))); } - public static AppointmentReminderTemplate get(Long langId, Appointment a, TimeZone tz) { - ensureApplication(langId); - return new AppointmentReminderTemplate(langId, a, tz); + public static AbstractSubjectEmailTemplate get(User u, Appointment a, TimeZone tz) { + ensureApplication(u.getLanguageId()); + return new AppointmentReminderTemplate(getOmSession().getLocale(u), a, tz).create(); } @Override String getPrefix() { - return ensureApplication().getOmString(1158, langId); + return ensureApplication().getOmString("1158", locale); } } Modified: openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html?rev=1769713&r1=1769712&r2=1769713&view=diff ============================================================================== --- openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html (original) +++ openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/template/subject/CanceledAppointmentTemplate.html Tue Nov 15 03:24:44 2016 @@ -9,7 +9,7 @@ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + 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