use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class PortletAdministrationHelper method getPortletApplications.
/**
* Retreive the list of portlet application contexts currently available in this portlet
* container.
*
* @return list of portlet context
*/
public List<PortletApplicationDefinition> getPortletApplications() {
final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService();
final List<PortletApplicationDefinition> contexts = new ArrayList<>();
for (final Iterator<String> iter = portletRegistryService.getRegisteredPortletApplicationNames(); iter.hasNext(); ) {
final String applicationName = iter.next();
final PortletApplicationDefinition applicationDefninition;
try {
applicationDefninition = portletRegistryService.getPortletApplication(applicationName);
} catch (PortletContainerException e) {
throw new RuntimeException("Failed to load PortletApplicationDefinition for '" + applicationName + "'");
}
final List<? extends PortletDefinition> portlets = applicationDefninition.getPortlets();
portlets.sort(new ComparableExtractingComparator<PortletDefinition, String>(String.CASE_INSENSITIVE_ORDER) {
@Override
protected String getComparable(PortletDefinition o) {
final List<? extends DisplayName> displayNames = o.getDisplayNames();
if (displayNames != null && displayNames.size() > 0) {
return displayNames.get(0).getDisplayName();
}
return o.getPortletName();
}
});
contexts.add(applicationDefninition);
}
contexts.sort(new ComparableExtractingComparator<PortletApplicationDefinition, String>(String.CASE_INSENSITIVE_ORDER) {
@Override
protected String getComparable(PortletApplicationDefinition o) {
final String portletContextName = o.getName();
if (portletContextName != null) {
return portletContextName;
}
final String applicationName = o.getContextPath();
if ("/".equals(applicationName)) {
return "ROOT";
}
if (applicationName.startsWith("/")) {
return applicationName.substring(1);
}
return applicationName;
}
});
return contexts;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class PortletEventCoordinatationService method supportsEvent.
protected boolean supportsEvent(Event event, IPortletDefinitionId portletDefinitionId) {
final QName eventName = event.getQName();
// The cache key to use
final Tuple<IPortletDefinitionId, QName> key = new Tuple<IPortletDefinitionId, QName>(portletDefinitionId, eventName);
// Check in the cache if the portlet definition supports this event
final Element element = this.supportedEventCache.get(key);
if (element != null) {
final Boolean supported = (Boolean) element.getObjectValue();
if (supported != null) {
return supported;
}
}
final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId);
if (portletApplicationDescriptor == null) {
return false;
}
final Set<QName> aliases = this.getAllAliases(eventName, portletApplicationDescriptor);
final String defaultNamespace = portletApplicationDescriptor.getDefaultNamespace();
// No support found so far, do more complex namespace matching
final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
if (portletDescriptor == null) {
return false;
}
final List<? extends EventDefinitionReference> supportedProcessingEvents = portletDescriptor.getSupportedProcessingEvents();
for (final EventDefinitionReference eventDefinitionReference : supportedProcessingEvents) {
final QName qualifiedName = eventDefinitionReference.getQualifiedName(defaultNamespace);
if (qualifiedName == null) {
continue;
}
// Look for alias names
if (qualifiedName.equals(eventName) || aliases.contains(qualifiedName)) {
this.supportedEventCache.put(new Element(key, Boolean.TRUE));
return true;
}
// Look for namespaced events
if (StringUtils.isEmpty(qualifiedName.getNamespaceURI())) {
final QName namespacedName = new QName(defaultNamespace, qualifiedName.getLocalPart());
if (eventName.equals(namespacedName)) {
this.supportedEventCache.put(new Element(key, Boolean.TRUE));
return true;
}
}
}
this.supportedEventCache.put(new Element(key, Boolean.FALSE));
return false;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class LocalPortletContextManager method register.
// Public Methods ----------------------------------------------------------
/**
* Retrieves the PortletContext associated with the given ServletContext. If one does not exist,
* it is created.
*
* @param config the servlet config.
* @return the InternalPortletContext associated with the ServletContext.
*/
@Override
public synchronized String register(ServletConfig config) throws PortletContainerException {
ServletContext servletContext = config.getServletContext();
String contextPath = servletContext.getContextPath();
if (!portletContexts.containsKey(contextPath)) {
PortletApplicationDefinition portletApp = this.getPortletAppDD(servletContext, contextPath, contextPath);
DriverPortletContext portletContext = new DriverPortletContextImpl(servletContext, portletApp, requestDispatcherService);
portletContexts.put(contextPath, portletContext);
fireRegistered(portletContext);
if (logger.isInfoEnabled()) {
logger.info("Registered portlet application for context '" + contextPath + "'");
logger.info("Registering " + portletApp.getPortlets().size() + " portlets for context " + portletContext.getApplicationName());
}
// TODO have the portlet servlet provide the portlet's classloader as parameter to this
// method
// This approach is needed as all pluto callbacks in uPortal have an aspect that
// switches the thread classloader back
// to uPortal's classloader.
ClassLoader classLoader = ThreadContextClassLoaderAspect.getPreviousClassLoader();
if (classLoader == null) {
classLoader = Thread.currentThread().getContextClassLoader();
}
classLoaders.put(portletApp.getName(), classLoader);
for (PortletDefinition portlet : portletApp.getPortlets()) {
String appName = portletContext.getApplicationName();
if (appName == null) {
throw new PortletContainerException("Portlet application name should not be null.");
}
portletConfigs.put(portletContext.getApplicationName() + "/" + portlet.getPortletName(), new DriverPortletConfigImpl(portletContext, portlet));
}
} else {
if (logger.isInfoEnabled()) {
logger.info("Portlet application for context '" + contextPath + "' already registered.");
}
}
return contextPath;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class LocalPortletContextManager method getPortletAppDD.
/**
* Retrieve the Portlet Application Deployment Descriptor for the given servlet context. Create
* it if it does not allready exist.
*
* @param servletContext the servlet context.
* @return The portlet application deployment descriptor.
* @throws PortletContainerException if the descriptor can not be found or parsed
*/
public synchronized PortletApplicationDefinition getPortletAppDD(ServletContext servletContext, String name, String contextPath) throws PortletContainerException {
PortletApplicationDefinition portletApp = this.portletAppDefinitionCache.get(servletContext);
if (portletApp == null) {
portletApp = createDefinition(servletContext, name, contextPath);
this.portletAppDefinitionCache.put(servletContext, portletApp);
}
return portletApp;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class EventProviderImpl method isDeclaredAsPublishingEvent.
private boolean isDeclaredAsPublishingEvent(QName qname) {
final PortletDefinition portletDescriptor = this.portletWindow.getPlutoPortletWindow().getPortletDefinition();
final List<? extends EventDefinitionReference> events = portletDescriptor.getSupportedPublishingEvents();
if (events == null) {
return false;
}
final PortletApplicationDefinition application = portletDescriptor.getApplication();
final String defaultNamespace = application.getDefaultNamespace();
for (final EventDefinitionReference ref : events) {
final QName name = ref.getQualifiedName(defaultNamespace);
if (name == null) {
continue;
}
if (qname.equals(name)) {
return true;
}
}
return false;
}
Aggregations