@Override public String resolveMessage(MessageKey key) { // Lazy load the bundle here if (!bundleLoaded) { bundleLoaded = true; if (locale != null) { ApplicationContext applicationContext = Request.getCurrent().getApplicationContext(); if (applicationContext != null) { bundle = applicationContext.resolveBundle(locale); } } } // String value = null; if (bundle != null) { try { value = bundle.getString(key.getValue()); } catch (MissingResourceException notFound) { // System.out.println("Could not resolve message " + key.getValue()); } } return value != null ? value : ""; } };
@Override public String resolveMessage(MessageKey key) { // Lazy load the bundle here if (!bundleLoaded) { bundleLoaded = true; if (locale != null) { ApplicationContext applicationContext = Request.getCurrent().getApplicationContext(); if (applicationContext != null) { bundle = applicationContext.resolveBundle(locale); } } } // String value = null; if (bundle != null) { try { value = bundle.getString(key.getValue()); } catch (MissingResourceException notFound) { // System.out.println("Could not resolve message " + key.getValue()); } } return value != null ? value : ""; } };
public ResourceBundle get() { Request request = Request.getCurrent(); Locale locale = request.getUserContext().getLocale(); return request.getApplicationContext().resolveBundle(locale); } }
public ResourceBundle get() { Request request = Request.getCurrent(); Locale locale = request.getUserContext().getLocale(); return request.getApplicationContext().resolveBundle(locale); } }
@View public Response index(ApplicationContext applicationContext, UserContext userContext){ //Redirect yo the home's page when the feature is off if (! CommonsUtils.isFeatureActive(NotificationUtils.FEATURE_NAME)) { return redirectToHomePage(); } this.locale = userContext.getLocale(); ResourceBundle rs = applicationContext.resolveBundle(this.locale); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("_ctx", new Context(rs)); List<GroupProvider> groups = pluginSettingService.getGroupPlugins(); parameters.put("groups", groups); // parameters.put("channels", getChannels()); //try to get sender name and email from database. If fail, get default value from properties file SettingValue<?> senderName = settingService.get(org.exoplatform.commons.api.settings.data.Context.GLOBAL, Scope.GLOBAL, NotificationPluginUtils.NOTIFICATION_SENDER_NAME); SettingValue<?> senderEmail = settingService.get(org.exoplatform.commons.api.settings.data.Context.GLOBAL, Scope.GLOBAL, NotificationPluginUtils.NOTIFICATION_SENDER_EMAIL); parameters.put("senderName", senderName != null ? (String)senderName.getValue() : System.getProperty("exo.notifications.portalname", "eXo")); parameters.put("senderEmail", senderEmail != null ? (String)senderEmail.getValue() : System.getProperty("gatein.email.smtp.from", "noreply@exoplatform.com")); return index.ok(parameters); }