Search in sources :

Example 56 with IPortletWindow

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());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) MultivaluedMapPopulator(org.apereo.portal.utils.MultivaluedMapPopulator)

Example 57 with IPortletWindow

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;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Definition(org.apereo.portal.soffit.model.v1_0.Definition) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) ArrayList(java.util.ArrayList) List(java.util.List) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) BasicHeader(org.apache.http.message.BasicHeader) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 58 with IPortletWindow

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;
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) QName(javax.xml.namespace.QName) ContainerRuntimeOption(org.apache.pluto.container.om.portlet.ContainerRuntimeOption) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 59 with IPortletWindow

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 60 with IPortletWindow

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

Aggregations

IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)88 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)32 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)32 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)23 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 IPortalRequestInfo (org.apereo.portal.url.IPortalRequestInfo)12 IUserInstance (org.apereo.portal.user.IUserInstance)12 List (java.util.List)10 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)10 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)9 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)9 IOException (java.io.IOException)8 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)7 WindowState (javax.portlet.WindowState)6 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)6 IPortalUrlBuilder (org.apereo.portal.url.IPortalUrlBuilder)6 LinkedHashMap (java.util.LinkedHashMap)5 Locale (java.util.Locale)5 PortletException (javax.portlet.PortletException)5 PortletMode (javax.portlet.PortletMode)5