public EventProviderImpl(PortletWindow portletWindow, PortletRegistryService portletRegistry) { this.portletWindow = portletWindow; this.portletRegistry = portletRegistry; if (LOG.isTraceEnabled()) { StringBuilder txt = new StringBuilder(128); txt.append("Portlet window: ").append(portletWindow.getId().getStringId()); LOG.debug(txt.toString()); } }
/** * Creates portlet-scoped ID for the specified attribute name. * Portlet-scoped ID for a given attribute name has the following form: * <code>javax.portlet.p.<ID>?<name></code> * where <code>ID</code> is a unique identification for the portlet window * (assigned by the portal/portlet-container) that must not contain a '?' * character. <code>name</code> is the attribute name. * <p> * Refer to Portlet Specification PLT. 15.3 for more details. * </p> * @param name the attribute name. * @return portlet-scoped ID for the attribute name. */ protected String createPortletScopedId(String name) { StringBuffer buffer = new StringBuffer(); buffer.append(PORTLET_SCOPE_NAMESPACE); buffer.append(portletWindow.getId().getStringId()); buffer.append(ID_NAME_SEPARATOR); buffer.append(name); return buffer.toString(); }
/** * Checks if the attribute name in APPLICATION_SCOPE is in the current * portlet scope. * @param name the attribute name to check. * @return true if the attribute name is in the current portlet scope. * @see #createPortletScopedId(String) */ protected boolean isInCurrentPortletScope(String name) { // Portlet-scoped attribute names MUST start with "javax.portlet.p.", // and contain the ID-name separator '?'. if (name.startsWith(PORTLET_SCOPE_NAMESPACE) && name.indexOf(ID_NAME_SEPARATOR) > -1) { String id = name.substring(PORTLET_SCOPE_NAMESPACE.length(), name.indexOf(ID_NAME_SEPARATOR)); return (id.equals(portletWindow.getId().getStringId())); } // Application-scoped attribute names are not in portlet scope. return false; }
public StateAwareResponseImpl(PortletStateAwareResponseContext responseContext) { super(responseContext); this.responseContext = responseContext; this.windowId = responseContext.getPortletWindow().getId().getStringId(); }
@Override public Map<String, String[]> getPrivateRenderParameterMap() { return paramFactory.getResourceRenderParameterMap(window.getId().getStringId()); }
@Override public String getWindowID() { return getPortletWindow().getId().getStringId(); }
@Override public Map<String, String[]> getPrivateParameterMap() { return paramFactory.getPrivateParameterMap(window.getId().getStringId()); }
@Override public Map<String, String[]> getPublicParameterMap() { return paramFactory.getPublicParameterMap(window.getId().getStringId()); }
@Override public IPortletWindow convertPortletWindow( HttpServletRequest request, PortletWindow plutoPortletWindow) { Validate.notNull(request, "request can not be null"); Validate.notNull(plutoPortletWindow, "portletWindow can not be null"); // Conver the pluto portlet window ID into a uPortal portlet window ID final PortletWindowID plutoWindowId = plutoPortletWindow.getId(); final IPortletWindowId portletWindowId; if (plutoWindowId instanceof IPortletWindowId) { portletWindowId = (IPortletWindowId) plutoWindowId; } else { portletWindowId = this.getPortletWindowId(request, plutoWindowId.getStringId()); } // Do a new get to make sure the referenced data gets updated correctly return this.getPortletWindow(request, portletWindowId); }
@Override public Map<String, String[]> getParameterMap() { return paramFactory.getParameterMap(window.getId().getStringId()); }
protected BaseURLImpl(PortletResponseContext responseContext, PortletURLProvider urlProvider) { this.responseContext = responseContext; this.portalContext = responseContext.getContainer() .getContainerServices().getPortalContext(); this.windowId = responseContext.getPortletWindow().getId().getStringId(); this.urlProvider = urlProvider; renderURL = PortletURLProvider.TYPE.RENDER == urlProvider.getType(); if (isTrace) { StringBuilder txt = new StringBuilder(); txt.append("URL provider type=").append(urlProvider.getType()); txt.append(", WindowId=").append(windowId); txt.append(", isRender=").append(renderURL); LOGGER.debug(txt.toString()); } }
/** * Creates a "read-only" URL provider that is used to provide portlet requests * with info. * * @param url * @param windowId */ public PortletURLProviderImpl(PortalURL url, PortletWindow portletWindow, PortletRequestContext reqctx) { this.url = url; this.type = urlTypeMap.get(url.getType()); this.window = portletWindow.getId().getStringId(); this.paramFactory = this.url.getPortletParameterFactory(reqctx); if (isTrace) { StringBuilder txt = new StringBuilder("Created 'read-only' URL provider."); txt.append(" type=").append(this.type); txt.append(", URL type=").append(url.getType()); txt.append(", window=").append(window); txt.append(", URL target=").append(url.getTargetWindow()); LOGGER.debug(txt.toString()); } }
@Override public IPortletWindow convertPortletWindow( HttpServletRequest request, PortletWindow plutoPortletWindow) { Validate.notNull(request, "request can not be null"); Validate.notNull(plutoPortletWindow, "portletWindow can not be null"); // Conver the pluto portlet window ID into a uPortal portlet window ID final PortletWindowID plutoWindowId = plutoPortletWindow.getId(); final IPortletWindowId portletWindowId; if (plutoWindowId instanceof IPortletWindowId) { portletWindowId = (IPortletWindowId) plutoWindowId; } else { portletWindowId = this.getPortletWindowId(request, plutoWindowId.getStringId()); } // Do a new get to make sure the referenced data gets updated correctly return this.getPortletWindow(request, portletWindowId); }
@SuppressWarnings("unchecked") @Override public void setTitle(String title) { if (!isClosed()) { Map<String, String> titles = (Map<String, String>) getServletRequest().getAttribute(AttributeKeys.PORTLET_TITLE); if (titles == null) { titles = new HashMap<String, String>(); getServletRequest().setAttribute(AttributeKeys.PORTLET_TITLE, titles); } String key = getPortletWindow().getId().getStringId(); titles.put(key, title); } }
@SuppressWarnings("unchecked") public void setTitle(String title) { if (!isClosed()) { Map<String, String> titles = (Map<String, String>) getServletRequest().getAttribute(AttributeKeys.PORTLET_TITLE); if (titles == null) { titles = new HashMap<String, String>(); getServletRequest().setAttribute(AttributeKeys.PORTLET_TITLE, titles); } String key = getPortletWindow().getId().getStringId(); titles.put(key, title); } } }
@Override public HttpSession getSession() { HttpSession sess = null; PortletConfig portletConfig = getPortletConfig(); Map<String, String[]> containerRuntimeOptions = portletConfig.getContainerRuntimeOptions(); String[] values = containerRuntimeOptions.get("javax.portlet.servletDefaultSessionScope"); if ((values != null) && (values.length > 0) && "PORTLET_SCOPE".equals(values[0])) { String portletWindowId = getPortletWindow().getId().getStringId(); sess = ServletPortletSessionProxy.createProxy(getServletRequest(), portletWindowId); } return sess; }
private boolean isDeclaredAsPublishingEvent(QName qname) { String applicationId = PortletWindowConfig.parseContextPath(portletWindow.getId().getStringId()); String applicationName = applicationId; String portletName = PortletWindowConfig.parsePortletName(portletWindow.getId().getStringId()); List<? extends EventDefinitionReference> events = null; try { events = portletRegistry.getPortlet(applicationName, portletName).getSupportedPublishingEvents(); } catch (PortletContainerException e1) { e1.printStackTrace(); } if (events != null) { for (EventDefinitionReference ref : events) { QName name = ref.getQualifiedName(); if (name == null) { continue; } if (qname.equals(name)) { return true; } } } return false; }
@Override public void close() { if (!isClosed()) { super.close(); if (isDebug) { LOGGER.debug("Applying the changes."); } PortalURL url = portletURLProvider.apply(); if (isDebug) { LOGGER.debug("Merging."); } PortalRequestContext.getContext(getServletRequest()).mergePortalURL(url, getPortletWindow().getId().getStringId()); if (isDebug) { LOGGER.debug("exiting."); } } }
this.url = url.clone(); this.type = type; this.window = portletWindow.getId().getStringId(); this.paramFactory = this.url.getPortletParameterFactory(reqctx);
/** * Constructor * * @param container * the container instance * @param containerRequest * the original HTTP request * @param containerResponse * the original HTTP response * @param window * the portlet window for this request * @param useRequestParameters * not used ... probably an error. sort out later * @param phase * the lifecycle phase being processed */ public PortletRequestContextImpl(PortletContainer container, HttpServletRequest containerRequest, HttpServletResponse containerResponse, PortletWindow window, boolean useRequestParameters, String phase) { this.container = container; this.containerRequest = containerRequest; this.containerResponse = containerResponse; this.window = window; this.windowId = window.getId().getStringId(); this.url = PortalRequestContext.getContext(containerRequest).createPortalURL(); this.urlProvider = new PortletURLProviderImpl(url, window, this); this.paramFactory = url.getPortletParameterFactory(this); this.phase = phase; this.asraHandler = new ActionScopedRequestAttributeHandler(this, paramFactory, phase); }