List of usage examples for javax.servlet.http HttpServletRequest getLocale
public Locale getLocale();
Locale
that the client will accept content in, based on the Accept-Language header. From source file:com.hp.avmon.config.service.AgentManageService.java
/** * ?AMP AMP?//from www. ja v a2s . co m * @param request * @return */ public Map findIssuedAmpSchedule(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); String scheduleJsonAttr = request.getParameter("agentAmpInfo"); String agentId = request.getParameter("agentId"); List<Map<String, String>> mapList = getListMapByJsonArrayString(scheduleJsonAttr); Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); //TODO ???? map.put("success", false); map.put("errorMsg", bundle.getString("cannotBeIssuedPolicyInformation")); return map; }
From source file:com.hp.avmon.config.service.AgentManageService.java
public Map pushIloHostSchedule(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); String agentId = request.getParameter("agentId"); List<Map<String, String>> ampListMapF = getListMapByJsonArrayString(request.getParameter("agentAmpInfo")); boolean flag = false; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); //TODO ???// ww w. ja va 2 s . c o m for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); String ip = ampMap.get("ip"); String sql = String.format( "select * from td_avmon_amp_policy where agent_id='%s' and amp_inst_id='%s' and node_key='%s'", agentId, ampInstId, ip); List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); for (Map<String, Object> m : list) { String result = avmonServer.deployAmpSchedule(agentId, ampInstId, ampMap.get("moId"), m.get("KPI_CODE").toString(), null, m.get("SCHEDULE").toString()); //String result = avmonServer.deployAmpSchedule(agentId, ampInstId,moId,kpiCode,null,schedule); if (result.startsWith("00")) { map.put("success", true); map.put("errorMsg", bundle.getString("dispatchIssuedSuccess")); } else { map.put("success", false); map.put("errorMsg", result); return map; } } } return map; }
From source file:fr.paris.lutece.plugins.calendar.web.CalendarApp.java
/** * Get the XPage for subscribing//from ww w .j av a2s. c om * @param request {@link HttpServletRequest} * @param plugin {@link Plugin} * @return the html */ private XPage getSubscriptionPage(HttpServletRequest request, Plugin plugin) { XPage page = new XPage(); boolean bIsCaptchaEnabled = PluginService.isPluginEnable(Constants.PLUGIN_JCAPTCHA); String strBaseUrl = AppPathService.getBaseUrl(request); UrlItem url = new UrlItem(strBaseUrl + JSP_PAGE_PORTAL); url.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); url.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_VERIFY_SUBSCRIBE); Map<String, Object> model = new HashMap<String, Object>(); model.put(Constants.MARK_JSP_URL, url.getUrl()); model.put(Constants.MARK_LOCALE, request.getLocale()); model.put(Constants.MARK_CALENDARS_LIST, getListAgenda(request, plugin)); model.put(Constants.MARK_IS_ACTIVE_CAPTCHA, bIsCaptchaEnabled); if (bIsCaptchaEnabled) { _captchaService = new CaptchaSecurityService(); model.put(Constants.MARK_CAPTCHA, _captchaService.getHtmlCode()); } HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_SUBSCRIPTION_FORM, request.getLocale(), model); page.setContent(template.getHtml()); page.setTitle( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_SUBSCRIPTION_TITLE, request.getLocale())); page.setPathLabel( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_SUBSCRIPTION_TITLE, request.getLocale())); return page; }
From source file:fr.paris.lutece.portal.service.admin.AdminUserService.java
/** * Check that the password respect user parameters * @param request The request/* w w w . j av a 2 s . co m*/ * @param strPassword The password to check * @param nUserId The id of the modified user * @param bSkipHistoryCheck Indicates if the password history should be checked or not. * @return Null if the password is correct, or the url of an admin message describing the error */ public static String checkPassword(HttpServletRequest request, String strPassword, int nUserId, boolean bSkipHistoryCheck) { // Minimum password length int nMinimumLength = AdminUserService.getIntegerSecurityParameter(PARAMETER_PASSWORD_MINIMUM_LENGTH); if ((nMinimumLength > 0) && (strPassword.length() < nMinimumLength)) { Object[] param = { nMinimumLength }; return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_MINIMUM_PASSWORD_LENGTH, param, AdminMessage.TYPE_STOP); } // Password format boolean bUserPasswordFormatUpperLowerCase = AdminUserService .getBooleanSecurityParameter(PARAMETER_PASSWORD_FORMAT_UPPER_LOWER_CASE); boolean bUserPasswordFormatNumero = AdminUserService .getBooleanSecurityParameter(PARAMETER_PASSWORD_FORMAT_NUMERO); boolean bUserPasswordFormatSpecialCaracters = AdminUserService .getBooleanSecurityParameter(PARAMETER_PASSWORD_FORMAT_SPECIAL_CHARACTERS); if ((bUserPasswordFormatUpperLowerCase || bUserPasswordFormatNumero || bUserPasswordFormatSpecialCaracters) && !PasswordUtil.checkPasswordFormat(strPassword, bUserPasswordFormatUpperLowerCase, bUserPasswordFormatNumero, bUserPasswordFormatSpecialCaracters)) { StringBuffer strParam = new StringBuffer(); //Add Message Upper Lower Case if (bUserPasswordFormatUpperLowerCase) { strParam.append(I18nService.getLocalizedString(PROPERTY_MESSAGE_PASSWORD_FORMAT_UPPER_LOWER_CASE, request.getLocale())); } //Add Message Numero if (bUserPasswordFormatNumero) { if (bUserPasswordFormatUpperLowerCase) { strParam.append(", "); } strParam.append(I18nService.getLocalizedString(PROPERTY_MESSAGE_PASSWORD_FORMAT_NUMERO, request.getLocale())); } //Add Message Special Characters if (bUserPasswordFormatSpecialCaracters) { if (bUserPasswordFormatUpperLowerCase || bUserPasswordFormatNumero) { strParam.append(", "); } strParam.append(I18nService.getLocalizedString(PROPERTY_MESSAGE_PASSWORD_FORMAT_SPECIAL_CHARACTERS, request.getLocale())); } Object[] param = { strParam.toString() }; return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_PASSWORD_FORMAT, param, AdminMessage.TYPE_STOP); } // Check password history if ((nUserId > 0) && !bSkipHistoryCheck) { int nPasswordHistorySize = AdminUserService .getIntegerSecurityParameter(PARAMETER_PASSWORD_HISTORY_SIZE); if (nPasswordHistorySize > 0) { String strEncryptedPassword = encryptPassword(strPassword); List<String> passwordHistory = AdminUserHome.selectUserPasswordHistory(nUserId); if (nPasswordHistorySize < passwordHistory.size()) { passwordHistory = passwordHistory.subList(0, nPasswordHistorySize); } if (passwordHistory.contains(strEncryptedPassword)) { return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_PASSWORD_ALREADY_USED, AdminMessage.TYPE_STOP); } } int nTSWSizePasswordChange = AdminUserService .getIntegerSecurityParameter(PARAMETER_TSW_SIZE_PASSWORD_CHANGE); int nMaximumNumberPasswordChange = AdminUserService .getIntegerSecurityParameter(PARAMETER_MAXIMUM_NUMBER_PASSWORD_CHANGE); if (nMaximumNumberPasswordChange > 0) { Timestamp minDate; if (nTSWSizePasswordChange > 0) { minDate = new Timestamp(new java.util.Date().getTime() - DateUtil.convertDaysInMiliseconds(nTSWSizePasswordChange)); } else { minDate = new Timestamp(0); } if (AdminUserHome.countUserPasswordHistoryFromDate(minDate, nUserId) >= nMaximumNumberPasswordChange) { return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_MAX_PASSWORD_CHANGE, AdminMessage.TYPE_STOP); } } } return null; }
From source file:com.hp.avmon.config.service.AgentManageService.java
/** * ?AMP/*from w w w . ja v a2 s . c om*/ * @param request * @return */ public Map pauseNormalAmp(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); //TODO ?AMP ??AMP? final List<Map<String, String>> ampListMapF = getListMapByJsonArrayString( request.getParameter("agentAmpInfo")); boolean flag = false; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); String agentId = ampMap.get("agentId"); String ampId = ampMap.get("ampId"); String result = avmonServer.stopAmp(agentId, ampInstId); if (result.startsWith("00")) { String updateAmpStatusSql = String.format( "UPDATE TD_AVMON_AMP_INST SET STATUS = 2 WHERE AMP_INST_ID ='%s' AND AMP_ID ='%s' AND AGENT_ID ='%s'", ampInstId, ampId, agentId); jdbcTemplate.update(updateAmpStatusSql); flag = true; map.put("errorMsg", bundle.getString("stopNormalAMPSuccess")); } else { map.put("errorMsg", result); } } //updateNormalAMPStatus(ampListMapF,ConfigConstant.AMP_STATUS_DISABLED); if (flag) { map.put("success", true); } else { map.put("success", false); } return map; }
From source file:com.hp.avmon.config.service.AgentManageService.java
/** * ?AMP/*w ww. j av a 2 s. c om*/ * @param request * @return */ public Map startNormalAmp(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); //TODO ?AMP ??AMP? final List<Map<String, String>> ampListMapF = getListMapByJsonArrayString( request.getParameter("agentAmpInfo")); boolean flag = false; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); String agentId = ampMap.get("agentId"); String ampId = ampMap.get("ampId"); String result = avmonServer.startAmp(agentId, ampInstId); if (result.startsWith("00")) { String updateAmpStatusSql = String.format( "UPDATE TD_AVMON_AMP_INST SET STATUS = 1 WHERE AMP_INST_ID ='%s' AND AMP_ID ='%s' AND AGENT_ID ='%s'", ampInstId, ampId, agentId); jdbcTemplate.update(updateAmpStatusSql); flag = true; map.put("errorMsg", bundle.getString("startNormalAMPSuccess")); } else { map.put("errorMsg", result); } } //boolean flag = updateNormalAMPStatus(ampListMapF, ConfigConstant.AMP_STATUS_ACTIVITY); if (flag) { map.put("success", true); } else { map.put("success", false); } return map; }
From source file:com.hp.avmon.config.service.AgentManageService.java
/** * ?+????AMP???/*w w w . j ava2 s . co m*/ * // modify by mark start //???AMP? --?? // modify by mark end * @param request ?--muzh * @return */ public Map pushAgentAmpScript(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); //???AMPList final List<Map<String, String>> ampListMapF = getListMapByJsonArrayString( request.getParameter("agentAmpInfo")); StringBuffer buff = new StringBuffer(); Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); String agentId = ampMap.get("agentId"); String ampId = ampMap.get("ampId"); String result = avmonServer.deployAmpPackage(agentId, ampInstId); buff.append(ampInstId); if (result.startsWith("00")) { // modify by mark start //???AMP? --?? String updateAmpStatusSql = String.format(SqlManager.getSql(this, "updateAmpStatus"), ampInstId, ampId, agentId); // modify by mark start jdbcTemplate.update(updateAmpStatusSql); buff.append(bundle.getString("scriptIssuedSuccess")); } else { buff.append(bundle.getString("scriptIssuedFail")); logger.debug(result); } buff.append("<br/>"); } map.put("msg", buff.toString()); // if(pushFlag){ // flag = updateNormalAMPStatus(ampListMapF,ConfigConstant.AMP_STATUS_DISABLED); // } map.put("success", true); return map; }
From source file:io.lavagna.web.support.ResourceController.java
@RequestMapping(value = { "/", // "user/{provider}/{username}", "user/{provider}/{username}/projects/", "user/{provider}/{username}/activity/", // "about", "about/third-party", // "search", // "search/" + PROJ_SHORT_NAME + "/" + BOARD_SHORT_NAME + "-" + CARD_SEQ, // PROJ_SHORT_NAME + "", // PROJ_SHORT_NAME + "/search", // PROJ_SHORT_NAME + "/search/" + BOARD_SHORT_NAME + "-" + CARD_SEQ, // / PROJ_SHORT_NAME + "/" + BOARD_SHORT_NAME, // PROJ_SHORT_NAME + "/statistics", // PROJ_SHORT_NAME + "/milestones", // PROJ_SHORT_NAME + "/milestones/" + BOARD_SHORT_NAME + "-" + CARD_SEQ, // PROJ_SHORT_NAME + "/" + BOARD_SHORT_NAME + "-" + CARD_SEQ }, method = RequestMethod.GET) public void handleIndex(HttpServletRequest request, HttpServletResponse response) throws IOException { ServletContext context = request.getServletContext(); if (contains(env.getActiveProfiles(), "dev") || indexTopTemplate.get() == null) { ByteArrayOutputStream indexTop = new ByteArrayOutputStream(); try (InputStream is = context.getResourceAsStream("/WEB-INF/views/index-top.html")) { StreamUtils.copy(is, indexTop); }/*from w w w. j a v a2s .c om*/ indexTopTemplate.set(Mustache.compiler().escapeHTML(false) .compile(indexTop.toString(StandardCharsets.UTF_8.name()))); } if (contains(env.getActiveProfiles(), "dev") || indexCache.get() == null) { ByteArrayOutputStream index = new ByteArrayOutputStream(); output("/WEB-INF/views/index.html", context, index, new BeforeAfter()); Map<String, Object> data = new HashMap<>(); data.put("contextPath", request.getServletContext().getContextPath() + "/"); data.put("version", version); List<String> inlineTemplates = prepareTemplates(context, "/app/"); inlineTemplates.addAll(prepareTemplates(context, "/partials/")); data.put("inlineTemplates", inlineTemplates); indexCache.set( Mustache.compiler().escapeHTML(false).compile(index.toString(StandardCharsets.UTF_8.name())) .execute(data).getBytes(StandardCharsets.UTF_8)); } try (OutputStream os = response.getOutputStream()) { response.setContentType("text/html; charset=UTF-8"); Map<String, Object> localizationData = new HashMap<>(); Locale currentLocale = ObjectUtils.firstNonNull(request.getLocale(), Locale.ENGLISH); localizationData.put("firstDayOfWeek", Calendar.getInstance(currentLocale).getFirstDayOfWeek()); StreamUtils.copy(indexTopTemplate.get().execute(localizationData).getBytes(StandardCharsets.UTF_8), os); StreamUtils.copy(indexCache.get(), os); } }
From source file:com.hp.avmon.config.service.AgentManageService.java
public Map removeAmp(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); //TODO ?AMP ??AMP? final List<Map<String, String>> ampListMapF = getListMapByJsonArrayString( request.getParameter("agentAmpInfo")); boolean flag = false; Locale locale = request.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); String agentId = ampMap.get("agentId"); String ampId = ampMap.get("ampId"); jdbcTemplate.execute(/* www. java2 s . c o m*/ String.format("delete from TD_AVMON_AMP_POLICY where agent_id='%s' and amp_inst_id='%s'", agentId, ampInstId)); jdbcTemplate.execute( String.format("delete from TD_AVMON_AMP_VM_HOST where agent_id='%s' and amp_inst_id='%s'", agentId, ampInstId)); jdbcTemplate.execute( String.format("delete from TD_AVMON_AMP_ILO_HOST where agent_id='%s' and amp_inst_id='%s'", agentId, ampInstId)); jdbcTemplate.execute( String.format("delete from TD_AVMON_AMP_INST_ATTR where agent_id='%s' and amp_inst_id='%s'", agentId, ampInstId)); jdbcTemplate.execute(String.format( "delete from TD_AVMON_AMP_INST where agent_id='%s' and amp_inst_id='%s'", agentId, ampInstId)); map.put("errorMsg", bundle.getString("uninstallSuccess")); } flag = true; //updateNormalAMPStatus(ampListMapF,ConfigConstant.AMP_STATUS_DISABLED); if (flag) { map.put("success", true); } else { map.put("success", false); } return map; }