use of org.apereo.portal.portlet.registry.IPortletDefinitionRegistry in project uPortal by Jasig.
the class ReferenceChannelNameFinder method getName.
/**
* Given the key, returns the entity's name.
*
* @param key java.lang.String
*/
@Override
public String getName(String key) throws Exception {
IPortletDefinitionRegistry registry = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry();
IPortletDefinition portletDefinition;
if (StringUtils.isNumeric(key)) {
portletDefinition = registry.getPortletDefinition(key);
} else {
portletDefinition = registry.getPortletDefinition(key.split("\\.")[1]);
}
return portletDefinition.getName();
}
use of org.apereo.portal.portlet.registry.IPortletDefinitionRegistry in project uPortal by Jasig.
the class DistributedLayoutManager method getPublishedChannelParametersMap.
/**
* Return a map parameter names to channel parameter objects representing the parameters
* specified at publish time for the channel with the passed-in publish id.
*
* @param channelPublishId
* @return
* @throws PortalException
*/
private Map getPublishedChannelParametersMap(String channelPublishId) throws PortalException {
try {
IPortletDefinitionRegistry registry = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry();
IPortletDefinition def = registry.getPortletDefinition(channelPublishId);
return def.getParametersAsUnmodifiableMap();
} catch (Exception e) {
throw new PortalException("Unable to acquire channel definition.", e);
}
}
use of org.apereo.portal.portlet.registry.IPortletDefinitionRegistry in project uPortal by Jasig.
the class PortletDefinitionRegistryLocator method getPortletDefinitionRegistry.
public static IPortletDefinitionRegistry getPortletDefinitionRegistry() {
AbstractBeanLocator<IPortletDefinitionRegistry> locator = locatorInstance;
if (locator == null) {
LOG.info("Looking up bean '" + BEAN_NAME + "' in ApplicationContext due to context not yet being initialized");
final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
applicationContext.getBean(PortletDefinitionRegistryLocator.class.getName());
locator = locatorInstance;
if (locator == null) {
LOG.warn("Instance of '" + BEAN_NAME + "' still null after portal application context has been initialized");
return applicationContext.getBean(BEAN_NAME, IPortletDefinitionRegistry.class);
}
}
return locator.getInstance();
}
use of org.apereo.portal.portlet.registry.IPortletDefinitionRegistry 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"));
}
Aggregations