Search in sources :

Example 66 with IPortletDefinition

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

the class JpaPortletDefinitionDao method deletePortletDefinition.

@Override
@PortalTransactional
public void deletePortletDefinition(IPortletDefinition definition) {
    Validate.notNull(definition, "definition can not be null");
    final IPortletDefinition persistentPortletDefinition;
    final EntityManager entityManager = this.getEntityManager();
    if (entityManager.contains(definition)) {
        persistentPortletDefinition = definition;
    } else {
        persistentPortletDefinition = entityManager.merge(definition);
    }
    entityManager.remove(persistentPortletDefinition);
}
Also used : EntityManager(javax.persistence.EntityManager) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 67 with IPortletDefinition

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

the class JpaPortletEntityDao method createPortletEntity.

@Override
@PortalTransactional
public IPortletEntity createPortletEntity(IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) {
    Validate.notNull(portletDefinitionId, "portletDefinitionId can not be null");
    Validate.notEmpty(layoutNodeId, "layoutNodeId can not be null");
    final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        throw new DataRetrievalFailureException("No IPortletDefinition exists for IPortletDefinitionId='" + portletDefinitionId + "'");
    }
    IPortletEntity portletEntity = new PortletEntityImpl(portletDefinition, layoutNodeId, userId);
    this.getEntityManager().persist(portletEntity);
    return portletEntity;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 68 with IPortletDefinition

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

the class PortletDelegationLocatorImpl method createRequestDispatcher.

/* (non-Javadoc)
     * @see org.apereo.portal.api.portlet.PortletDelegationLocator#createRequestDispatcher(java.lang.String)
     */
@Override
public PortletDelegationDispatcher createRequestDispatcher(PortletRequest portletRequest, String fName) {
    final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinitionByFname(fName);
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    return this.createRequestDispatcher(portletRequest, portletDefinitionId);
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 69 with IPortletDefinition

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

the class MarketplaceService method featuredEntriesForUser.

@Override
public Set<MarketplaceEntry> featuredEntriesForUser(final IPerson user, final Set<PortletCategory> categories) {
    Validate.notNull(user, "Cannot determine relevant featured portlets for null user.");
    final Set<MarketplaceEntry> browseablePortlets = browseableMarketplaceEntriesFor(user, categories);
    final Set<MarketplaceEntry> featuredPortlets = new HashSet<>();
    for (final MarketplaceEntry entry : browseablePortlets) {
        final IPortletDefinition portletDefinition = entry.getMarketplacePortletDefinition();
        for (final PortletCategory category : this.portletCategoryRegistry.getParentCategories(portletDefinition)) {
            if (FEATURED_CATEGORY_NAME.equalsIgnoreCase(category.getName())) {
                featuredPortlets.add(entry);
            }
        }
    }
    return featuredPortlets;
}
Also used : MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 70 with IPortletDefinition

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

the class ChannelListController method preparePortletCategoryBean.

private PortletCategoryBean preparePortletCategoryBean(WebRequest req, PortletCategory category, Set<IPortletDefinition> portletsNotYetCategorized, IPerson user, Locale locale) {
    /* Prepare child categories. */
    Set<PortletCategoryBean> subcategories = new HashSet<>();
    for (PortletCategory childCategory : this.portletCategoryRegistry.getChildCategories(category)) {
        PortletCategoryBean childBean = preparePortletCategoryBean(req, childCategory, portletsNotYetCategorized, user, locale);
        subcategories.add(childBean);
    }
    // add the direct child channels for this category
    Set<IPortletDefinition> portlets = portletCategoryRegistry.getChildPortlets(category);
    EntityIdentifier ei = user.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
    for (IPortletDefinition portlet : portlets) {
        if (authorizationService.canPrincipalBrowse(ap, portlet)) {
            PortletDefinitionBean pdb = preparePortletDefinitionBean(req, portlet, locale);
            marketplacePortlets.add(pdb);
        }
        /*
             * Remove the portlet from the uncategorized collection;
             * note -- this approach will not prevent portlets from
             * appearing in multiple categories (as appropriate).
             */
        portletsNotYetCategorized.remove(portlet);
    }
    // construct a new portlet category bean for this category
    PortletCategoryBean categoryBean = PortletCategoryBean.fromPortletCategory(category, subcategories, marketplacePortlets);
    categoryBean.setName(messageSource.getMessage(category.getName(), new Object[] {}, locale));
    return categoryBean;
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) 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