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:fr.paris.lutece.plugins.crm.web.demand.DemandTypeJspBean.java
/** * Returns the form to update info about a demand type * @param request The Http request/*from w w w .j ava2 s. com*/ * @return The HTML form to update info */ public String getModifyDemandType(HttpServletRequest request) { setPageTitleProperty(CRMConstants.PROPERTY_MODIFY_DEMAND_TYPE_PAGE_TITLE); String strHtml = StringUtils.EMPTY; String strIdDemandType = request.getParameter(CRMConstants.PARAMETER_ID_DEMAND_TYPE); if (StringUtils.isNotBlank(strIdDemandType) && StringUtils.isNumeric(strIdDemandType)) { int nIdDemandType = Integer.parseInt(strIdDemandType); DemandType demandType = _demandTypeService.findByPrimaryKey(nIdDemandType); if (demandType != null) { Map<String, Object> model = new HashMap<String, Object>(); model.put(CRMConstants.MARK_DEMAND_TYPE, demandType); model.put(CRMConstants.MARK_CATEGORIES_LIST, _categoryService.getCategories(getLocale(), false, false)); model.put(CRMConstants.MARK_MAX_ORDER, _demandTypeService.findMaxOrder()); model.put(CRMConstants.MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups(getUser(), getLocale())); model.put(CRMConstants.MARK_TARGETS_LIST, _demandTypeService.getTargetsList()); model.put(CRMConstants.MARK_LOCALE, request.getLocale()); if (SecurityService.isAuthenticationEnable()) { model.put(CRMConstants.MARK_ROLE_REF_LIST, _demandTypeService.getRolesList()); } HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_DEMAND_TYPE, getLocale(), model); strHtml = getAdminPage(template.getHtml()); } else { throw new AppException( I18nService.getLocalizedString(CRMConstants.MESSAGE_ERROR, request.getLocale())); } } else { throw new AppException(I18nService.getLocalizedString(CRMConstants.MESSAGE_ERROR, request.getLocale())); } return strHtml; }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractRegistrationController.java
/** * Method for request Call//from www .jav a 2 s.c o m * * @param phoneNumber * @param countryCode * @param request * @return Map of String * @throws JsonGenerationException * @throws JsonMappingException * @throws IOException */ @RequestMapping(value = "/request_call", method = RequestMethod.POST) @ResponseBody public Map<String, String> requestCall(@RequestParam(value = "phoneNumber", required = true) String phoneNumber, @RequestParam(value = "countryCode", required = true) String countryCode, HttpServletRequest request) throws JsonGenerationException, JsonMappingException, IOException { Map<String, String> returnResponse = new HashMap<String, String>(); try { Map<String, String> phoneTypeResp = ((TelephoneTypeVerificationService) connectorManagementService .getOssServiceInstancebycategory(ConnectorType.PHONE_VERIFICATION)).verifyPhoneType(countryCode, phoneNumber, request.getLocale()); if (!Boolean.valueOf(phoneTypeResp.get("result").toString())) { returnResponse.put("result", "failed"); returnResponse.put("message", phoneTypeResp.get("message")); return returnResponse; } } catch (TelephoneVerificationServiceException e) { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource .getMessage("js.errors.register.phone.type.validation.failure", null, request.getLocale())); return returnResponse; } String generatedPhoneVerificationPin = request.getSession().getAttribute("phoneVerificationPin").toString(); request.getSession().setAttribute("phoneNumber", phoneNumber); try { String refId = ((TelephoneVerificationService) connectorManagementService .getOssServiceInstancebycategory(ConnectorType.PHONE_VERIFICATION)).requestCall(countryCode, phoneNumber, generatedPhoneVerificationPin); if (refId != null) { returnResponse.put("result", "success"); returnResponse.put("message", messageSource.getMessage("js.errors.register.callRequested", null, request.getLocale())); } else { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource.getMessage("js.errors.register.callFailed", null, request.getLocale())); } } catch (TelephoneVerificationServiceException e) { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource.getMessage("js.errors.register.callFailed", null, request.getLocale())); } return returnResponse; }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractRegistrationController.java
/** * Method for Request of SMS/*from www. j a v a 2s .com*/ * * @param phoneNumber * @param countryCode * @param request * @return Map of String * @throws JsonGenerationException * @throws JsonMappingException * @throws IOException */ @RequestMapping(value = "/request_sms", method = RequestMethod.POST) @ResponseBody public Map<String, String> requestSMS(@RequestParam(value = "phoneNumber", required = true) String phoneNumber, @RequestParam(value = "countryCode", required = true) String countryCode, HttpServletRequest request) throws JsonGenerationException, JsonMappingException, IOException { Map<String, String> returnResponse = new HashMap<String, String>(); try { Map<String, String> phoneTypeResp = ((TelephoneTypeVerificationService) connectorManagementService .getOssServiceInstancebycategory(ConnectorType.PHONE_VERIFICATION)).verifyPhoneType(countryCode, phoneNumber, request.getLocale()); if (!Boolean.valueOf(phoneTypeResp.get("result").toString())) { returnResponse.put("result", "failed"); returnResponse.put("message", phoneTypeResp.get("message")); return returnResponse; } } catch (TelephoneVerificationServiceException e) { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource .getMessage("js.errors.register.phone.type.validation.failure", null, request.getLocale())); return returnResponse; } String generatedPhoneVerificationPin = request.getSession().getAttribute("phoneVerificationPin").toString(); request.getSession().setAttribute("phoneNumber", phoneNumber); try { String refId = ((TelephoneVerificationService) connectorManagementService .getOssServiceInstancebycategory(ConnectorType.PHONE_VERIFICATION)).requestSMS(countryCode, phoneNumber, generatedPhoneVerificationPin); if (refId != null) { returnResponse.put("result", "success"); returnResponse.put("message", messageSource.getMessage("js.errors.register.textMessageRequested", null, request.getLocale())); } else { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource.getMessage("js.errors.register.textMessageFailed", null, request.getLocale())); } } catch (TelephoneVerificationServiceException e) { returnResponse.put("result", "failed"); returnResponse.put("message", messageSource.getMessage("js.errors.register.textMessageFailed", null, request.getLocale())); } return returnResponse; }
From source file:mx.edu.um.mateo.contabilidad.web.EjercicioController.java
@SuppressWarnings("unchecked") @RequestMapping/*from w ww.j av a 2s.c om*/ public String lista(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina, @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo, @RequestParam(required = false) String order, @RequestParam(required = false) String sort, Model modelo) { log.debug("Mostrando lista de ejercicios"); Map<String, Object> params = this.convierteParams(request.getParameterMap()); Long organizacionId = (Long) request.getSession().getAttribute("organizacionId"); params.put("organizacion", organizacionId); if (StringUtils.isNotBlank(tipo)) { params.put("reporte", true); params = ejercicioDao.lista(params); try { generaReporte(tipo, (List<Ejercicio>) params.get("ejercicios"), response, "ejercicios", Constantes.ORG, organizacionId); return null; } catch (ReporteException e) { log.error("No se pudo generar el reporte", e); } } if (StringUtils.isNotBlank(correo)) { params.put("reporte", true); params = ejercicioDao.lista(params); params.remove("reporte"); try { enviaCorreo(correo, (List<Ejercicio>) params.get("ejercicios"), request, "ejercicios", Constantes.ORG, organizacionId); modelo.addAttribute("message", "lista.enviada.message"); modelo.addAttribute("messageAttrs", new String[] { messageSource.getMessage("ejercicio.lista.label", null, request.getLocale()), ambiente.obtieneUsuario().getUsername() }); } catch (ReporteException e) { log.error("No se pudo enviar el reporte por correo", e); } } params = ejercicioDao.lista(params); modelo.addAttribute("ejercicios", params.get("ejercicios")); this.pagina(params, modelo, "ejercicios", pagina); return "contabilidad/ejercicio/lista"; }
From source file:fr.paris.lutece.plugins.pluginwizard.web.PluginWizardApp.java
/** * The management of the plugin applications associated to the generated * plugin// ww w. j av a 2s . co m * * @param request The Http Request * @return The XPage of the rest */ @View(VIEW_MANAGE_REST) public XPage getManageRest(HttpServletRequest request) { Map<String, Object> model = getModel(); if (ModelService.getRest(_nPluginId) == null) { _rest = new Rest(); _rest.setIdBusinessClasses(new ArrayList<Integer>()); _rest.setId(1); ModelService.addRest(_nPluginId, _rest); } else { _rest = ModelService.getRest(_nPluginId); } model.put(MARK_PLUGIN_ID, Integer.toString(_nPluginId)); model.put(MARK_BUSINESS_CLASSES_COMBO, ModelService.getComboBusinessClasses(_nPluginId)); model.put(MARK_PLUGIN_REST, ModelService.getRest(_nPluginId)); return getXPage(TEMPLATE_MANAGE_REST, request.getLocale(), model); }
From source file:mx.edu.um.mateo.contabilidad.web.OrdenPagoController.java
@SuppressWarnings("unchecked") @RequestMapping/*from w ww.j ava 2 s. co m*/ public String lista(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina, @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo, @RequestParam(required = false) String order, @RequestParam(required = false) String sort, Model modelo) { log.debug("Mostrando lista de ordenes de pago"); Map<String, Object> params = this.convierteParams(request.getParameterMap()); Long empresaId = (Long) request.getSession().getAttribute("empresaId"); params.put("empresa", empresaId); if (StringUtils.isNotBlank(tipo)) { params.put("reporte", true); params = mgr.lista(params); try { generaReporte(tipo, (List<OrdenPago>) params.get(Constantes.ORDENPAGO_LIST), response, Constantes.ORDENPAGO_LIST, Constantes.ORG, empresaId); return null; } catch (ReporteException e) { log.error("No se pudo generar el reporte", e); } } if (StringUtils.isNotBlank(correo)) { params.put("reporte", true); params = mgr.lista(params); params.remove("reporte"); try { enviaCorreo(correo, (List<OrdenPago>) params.get(Constantes.ORDENPAGO_LIST), request, Constantes.ORDENPAGO_LIST, Constantes.ORG, empresaId); modelo.addAttribute("message", "lista.enviada.message"); modelo.addAttribute("messageAttrs", new String[] { messageSource.getMessage("ordenPago.lista.label", null, request.getLocale()), ambiente.obtieneUsuario().getUsername() }); } catch (ReporteException e) { log.error("No se pudo enviar el reporte por correo", e); } } params = mgr.lista(params); modelo.addAttribute(Constantes.ORDENPAGO_LIST, params.get(Constantes.ORDENPAGO_LIST)); this.pagina(params, modelo, Constantes.ORDENPAGO_LIST, pagina); return Constantes.ORDENPAGO_PATH_LISTA; }
From source file:fr.paris.lutece.plugins.pluginwizard.web.PluginWizardApp.java
/** * The get page of the plugin recapitulation * * @param request The Http Request//from www . j av a 2 s. c om * @return The XPage */ @View(VIEW_RECAPITULATE) public XPage getPluginRecapitulate(HttpServletRequest request) { PluginModel pm = ModelService.getPluginModel(_nPluginId); Map<String, Object> model = getPluginModel(); model.put(MARK_PLUGIN_ID, Integer.toString(_nPluginId)); model.put(MARK_PLUGIN_APPLICATIONS, pm.getApplications()); // FIXME can be found in the _model model.put(MARK_ADMIN_FEATURES, pm.getFeatures()); model.put(MARK_PLUGIN_PORTLETS, pm.getPortlets()); model.put(MARK_PLUGIN_REST, pm.getRest()); model.put(MARK_BUSINESS_CLASSES, pm.getBusinessClasses()); model.put(MARK_SCHEMES_COMBO, GeneratorService.getGenerationSchemes()); return getXPage(TEMPLATE_GET_RECAPITULATE, request.getLocale(), model); }
From source file:fr.paris.lutece.plugins.directory.service.upload.DirectoryAsynchronousUploadHandler.java
/** * {@inheritDoc}//from w w w . j a va 2 s . co m * @category CALLED_BY_JS (directoryupload.js) */ @Override public void process(HttpServletRequest request, HttpServletResponse response, JSONObject mainObject, List<FileItem> listFileItemsToUpload) { // prevent 0 or multiple uploads for the same field if ((listFileItemsToUpload == null) || listFileItemsToUpload.isEmpty()) { throw new AppException("No file uploaded"); } String strIdSession = request.getParameter(PARAMETER_JSESSION_ID); if (StringUtils.isNotBlank(strIdSession)) { String strFieldName = request.getParameter(PARAMETER_FIELD_NAME); if (StringUtils.isBlank(strFieldName)) { throw new AppException("id entry is not provided for the current file upload"); } initMap(strIdSession, strFieldName); // find session-related files in the map Map<String, List<FileItem>> mapFileItemsSession = _mapAsynchronousUpload.get(strIdSession); List<FileItem> fileItemsSession = mapFileItemsSession.get(strFieldName); if (canUploadFiles(strFieldName, fileItemsSession, listFileItemsToUpload, mainObject, request.getLocale())) { fileItemsSession.addAll(listFileItemsToUpload); JSONObject jsonListFileItems = JSONUtils.getUploadedFileJSON(fileItemsSession); mainObject.accumulateAll(jsonListFileItems); // add entry id to json JSONUtils.buildJsonSuccess(strFieldName, mainObject); } } else { AppLogService.error(DirectoryAsynchronousUploadHandler.class.getName() + " : Session does not exists"); String strMessage = I18nService.getLocalizedString(PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_SESSION_LOST, request.getLocale()); JSONUtils.buildJsonError(mainObject, strMessage); } }
From source file:com.hp.avmon.kpigetconfig.service.KpigetconfigAgentManageService.java
/** * ??//from w w w.jav a2 s . c om * @param request * @return */ public Map pushAgentAmpConfig(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 ??? for (Map<String, String> ampMap : ampListMapF) { String ampInstId = ampMap.get("ampInstId"); //String moId = ampMap.get("moId"); //String kpiCode = ampMap.get("kpiCode"); //String schedule = ampMap.get("schedule"); String result = avmonServer.deployAmpConfig(agentId, ampInstId); //String result = avmonServer.deployAmpSchedule(agentId, ampInstId,moId,kpiCode,null,schedule); if (result.startsWith("00")) { map.put("success", true); map.put("msg", bundle.getString("configIssuedSuccess")); String sql = String.format( "UPDATE TD_AVMON_AMP_INST SET LAST_CONFIG_UPDATE_TIME = sysdate WHERE AMP_INST_ID ='%s' AND AGENT_ID ='%s'", ampInstId, agentId); jdbcTemplate.execute(sql); } else { map.put("success", false); map.put("msg", result); } } return map; }
From source file:fr.paris.lutece.plugins.plu.web.PluApp.java
/** * @param request the request// w ww . j a va 2 s . c o m * @return the search */ private String doPluSearch(HttpServletRequest request) { Map<String, Object> model = new HashMap<String, Object>(); String sDateDebut = request.getParameter(PARAMETER_DATE_APPLICATION_DEBUT); String sDateFin = request.getParameter(PARAMETER_DATE_APPLICATION_FIN); model.put(PARAMETER_DATE_APPLICATION_DEBUT, sDateDebut); model.put(PARAMETER_DATE_APPLICATION_FIN, sDateFin); List<String> errors = new ArrayList<String>(); if (StringUtils.isEmpty(sDateDebut)) { sDateDebut = "01/01/1900"; } if (StringUtils.isEmpty(sDateFin)) { sDateFin = "01/01/2100"; } Date dateDebut = null; Date dateFin = null; try { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); dateDebut = formatter.parse(sDateDebut); dateFin = formatter.parse(sDateFin); } catch (ParseException e) { errors.add(I18nService.getLocalizedString(PROPERTY_ERROR_DATE_FORMAT, I18nService.getDefaultLocale())); } List<Plu> listPlu = new ArrayList<Plu>(); //If no errors, get plu list if (errors.isEmpty()) { listPlu = PluServices.getInstance().findWithFilters(dateDebut, dateFin); //If research return an empty list, add error message in the model if (listPlu.isEmpty()) { String[] argsDates = { sDateDebut, sDateFin }; errors.add(I18nService.getLocalizedString(PROPERTY_ERROR_DATE_NO_RESULT, argsDates, I18nService.getDefaultLocale())); } } model.put(PARAMETER_LIST_PLU, listPlu); model.put(PARAMETER_ERRORS, errors); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_XPAGE_PLU_SEARCH, request.getLocale(), model); return template.getHtml(); }