use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletDelegationFnameSubscribeIdPostUrlParsing.
@Test
public void testSingleFolderPortletDelegationFnameSubscribeIdPostUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/p/portlet-admin.ctf3/max/resource.uP");
request.setQueryString("?pCa=30_dlg-16-ctf3-5_5&pCd_30_dlg-16-ctf3-5_5=16_ctf3_5&pCr_30_dlg-16-ctf3-5_5=preview&pP_execution=e2s3&pP__eventId=configModeAction");
request.addParameter("pCa", "30_dlg-16-ctf3-5_5");
request.addParameter("pCd_30_dlg-16-ctf3-5_5", "16_ctf3_5");
request.addParameter("pCr_30_dlg-16-ctf3-5_5", "preview");
request.addParameter("pP_execution", "e2s3");
request.addParameter("pP__eventId", "configModeAction");
// not on URL, was posted
request.addParameter("content", "<div>some content</div>");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("16_ctf3_5");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("30_dlg-16-ctf3-5_5");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, null, "portlet-admin.ctf3")).thenReturn(portletWindowId1);
when(this.portletWindowRegistry.getPortletWindowId(request, "30_dlg-16-ctf3-5_5")).thenReturn(portletWindowId2);
when(this.portletWindowRegistry.getPortletWindowId(request, "16_ctf3_5")).thenReturn(portletWindowId1);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertNull(portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.MAX, portalRequestInfo.getUrlState());
assertEquals(UrlType.RESOURCE, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(2, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
assertNotNull(portletRequestInfo);
assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
assertEquals(ImmutableMap.of("execution", Arrays.asList("e2s3"), "_eventId", Arrays.asList("configModeAction")), portletRequestInfo.getPortletParameters());
assertNull(portletRequestInfo.getDelegateParentWindowId());
final IPortletRequestInfo portletRequestInfo2 = portletRequestInfoMap.get(portletWindowId2);
assertNotNull(portletRequestInfo2);
assertEquals(portletWindowId2, portletRequestInfo2.getPortletWindowId());
assertEquals(ImmutableMap.of("content", Arrays.asList("<div>some content</div>")), portletRequestInfo2.getPortletParameters());
assertEquals(portletWindowId1, portletRequestInfo2.getDelegateParentWindowId());
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testLegacyDetachedResourceUrlParsing.
@Test
public void testLegacyDetachedResourceUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/f/u12l1s5/p/news.u12l1n7/detached/resource.uP");
request.setQueryString("?pCc=cacheLevelPage&pCr=calendar.2012-06-01.7");
request.addParameter("pCc", "cacheLevelPage");
request.addParameter("pCr", "calendar.2012-06-01.7");
final MockPortletWindowId portletWindowId = new MockPortletWindowId("s3");
final MockPortletWindowId detachedPortletWindowId = new MockPortletWindowId("d3");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getLayoutNodeForFolderNames(request, Arrays.asList("u12l1s5"))).thenReturn("u12l1s5");
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, "u12l1s5", "news.u12l1n7")).thenReturn(portletWindowId);
when(this.portletWindowRegistry.getOrCreateStatelessPortletWindow(request, portletWindowId)).thenReturn(portletWindow1);
when(portletWindow1.getPortletWindowId()).thenReturn(detachedPortletWindowId);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertEquals("u12l1s5", portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(detachedPortletWindowId, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.DETACHED, portalRequestInfo.getUrlState());
assertEquals(UrlType.RESOURCE, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(1, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(detachedPortletWindowId);
assertNotNull(portletRequestInfo);
assertEquals(detachedPortletWindowId, portletRequestInfo.getPortletWindowId());
assertEquals(Collections.EMPTY_MAP, portletRequestInfo.getPortletParameters());
assertEquals(IPortletRenderer.DETACHED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getPortletMode());
assertEquals(ResourceURL.PAGE, portletRequestInfo.getCacheability());
assertEquals("calendar.2012-06-01.7", portletRequestInfo.getResourceId());
final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, "u12l1s5", detachedPortletWindowId, UrlType.RESOURCE);
when(this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, detachedPortletWindowId, UrlType.RESOURCE)).thenReturn(portalUrlBuilder);
when(this.portletWindowRegistry.getPortletWindow(request, detachedPortletWindowId)).thenReturn(portletWindow2);
when(portletWindow2.getPortletEntity()).thenReturn(portletEntity1);
when(portletEntity1.getLayoutNodeId()).thenReturn("u12l1s5");
when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, detachedPortletWindowId)).thenReturn("news.u12l1n7");
when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, "u12l1s5")).thenReturn(Collections.singletonList("u12l1s5"));
final String canonicalUrl = this.urlSyntaxProvider.getCanonicalUrl(request);
assertEquals("/uPortal/f/u12l1s5/p/news.u12l1n7/detached/calendar.2012-06-01.7.resource.uP?pCc=cacheLevelPage", canonicalUrl);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testLegacyPortletUrlParsingNoParams.
@Test
public void testLegacyPortletUrlParsingNoParams() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/portal");
request.setRequestURI("/render.userLayoutRootNode.uP");
request.setQueryString("?uP_fname=contact-information");
request.addParameter("uP_fname", "contact-information");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("u110l1n41");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, "contact-information")).thenReturn(this.portletWindow1);
when(this.portletWindow1.getPortletWindowId()).thenReturn(portletWindowId1);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertNull(portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.MAX, portalRequestInfo.getUrlState());
assertEquals(UrlType.RENDER, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(1, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
assertNotNull(portletRequestInfo);
assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
assertEquals(Collections.emptyMap(), portletRequestInfo.getPortletParameters());
assertEquals(WindowState.MAXIMIZED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getDelegateParentWindowId());
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlParsing.
@Test
public void testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/f/n2/normal/render.uP");
request.setQueryString("?pCt=fname.s3&pCs=minimized&pP_action=dashboard&pCd_pw2=pw1&pCm_pw2=help&pP_pw2_a=b&pP_pw2_b=c&pCa=pw2");
request.addParameter("pCt", "fname.s3");
request.addParameter("pCs", "minimized");
request.addParameter("pP_action", "dashboard");
request.addParameter("pCa", "pw2");
request.addParameter("pCd_pw2", "pw1");
request.addParameter("pCm_pw2", "help");
request.addParameter("pP_pw2_a", "b");
request.addParameter("pP_pw2_b", "c");
request.addParameter("postedParameter", "foobar");
final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("pw1");
final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("pw2");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
when(this.urlNodeSyntaxHelper.getLayoutNodeForFolderNames(request, Arrays.asList("n2"))).thenReturn("n2");
when(this.urlNodeSyntaxHelper.getPortletForFolderName(request, "n2", "fname.s3")).thenReturn(portletWindowId1);
when(this.portletWindowRegistry.getPortletWindowId(request, "pw2")).thenReturn(portletWindowId2);
when(this.portletWindowRegistry.getPortletWindowId(request, "pw1")).thenReturn(portletWindowId1);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertEquals("n2", portalRequestInfo.getTargetedLayoutNodeId());
assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.NORMAL, portalRequestInfo.getUrlState());
assertEquals(UrlType.RENDER, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(2, portletRequestInfoMap.size());
final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
assertNotNull(portletRequestInfo);
assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
assertEquals(ImmutableMap.of("action", Arrays.asList("dashboard")), portletRequestInfo.getPortletParameters());
assertEquals(WindowState.MINIMIZED, portletRequestInfo.getWindowState());
assertNull(portletRequestInfo.getPortletMode());
assertNull(portletRequestInfo.getDelegateParentWindowId());
final IPortletRequestInfo portletRequestInfo2 = portletRequestInfoMap.get(portletWindowId2);
assertNotNull(portletRequestInfo2);
assertEquals(portletWindowId2, portletRequestInfo2.getPortletWindowId());
assertEquals(ImmutableMap.of("a", Arrays.asList("b"), "b", Arrays.asList("c"), "postedParameter", Arrays.asList("foobar")), portletRequestInfo2.getPortletParameters());
assertNull(portletRequestInfo2.getWindowState());
assertEquals(PortletMode.HELP, portletRequestInfo2.getPortletMode());
assertEquals(portletWindowId1, portletRequestInfo2.getDelegateParentWindowId());
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImplTest method testLegacyTargetedTabParsing.
@Test
public void testLegacyTargetedTabParsing() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath("/uPortal");
request.setRequestURI("/render.userLayoutRootNode.uP");
request.setQueryString("?root=uP_root&uP_sparam=activeTab&activeTab=1");
request.addParameter("root", "uP_root");
request.addParameter("uP_sparam", "activeTab");
request.addParameter("activeTab", "1");
when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
when(this.xpathOperations.doWithExpression(ArgumentMatchers.eq("/layout/folder/folder[@type='regular' and @hidden='false'][position() = $activeTabId]/@ID"), ArgumentMatchers.eq(Collections.singletonMap("activeTabId", "1")), ArgumentMatchers.<Function>any())).thenReturn("n12");
when(this.userInstanceManager.getUserInstance(request)).thenReturn(userInstance);
when(userInstance.getPreferencesManager()).thenReturn(userPreferencesManager);
when(userPreferencesManager.getUserLayoutManager()).thenReturn(userLayoutManager);
when(userLayoutManager.getUserLayout()).thenReturn(userLayout);
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
assertNotNull(portalRequestInfo);
assertEquals("n12", portalRequestInfo.getTargetedLayoutNodeId());
assertNull(portalRequestInfo.getTargetedPortletWindowId());
assertEquals(UrlState.NORMAL, portalRequestInfo.getUrlState());
assertEquals(UrlType.RENDER, portalRequestInfo.getUrlType());
final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
assertNotNull(portletRequestInfoMap);
assertEquals(0, portletRequestInfoMap.size());
}
Aggregations