List of usage examples for com.vaadin.server VaadinRequest getWrappedSession
public WrappedSession getWrappedSession();
From source file:com.haulmont.cuba.web.AppUI.java
License:Apache License
public void processExternalLink(VaadinRequest request) { WrappedSession wrappedSession = request.getWrappedSession(); String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR); if (webConfig.getLinkHandlerActions().contains(action)) { //noinspection unchecked Map<String, String> params = (Map<String, String>) wrappedSession .getAttribute(LAST_REQUEST_PARAMS_ATTR); params = params != null ? params : Collections.emptyMap(); try {/* www . ja v a 2 s . c o m*/ LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params); if (app.connection.isConnected() && linkHandler.canHandleLink()) { linkHandler.handle(); } else { app.linkHandler = linkHandler; } } catch (Exception e) { error(new com.vaadin.server.ErrorEvent(e)); } } }
From source file:com.haulmont.cuba.web.sys.LinkHandler.java
License:Apache License
/** * Called to handle the link.//from w ww . j a va2 s . c o m */ public void handle() { try { String folderId = requestParams.get("folder"); if (!StringUtils.isEmpty(folderId)) { AbstractSearchFolder folder = loadFolder(UUID.fromString(folderId)); if (folder != null) { folders.openFolder(folder); } else { log.warn("Folder not found: {}", folderId); } return; } String screenName = requestParams.get("screen"); if (screenName == null) { log.warn("ScreenId not found in request parameters"); return; } WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); final WindowInfo windowInfo = windowConfig.getWindowInfo(screenName); if (windowInfo == null) { log.warn("WindowInfo not found for screen: {}", screenName); return; } UUID userId = getUUID(requestParams.get("user")); UserSession userSession = app.getConnection().getSession(); if (userSession == null) { log.warn("No user session"); return; } if (!(userId == null || userSession.getCurrentOrSubstitutedUser().getId().equals(userId))) { substituteUserAndOpenWindow(windowInfo, userId); } else { openWindow(windowInfo, requestParams); } } catch (AccessDeniedException e) { accessDeniedHandler.handle(e, app.getWindowManager()); } catch (NoSuchScreenException e) { noSuchScreenHandler.handle(e, app.getWindowManager()); } catch (EntityAccessException e) { entityAccessExceptionHandler.handle(e, app.getWindowManager()); } finally { VaadinRequest request = VaadinService.getCurrentRequest(); WrappedSession wrappedSession = request.getWrappedSession(); wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR); wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR); } }
From source file:com.haulmont.cuba.web.sys.remoting.discovery.WebHttpSessionUrlsHolder.java
License:Apache License
@SuppressWarnings("unchecked") @Override// w w w. ja v a2 s . com @Nullable public List<String> getUrls(String selectorId) { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) return (List) vaadinRequest.getWrappedSession().getAttribute(getAttributeName(selectorId)); else { HttpSession httpSession = getHttpSession(); return httpSession != null ? (List<String>) httpSession.getAttribute(getAttributeName(selectorId)) : null; } }
From source file:com.haulmont.cuba.web.sys.remoting.discovery.WebHttpSessionUrlsHolder.java
License:Apache License
@Override public void setUrls(String selectorId, List<String> urls) { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) vaadinRequest.getWrappedSession().setAttribute(getAttributeName(selectorId), urls); else {/*from w ww .j a va 2 s .c o m*/ HttpSession httpSession = getHttpSession(); if (httpSession != null) { httpSession.setAttribute(getAttributeName(selectorId), urls); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaMultiUpload.java
License:Apache License
@Override public void beforeClientResponse(boolean initial) { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); if (currentRequest != null) { getState().jsessionId = currentRequest.getWrappedSession().getId(); } else {/*from w w w .j a va 2s . c om*/ LoggerFactory.getLogger(CubaMultiUpload.class).debug("Unable to set JSESSIONID for widget"); } super.beforeClientResponse(initial); }
From source file:com.jee.client.JeeclientUI.java
@Override protected void init(VaadinRequest request) { new Navigator(this, this); getNavigator().addView(LoginForm.NAME, LoginForm.class); getNavigator().addView(MainView.NAME, MainView.class); getNavigator().addViewChangeListener(new ViewChangeListener() { @Override//from w w w. java2 s .c o m public boolean beforeViewChange(ViewChangeEvent event) { // Check if a user has logged in boolean isLoggedIn = VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(USER_NAME_ATTRIBUTE_NAME) != null;// getSession().getAttribute(USER_NAME_ATTRIBUTE_NAME) != null; boolean isLoginView = event.getNewView() instanceof LoginForm; if (!isLoggedIn && !isLoginView) { // Redirect to login view always if a user has not yet // logged in getNavigator().navigateTo(LoginForm.NAME); return false; } else if (isLoggedIn && isLoginView) { // If someone tries to access to login view while logged in, // then cancel return false; } return true; } @Override public void afterViewChange(ViewChangeEvent event) { } }); WrappedSession session = request.getWrappedSession(); HttpSession httpSession = ((WrappedHttpSession) session).getHttpSession(); ServletContext servletContext = httpSession.getServletContext(); applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); messageSource = (ReloadableResourceBundleMessageSource) applicationContext.getBean("resource"); userAdminManager = (VoucheringManager) applicationContext.getBean("userAdminManager"); WebUtil.absolutePath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); this.getLoadingIndicatorConfiguration().setFirstDelay(500); this.getLoadingIndicatorConfiguration().setSecondDelay(30000); this.getLoadingIndicatorConfiguration().setThirdDelay(80000); }
From source file:com.sonoport.util.UISessionState.java
License:Apache License
public boolean staleSessionCheck(VaadinSession inSession, VaadinRequest request) { if (!vaadinSession.equals(inSession)) { LOG.log(Level.INFO, "Stale session detected, invalidating HTTPSession and reloading!"); HttpSession httpSession = ((WrappedHttpSession) request.getWrappedSession()).getHttpSession(); httpSession.invalidate();//w ww.ja v a2 s .c o m Page.getCurrent().setLocation("/"); replaceSession = true; return true; } return false; }
From source file:de.kaiserpfalzEdv.vaadin.PiraccUI.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { Responsive.makeResponsive(this); setLocale(vaadinRequest.getLocale()); i18n.setLocale(vaadinRequest.getLocale()); getPage().setTitle(translate("application.name")); if (userStore.getCurrentUser() == null) { LOG.info("Starting log-in for session: {}", vaadinRequest.getWrappedSession().getId()); setContent(new LoginScreen(accessControl, this::showMainView, i18n, bus)); } else {//from w w w. j a v a 2 s .com LOG.info("New Request in session: {}", vaadinRequest.getWrappedSession().getId()); showMainView(); } }
From source file:de.kaiserpfalzEdv.vaadin.VaadinCurrentUserStore.java
License:Apache License
private static WrappedSession getCurrentSession() { VaadinRequest request = VaadinService.getCurrentRequest(); if (request == null) { throw new IllegalStateException("No request bound to current thread"); }/*from w w w . jav a 2 s . c o m*/ return request.getWrappedSession(); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java
License:Open Source License
/** * /*from w w w . jav a2s . c o m*/ * @return */ public PortletSession getPortletSession() { UI.getCurrent().getSession().getService(); VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); WrappedPortletSession wrappedPortletSession = (WrappedPortletSession) vaadinRequest.getWrappedSession(); return wrappedPortletSession.getPortletSession(); }