use of javax.portlet.WindowState in project uPortal by Jasig.
the class WindowStateSettingsStAXComponent method getEventReader.
/* (non-Javadoc)
* @see org.apereo.portal.rendering.PipelineComponent#getEventReader(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(HttpServletRequest request, HttpServletResponse response) {
final PipelineEventReader<XMLEventReader, XMLEvent> pipelineEventReader = this.wrappedComponent.getEventReader(request, response);
final XMLEventReader eventReader = pipelineEventReader.getEventReader();
final IStylesheetDescriptor stylesheetDescriptor = stylesheetAttributeSource.getStylesheetDescriptor(request);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final XMLEventReader filteredEventReader;
if (portalRequestInfo.getTargetedPortletWindowId() == null) {
final IStylesheetParameterDescriptor defaultWindowStateParam = stylesheetDescriptor.getStylesheetParameterDescriptor("dashboardForcedWindowState");
if (defaultWindowStateParam != null) {
// Set all window states to the specified default
final WindowState windowState = PortletUtils.getWindowState(defaultWindowStateParam.getDefaultValue());
filteredEventReader = new SinglePortletWindowStateSettingXMLEventReader(request, eventReader, windowState);
} else {
// Make sure there aren't any portlets in a "targeted" window state
filteredEventReader = new NonTargetedPortletWindowStateSettingXMLEventReader(request, eventReader);
}
} else {
// Not mobile, don't bother filtering
filteredEventReader = eventReader;
}
final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
return new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(filteredEventReader, outputProperties);
}
use of javax.portlet.WindowState in project uPortal by Jasig.
the class XsltPortalUrlProviderTest method testPortletUrlById.
@Test
public void testPortletUrlById() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindowId portletWindowId = new MockPortletWindowId("w1");
when(portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, "foo", UrlType.RENDER)).thenReturn(portalUrlBuilder);
when(portalUrlBuilder.getPortletUrlBuilder(portletWindowId)).thenReturn(portletUrlBuilder);
when(portalUrlBuilder.getUrlString()).thenReturn("/uPortal/home/normal/render.uP?layoutUrl");
when(portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, "foo")).thenReturn(portletWindow);
when(portletWindow.getPortletWindowId()).thenReturn(portletWindowId);
final Transformer transformer = xslTemplate.newTransformer();
transformer.setParameter(XsltPortalUrlProvider.XSLT_PORTAL_URL_PROVIDER, xsltPortalUrlProvider);
transformer.setParameter("CURRENT_REQUEST", request);
// xsl template mode to use
transformer.setParameter("TEST", "portletUrlById");
// set up configuration in the transformer impl
final StringWriter resultWriter = new StringWriter();
transformer.transform(xmlSource, new StreamResult(resultWriter));
verify(portalUrlBuilder).addParameter("pageNum", "42");
verify(portalUrlBuilder).getPortletUrlBuilder(portletWindowId);
verify(portalUrlBuilder).getUrlString();
verifyNoMoreInteractions(portalUrlBuilder);
verify(portletUrlBuilder).setWindowState(new WindowState("maximized"));
verify(portletUrlBuilder).addParameter("tmp", "blah");
verify(portletUrlBuilder).setCopyCurrentRenderParameters(false);
verifyNoMoreInteractions(portletUrlBuilder);
final String result = resultWriter.getBuffer().toString();
logger.debug(result);
XMLUnit.setIgnoreWhitespace(true);
Diff d = new Diff(expected, result);
assertTrue("Transformation result differs from what's expected" + d, d.similar());
}
use of javax.portlet.WindowState in project uPortal by Jasig.
the class XsltPortalUrlProviderTest method testMultiPortletUrlById.
@Test
public void testMultiPortletUrlById() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindowId portletWindowId = new MockPortletWindowId("w1");
final IPortletWindow portletWindow2 = mock(IPortletWindow.class);
final IPortletWindowId portletWindowId2 = new MockPortletWindowId("w2");
final IPortletUrlBuilder portletUrlBuilder2 = mock(IPortletUrlBuilder.class);
when(portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, "foo", UrlType.RENDER)).thenReturn(portalUrlBuilder);
when(portalUrlBuilder.getPortletUrlBuilder(portletWindowId)).thenReturn(portletUrlBuilder);
when(portalUrlBuilder.getUrlString()).thenReturn("/uPortal/home/normal/render.uP?layoutUrl");
when(portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, "foo")).thenReturn(portletWindow);
when(portletWindow.getPortletWindowId()).thenReturn(portletWindowId);
when(portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, "my-portlet")).thenReturn(portletWindow2);
when(portletWindow2.getPortletWindowId()).thenReturn(portletWindowId2);
when(portalUrlBuilder.getPortletUrlBuilder(portletWindowId2)).thenReturn(portletUrlBuilder2);
final Transformer transformer = xslTemplate.newTransformer();
transformer.setParameter(XsltPortalUrlProvider.XSLT_PORTAL_URL_PROVIDER, xsltPortalUrlProvider);
transformer.setParameter("CURRENT_REQUEST", request);
// xsl template mode to use
transformer.setParameter("TEST", "multiPortletUrlById");
// set up configuration in the transformer impl
final StringWriter resultWriter = new StringWriter();
transformer.transform(xmlSource, new StreamResult(resultWriter));
verify(portalUrlBuilder).addParameter("pageNum", "42");
verify(portalUrlBuilder).getPortletUrlBuilder(portletWindowId);
verify(portalUrlBuilder).getPortletUrlBuilder(portletWindowId2);
verify(portalUrlBuilder).getUrlString();
verifyNoMoreInteractions(portalUrlBuilder);
verify(portletUrlBuilder).addParameter("tmp", "blah");
verify(portletUrlBuilder).setCopyCurrentRenderParameters(false);
verifyNoMoreInteractions(portletUrlBuilder);
verify(portletUrlBuilder2).setWindowState(new WindowState("minimized"));
verify(portletUrlBuilder2).addParameter("event", "param");
verify(portletUrlBuilder2).setCopyCurrentRenderParameters(false);
verifyNoMoreInteractions(portletUrlBuilder2);
final String result = resultWriter.getBuffer().toString();
logger.debug(result);
XMLUnit.setIgnoreWhitespace(true);
Diff d = new Diff(expected, result);
assertTrue("Transformation result differs from what's expected" + d, d.similar());
}
use of javax.portlet.WindowState in project uPortal by Jasig.
the class PortletEntityImpl method getWindowStates.
@Override
public Map<Long, WindowState> getWindowStates() {
final Map<Long, WindowState> simpleWindowStates = new LinkedHashMap<Long, WindowState>();
synchronized (this.windowStates) {
for (Map.Entry<StylesheetDescriptorImpl, WindowState> windowStateEntry : windowStates.entrySet()) {
final StylesheetDescriptorImpl stylesheetDescriptor = windowStateEntry.getKey();
final long stylesheetDescriptorId = stylesheetDescriptor.getId();
final WindowState windowState = windowStateEntry.getValue();
simpleWindowStates.put(stylesheetDescriptorId, windowState);
}
}
return Collections.unmodifiableMap(simpleWindowStates);
}
use of javax.portlet.WindowState in project uPortal by Jasig.
the class PortletWindowRegistryImpl method initializePortletWindowData.
/**
* Initializes a newly created {@link PortletWindow}, the default implementation sets up the
* appropriate {@link WindowState} and {@link javax.portlet.PortletMode}
*/
protected void initializePortletWindowData(HttpServletRequest request, PortletWindowData portletWindowData) {
final IStylesheetDescriptor stylesheetDescriptor = getThemeStylesheetDescriptor(request);
final IPortletEntityId portletEntityId = portletWindowData.getPortletEntityId();
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
final WindowState entityWindowState = portletEntity.getWindowState(stylesheetDescriptor);
if (persistentWindowStates.contains(entityWindowState)) {
portletWindowData.setWindowState(entityWindowState);
} else if (entityWindowState != null) {
// Set of persistent window states must have changed, nuke the old value
this.logger.warn("PortletEntity.windowState=" + entityWindowState + " but that state is not in the set of persistent WindowStates. PortletEntity.windowState will be set to null");
portletEntity.setWindowState(stylesheetDescriptor, null);
this.portletEntityRegistry.storePortletEntity(request, portletEntity);
}
}
Aggregations