Search in sources :

Example 1 with IPortalRequestUtils

use of org.apereo.portal.url.IPortalRequestUtils in project uPortal by Jasig.

the class ProfileEvaluator method isApplicable.

@Override
public boolean isApplicable(IPerson person) {
    final ApplicationContext applicationContext = ApplicationContextLocator.getApplicationContext();
    final IPortalRequestUtils portalRequestUtils = applicationContext.getBean(IPortalRequestUtils.class);
    final IProfileMapper profileMapper = applicationContext.getBean("profileMapper", IProfileMapper.class);
    final HttpServletRequest request = portalRequestUtils.getCurrentPortalRequest();
    final String currentFname = profileMapper.getProfileFname(person, request);
    return profileFname.equals(currentFname);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ApplicationContext(org.springframework.context.ApplicationContext) IPortalRequestUtils(org.apereo.portal.url.IPortalRequestUtils) IProfileMapper(org.apereo.portal.layout.profile.IProfileMapper)

Example 2 with IPortalRequestUtils

use of org.apereo.portal.url.IPortalRequestUtils in project uPortal by Jasig.

the class HttpRequestPropertiesManagerTest method testGetRequestProperties.

public void testGetRequestProperties() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("1.2.3.4");
    request.setMethod("POST");
    final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
    final IPortalRequestUtils portalRequestUtils = EasyMock.createMock(IPortalRequestUtils.class);
    EasyMock.expect(portalRequestUtils.getOriginalPortalRequest(request)).andReturn(request);
    EasyMock.replay(portletWindow, portalRequestUtils);
    this.httpRequestPropertiesManager.setPortalRequestUtils(portalRequestUtils);
    final MultivaluedMapPopulator<String, String> populator = new MultivaluedMapPopulator<String, String>();
    this.httpRequestPropertiesManager.populateRequestProperties(request, portletWindow, populator);
    final Map<String, List<String>> properties = populator.getMap();
    assertNotNull("properties Map should not be null", properties);
    final Map<String, List<String>> expected = ImmutableMap.of("REMOTE_ADDR", Collections.singletonList("1.2.3.4"), "REQUEST_METHOD", Collections.singletonList("POST"), "REMOTE_HOST", Collections.singletonList("localhost"));
    assertEquals(expected, properties);
    EasyMock.verify(portletWindow, portalRequestUtils);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) IPortalRequestUtils(org.apereo.portal.url.IPortalRequestUtils) List(java.util.List) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) MultivaluedMapPopulator(org.apereo.portal.utils.MultivaluedMapPopulator)

Aggregations

IPortalRequestUtils (org.apereo.portal.url.IPortalRequestUtils)2 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 IProfileMapper (org.apereo.portal.layout.profile.IProfileMapper)1 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)1 MultivaluedMapPopulator (org.apereo.portal.utils.MultivaluedMapPopulator)1 ApplicationContext (org.springframework.context.ApplicationContext)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1