use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testGetProperties.
public void testGetProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
EasyMock.replay(portletWindow);
final MockRequestPropertiesManager delegateManager1 = new MockRequestPropertiesManager();
delegateManager1.setOrder(Ordered.HIGHEST_PRECEDENCE);
final MockRequestPropertiesManager delegateManager2 = new MockRequestPropertiesManager();
delegateManager2.setOrder(Ordered.LOWEST_PRECEDENCE);
this.requestPropertiesManagerBroker.setPropertiesManagers(ImmutableList.of(delegateManager1, delegateManager2));
delegateManager1.setResponseProperty(request, portletWindow, "prop.A", "prop.A.1");
delegateManager1.setResponseProperty(request, portletWindow, "prop.B", "prop.B.1");
delegateManager2.setResponseProperty(request, portletWindow, "prop.C", "prop.C.1");
MultivaluedMapPopulator<String, String> multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
final Map<String, List<String>> expected1 = ImmutableMap.<String, List<String>>of("prop.A", ImmutableList.of("prop.A.1"), "prop.B", ImmutableList.of("prop.B.1"), "prop.C", ImmutableList.of("prop.C.1"));
assertEquals(expected1, multivaluedMapPopulator.getMap());
delegateManager2.setResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
final Map<String, List<String>> expected2 = ImmutableMap.<String, List<String>>of("prop.A", ImmutableList.of("prop.A.1", "prop.A.2"), "prop.B", ImmutableList.of("prop.B.1"), "prop.C", ImmutableList.of("prop.C.1"));
assertEquals(expected2, multivaluedMapPopulator.getMap());
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testSetProperties.
public void testSetProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
EasyMock.replay(portletWindow);
final MockRequestPropertiesManager delegateManager1 = new MockRequestPropertiesManager();
delegateManager1.setOrder(Ordered.HIGHEST_PRECEDENCE);
final MockRequestPropertiesManager delegateManager2 = new MockRequestPropertiesManager();
delegateManager2.setOrder(Ordered.LOWEST_PRECEDENCE);
this.requestPropertiesManagerBroker.setPropertiesManagers(ImmutableList.of(delegateManager1, delegateManager2));
this.requestPropertiesManagerBroker.setResponseProperty(request, portletWindow, "prop.A", "prop.A.1");
final Map<String, List<String>> expected1 = Collections.singletonMap("prop.A", Collections.singletonList("prop.A.1"));
MultivaluedMapPopulator<String, String> multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
this.requestPropertiesManagerBroker.setResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
final Map<String, List<String>> expected2 = Collections.<String, List<String>>singletonMap("prop.A", ImmutableList.of("prop.A.2"));
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class XsltPortalUrlProvider method getPortletUrlBuilder.
/**
* Get the portlet URL builder for the specified fname or layoutId (fname takes precedence)
*
* @param request
* @param portalUrlBuilder
* @param fname - can be empty string
* @param layoutId - can by empty string
* @param state - can be empty string
* @param mode - can be empty string
* @param copyCurrentRenderParameters
* @param resourceId - can be empty string
* @return IPortletUrlBuilder
* @since 4.1
*/
public IPortletUrlBuilder getPortletUrlBuilder(HttpServletRequest request, IPortalUrlBuilder portalUrlBuilder, String fname, String layoutId, String state, String mode, String copyCurrentRenderParameters, String resourceId) {
final IPortletUrlBuilder portletUrlBuilder;
if (StringUtils.isNotEmpty(fname)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
} else if (StringUtils.isNotEmpty(layoutId)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutId);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
} else {
final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
if (targetPortletWindowId == null) {
if (this.logger.isDebugEnabled()) {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet.", new Throwable());
} else {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet. Enable debug for stack trace.");
}
return new FailSafePortletUrlBuilder(null, portalUrlBuilder);
}
portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
}
portletUrlBuilder.setCopyCurrentRenderParameters(Boolean.parseBoolean(copyCurrentRenderParameters));
if (StringUtils.isNotEmpty(state)) {
portletUrlBuilder.setWindowState(PortletUtils.getWindowState(state));
}
if (StringUtils.isNotEmpty(mode)) {
portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(mode));
}
if (StringUtils.isNotEmpty(resourceId) && portletUrlBuilder.getPortalUrlBuilder().getUrlType() == UrlType.RESOURCE) {
portletUrlBuilder.setResourceId(resourceId);
}
return portletUrlBuilder;
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletWindowAttributeSource method getCacheKey.
@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
final Set<IPortletWindow> portletWindows = this.portletWindowRegistry.getAllLayoutPortletWindows(request);
final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.name);
for (final IPortletWindow portletWindow : portletWindows) {
if (portletWindow != null) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
final WindowState windowState = portletWindow.getWindowState();
final PortletMode portletMode = portletWindow.getPortletMode();
cacheKeyBuilder.addAll(portletWindowId, windowState.toString(), portletMode.toString());
} else {
this.logger.warn("portletWindowRegistry#getAllLayoutPortletWindows() returned a null portletWindow");
}
}
return cacheKeyBuilder.build();
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class RequestRenderingPipelineUtilsImpl method getPortletDefinitionFromServletRequest.
@Override
public IPortletDefinition getPortletDefinitionFromServletRequest(HttpServletRequest request) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
if (portalRequestInfo != null && portalRequestInfo.getTargetedPortletWindowId() != null) {
IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);
if (portletWindow != null && portletWindow.getPortletEntity() != null) {
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
return portletDefinition;
}
}
return null;
}
Aggregations