use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortalUrlProviderImpl method verifyPortletWindowId.
/**
* Verify the requested portlet window corresponds to a node in the user's layout and return the
* corresponding layout node id
*/
protected String verifyPortletWindowId(HttpServletRequest request, IPortletWindowId portletWindowId) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
final IPortletWindowId delegationParentWindowId = portletWindow.getDelegationParentId();
if (delegationParentWindowId != null) {
return verifyPortletWindowId(request, delegationParentWindowId);
}
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final String channelSubscribeId = portletEntity.getLayoutNodeId();
final IUserLayoutNodeDescription node = userLayoutManager.getNode(channelSubscribeId);
if (node == null) {
throw new IllegalArgumentException("No layout node exists for id " + channelSubscribeId + " of window " + portletWindowId);
}
return node.getId();
}
use of org.apereo.portal.portlet.om.IPortletWindow 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 org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletPlaceholderEventSource method generateCharacterEvents.
@Override
public void generateCharacterEvents(HttpServletRequest servletRequest, XMLEventReader eventReader, StartElement event, Collection<CharacterEvent> eventBuffer) throws XMLStreamException {
final Tuple<IPortletWindow, StartElement> portletWindowAndElement = this.portletWindowRegistry.getPortletWindow(servletRequest, event);
if (portletWindowAndElement == null) {
this.logger.warn("Could not find IPortletWindow for StartElement " + event + ". No PortletPlaceholderEvent will be generated. " + event.getLocation());
return;
}
final IPortletWindowId portletWindowId = portletWindowAndElement.first.getPortletWindowId();
this.generateCharacterEvents(portletWindowId, eventReader, event, eventBuffer);
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class LocalPortletRequestContextServiceImpl method getPortletEventRequestContext.
/* (non-Javadoc)
* @see org.apache.pluto.container.PortletRequestContextService#getPortletEventRequestContext(org.apache.pluto.container.PortletContainer, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.pluto.container.PortletWindow)
*/
@Override
public PortletRequestContext getPortletEventRequestContext(PortletContainer container, HttpServletRequest containerRequest, HttpServletResponse containerResponse, PortletWindow window) {
final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(containerRequest, window);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(containerRequest);
return new PortletRequestContextImpl(container, portletWindow, containerRequest, containerResponse, this.requestPropertiesManager, portalRequestInfo, portletCookieService, requestAttributeService);
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class LocalPortletRequestContextServiceImpl method getPortletEventResponseContext.
/* (non-Javadoc)
* @see org.apache.pluto.container.PortletRequestContextService#getPortletEventResponseContext(org.apache.pluto.container.PortletContainer, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.pluto.container.PortletWindow)
*/
@Override
public PortletEventResponseContext getPortletEventResponseContext(PortletContainer container, HttpServletRequest containerRequest, HttpServletResponse containerResponse, PortletWindow window) {
final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(containerRequest, window);
final IPortalActionUrlBuilder portalActionUrlBuilder = this.portalUrlProvider.getPortalActionUrlBuilder(containerRequest);
final IPortletUrlBuilder portletUrlBuilder = portalActionUrlBuilder.getPortletUrlBuilder(portletWindow.getPortletWindowId());
return new PortletEventResponseContextImpl(container, portletWindow, containerRequest, containerResponse, requestPropertiesManager, portletUrlBuilder, this.portletContextService, this.portletCookieService);
}
Aggregations