WebContext ctx = WebContextFactory.get(); HttpServletRequest request = ctx.getHttpServletRequest();
public Object convertInbound(Class<?> paramType, InboundVariable data) { WebContext webcx = WebContextFactory.get(); if (HttpServletRequest.class.isAssignableFrom(paramType)) { return webcx.getHttpServletRequest(); } if (HttpServletResponse.class.isAssignableFrom(paramType)) { return webcx.getHttpServletResponse(); } if (ServletConfig.class.isAssignableFrom(paramType)) { return webcx.getServletConfig(); } if (ServletContext.class.isAssignableFrom(paramType)) { return webcx.getServletContext(); } if (HttpSession.class.isAssignableFrom(paramType)) { return webcx.getSession(true); } return null; }
object = webcx.getServletContext().getAttribute(name); object = webcx.getSession().getAttribute(name); object = webcx.getScriptSession().getAttribute(name); object = webcx.getHttpServletRequest().getAttribute(name); webcx.getServletContext().setAttribute(name, object); webcx.getSession().setAttribute(name, object); webcx.getScriptSession().setAttribute(name, object); webcx.getHttpServletRequest().setAttribute(name, object);
/** * Performs a logout. */ @RemoteMethod public void logout() { WebContext ctx = WebContextFactory.get(); LoginManager.logout(ctx.getHttpServletRequest(), ctx.getHttpServletResponse()); }
/** * Method responsible for generating form for reporting errors. * @param elementId * @return */ public Map<String, Object> getForm(String elementId) { Map<String, Object> result = new HashMap<String, Object>(); try { Map<String, Object> model = new HashMap<String, Object>(); WebContext context = WebContextFactory.get(); String captchaId = captchaIdGenerator.getId(context.getSession().getId()); model.put("captchaId", captchaId); model.put("extId", elementId); model.put("logged", false); model.put("timestamp", (new Date()).getTime()); context.getHttpServletRequest().setAttribute("viewModel", model); String html = context.forwardToString(forcedViewName); result.put(DWRConstants.CONTENT, html); } catch (Exception e) { log.warn("Exception occurred when rendering DWR error form for element " + elementId, e); result.put(DWRConstants.ERROR, messageSource.getMessage( MessageConstants.DWR_NO_DATA, null, LocaleContextHolder.getLocale())); } return result; }
public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception { WebContext webContext = WebContextFactory.get(); if (resourceBundleDirectory != null && resourceBundleLoader == null) resourceBundleLoader = new ResourceBundleLoader(webContext.getServletContext().getRealPath( resourceBundleDirectory)); I18NUtils.prepareRequest(webContext.getHttpServletRequest(), localeResolverName, bundleBaseName, resourceBundleLoader); return chain.doFilter(obj, method, params); } }
private Map<String, Object> prepareDWRModelAndView(StyledCitationVO citationView) { Map<String, Object> model = new HashMap<>(); if (citationView != null) { model.put("styledCitation", citationView); try { WebContext context = WebContextFactory.get(); final HttpServletRequest httpServletRequest = context.getHttpServletRequest(); model.put("locale", localeResolver.resolveLocale(httpServletRequest).getLanguage()); httpServletRequest.setAttribute("content", model); model.put(DWRConstants.CONTENT, context.forwardToString(view)); } catch (ServletException e) { throw new SystemException(Modules.CATALOG, "Servlet error", e); } catch (IOException e) { throw new SystemException(Modules.CATALOG, "IO error", e); } } noDWRDataMessage(model); return model; }
private void initScriptSession() { WebContext webContext = WebContextFactory.get(); HttpServletRequest request = webContext.getHttpServletRequest(); ScriptSession currentSession = webContext.getScriptSession(); String host = request.getServerName(); RiotUser user = AccessController.getCurrentUser(); currentSession.setAttribute("host", host); currentSession.setAttribute("userId", user.getUserId()); }
public Object getInstance() throws InstantiationException { // fills for the first time the moduleConfig ActionForm formInstance = (ActionForm) WebContextFactory.get().getSession().getAttribute(formBean); if (formInstance == null) { throw new InstantiationException("Can't find formInstance for " + formBean); } return formInstance; }
/** * Generates and returns a new unique id suitable to use for the * CSRF session cookie. This method is itself exempted from CSRF checking. */ public String generateId() { WebContext webContext = WebContextFactory.get(); // If the current session already has a set DWRSESSIONID then we return that HttpServletRequest request = webContext.getHttpServletRequest(); HttpSession sess = request.getSession(false); if (sess != null && sess.getAttribute(ATTRIBUTE_DWRSESSIONID) != null) { return (String) sess.getAttribute(ATTRIBUTE_DWRSESSIONID); } // Otherwise generate a fresh ID IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class); return idGenerator.generate(); }
public Object doFilter(Object object, Method method, Object[] params, AjaxFilterChain chain) throws Exception { ServletContext context = WebContextFactory.get().getServletContext(); SessionFactory sessionFactory = (SessionFactory) context.getAttribute(ATTRIBUTE_SESSION); Transaction transaction = null; if (sessionFactory != null) { Session session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); } else { log.error("SessionFactory not initialized for this web application. Use: H3SessionAjaxFilter.setSessionFactory(servletContext, sessionFactory);"); } Object reply = chain.doFilter(object, method, params); if (transaction != null) { transaction.commit(); } return reply; }
public ScriptSession get() { WebContext webcx = WebContextFactory.get(); return webcx.getScriptSession(); }
RealScriptSession scriptSession = (RealScriptSession) webCtx.getScriptSession(); HttpSession httpSession = webCtx.getSession(false); String httpSessionId = (httpSession != null ? httpSession.getId() : null);
public HttpServletResponse get() { WebContext webcx = WebContextFactory.get(); return webcx.getHttpServletResponse(); }
ScriptSession session = webContext.getScriptSession(); ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class);
@DwrPermission(anonymous = true) public void setLocale(String locale) { WebContext webContext = WebContextFactory.get(); LocaleResolver localeResolver = new SessionLocaleResolver(); LocaleEditor localeEditor = new LocaleEditor(); localeEditor.setAsText(locale); localeResolver.setLocale(webContext.getHttpServletRequest(), webContext.getHttpServletResponse(), (Locale) localeEditor.getValue()); }
public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception { WebContext webContext = WebContextFactory.get(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(webContext .getServletContext()); MessageSource messageSource = (MessageSource) wac.getBean(messageSourceKey); JstlUtils.exposeLocalizationContext(webContext.getHttpServletRequest(), messageSource); return chain.doFilter(obj, method, params); } }
try { String cid = captchaIdGenerator.getId( context.getSession().getId()); model.put("captchaId", cid); model.put("extId", elementId); model.put("logged", false); model.put("timestamp", (new Date()).getTime()); context.getHttpServletRequest().setAttribute("viewModel", model); String html = context.forwardToString(forcedViewName); result.put(DWRConstants.CONTENT, html); } catch (Exception e) {
public Map<String, Object> getDetails(String elementId) { Map<String, Object> result = new HashMap<String, Object>(); try { String viewName; if (elementId == null || "".equals(elementId)) throw new SystemException(Modules.DETAILS, "Parameter id value not provided."); elementHandler.setId(elementId); String resolvedViewName = elementHandler.buildView(); viewName = forcedViewName != null ? forcedViewName : resolvedViewName; WebContext context = WebContextFactory.get(); context.getHttpServletRequest().setAttribute("viewModel", elementHandler.getModel()); String html = context.forwardToString(viewName); result.put(DWRConstants.CONTENT, html); } catch (Exception e) { log.warn("Exception occurred when rendering DWR Part for element " + elementId, e); result.put(DWRConstants.ERROR, messageSource.getMessage(MessageConstants.DWR_NO_DATA, null, LocaleContextHolder.getLocale())); } return result; }
private void nofifyUsers() { WebContext webContext = WebContextFactory.get(); HttpServletRequest request = webContext.getHttpServletRequest(); final ScriptSession currentSession = webContext.getScriptSession(); final RiotUser user = AccessController.getCurrentUser(); final String host = request.getServerName();