use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindow.
@Override
public IPortletWindow getOrCreateDefaultPortletWindow(HttpServletRequest request, IPortletEntityId portletEntityId) {
Validate.notNull(request, "request can not be null");
Validate.notNull(portletEntityId, "portletEntityId can not be null");
final IPortletWindowId portletWindowId = this.getDefaultPortletWindowId(request, portletEntityId);
final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request);
// Check if there is portlet window cached in the request
IPortletWindow portletWindow = portletWindowMap.getWindow(portletWindowId);
if (portletWindow != null) {
logger.trace("Found IPortletWindow {} in request cache", portletWindow.getPortletWindowId());
return portletWindow;
}
final PortletWindowData portletWindowData = this.getOrCreateDefaultPortletWindowData(request, portletEntityId, portletWindowId);
portletWindow = wrapPortletWindowData(request, portletWindowData);
if (portletWindow == null) {
return null;
}
// Cache the wrapped window in the request
return portletWindowMap.storeIfAbsentWindow(portletWindow);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class ThreadNamingPortletExecutionInterceptorAdaptor method preExecution.
@Override
public void preExecution(HttpServletRequest request, HttpServletResponse response, IPortletExecutionContext context) {
final IPortletWindowId portletWindowId = context.getPortletWindowId();
final String fname = this.getFname(request, portletWindowId);
final String userName = this.getUserName(request);
final Thread currentThread = Thread.currentThread();
final String threadName = currentThread.getName();
context.setExecutionAttribute(THREAD_NAME, threadName);
final IPortletExecutionContext.ExecutionType executionType = context.getExecutionType();
currentThread.setName(threadName + "-" + userName + "-" + executionType + "-[" + fname + "]");
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class SingleTabUrlNodeSyntaxHelperTest method getPortletForFolderNameFnameTest.
@Test
public void getPortletForFolderNameFnameTest() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final String folder = "fname";
final MockPortletWindowId portletWindowId = new MockPortletWindowId("wid");
when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, folder)).thenReturn(portletWindow);
when(portletWindow.getPortletWindowId()).thenReturn(portletWindowId);
final IPortletWindowId parsedPortletWindowId = this.urlNodeSyntaxHelper.getPortletForFolderName(request, null, folder);
assertNotNull(parsedPortletWindowId);
assertEquals(portletWindowId, parsedPortletWindowId);
}
use of org.apereo.portal.portlet.om.IPortletWindowId 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.IPortletWindowId 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());
}
Aggregations