Search in sources :

Example 86 with IPortletDefinition

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

the class PortletAdministrationHelper method createPortletDefinitionForm.

/**
 * Construct a new PortletDefinitionForm for the given IPortletDefinition id. If a
 * PortletDefinition matching this ID already exists, the form will be pre-populated with the
 * PortletDefinition's current configuration. If the PortletDefinition does not yet exist, a new
 * default form will be created.
 *
 * @param person user that is required to have related lifecycle permission
 * @param portletId identifier for the portlet definition
 * @return {@PortletDefinitionForm} with set values based on portlet definition or default
 *     category and principal if no definition is found
 */
public PortletDefinitionForm createPortletDefinitionForm(IPerson person, String portletId) {
    IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(portletId);
    // create the new form
    final PortletDefinitionForm form;
    if (def != null) {
        // if this is a pre-existing portlet, set the category and permissions
        form = new PortletDefinitionForm(def);
        form.setId(def.getPortletDefinitionId().getStringId());
        // create a JsonEntityBean for each current category and add it
        // to our form bean's category list
        Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(def);
        for (PortletCategory cat : categories) {
            form.addCategory(new JsonEntityBean(cat));
        }
        addPrincipalPermissionsToForm(def, form);
    } else {
        form = createNewPortletDefinitionForm();
    }
    // hierarchical, so we'll test with the weakest.
    if (!hasLifecyclePermission(person, PortletLifecycleState.CREATED, form.getCategories())) {
        logger.warn("User '" + person.getUserName() + "' attempted to edit the following portlet without MANAGE permission:  " + def);
        throw new SecurityException("Not Authorized");
    }
    return form;
}
Also used : JsonEntityBean(org.apereo.portal.layout.dlm.remoting.JsonEntityBean) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 87 with IPortletDefinition

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

the class SearchPortletController method modifySearchResultLinkTitle.

/**
 * Since portlets don't have access to the portlet definition to create a useful search results
 * link using something like the portlet definition's title, post-process the link text and for
 * those portlets whose type is present in the substitution set, replace the title with the
 * portlet definition's title.
 *
 * @param result Search results object (may be modified)
 * @param httpServletRequest HttpServletRequest
 * @param portletWindowId Portlet Window ID
 */
protected void modifySearchResultLinkTitle(SearchResult result, final HttpServletRequest httpServletRequest, final IPortletWindowId portletWindowId) {
    // evaluation context.
    if (result.getType().size() > 0 && result.getTitle().contains("${")) {
        final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
        final IPortletEntity portletEntity = portletWindow.getPortletEntity();
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final SpELEnvironmentRoot spelEnvironment = new SpELEnvironmentRoot(portletDefinition);
        try {
            result.setTitle(spELService.getValue(result.getTitle(), spelEnvironment));
        } catch (SpelParseException | SpelEvaluationException e) {
            result.setTitle("(Invalid portlet title) - see details in log file");
            logger.error("Invalid Spring EL expression {} in search result portlet title", result.getTitle(), e);
        }
    }
}
Also used : SpelParseException(org.springframework.expression.spel.SpelParseException) SpelEvaluationException(org.springframework.expression.spel.SpelEvaluationException) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 88 with IPortletDefinition

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

the class PortletRegistrySearchService method getSearchResults.

@Override
public SearchResults getSearchResults(PortletRequest request, SearchRequest query) {
    final String queryString = query.getSearchTerms().toLowerCase();
    final List<IPortletDefinition> portlets = portletDefinitionRegistry.getAllPortletDefinitions();
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final SearchResults results = new SearchResults();
    for (IPortletDefinition portlet : portlets) {
        if (portletRegistryUtil.matches(queryString, portlet)) {
            final SearchResult result = new SearchResult();
            result.setTitle(portlet.getTitle());
            result.setSummary(portlet.getDescription());
            result.getType().add(searchResultType);
            String url = portletRegistryUtil.buildPortletUrl(httpServletRequest, portlet);
            if (url != null) {
                result.setExternalUrl(url);
                results.getSearchResult().add(result);
            }
        }
    }
    return results;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SearchResult(org.apereo.portal.search.SearchResult) SearchResults(org.apereo.portal.search.SearchResults) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 89 with IPortletDefinition

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

the class CachedPasswordUserInfoService method isPasswordRequested.

/**
 * Determine whether the portlet has expects a password as one of the user attributes.
 *
 * @param request portlet request
 * @param plutoPortletWindow portlet window
 * @return <code>true</code> if a password is expected, <code>false</code> otherwise
 * @throws PortletContainerException if expeced attributes cannot be determined
 */
public boolean isPasswordRequested(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 password 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.passwordKey))
            return true;
    }
    // if the password key wasn't found in the list of requested attributes
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 90 with IPortletDefinition

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

the class PersonDirectoryUserInfoService 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
 * @throws PortletContainerException If expected attributes cannot be determined
 */
protected List<? extends UserAttribute> getExpectedUserAttributes(HttpServletRequest request, final IPortletWindow portletWindow) throws PortletContainerException {
    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)

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