Search in sources :

Example 36 with IPortletWindowId

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);
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 37 with IPortletWindowId

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 + "]");
}
Also used : IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 38 with IPortletWindowId

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);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) Test(org.junit.Test)

Example 39 with IPortletWindowId

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());
}
Also used : WindowState(javax.portlet.WindowState) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) Diff(org.custommonkey.xmlunit.Diff) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) Test(org.junit.Test)

Example 40 with IPortletWindowId

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());
}
Also used : WindowState(javax.portlet.WindowState) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) Diff(org.custommonkey.xmlunit.Diff) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) Test(org.junit.Test)

Aggregations

IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)85 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)31 Test (org.junit.Test)19 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)15 WindowState (javax.portlet.WindowState)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)9 PortletMode (javax.portlet.PortletMode)8 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)8 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 IPortletRenderExecutionWorker (org.apereo.portal.portlet.rendering.worker.IPortletRenderExecutionWorker)7 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)7 LinkedHashMap (java.util.LinkedHashMap)6 IPerson (org.apereo.portal.security.IPerson)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 IOException (java.io.IOException)5 List (java.util.List)5 IUserInstance (org.apereo.portal.user.IUserInstance)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5