use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class RequestAttributeServiceImpl method getExpectedUserAttributes.
/**
* Get the list of user attributes the portlet expects.
*
* @param request The current request.
* @param portletWindow The window to get the expected user attributes for.
* @return The List of expected user attributes for the portlet
*/
protected List<? extends UserAttribute> getExpectedUserAttributes(HttpServletRequest request, final IPortletWindow portletWindow) {
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
return portletApplicationDescriptor.getUserAttributes();
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition in project uPortal by Jasig.
the class CasTicketUserInfoService method isCasProxyTicketRequested.
/**
* Determine whether the portlet has expects a CAS proxy ticket as one of the user attributes.
*
* @param request portlet request
* @param plutoPortletWindow portlet window
* @return <code>true</code> if a CAS proxy ticket is expected, <code>false</code> otherwise
* @throws PortletContainerException if expeced attributes cannot be determined
*/
public boolean isCasProxyTicketRequested(PortletRequest request, PortletWindow plutoPortletWindow) throws PortletContainerException {
// get the list of requested user attributes
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
// check to see if the proxy ticket key is one of the requested user attributes
List<? extends UserAttribute> requestedUserAttributes = portletApplicationDescriptor.getUserAttributes();
for (final UserAttribute userAttributeDD : requestedUserAttributes) {
final String attributeName = userAttributeDD.getName();
if (attributeName.equals(this.proxyTicketKey))
return true;
}
// if the proxy ticket key wasn't found in the list of requested attributes
return false;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition 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;
}
use of org.apache.pluto.container.om.portlet.PortletApplicationDefinition 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());
}
Aggregations