Search in sources :

Example 11 with PortletContainerException

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

the class PortletDefinitionRegistryImpl method getParentPortletDescriptor.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletDescriptor(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletDefinition getParentPortletDescriptor(IPortletDefinitionId portletDefinitionId) {
    final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        return null;
    }
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
    final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
    try {
        return portletRegistryService.getPortlet(portletDescriptorKeys.first, portletDescriptorKeys.second);
    } catch (PortletContainerException e) {
        if (this.logger.isDebugEnabled()) {
            this.logger.warn("No portlet descriptor could be found for the portlet definition, null will be returned: " + portletDefinition, e);
        } else {
            this.logger.warn("No portlet descriptor could be found for the portlet definition, null will be returned: " + portletDefinition + " Enable DEBUG for stack trace.");
        }
        return null;
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 12 with PortletContainerException

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

the class PortletAdministrationHelper method loadDefaultsFromPortletDefinitionIfNew.

/**
 * Pre-populate a new {@link PortletDefinitionForm} with information from the {@link
 * PortletDefinition}.
 *
 * @param form
 */
public void loadDefaultsFromPortletDefinitionIfNew(PortletDefinitionForm form) {
    if (!form.isNew()) {
        // Get out;  we only prepopulate new portlets
        return;
    }
    // appName/portletName must be set at this point
    Validate.notBlank(form.getApplicationId(), "ApplicationId not set");
    Validate.notBlank(form.getPortletName(), "PortletName not set");
    final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService();
    final PortletDefinition portletDef;
    try {
        portletDef = portletRegistryService.getPortlet(form.getApplicationId(), form.getPortletName());
    } catch (PortletContainerException e) {
        this.logger.warn("Failed to load portlet descriptor for appId='" + form.getApplicationId() + "', portletName='" + form.getPortletName() + "'", e);
        return;
    }
    form.setTitle(portletDef.getPortletName());
    form.setName(portletDef.getPortletName());
    for (Supports supports : portletDef.getSupports()) {
        for (String mode : supports.getPortletModes()) {
            if ("edit".equalsIgnoreCase(mode)) {
                form.setEditable(true);
            } else if ("help".equalsIgnoreCase(mode)) {
                form.setHasHelp(true);
            } else if ("config".equalsIgnoreCase(mode)) {
                form.setConfigurable(true);
            }
        }
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) Supports(org.apache.pluto.container.om.portlet.Supports) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition)

Example 13 with PortletContainerException

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

the class PortletDefinitionRegistryImpl method getParentPortletApplicationDescriptor.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletApplicationDescriptor(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletApplicationDefinition getParentPortletApplicationDescriptor(IPortletDefinitionId portletDefinitionId) {
    final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        return null;
    }
    final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
    final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
    try {
        return portletRegistryService.getPortletApplication(portletDescriptorKeys.first);
    } catch (PortletContainerException e) {
        this.logger.warn("No portlet application descriptor could be found likely not deployed. For portlet definition: " + portletDefinition, e);
        return null;
    }
}
Also used : PortletRegistryService(org.apache.pluto.container.driver.PortletRegistryService) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 14 with PortletContainerException

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

the class LocalPortletContextManager method createDefinition.

// Private Methods ---------------------------------------------------------
/**
 * Creates the portlet.xml deployment descriptor representation.
 *
 * @param servletContext the servlet context for which the DD is requested.
 * @return the Portlet Application Deployment Descriptor.
 * @throws PortletContainerException
 */
private PortletApplicationDefinition createDefinition(ServletContext servletContext, String name, String contextPath) throws PortletContainerException {
    PortletApplicationDefinition portletApp = null;
    try {
        InputStream paIn = servletContext.getResourceAsStream(PORTLET_XML);
        InputStream webIn = servletContext.getResourceAsStream(WEB_XML);
        if (paIn == null) {
            throw new PortletContainerException("Cannot find '" + PORTLET_XML + "'. Are you sure it is in the deployed package?");
        }
        if (webIn == null) {
            throw new PortletContainerException("Cannot find '" + WEB_XML + "'. Are you sure it is in the deployed package?");
        }
        portletApp = this.portletAppDescriptorService.read(name, contextPath, paIn);
        this.portletAppDescriptorService.mergeWebDescriptor(portletApp, webIn);
    } catch (Exception ex) {
        throw new PortletContainerException("Exception loading portlet descriptor for: " + servletContext.getServletContextName(), ex);
    }
    return portletApp;
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) InputStream(java.io.InputStream) PortletContainerException(org.apache.pluto.container.PortletContainerException) PortletContainerException(org.apache.pluto.container.PortletContainerException)

Example 15 with PortletContainerException

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

the class PortletEventCoordinatationService method unmarshall.

protected Event unmarshall(IPortletWindow portletWindow, Event event) {
    // TODO make two types of Event impls, one for marshalled data and one for unmarshalled data
    String value = (String) event.getValue();
    final XMLInputFactory xmlInputFactory = this.xmlUtilities.getXmlInputFactory();
    final XMLStreamReader xml;
    try {
        xml = xmlInputFactory.createXMLStreamReader(new StringReader(value));
    } catch (XMLStreamException e) {
        throw new IllegalStateException("Failed to create XMLStreamReader for portlet event: " + event, e);
    }
    // now test if object is jaxb
    final EventDefinition eventDefinitionDD = getEventDefintion(portletWindow, event.getQName());
    final PortletDefinition portletDefinition = portletWindow.getPlutoPortletWindow().getPortletDefinition();
    final PortletApplicationDefinition application = portletDefinition.getApplication();
    final String portletApplicationName = application.getName();
    final ClassLoader loader;
    try {
        loader = portletContextService.getClassLoader(portletApplicationName);
    } catch (PortletContainerException e) {
        throw new IllegalStateException("Failed to get ClassLoader for portlet application: " + portletApplicationName, e);
    }
    final String eventType = eventDefinitionDD.getValueType();
    final Class<? extends Serializable> clazz;
    try {
        clazz = loader.loadClass(eventType).asSubclass(Serializable.class);
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException("Declared event type '" + eventType + "' cannot be found in portlet application: " + portletApplicationName, e);
    }
    // TODO cache JAXBContext in registered portlet application
    final JAXBElement<? extends Serializable> result;
    try {
        final JAXBContext jc = JAXBContext.newInstance(clazz);
        final Unmarshaller unmarshaller = jc.createUnmarshaller();
        result = unmarshaller.unmarshal(xml, clazz);
    } catch (JAXBException e) {
        throw new IllegalArgumentException("Cannot create JAXBContext for event type '" + eventType + "' from portlet application: " + portletApplicationName, e);
    }
    return new EventImpl(event.getQName(), result.getValue());
}
Also used : Serializable(java.io.Serializable) XMLStreamReader(javax.xml.stream.XMLStreamReader) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) EventDefinition(org.apache.pluto.container.om.portlet.EventDefinition) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) XMLStreamException(javax.xml.stream.XMLStreamException) EventImpl(org.apereo.portal.portlet.container.EventImpl) StringReader(java.io.StringReader) Unmarshaller(javax.xml.bind.Unmarshaller) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

PortletContainerException (org.apache.pluto.container.PortletContainerException)17 PortletRegistryService (org.apache.pluto.container.driver.PortletRegistryService)6 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)6 IOException (java.io.IOException)5 PortletException (javax.portlet.PortletException)5 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)5 PortletDispatchException (org.apereo.portal.portlet.PortletDispatchException)5 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)5 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)4 PortletHttpServletResponseWrapper (org.apereo.portal.utils.web.PortletHttpServletResponseWrapper)3 CacheControl (javax.portlet.CacheControl)2 DriverPortletConfig (org.apache.pluto.container.driver.DriverPortletConfig)2 DriverPortletContext (org.apache.pluto.container.driver.DriverPortletContext)2 Supports (org.apache.pluto.container.om.portlet.Supports)2 HeaderSettingCacheControl (org.apereo.portal.portlet.container.cache.HeaderSettingCacheControl)2 InputStream (java.io.InputStream)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1