Search in sources :

Example 91 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition 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();
}
Also used : PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 92 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletCategoryRegistryImpl method getChildPortlets.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.registry.IPortletCategoryRegistry#getChildChannels(org.apereo.portal.portlet.om.PortletCategory)
     */
@Override
public Set<IPortletDefinition> getChildPortlets(PortletCategory parent) {
    String parentKey = String.valueOf(parent.getId());
    IEntityGroup parentGroup = GroupService.findGroup(parentKey);
    Set<IPortletDefinition> portletDefs = new HashSet<IPortletDefinition>();
    for (IGroupMember gm : parentGroup.getChildren()) {
        if (!gm.isGroup()) {
            IPortletDefinition portletDefinition = portletDefinitionRegistry.getPortletDefinition(gm.getKey());
            if (portletDefinition != null) {
                portletDefs.add(portletDefinition);
            } else {
                // This isn't supposed to happen.
                log.warn("Failed to obtain a portletDefinition for groupMember '" + gm.getUnderlyingEntityIdentifier() + "';  this circumstance probably means a portlet was deleted " + "in a way that didn't clean up details like categpry memberships " + "and permissions;  all interfaces that delete portlets should go " + "through IPortletPublishingService.removePortletDefinition();  " + "memberships for this missing portlet will be removed.");
                // Delete existing category memberships for this portlet
                for (IEntityGroup group : gm.getParentGroups()) {
                    group.removeChild(gm);
                    group.update();
                }
            }
        }
    }
    return portletDefs;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) HashSet(java.util.HashSet)

Example 93 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition 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 94 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletDefinitionAttributeSource method getAdditionalAttributes.

@Override
public final Iterator<Attribute> getAdditionalAttributes(HttpServletRequest request, HttpServletResponse response, StartElement event) {
    final QName eventName = event.getName();
    final String localEventName = eventName.getLocalPart();
    // Only pay attention to channel events
    if (!IUserLayoutManager.CHANNEL.equals(localEventName)) {
        return null;
    }
    final Collection<Attribute> attributes = new LinkedList<Attribute>();
    // Add the portlet's portlet name and either the webapp URL or framework flag to the list of
    // attributes.
    final Attribute fnameAttribute = event.getAttributeByName(PORTLET_FNAME_ATTR_NAME);
    if (fnameAttribute != null) {
        final String fname = fnameAttribute.getValue();
        IPortletDefinition def = portletDefinitionDao.getPortletDefinitionByFname(fname);
        if (def == null) {
            this.logger.warn("Cannot get portlet definition attributes.  No portlet definition found for fname: '" + fname + "'.");
        } else {
            IPortletDescriptorKey descriptorKey = def.getPortletDescriptorKey();
            attributes.add(xmlEventFactory.createAttribute(PORTLET_NAME_ATTRIBUTE, descriptorKey.getPortletName()));
            attributes.add(xmlEventFactory.createAttribute(PORTLET_LIFECYCLE_ATTRIBUTE, def.getLifecycleState().toString()));
            if (descriptorKey.isFrameworkPortlet()) {
                attributes.add(xmlEventFactory.createAttribute(FRAMEWORK_PORTLET_ATTRIBUTE, "true"));
            } else {
                attributes.add(xmlEventFactory.createAttribute(WEBAPP_NAME_ATTRIBUTE, descriptorKey.getWebAppName()));
            }
        }
    }
    return attributes.iterator();
}
Also used : Attribute(javax.xml.stream.events.Attribute) QName(javax.xml.namespace.QName) IPortletDescriptorKey(org.apereo.portal.portlet.om.IPortletDescriptorKey) LinkedList(java.util.LinkedList) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 95 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class RenderOnWebFlagSetPredicate method test.

@Override
public boolean test(final HttpServletRequest request) {
    try {
        final IPortletDefinition portletDefinition = utils.getPortletDefinitionFromServletRequest(request);
        Iterator<IPortletPreference> iterator = portletDefinition.getPortletPreferences().iterator();
        while (iterator.hasNext()) {
            IPortletPreference cur = iterator.next();
            if ("renderOnWeb".equalsIgnoreCase(cur.getName())) {
                return cur.getValues() != null && cur.getValues().length == 1 && Boolean.parseBoolean(cur.getValues()[0]);
            }
        }
    } catch (Exception e) {
        logger.error("Failed to process renderOnWeb check for redirect during pipeline. Failing gracefully by returning false.", e);
    }
    return false;
}
Also used : IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)109 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)24 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)22 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)17 ArrayList (java.util.ArrayList)16 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)14 HashSet (java.util.HashSet)13 IPerson (org.apereo.portal.security.IPerson)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)12 EntityIdentifier (org.apereo.portal.EntityIdentifier)11 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)9 HashMap (java.util.HashMap)8 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)8 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)7 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)7 IUserInstance (org.apereo.portal.user.IUserInstance)7 Locale (java.util.Locale)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)6