/** * Update the user expiration date with new values, and notify him with an email. * * @param nIdUser Id of the user to update * @param plugin The plugin */ @SuppressWarnings("deprecation") public void updateUserExpirationDate(int nIdUser, Plugin plugin) { // We update the user account int nbMailSend = DatabaseUserHome.getNbAccountLifeTimeNotification(nIdUser, plugin); Timestamp newExpirationDate = SecurityUtils.getAccountMaxValidDate(_userParamService, plugin); DatabaseUserHome.updateUserExpirationDate(nIdUser, newExpirationDate, plugin); // We notify the user DatabaseAccountLifeTimeService accountLifeTimeService = new DatabaseAccountLifeTimeService(); String strUserMail = accountLifeTimeService.getUserMainEmail(nIdUser); if ((nbMailSend > 0) && StringUtils.isNotBlank(strUserMail)) { String strBody = DatabaseTemplateService.getTemplateFromKey(PARAMETER_ACCOUNT_REACTIVATED_MAIL_BODY); ReferenceItem referenceItem = _userParamService.findByKey(PARAMETER_ACCOUNT_REACTIVATED_MAIL_SENDER, plugin); String strSender = (referenceItem == null) ? StringUtils.EMPTY : referenceItem.getName(); referenceItem = _userParamService.findByKey(PARAMETER_ACCOUNT_REACTIVATED_MAIL_SUBJECT, plugin); String strSubject = (referenceItem == null) ? StringUtils.EMPTY : referenceItem.getName(); Map<String, String> model = new HashMap<String, String>(); accountLifeTimeService.addParametersToModel(model, nIdUser); HtmlTemplate template = AppTemplateService.getTemplateFromStringFtl(strBody, Locale.getDefault(), model); MailService.sendMailHtml(strUserMail, strSender, strSender, strSubject, template.getHtml()); } }
/** * Get the encoding for export XML * * @return the encoding for export XML */ public String getExportXMLEncoding() { ReferenceItem param = findByKey(PARAMETER_EXPORT_XML_ENCODING); if (param == null) { return AppPropertiesService.getProperty(PROPERTY_DEFAULT_EXPORT_ENCODING); } return param.getName(); }
/** * Constructor * * @param group The group * @param locale The locale */ public LocalizedDataGroup(ILocalizedDataGroup group, Locale locale) { _strName = I18nService.getLocalizedString(group.getNameKey(), locale); _strDescription = I18nService.getLocalizedString(group.getDescriptionKey(), locale); ReferenceList listProperties = DatastoreService.getDataByPrefix(group.getDatastoreKeysPrefix()); for (int i = 0; i < listProperties.size(); i++) { ReferenceItem item = listProperties.get(i); LocalizedData property = new LocalizedData(); property.setKey(item.getCode()); property.setValue(item.getName()); property.setLabel(I18nService.getLocalizedString(item.getCode(), locale)); property.setHelp(I18nService.getLocalizedString(item.getCode() + SUFFIX_HELP, locale)); _listLocalizedData.add(property); } }
/** * Gets the export format modification page * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The export format creation page */ public String getModifyXslExport(HttpServletRequest request) throws AccessDeniedException { if (!RBACService.isAuthorized( XslExport.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, XslExportResourceIdService.PERMISSION_MODIFY, getUser())) { throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED); } XslExport xslExport; String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT); HashMap<String, Object> model = new HashMap<String, Object>(); int nIdXslExport = Integer.parseInt(strIdXslExport); xslExport = XslExportHome.findByPrimaryKey(nIdXslExport); model.put(MARK_XSL_EXPORT, xslExport); Collection<Plugin> listPlugins = PluginService.getPluginList(); ReferenceList refListPlugins = new ReferenceList(); ReferenceItem refItem = new ReferenceItem(); Plugin pluginCore = PluginService.getCore(); refItem.setCode(pluginCore.getName()); refItem.setName(pluginCore.getName()); refListPlugins.add(refItem); for (Plugin plugin : listPlugins) { if (plugin != null) { refItem = new ReferenceItem(); refItem.setCode(plugin.getName()); refItem.setName(plugin.getName()); refListPlugins.add(refItem); } } model.put(MARK_LIST_PLUGINS, refListPlugins); setPageTitleProperty(PROPERTY_MODIFY_XSL_EXPORT_TITLE); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_XSL_EXPORT, getLocale(), model); return getAdminPage(template.getHtml()); }
/** * Change all user's password and notify them with an email. * * @param strBaseURL The base url of the application * @param plugin The plugin * @param locale The locale to use */ public void changeUserPasswordAndNotify(String strBaseURL, Plugin plugin, Locale locale) { // Alert all users their password have been reinitialized. Collection<DatabaseUser> listUsers = DatabaseUserHome.findDatabaseUsersList(plugin); for (DatabaseUser user : listUsers) { // Makes password String strPassword = SecurityUtils.makePassword(_userParamService, plugin); doModifyPassword(user, strPassword, plugin); if (StringUtils.isNotBlank(user.getEmail())) { // Sends password by e-mail ReferenceItem referenceItem = _userParamService.findByKey(PARAMETER_MAIL_PASSWORD_ENCRYPTION_CHANGED_SENDER, plugin); String strSenderEmail = (referenceItem == null) ? StringUtils.EMPTY : referenceItem.getName(); referenceItem = _userParamService.findByKey(PARAMETER_MAIL_PASSWORD_ENCRYPTION_CHANGED_SUBJECT, plugin); String strEmailSubject = (referenceItem == null) ? StringUtils.EMPTY : referenceItem.getName(); Map<String, Object> model = new HashMap<String, Object>(); model.put(MARK_NEW_PASSWORD, strPassword); model.put( MARK_LOGIN_URL, strBaseURL + AdminAuthenticationService.getInstance().getLoginPageUrl()); model.put(MARK_SITE_LINK, MailService.getSiteLink(strBaseURL, true)); String strTemplate = DatabaseTemplateService.getTemplateFromKey(PARAMETER_MAIL_PASSWORD_ENCRYPTION_CHANGED); HtmlTemplate template = AppTemplateService.getTemplateFromStringFtl(strTemplate, locale, model); MailService.sendMailHtml( user.getEmail(), strSenderEmail, strSenderEmail, strEmailSubject, template.getHtml()); } } }
/** * Gets the xsl export creation page * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The xsl export creation page */ public String getCreateXslExport(HttpServletRequest request) throws AccessDeniedException { HashMap<String, Object> model = new HashMap<String, Object>(); Collection<Plugin> listPlugins = PluginService.getPluginList(); ReferenceList refListPlugins = new ReferenceList(); ReferenceItem refItem = new ReferenceItem(); Plugin pluginCore = PluginService.getCore(); refItem.setCode(pluginCore.getName()); refItem.setName(pluginCore.getName()); refListPlugins.add(refItem); for (Plugin plugin : listPlugins) { if (plugin != null) { refItem = new ReferenceItem(); refItem.setCode(plugin.getName()); refItem.setName(plugin.getName()); refListPlugins.add(refItem); } } model.put(MARK_LIST_PLUGINS, refListPlugins); if (!RBACService.isAuthorized( XslExport.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, XslExportResourceIdService.PERMISSION_CREATE, getUser())) { throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED); } setPageTitleProperty(PROPERTY_CREATE_XSL_EXPORT_TITLE); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CREATE_XSL_EXPORT, getLocale(), model); return getAdminPage(template.getHtml()); }