Search in sources :

Example 21 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletRendererImpl method publishRenderEvent.

/**
 * Publish the portlet render event
 */
protected void publishRenderEvent(IPortletWindow portletWindow, HttpServletRequest httpServletRequest, RenderPart renderPart, long executionTime, boolean cached) {
    final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
    // Determine if the portlet was targeted
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(httpServletRequest);
    final boolean targeted = portletWindowId.equals(portalRequestInfo.getTargetedPortletWindowId());
    renderPart.publishRenderExecutionEvent(this.portalEventFactory, this, httpServletRequest, portletWindowId, executionTime, targeted, cached);
}
Also used : IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 22 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletCookieServiceImplTest method testAddCookieControl.

/**
 * Control test for adding a portlet cookie: no existing portalCookie, portlet cookie requires
 * persistence.
 */
@Test
public void testAddCookieControl() {
    Cookie portletCookie = new Cookie("somePortletCookieName", "somePortletCookieValue");
    // max age will trigger persistence
    portletCookie.setMaxAge(360);
    IPortletCookieDao portletCookieDao = EasyMock.createMock(IPortletCookieDao.class);
    MockPortalCookie portalCookie = new MockPortalCookie();
    portalCookie.setValue("ABCDEF");
    EasyMock.expect(portletCookieDao.createPortalCookie(PortletCookieServiceImpl.DEFAULT_MAX_AGE)).andReturn(portalCookie);
    EasyMock.expect(portletCookieDao.addOrUpdatePortletCookie(portalCookie, portletCookie)).andReturn(portalCookie);
    PortletCookieServiceImpl cookieService = new PortletCookieServiceImpl();
    cookieService.setPortletCookieDao(portletCookieDao);
    IPortletWindowId mockWindowId = EasyMock.createMock(IPortletWindowId.class);
    EasyMock.replay(portletCookieDao, mockWindowId);
    MockHttpServletRequest request = new MockHttpServletRequest();
    cookieService.addCookie(request, mockWindowId, portletCookie);
    EasyMock.verify(portletCookieDao, mockWindowId);
}
Also used : IPortletCookie(org.apereo.portal.portlet.om.IPortletCookie) IPortalCookie(org.apereo.portal.portlet.om.IPortalCookie) Cookie(javax.servlet.http.Cookie) IPortletCookieDao(org.apereo.portal.portlet.dao.IPortletCookieDao) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) Test(org.junit.Test)

Example 23 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortletDelegationLocatorImpl method createRequestDispatcher.

/* (non-Javadoc)
     * @see org.apereo.portal.api.portlet.PortletDelegationLocator#createRequestDispatcher(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletDelegationDispatcher createRequestDispatcher(PortletRequest portletRequest, IPortletDefinitionId delegatePortletDefinitionId) {
    final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
    final String windowID = portletRequest.getWindowID();
    final IPortletWindowId parentPortletWindowId = this.portletWindowRegistry.getPortletWindowId(request, windowID);
    final IPortletEntity delegatePortletEntity = this.portletEntityRegistry.getOrCreateDelegatePortletEntity(request, parentPortletWindowId, delegatePortletDefinitionId);
    final IPortletEntityId delegatePortletEntityId = delegatePortletEntity.getPortletEntityId();
    final IPortletWindow delegatePortletWindow = this.portletWindowRegistry.createDelegatePortletWindow(request, delegatePortletEntityId, parentPortletWindowId);
    final IPerson person = this.personManager.getPerson(request);
    final int userId = person.getID();
    return new PortletDelegationDispatcherImpl(delegatePortletWindow, userId, portalRequestUtils, personManager, portletRenderer, portalUrlProvider, portletDelegationManager);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 24 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class AnalyticsIncorporationComponent method serializePortletRenderExecutionEvents.

protected String serializePortletRenderExecutionEvents(final Set<PortalEvent> portalEvents) {
    // Filter to include just portlet render events
    final Map<String, PortletRenderExecutionEvent> renderEvents = new HashMap<>();
    for (final PortalEvent portalEvent : portalEvents) {
        if (portalEvent instanceof PortletRenderExecutionEvent) {
            final PortletRenderExecutionEvent portletRenderEvent = (PortletRenderExecutionEvent) portalEvent;
            // Don't write out info for minimized portlets
            if (!WindowState.MINIMIZED.equals(portletRenderEvent.getWindowState())) {
                final IPortletWindowId portletWindowId = portletRenderEvent.getPortletWindowId();
                final String eventKey = portletWindowId != null ? portletWindowId.getStringId() : portletRenderEvent.getFname();
                renderEvents.put(eventKey, portletRenderEvent);
            }
        }
    }
    try {
        return portletEventWriter.writeValueAsString(renderEvents);
    } catch (JsonParseException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    } catch (JsonMappingException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    } catch (IOException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    }
    return "{}";
}
Also used : PortalEvent(org.apereo.portal.events.PortalEvent) HashMap(java.util.HashMap) PortletRenderExecutionEvent(org.apereo.portal.events.PortletRenderExecutionEvent) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 25 with IPortletWindowId

use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.

the class PortalUrlProviderImpl method verifyPortletWindowId.

/**
 * Verify the requested portlet window corresponds to a node in the user's layout and return the
 * corresponding layout node id
 */
protected String verifyPortletWindowId(HttpServletRequest request, IPortletWindowId portletWindowId) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    final IPortletWindowId delegationParentWindowId = portletWindow.getDelegationParentId();
    if (delegationParentWindowId != null) {
        return verifyPortletWindowId(request, delegationParentWindowId);
    }
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final String channelSubscribeId = portletEntity.getLayoutNodeId();
    final IUserLayoutNodeDescription node = userLayoutManager.getNode(channelSubscribeId);
    if (node == null) {
        throw new IllegalArgumentException("No layout node exists for id " + channelSubscribeId + " of window " + portletWindowId);
    }
    return node.getId();
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

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