// get a list of all channels
List<IChannelDefinition> allChannels = channelRegistryStore.getChannelDefinitions();
// construct a new channel registry
ChannelRegistryBean registry = new ChannelRegistryBean();
// add the root category and all its children to the registry
ChannelCategory rootCategory = channelRegistryStore.getTopLevelChannelCategory();
registry.addCategory(addChildren(rootCategory, allChannels, user, type));
/*
* uPortal historically has provided for a convention that channels
* not in any category may potentially be viewed by users but may not
* be subscribed to. We'd like administrators to still be able to
* modify these channels through the portlet administration tool. The
* logic below takes any channels that have not already been identified
* as belonging to a category and adds them to the top-level of the
* registry, assuming the current user has manage permissions.
*/
if (type.equals(TYPE_MANAGE)) {
EntityIdentifier ei = user.getEntityIdentifier();
IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
for (IChannelDefinition channel : allChannels) {
if (ap.canManage(channel.getId())) {
registry.addChannel(new ChannelBean(channel));
}
}
}
return registry;