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.extend.modules.follow.web.component.FollowResourceExtenderComponent.java
/** * {@inheritDoc}/*from www . j a v a 2 s.c om*/ */ @Override public String getInfoHtml(ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request) { if (resourceExtender != null) { Map<String, Object> model = new HashMap<String, Object>(); model.put(FollowConstants.MARK_FOLLOW, _followService.findByResource( resourceExtender.getIdExtendableResource(), resourceExtender.getExtendableResourceType())); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_FOLLOW_INFO, request.getLocale(), model); return template.getHtml(); } return StringUtils.EMPTY; }
From source file:org.n52.smartsensoreditor.controller.BasicPublishControllerSML.java
/** * This is triggered when the form is submitted * * @param request/*from w ww.j a v a 2 s . c o m*/ * @param response * @param command * @param errors * @return * @throws Exception */ @Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { PublishBeanSML lBean = (PublishBeanSML) command; Document doc = getBackendManager().mergeBackend(); Document catalogRequest = null; //get the State using the selected operation in selectStates.jsp IState selectedState = operationSOSManager.getState(lBean.getServiceOperationSOS(), request.getLocale()); // reset update getBackendManager().setUpdate(false); Map<String, Object> parameterMap = new HashMap<String, Object>(); String[] swesObservablePropertyList = toList(lBean.getSwesObservableProperties()); parameterMap.put("swesObservablePropertyList", swesObservablePropertyList); String[] sosObservationTypeList = toList(lBean.getSosObservationTypes()); parameterMap.put("sosObservationTypeList", sosObservationTypeList); String[] sosFeatureOfInterestTypeList = toList(lBean.getSosFeatureOfInterestTypes()); parameterMap.put("sosFeatureOfInterestTypeList", sosFeatureOfInterestTypeList); // create request catalogRequest = getRequestFactory().createRequest(selectedState.getStateId(), doc, parameterMap); LOG.debug("catalog request:" + "\n" + DOMUtil.convertToString(catalogRequest, true)); // add additional fields for SOS publish AbstractCatalogService service = getCatalogService(); if (service instanceof SOSCatalogService) { SOSCatalogService sosService = (SOSCatalogService) service; sosService.init(lBean.getServiceUrlSOS()); sosService.addRequestHeader("Authorization", lBean.getServiceTokenSOS()); sosService.addRequestHeader("Content-Type", "application/soap+xml"); } Document catalogResponse = getCatalogService().transaction(catalogRequest); Map<String, Object> lModel = new HashMap<String, Object>(); lModel.put("sourcePage", "publish"); if (catalogResponse == null) { lModel.put("response", new TransactionResponseSOS()); lModel.put("serverError", "errors.service.connect.request"); return new ModelAndView(getSuccessView(), lModel); } if (getBackendManager().getResourceType().equals("sensor")) { lModel.put("response", new TransactionResponseSOS(catalogResponse)); } else { lModel.put("response", new TransactionResponse(catalogResponse)); } return new ModelAndView(getSuccessView(), lModel); }
From source file:fr.paris.lutece.plugins.workflow.modules.notifymylutece.service.NotifyMyLuteceService.java
/** * Get the locale//from w ww . j ava 2s .com * @param request the HTTP request * @return the locale */ private Locale getLocale(HttpServletRequest request) { Locale locale = null; if (request != null) { locale = request.getLocale(); } else { locale = I18nService.getDefaultLocale(); } return locale; }
From source file:fr.paris.lutece.plugins.extend.modules.favorite.web.component.FavoriteResourceExtenderComponent.java
/** * {@inheritDoc}//from w w w . jav a 2s .c om */ @Override public String getInfoHtml(ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request) { if (resourceExtender != null) { Map<String, Object> model = new HashMap<String, Object>(); model.put(FavoriteConstants.MARK_FAVORITE, _favoriteService.findByResource( resourceExtender.getIdExtendableResource(), resourceExtender.getExtendableResourceType())); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_FAVORITE_INFO, request.getLocale(), model); return template.getHtml(); } return StringUtils.EMPTY; }
From source file:es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoControllerImpl.java
/** * @see es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoController#cargarNodo(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.nodos.modificarNodo.CargarNodoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from ww w . j ava 2s. c om*/ public final void cargarNodo(ActionMapping mapping, es.pode.administracion.presentacion.nodos.modificarNodo.CargarNodoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { //recogemos las ccaa de la bbdd y las internacionalizamos desde el properties Locale locale = new Locale(LdapUserDetailsUtils.getIdioma()); ficheroRecursos = ResourceBundle.getBundle("application-resources", request.getLocale()); List ccaa = Arrays.asList(this.getSrvNodoService().obtenerCCAAs()); CcaaVO[] ccaaVOArray = (CcaaVO[]) ccaa.toArray(); List ccaaList = new ArrayList(); for (int i = 0; i < ccaaVOArray.length; i++) { if (ccaaVOArray[i].getCodigo() != null) { String descripcion = null; try { descripcion = ficheroRecursos.getString(ccaaVOArray[i].getCodigo()); } catch (Exception ex) { log.warn("El codigo de la comunidad " + ccaaVOArray[i].getCodigo() + " no esta en el fichero de internacionalizacion"); descripcion = ccaaVOArray[i].getDescripcion(); } ccaaList.add(descripcion.toLowerCase()); ccaaVOArray[i].setDescripcion(descripcion); } else ccaaVOArray[i].setCodigo(""); } Collections.sort(ccaaList); ccaa = ordenarLista(ccaaList, ccaaVOArray); // Rellena el combo de ccaa ((ModificarNodoFormImpl) form).setCcaaBackingList(ccaa, "id", "descripcion"); Long id = new Long(request.getParameter("id")); if (id == null) { throw new ValidatorException("{errors.modificarnodo.idNulo}"); } NodoVO nodo = this.getSrvNodoService().obtenerNodo(id); form.setId(id); form.setNodo(nodo.getNodo()); form.setUrl(nodo.getUrl()); form.setUrlWS(nodo.getUrlWS()); form.setIdNodo(nodo.getIdNodo()); if (nodo.getCcaa() != null) { form.setCcaa(nodo.getCcaa().getId()); } form.setPuerto(nodo.getPuerto()); } catch (ValidatorException e) { log.equals("Error al recuperar: " + e); throw e; } catch (Exception e) { log.equals("Error al recuperar el nodo: " + e); throw e; } }
From source file:com.jaspersoft.jasperserver.war.control.JSCommonController.java
public ModelAndView heartbeatInfo(HttpServletRequest req, HttpServletResponse res) throws ServletException { final HeartbeatClientInfo info = new HeartbeatClientInfo(); info.setNavigatorAppName(req.getParameter("navAppName")); info.setNavigatorAppVersion(req.getParameter("navAppVersion")); info.setNavigatorLocale(req.getLocale()); info.setUserLocale(LocaleContextHolder.getLocale()); if (req.getParameter("scrWidth") != null) { info.setScreenWidth(new Integer(req.getParameter("scrWidth"))); }/* w ww . j a va 2 s . c o m*/ if (req.getParameter("scrHeight") != null) { info.setScreenHeight(new Integer(req.getParameter("scrHeight"))); } if (req.getParameter("scrColorDepth") != null) { info.setScreenColorDepth(new Integer(req.getParameter("scrColorDepth"))); } info.setUserAgent(req.getHeader("user-agent")); new Thread(new Runnable() { public void run() { heartbeat.updateClientInfo(info); } }).start(); return new ModelAndView("ajax/ajaxresponse"); }
From source file:alpha.portal.webapp.controller.CardAssignFormController.java
/** * Handles the viewing of all users who have the card's ContributorRole. * /*from w w w.j av a2s. c om*/ * @param request * the request * @param model * the model */ @RequestMapping(method = RequestMethod.GET) protected void showForm(final HttpServletRequest request, final Model model) { final String caseId = request.getParameter("case"); final String cardId = request.getParameter("card"); AlphaCard card = null; try { card = this.cardManager.get(new AlphaCardIdentifier(caseId, cardId)); } catch (final ObjectRetrievalFailureException e) { this.saveError(request, this.getText("cardassign.noCard", request.getLocale())); } if (card == null) return; final Adornment contributorRole = card.getAlphaCardDescriptor() .getAdornment(AdornmentType.ContributorRole.getName()); if (contributorRole == null) { this.saveError(request, this.getText("cardassign.noContributorRole", request.getLocale())); return; } final ContributorRole role = this.contributorRoleManager .getContributorRoleByName(contributorRole.getValue()); List<UserExtension> users = new LinkedList<UserExtension>(); if ((role == null) || StringUtils.isBlank(role.getName())) { final List<User> list = this.getUserManager().getAll(); for (final User u : list) { users.add(new UserExtension(u)); } } else { users = this.userExtensionManager.getUserExtensionsByContributorRole(role); } model.addAttribute("users", users); }
From source file:fr.paris.lutece.plugins.notifygru.modules.directory.services.NotifyGruDirectoryService.java
@Override public Locale getLocale(HttpServletRequest request) { Locale locale = null;//from www . j ava2 s . c om if (request != null) { locale = request.getLocale(); } else { locale = I18nService.getDefaultLocale(); } return locale; }
From source file:com.octo.captcha.module.acegi.JCaptchaImageController.java
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception { byte[] captchaChallengeAsJpeg = null; ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream(); //get the session id that will identify the generated captcha. //the same id must be used to validate the response, the session id is a good candidate! String captchaId = httpServletRequest.getSession().getId(); BufferedImage challenge = imageCaptchaService.getImageChallengeForID(captchaId, httpServletRequest.getLocale()); JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream); jpegEncoder.encode(challenge);/*from w ww . j a v a 2s . c o m*/ captchaChallengeAsJpeg = jpegOutputStream.toByteArray(); // configure cache directives response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); //flush content in the response response.setContentType("image/jpeg"); ServletOutputStream responseOutputStream = response.getOutputStream(); responseOutputStream.write(captchaChallengeAsJpeg); responseOutputStream.flush(); responseOutputStream.close(); return null; }
From source file:com.octo.captcha.module.acegi.JCaptchaSoundController.java
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception { byte[] captchaChallengeAsWav = null; ByteArrayOutputStream wavOutputStream = new ByteArrayOutputStream(); //get the session id that will identify the generated captcha. //the same id must be used to validate the response, the session id is a good candidate! String captchaId = httpServletRequest.getSession().getId(); AudioInputStream challenge = soundCaptchaService.getSoundChallengeForID(captchaId, httpServletRequest.getLocale()); // a jpeg encoder AudioInputStream stream = (AudioInputStream) challenge; // call the ImageCaptchaService method to retrieve a captcha AudioSystem.write(stream, AudioFileFormat.Type.WAVE, wavOutputStream); captchaChallengeAsWav = wavOutputStream.toByteArray(); // configure cache directives response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); //flush content in the response response.setContentType("audio/x-wav"); ServletOutputStream responseOutputStream = response.getOutputStream(); responseOutputStream.write(captchaChallengeAsWav); responseOutputStream.flush();// ww w. ja va 2 s .c o m responseOutputStream.close(); return null; }