@Override public String getConfiguredWidgetset(VaadinRequest request) { String widgetset = getDeploymentConfiguration().getWidgetset(null); if (widgetset == null) { widgetset = getParameter(request, Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET, Constants.DEFAULT_WIDGETSET); } return widgetset; }
protected VaadinPortletService createPortletService( DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinPortletService service = new VaadinPortletService(this, deploymentConfiguration); service.init(); return service; }
/** * Gets the currently processed portlet request. The current portlet request * is automatically defined when the request is started. The current portlet * request can not be used in e.g. background threads because of the way * server implementations reuse request instances. * * @return the current portlet request instance if available, otherwise * <code>null</code> * @since 7.3 */ public static PortletRequest getCurrentPortletRequest() { return VaadinPortletService.getCurrentPortletRequest(); }
protected void initializePlugin(VaadinPortletService service) { // Spring system messages provider if (systemMessagesBeanName != null && systemMessagesBeanName != "") { SpringVaadinSystemMessagesProvider messagesProvider = new SpringVaadinSystemMessagesProvider(applicationContext, systemMessagesBeanName); logger.debug("set SpringVaadinSystemMessagesProvider"); service.setSystemMessagesProvider(messagesProvider); } String uiProviderProperty = service.getDeploymentConfiguration().getApplicationOrSystemProperty(Constants.SERVLET_PARAMETER_UI_PROVIDER, null); // Add SpringUIProvider if custom provider doesn't defined. if (uiProviderProperty == null) { service.addSessionInitListener(new SessionInitListener() { @Override public void sessionInit(SessionInitEvent event) throws ServiceException { event.getSession().addUIProvider(new SpringUIProvider()); } }); } }
@Override public void init(PortletConfig portletConfig) throws PortletException { super.init(portletConfig); getService().addSessionInitListener((SessionInitEvent event) -> { try { onVaadinSessionStarted( (VaadinPortletRequest) event.getRequest(), (VaadinPortletSession) event.getSession()); } catch (PortletException e) { throw new ServiceException(e); } }); }
private String getAppOrSystemProperty(String name, String defaultValue) { DeploymentConfiguration deploymentConfiguration = getDeploymentConfiguration(); return deploymentConfiguration.getApplicationOrSystemProperty(name, defaultValue); }
private String getParameter(VaadinRequest request, String name, String defaultValue) { VaadinPortletRequest portletRequest = (VaadinPortletRequest) request; String preference = portletRequest.getPortletPreference(name); if (preference != null) { return preference; } String appOrSystemProperty = getAppOrSystemProperty(name, null); if (appOrSystemProperty != null) { return appOrSystemProperty; } String portalProperty = portletRequest.getPortalProperty(name); if (portalProperty != null) { // For backwards compatibility - automatically map old portal // default widget set to default widget set if (name.equals(Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET)) { return mapDefaultWidgetset(portalProperty); } return portalProperty; } return defaultValue; }
@Override public File getBaseDirectory() { PortletContext context = getPortletContext(); String resultPath = context.getRealPath("/"); if (resultPath != null) { return new File(resultPath); } else { try { final URL url = context.getResource("/"); return new File(url.getFile()); } catch (final Exception e) { // FIXME: Handle exception getLogger().log(Level.INFO, "Cannot access base directory, possible security issue " + "with Application Server or Servlet Container", e); } } return null; }
@Override public String getConfiguredTheme(VaadinRequest request) { return getParameter(request, Constants.PORTAL_PARAMETER_VAADIN_THEME, Constants.DEFAULT_THEME_NAME); }
/** * 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> * @since 7.3 */ public static VaadinPortletRequest getCurrent() { return VaadinPortletService.getCurrentRequest(); } }
@Override protected void handleSessionExpired(VaadinRequest request, VaadinResponse response) { // TODO Figure out a better way to deal with // SessionExpiredExceptions getLogger().finest("A user session has expired"); }
@Override public void destroy() { super.destroy(); getService().destroy(); }
@Override protected void portletInitialized() throws PortletException { getService().addSessionInitListener(new SessionInitListener() { private static final long serialVersionUID = -4571879262155039969L; @Override public void sessionInit(SessionInitEvent event) throws ServiceException { try { ApplicationContext context = PortletApplicationContextUtils .getRequiredWebApplicationContext(getPortletContext()); SpringAwareUIProvider uiProvider = new SpringAwareUIProvider(context); event.getSession().addUIProvider(uiProvider); } catch (IllegalStateException e) { throw new ServiceException(e); } } }); } }
@Override public String getStaticFileLocation(VaadinRequest request) { // /html is default for Liferay String staticFileLocation = getParameter(request, Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, "/html"); if (Constants.PORTLET_CONTEXT.equals(staticFileLocation)) { return request.getContextPath(); } else { return trimTrailingSlashes(staticFileLocation); } }
/** * Gets the currently processed portlet request. The current portlet request * is automatically defined when the request is started. The current portlet * request can not be used in e.g. background threads because of the way * server implementations reuse request instances. * * @return the current portlet request instance if available, otherwise * <code>null</code> * */ public static PortletRequest getCurrentPortletRequest() { VaadinPortletRequest currentRequest = getCurrentRequest(); if (currentRequest != null) { return currentRequest.getPortletRequest(); } else { return null; } }
@Override protected LegacyApplication createApplication() { VaadinPortlet portlet = VaadinPortlet.getCurrent(); if (portlet instanceof LegacyVaadinPortlet) { LegacyVaadinPortlet legacyPortlet = (LegacyVaadinPortlet) portlet; PortletRequest request = VaadinPortletService .getCurrentPortletRequest(); if (legacyPortlet.shouldCreateApplication(request)) { try { return legacyPortlet.getNewApplication(request); } catch (PortletException e) { throw new RuntimeException(e); } } } return null; } };