use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testAddProperties.
public void testAddProperties() {
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.addResponseProperty(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.addResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
final Map<String, List<String>> expected2 = Collections.<String, List<String>>singletonMap("prop.A", ImmutableList.of("prop.A.1", "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 DefinitionHeaderProvider method createHeader.
@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
// Username
final String username = getUsername(renderRequest);
// Obtain the MarketplacePortletDefinition for this soffit
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);
final IPerson user = personManager.getPerson(httpr);
final Locale locale = getUserLocale(user);
// Title
final String title = mpdef.getTitle(locale.toString());
// FName
final String fname = mpdef.getFName();
// Description
final String description = mpdef.getDescription(locale.toString());
// Categories
List<String> categories = new ArrayList<>();
for (PortletCategory pc : mpdef.getCategories()) {
categories.add(pc.getName());
}
// Parameters
Map<String, List<String>> parameters = new HashMap<>();
for (IPortletDefinitionParameter param : mpdef.getParameters()) {
parameters.put(param.getName(), Collections.singletonList(param.getValue()));
}
final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest));
final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken());
logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt);
return rslt;
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletEventCoordinatationService method isGlobalEvent.
protected boolean isGlobalEvent(HttpServletRequest request, IPortletWindowId sourceWindowId, Event event) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, sourceWindowId);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
final PortletApplicationDefinition parentPortletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId);
final ContainerRuntimeOption globalEvents = parentPortletApplicationDescriptor.getContainerRuntimeOption(GLOBAL_EVENT__CONTAINER_OPTION);
if (globalEvents != null) {
final QName qName = event.getQName();
final String qNameStr = qName.toString();
for (final String globalEvent : globalEvents.getValues()) {
if (qNameStr.equals(globalEvent)) {
return true;
}
}
}
return false;
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletDelegationLocatorImpl method getRequestDispatcher.
/* (non-Javadoc)
* @see org.apereo.portal.api.portlet.PortletDelegationLocator#getRequestDispatcher(org.apereo.portal.portlet.om.IPortletWindowId)
*/
@Override
public PortletDelegationDispatcher getRequestDispatcher(PortletRequest portletRequest, IPortletWindowId portletWindowId) {
final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final IPerson person = this.personManager.getPerson(request);
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
final IPortletWindowId delegationParentId = portletWindow.getDelegationParentId();
if (delegationParentId == null) {
throw new IllegalArgumentException("Portlet window '" + portletWindow + "' is not a delegate window and cannot be delgated to.");
}
return new PortletDelegationDispatcherImpl(portletWindow, person.getID(), this.portalRequestUtils, this.personManager, this.portletRenderer, this.portalUrlProvider, this.portletDelegationManager);
}
use of org.apereo.portal.portlet.om.IPortletWindow in project uPortal by Jasig.
the class PortletRegistryUtil method buildPortletUrl.
/**
* Builds a portal URL to the specific portlet definition {@link IPortletDefinition}, if the
* remote user in the request has browse permissions to the portlet.
*
* @param httpServletRequest Web request with requester as remote user
* @param portlet Definition of portlet to build a maximized portal URL
* @return URL string if user has access; otherwise, return null
*/
public String buildPortletUrl(HttpServletRequest httpServletRequest, IPortletDefinition portlet) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(httpServletRequest, portlet.getFName());
// portletWindow is null if user does not have access to portlet.
if (portletWindow == null) {
return null;
}
// If user does not have browse permission, exclude the portlet.
if (!this.authorizationService.canPrincipalBrowse(this.authorizationService.newPrincipal(httpServletRequest.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) {
return null;
}
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpServletRequest, portlet.getFName(), UrlType.RENDER);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(PortletUtils.getWindowState("maximized"));
return portalUrlBuilder.getUrlString();
}
Aggregations