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.workflow.modules.rest.rs.ActionRest.java
/** * Execute the workflow action//w w w.j av a2 s . co m * @param nIdAction the id action * @param nIdResource the id resource * @param strResourceType the resource type * @param request the HTTP request * @return the action result */ @POST @Path(WorkflowRestConstants.PATH_DO) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public List<IActionResult> doAction(@FormParam(WorkflowRestConstants.PARAMETER_ID_ACTION) int nIdAction, @FormParam(WorkflowRestConstants.PARAMETER_ID_RESOURCE) int nIdResource, @FormParam(WorkflowRestConstants.PARAMETER_RESOURCE_TYPE) String strResourceType, @Context HttpServletRequest request) { List<IActionResult> listResults = new ArrayList<IActionResult>(); IActionResult failedResult = checkDoAction(nIdAction, nIdResource, strResourceType, request); if (failedResult != null) { listResults.add(failedResult); return listResults; } Action action = _workflowRestService.getAction(nIdAction); ResourceWorkflow resource = _workflowRestService.getResourceWorkflow(nIdResource, strResourceType, action.getWorkflow().getId()); WorkflowService.getInstance().doProcessAction(nIdResource, strResourceType, nIdAction, resource.getExternalParentId(), request, request.getLocale(), true); listResults.add(new SuccessfulActionResult(nIdAction, nIdResource, strResourceType)); return listResults; }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Returns the code for the popup of the legal infos * * @param request The Http Request//from w w w . j ava 2 s. c o m * @return the html code for the legal infos */ public String getLegalInfos(HttpServletRequest request) { HashMap<String, Object> model = new HashMap<String, Object>(); fillPageModel(request, model); model.put(MARK_ADDRESS_INFOS_CNIL, AppPropertiesService.getProperty(PROPERTY_INFOS_CNIL)); model.put(MARK_PORTAL_DOMAIN, PortalService.getSiteName()); model.put(Markers.PAGE_TITLE, I18nService.getLocalizedString(PROPERTY_PAGE_TITLE_LEGAL_INFO, request.getLocale())); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_POPUP_LEGAL_INFO, request.getLocale(), model); return template.getHtml(); }
From source file:it.cilea.osd.jdyna.web.controller.PropertiesDefinitionController.java
private ModelAndView handleDelete(HttpServletRequest request) { Map<String, Object> model = new HashMap<String, Object>(); String paramOTipologiaProprietaId = request.getParameter("id"); Integer tipologiaProprietaId = Integer.decode(paramOTipologiaProprietaId); try {/*from w w w . j a va 2s. c o m*/ TP tip = applicationService.get(targetModel, tipologiaProprietaId); //cancello tutte le proprieta' salvate in passato applicationService.deleteAllProprietaByTipologiaProprieta(targetModel, tip); //cancello la tipologia di proprieta applicationService.delete(targetModel, tipologiaProprietaId); } catch (Exception ecc) { return new ModelAndView(getErrorView(), model); } saveMessage(request, getText("action.tipologiaProprietaOpera.deleted", request.getLocale())); return new ModelAndView(getListView(), model); }
From source file:fr.paris.lutece.plugins.extend.modules.feedback.web.component.FeedbackResourceExtenderComponent.java
/** * {@inheritDoc}//ww w. ja v a2s .com */ @Override public String getPageAddOn(String strIdExtendableResource, String strExtendableResourceType, String strParameters, HttpServletRequest request) { FeedbackExtenderConfig config = _configService.find(getResourceExtender().getKey(), strIdExtendableResource, strExtendableResourceType); String strMessage = StringUtils.EMPTY; if (config != null) { strMessage = config.getMessage(); } Map<String, Object> model = new HashMap<String, Object>(); _feedbackCaptchaService.fillModel(model); model.put(FeedbackConstants.MARK_MESSAGE, strMessage); model.put(FeedbackConstants.MARK_ID_EXTENDABLE_RESOURCE, strIdExtendableResource); model.put(FeedbackConstants.MARK_EXTENDABLE_RESOURCE_TYPE, strExtendableResourceType); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_FEEDBACK, request.getLocale(), model); return template.getHtml(); }
From source file:grails.plugin.cookielayout.CookiePageLayoutFinder.java
@Override public Decorator getNamedDecorator(HttpServletRequest request, String name, boolean viewMustExist) { if (StringUtils.isBlank(name) || NONE_LAYOUT.equals(name)) { return null; }//from w ww . j a v a2 s . co m if (cacheEnabled) { DecoratorCacheValue cacheValue = decoratorCache.get(name); if (cacheValue != null && (!gspReloadEnabled || !cacheValue.isExpired())) { return cacheValue.getDecorator(); } } View view; try { view = viewResolver.resolveViewName(GrailsResourceUtils.appendPiecesForUri(LAYOUTS_PATH, name), request.getLocale()); // it's only possible to check that GroovyPageView exists if (viewMustExist && !(view instanceof GroovyPageView)) { view = null; } } catch (Exception e) { throw new RuntimeException("Unable to resolve view", e); } Decorator d = null; if (view != null) { d = createDecorator(name, view); } if (cacheEnabled) { decoratorCache.put(name, new DecoratorCacheValue(d)); } return d; }
From source file:de.berlios.jhelpdesk.web.tools.LocaleCustomResolver.java
public Locale resolveLocale(HttpServletRequest request) { Locale raLocale = (Locale) request.getAttribute("jhd_locale"); if (raLocale != null) { return raLocale; }/*from w w w .ja v a2s. co m*/ HttpSession session = request.getSession(); User currentUser = (User) session.getAttribute("user"); if (currentUser != null && currentUser.getUserId() != null) { request.setAttribute("jhd_locale", currentUser.getPreferredLocale()); return currentUser.getPreferredLocale(); } Cookie localeCookie = WebUtils.getCookie(request, "jhd_locale"); if (localeCookie != null) { Locale locale = StringUtils.parseLocaleString(localeCookie.getValue()); if (locale != null) { request.setAttribute("jhd_locale", locale); return locale; } } request.setAttribute("jhd_locale", request.getLocale()); return request.getLocale(); }
From source file:net.sourceforge.vulcan.web.struts.actions.ProjectReportBaseAction.java
protected ActionForward sendDocument(Document doc, String transform, ProjectConfigDto projectConfig, int buildNumber, Map<String, Object> transformParams, ActionMapping mapping, HttpServletRequest request, HttpServletResponse response)//from ww w. j a va 2 s. c o m throws IOException, MalformedURLException, SAXException, TransformerException { if (StringUtils.isBlank(transform)) { final PrintWriter writer = response.getWriter(); response.setContentType("application/xml"); try { sendDocument(doc, writer); } finally { writer.close(); } } else { try { final Map<String, Object> params = new HashMap<String, Object>(); if (transformParams != null) { params.putAll(transformParams); } params.put("locale", request.getLocale().toString()); params.put("preferences", findPreferences(request)); params.put("viewProjectStatusURL", getSelfURL(mapping, request, transform)); params.put("contextRoot", request.getContextPath()); if (projectConfig != null) { final String bugtraqUrl = bugtraqRegex.matcher(projectConfig.getBugtraqUrl()) .replaceAll("%BUGID%"); params.put("issueTrackerURL", bugtraqUrl); } final StringWriter tmpWriter = new StringWriter(); final StreamResult result = new StreamResult(tmpWriter); final String contentType = projectDomBuilder.transform(doc, params, request.getLocale(), transform, result); if (StringUtils.isNotBlank(contentType)) { response.setContentType(contentType); } else { response.setContentType("application/xml"); } final PrintWriter writer = response.getWriter(); try { IOUtils.copy(new StringReader(tmpWriter.toString()), writer); } finally { writer.close(); } } catch (NoSuchTransformFormatException e) { BaseDispatchAction.saveError(request, ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.transform.not.found", new String[] { transform })); return mapping.findForward("failure"); } } return null; }
From source file:org.apache.ofbiz.base.util.UtilHttp.java
public static void setInitialRequestInfo(HttpServletRequest request) { HttpSession session = request.getSession(); if (UtilValidate.isNotEmpty(session.getAttribute("_WEBAPP_NAME_"))) { // oops, info already in place... return;//from w w w . j av a 2 s. com } String fullRequestUrl = getFullRequestUrl(request); session.setAttribute("_WEBAPP_NAME_", getApplicationName(request)); session.setAttribute("_CLIENT_LOCALE_", request.getLocale()); session.setAttribute("_CLIENT_REQUEST_", fullRequestUrl); session.setAttribute("_CLIENT_USER_AGENT_", request.getHeader("User-Agent") != null ? request.getHeader("User-Agent") : ""); session.setAttribute("_CLIENT_REFERER_", request.getHeader("Referer") != null ? request.getHeader("Referer") : ""); session.setAttribute("_CLIENT_FORWARDED_FOR_", request.getHeader("X-Forwarded-For")); session.setAttribute("_CLIENT_REMOTE_ADDR_", request.getRemoteAddr()); session.setAttribute("_CLIENT_REMOTE_HOST_", request.getRemoteHost()); session.setAttribute("_CLIENT_REMOTE_USER_", request.getRemoteUser()); }
From source file:org.openmrs.web.controller.observation.ObsFormController.java
/** * The other things shown on the obs form that are in the database * * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest, * java.lang.Object, org.springframework.validation.Errors) *///from w w w . ja v a2 s. c o m protected Map<String, Object> referenceData(HttpServletRequest request, Object obj, Errors errs) throws Exception { Obs obs = (Obs) obj; Map<String, Object> map = new HashMap<String, Object>(); String defaultVerbose = "false"; if (Context.isAuthenticated()) { map.put("forms", Context.getFormService().getAllForms()); if (obs.getConcept() != null) { // Reload concept because it can be dettached Concept concept = Context.getConceptService().getConcept(obs.getConcept().getConceptId()); map.put("conceptName", concept.getName(request.getLocale())); ObsService os = Context.getObsService(); Integer obsId = obs.getObsId(); if (obsId != null && obs.getConcept().isComplex()) { ComplexObsHandler handler = os.getHandler(obs); // HTML view (i.e. inlining) if (handler.supportsView(ComplexObsHandler.HTML_VIEW)) { Obs complexObs_html = handler.getObs(obs, ComplexObsHandler.HTML_VIEW); Assert.notNull(complexObs_html, "Handler declares HTML view support but fails to deliver"); ComplexData complexData = complexObs_html.getComplexData(); map.put("htmlView", complexData.getData()); } // Hyperlink view (provide URL) if (handler.supportsView(ComplexObsHandler.URI_VIEW)) { Obs complexObs_uri = handler.getObs(obs, ComplexObsHandler.URI_VIEW); Assert.notNull(complexObs_uri, "Handler declares URL view support but fails to deliver"); ComplexData complexData = complexObs_uri.getComplexData(); map.put("hyperlinkView", complexData.getData()); } } } defaultVerbose = Context.getAuthenticatedUser() .getUserProperty(OpenmrsConstants.USER_PROPERTY_SHOW_VERBOSE); } map.put("defaultVerbose", defaultVerbose.equals("true") ? true : false); String editReason = request.getParameter("editReason"); if (editReason == null) { editReason = ""; } map.put("editReason", editReason); return map; }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StockBilletterieReservationApp.java
/** * Return page with action specified./*w ww .java 2 s. c om*/ * * @param request the request * @param nMode the n mode * @param plugin the plugin * @return the page * @throws UserNotSignedException the user not signed exception * @throws SiteMessageException the site message exception */ public XPage getPage(HttpServletRequest request, int nMode, Plugin plugin) throws UserNotSignedException, SiteMessageException { XPage page = new XPage(); Locale locale = request.getLocale(); String strAction = request.getParameter(PARAMETER_ACTION); if (ACTION_BOOK.equals(strAction)) { page = getConfirmBooking(page, request, locale); } else if (ACTION_MY_BOOKINGS.equals(strAction)) { request.setAttribute(PARAMETER_TAB_ACTIVE, CONSTANT_RESERVATION_TAB_ACTIVE); String strContent = getMyBookings(request, getUser(request), locale); page.setContent(strContent); String pageTitle = getMessage(TITLE_MY_BOOKINGS, request); page.setPathLabel(pageTitle); page.setTitle(pageTitle); } else if (ACTION_DELETE_BOOKING.equals(strAction)) { page = getDeleteBooking(page, request, locale); } else if (ACTION_DELETE_SUBSCRIPTION.equals(strAction)) { deleteSubscription(page, request, locale); String strContent = getMyBookings(request, getUser(request), locale); page.setContent(strContent); String pageTitle = getMessage(TITLE_MY_BOOKINGS, request); page.setPathLabel(pageTitle); page.setTitle(pageTitle); } else if (ACTION_MODIFY_BOOKING.equals(strAction)) { } return page; }