protected PortletWindowIdImpl convertPortletWindowId( HttpServletRequest request, IPortletWindowId portletWindowId) { if (portletWindowId instanceof PortletWindowIdImpl) { return (PortletWindowIdImpl) portletWindowId; } return this.getPortletWindowId(request, portletWindowId.getStringId()); }
protected String getAttributeName(IPortletWindow portletWindow, String property) { final String mappedAttributeName = this.propertyToAttributeMappings.get(property); final String attributeName; if (mappedAttributeName == null) { attributeName = property; } else { attributeName = mappedAttributeName; } if (this.nonNamespacedProperties.contains(property)) { return attributeName; } final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId(); return portletWindowId.getStringId() + attributeName; }
protected StartElement addPortletWindowId( StartElement element, IPortletWindowId portletWindowId) { final Attribute windowIdAttribute = xmlEventFactory.createAttribute(PORTLET_WINDOW_ID_ATTR_NAME, portletWindowId.getStringId()); // Clone the start element to add the new attribute final QName name = element.getName(); final String prefix = name.getPrefix(); final String namespaceURI = name.getNamespaceURI(); final String localPart = name.getLocalPart(); @SuppressWarnings("unchecked") final Iterator<Attribute> attributes = element.getAttributes(); @SuppressWarnings("unchecked") final Iterator<Namespace> namespaces = element.getNamespaces(); final NamespaceContext namespaceContext = element.getNamespaceContext(); // Create a new iterator of the existing attributes + the new window id attribute final Iterator<Attribute> newAttributes = Iterators.concat(attributes, Iterators.forArray(windowIdAttribute)); return xmlEventFactory.createStartElement( prefix, namespaceURI, localPart, newAttributes, namespaces, namespaceContext); }
@Override public IPortletWindow getOrCreateStatelessPortletWindow( HttpServletRequest request, IPortletWindowId basePortletWindowId) { // Need the basePortletWindowId to be an instance of PortletWindowIdImpl so that we can extract // the entity ID if (!(basePortletWindowId instanceof PortletWindowIdImpl)) { final String basePortletWindowIdStr = basePortletWindowId.getStringId(); basePortletWindowId = this.getPortletWindowId(request, basePortletWindowIdStr); } // Get the entity ID for the portlet window final IPortletEntityId portletEntityId = ((PortletWindowIdImpl) basePortletWindowId).getPortletEntityId(); // Create the stateless ID final PortletWindowIdImpl statelessPortletWindowId = this.createPortletWindowId(STATELESS_PORTLET_WINDOW_ID, portletEntityId); // See if there is already a request cached stateless window IPortletWindow statelessPortletWindow = this.getPortletWindow(request, statelessPortletWindowId); if (statelessPortletWindow != null) { return statelessPortletWindow; } // Lookup the base portlet window to clone the stateless from final IPortletWindow basePortletWindow = this.getPortletWindow(request, basePortletWindowId); final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, true); // If no base to clone from lookup the entity and pluto definition data if (basePortletWindow == null) { final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId); if (portletEntity == null) { throw new IllegalArgumentException( "No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId); } final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId); final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId); statelessPortletWindowDataMap.storeWindow(portletWindowData); statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor); } // Clone the existing base window else { final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId); portletWindowData.setExpirationCache(basePortletWindow.getExpirationCache()); portletWindowData.setPortletMode(basePortletWindow.getPortletMode()); portletWindowData.setWindowState(basePortletWindow.getWindowState()); portletWindowData.setPublicRenderParameters(basePortletWindow.getPublicRenderParameters()); portletWindowData.setRenderParameters(basePortletWindow.getRenderParameters()); statelessPortletWindowDataMap.storeWindow(portletWindowData); final IPortletEntity portletEntity = basePortletWindow.getPortletEntity(); final PortletDefinition portletDescriptor = basePortletWindow.getPlutoPortletWindow().getPortletDefinition(); statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor); } // Cache the stateless window in the request final PortletWindowCache<IPortletWindow> portletWindowMap = this.getPortletWindowMap(request); portletWindowMap.storeWindow(statelessPortletWindow); return statelessPortletWindow; }