/** * Gets the currently processed Vaadin portlet request. The current request * is automatically defined when the request is started. The current request * can not be used in e.g. background threads because of the way server * implementations reuse request instances. * * @return the current Vaadin portlet request instance if available, * otherwise <code>null</code> * */ public static VaadinPortletRequest getCurrentRequest() { return (VaadinPortletRequest) VaadinService.getCurrentRequest(); }
private boolean storeSentHierarchy(JsonObject hierarchyInfo, Set<String> stateUpdateConnectors) { VaadinRequest request = VaadinService.getCurrentRequest(); if (request != null) { request.setAttribute( ConnectorHierarchyWriter.class.getName() + ".hierarchyInfo", hierarchyInfo); request.setAttribute(ConnectorHierarchyWriter.class.getName() + ".stateUpdateConnectors", stateUpdateConnectors); } // Always true, we're just setting up for another assert return true; }
private boolean isRemovalSentToClient(ClientConnector connector) { VaadinRequest request = VaadinService.getCurrentRequest(); if (request == null) {
request = VaadinService.getCurrentRequest();
+ "Session destroy events will not be fired and UIs in the session will not get detached. " + "This might happen if a session is deserialized but never used before it expires."); } else if (VaadinService.getCurrentRequest() != null && getCurrent() == this) { assert hasLock();
/** * Gets the current Vaadin request, cast to a HttpServletRequest.<p> * * @return the current request */ public static HttpServletRequest getRequest() { return (HttpServletRequest)VaadinService.getCurrentRequest(); }
private LegacyApplication getApplication() { LegacyApplication application = VaadinSession.getCurrent() .getAttribute(LegacyApplication.class); if (application == null) { application = createApplication(); if (application == null) { return null; } VaadinSession.getCurrent().setAttribute(LegacyApplication.class, application); URL applicationUrl; try { applicationUrl = VaadinService.getCurrent() .getApplicationUrl(VaadinService.getCurrentRequest()); } catch (MalformedURLException e) { throw new RuntimeException(e); } application.doInit(applicationUrl); } if (application != null && !application.isRunning()) { VaadinSession.getCurrent().setAttribute(LegacyApplication.class, null); // Run again without a current application return getApplication(); } return application; }
/** * Load and initialize the mobile drag-drop-polyfill if needed and not yet * done so. */ private void loadMobileHtml5DndPolyfill() { if (mobileHtml5DndPolyfillLoaded) { return; } if (!getPage().getWebBrowser().isTouchDevice()) { return; } mobileHtml5DndPolyfillLoaded = true; String vaadinLocation = getSession().getService().getStaticFileLocation( VaadinService.getCurrentRequest()) + "/VAADIN/"; getPage().addDependency(new Dependency(Type.JAVASCRIPT, vaadinLocation + ApplicationConstants.MOBILE_DND_POLYFILL_JS)); getRpcProxy(PageClientRpc.class).initializeMobileHtml5DndPolyfill(); }
public static boolean isMobile() { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); boolean mobileUserAgent = vaadinRequest.getHeader("user-agent") .toLowerCase().contains("mobile"); return mobileUserAgent; }
@Nullable protected String getUserRemoteAddress() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); return currentRequest != null ? currentRequest.getRemoteAddr() : null; }
public static UserDetails getCurrentUser() { final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); return (UserDetails) context.getAuthentication().getPrincipal(); }
public void buttonClick(ClickEvent event) { VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayService", replayService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("platformConfigurationService", platformConfigurationService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService", topologyService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayEvent", (ReplayEvent)replayEvent); } });
public void buttonClick(ClickEvent event) { VaadinService.getCurrentRequest().getWrappedSession().setAttribute("exclusionEvents", getResubmissionEvents()); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService", topologyService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("errorReportingService", errorReportingService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("errorReportingManagementService", errorReportingManagementService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("exclusionManagementService", exclusionManagementService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("container", container); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("action", ResubmitIgnoreStatusPanel.IGNORE); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("hospitalService", hospitalService); } });
public void buttonClick(ClickEvent event) { // todo add replay events VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayEvents", getReplayEvents()); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayService", replayService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService",topologyService ); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("platformConfigurationService", platformConfigurationService); } });
/** * Opens the login target for a logged in user.<p> * * @param loginTarget the login target * @param isPublicPC the public PC flag */ public void openLoginTarget(String loginTarget, boolean isPublicPC) { // login was successful, remove login init data from session VaadinService.getCurrentRequest().getWrappedSession().removeAttribute(INIT_DATA_SESSION_ATTR); m_targetOpener.openTarget(loginTarget, isPublicPC); }
@SuppressWarnings("unchecked") @Override @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; } }
@Override public void setUrls(String selectorId, List<String> urls) { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) vaadinRequest.getWrappedSession().setAttribute(getAttributeName(selectorId), urls); else { HttpSession httpSession = getHttpSession(); if (httpSession != null) { httpSession.setAttribute(getAttributeName(selectorId), urls); } } }
public void windowClose(CloseEvent e) { if((IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER) == null) { Notification.show("You cannot access this page!", Type.ERROR_MESSAGE); //Redirect the user to the login/default Page Page.getCurrent().setLocation("/ikasan-dashboard"); } } });
public void windowClose(CloseEvent e) { if((IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER) == null) { UI.getCurrent().getNavigator().navigateTo("landingView"); Notification.show("You cannot view this error!", Type.ERROR_MESSAGE); } } });
public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); IkasanAuthentication ikasanAuthentication = (IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); String action = "Role " + role.getName() + " removed by " + ikasanAuthentication.getName(); systemEventService.logSystemEvent(SystemEventConstants.DASHBOARD_USER_ROLE_CHANGED_CONSTANTS, action,principal.getName()); } });