Search in sources :

Example 1 with PortletWindow

use of org.apache.pluto.container.PortletWindow in project uPortal by Jasig.

the class RequestAttributeServiceImplTest method testNull.

@Test
public void testNull() {
    MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
    PortletWindow plutoPortletWindow = mock(PortletWindow.class);
    RequestAttributeServiceImpl service = new RequestAttributeServiceImpl();
    Assert.assertNull(service.getAttribute(httpServletRequest, plutoPortletWindow, null));
    Assert.assertNull(service.getAttribute(httpServletRequest, plutoPortletWindow, "someotherattribute"));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) PortletWindow(org.apache.pluto.container.PortletWindow) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) Test(org.junit.Test)

Example 2 with PortletWindow

use of org.apache.pluto.container.PortletWindow in project uPortal by Jasig.

the class RequestAttributeServiceImplTest method testControl.

/**
     * Default test for function, returns the multivalued attribute map with one multi-valued
     * attribute.
     */
@Test
public void testControl() {
    MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
    httpServletRequest.setRemoteUser("username");
    Map<String, List<Object>> attributes = new HashMap<String, List<Object>>();
    attributes.put("attribute1", Arrays.asList(new Object[] { "value1", "value2", "value3" }));
    NamedPersonImpl personAttributes = new NamedPersonImpl("username", attributes);
    PortletWindow plutoPortletWindow = mock(PortletWindow.class);
    IPortletWindow portletWindow = mock(IPortletWindow.class);
    IPortletEntity portletEntity = mock(IPortletEntity.class);
    when(portletWindow.getPortletEntity()).thenReturn(portletEntity);
    IPortletDefinition portletDefinition = mock(IPortletDefinition.class);
    when(portletEntity.getPortletDefinition()).thenReturn(portletDefinition);
    IPortletDefinitionId portletDefinitionId = mock(IPortletDefinitionId.class);
    when(portletDefinition.getPortletDefinitionId()).thenReturn(portletDefinitionId);
    IPersonAttributeDao personAttributeDao = mock(IPersonAttributeDao.class);
    when(personAttributeDao.getPerson("username")).thenReturn(personAttributes);
    IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
    when(portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow)).thenReturn(portletWindow);
    List<UserAttributeType> userAttributesList = new ArrayList<UserAttributeType>();
    UserAttributeType userAttribute = new UserAttributeType();
    userAttribute.setName("attribute1");
    userAttributesList.add(userAttribute);
    PortletAppType portletApplicationDefinition = new PortletAppType();
    portletApplicationDefinition.addUserAttribute("attribute1");
    IPortletDefinitionRegistry portletDefinitionRegistry = mock(IPortletDefinitionRegistry.class);
    when(portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId)).thenReturn(portletApplicationDefinition);
    RequestAttributeServiceImpl service = new RequestAttributeServiceImpl();
    service.setPersonAttributeDao(personAttributeDao);
    service.setPortletDefinitionRegistry(portletDefinitionRegistry);
    service.setPortletWindowRegistry(portletWindowRegistry);
    Object attribute = service.getAttribute(httpServletRequest, plutoPortletWindow, IPortletRenderer.MULTIVALUED_USERINFO_MAP_ATTRIBUTE);
    Assert.assertNotNull(attribute);
    Assert.assertTrue(attribute instanceof Map);
    @SuppressWarnings("unchecked") Map<String, List<Object>> attributeMap = (Map<String, List<Object>>) attribute;
    List<Object> values = attributeMap.get("attribute1");
    Assert.assertEquals(3, values.size());
    Assert.assertTrue(values.contains("value1"));
    Assert.assertTrue(values.contains("value2"));
    Assert.assertTrue(values.contains("value3"));
}
Also used : IPortletWindowRegistry(org.apereo.portal.portlet.registry.IPortletWindowRegistry) PortletAppType(org.apache.pluto.container.om.portlet.impl.PortletAppType) HashMap(java.util.HashMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) UserAttributeType(org.apache.pluto.container.om.portlet.impl.UserAttributeType) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletDefinitionRegistry(org.apereo.portal.portlet.registry.IPortletDefinitionRegistry) NamedPersonImpl(org.jasig.services.persondir.support.NamedPersonImpl) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao) ArrayList(java.util.ArrayList) List(java.util.List) PortletWindow(org.apache.pluto.container.PortletWindow) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) HashMap(java.util.HashMap) Map(java.util.Map) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Test(org.junit.Test)

Example 3 with PortletWindow

use of org.apache.pluto.container.PortletWindow in project uPortal by Jasig.

the class PortletPreferencesFactoryImpl method createPortletPreferences.

@Override
public PortletPreferences createPortletPreferences(final PortletRequestContext requestContext, boolean render) {
    final HttpServletRequest containerRequest = requestContext.getContainerRequest();
    final PortletWindow plutoPortletWindow = requestContext.getPortletWindow();
    final IPortletWindow portletWindow = portletWindowRegistry.convertPortletWindow(containerRequest, plutoPortletWindow);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final boolean configMode = IPortletRenderer.CONFIG.equals(portletWindow.getPortletMode());
    if (configMode) {
        final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
        return new PortletDefinitionPreferencesImpl(portletDefinitionRegistry, transactionOperations, portletDefinitionId, render);
    } else if (this.isStoreInMemory(containerRequest)) {
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        return new GuestPortletEntityPreferencesImpl(requestContext, portletEntityRegistry, portletDefinitionRegistry, portletEntityId, render);
    } else {
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        return new PortletEntityPreferencesImpl(requestContext, portletEntityRegistry, portletDefinitionRegistry, transactionOperations, portletEntityId, render);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) PortletWindow(org.apache.pluto.container.PortletWindow) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId)

Aggregations

PortletWindow (org.apache.pluto.container.PortletWindow)3 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)3 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)2 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)2 Test (org.junit.Test)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 PortletAppType (org.apache.pluto.container.om.portlet.impl.PortletAppType)1 UserAttributeType (org.apache.pluto.container.om.portlet.impl.UserAttributeType)1 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)1 IPortletDefinitionRegistry (org.apereo.portal.portlet.registry.IPortletDefinitionRegistry)1 IPortletWindowRegistry (org.apereo.portal.portlet.registry.IPortletWindowRegistry)1 IPersonAttributeDao (org.jasig.services.persondir.IPersonAttributeDao)1 NamedPersonImpl (org.jasig.services.persondir.support.NamedPersonImpl)1