Search in sources :

Example 61 with IPortletDefinition

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

the class JpaAggregatedPortletLookupDao method getMappedPortletForFname.

@OpenEntityManager(unitName = BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME)
@Override
public AggregatedPortletMapping getMappedPortletForFname(final String fname) {
    final CacheKey key = CacheKey.build(this.getClass().getName(), fname);
    AggregatedPortletMapping portletMapping = this.entityManagerCache.get(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key);
    if (portletMapping != null) {
        return portletMapping;
    }
    final NaturalIdQuery<AggregatedPortletMappingImpl> query = this.createNaturalIdQuery(AggregatedPortletMappingImpl.class);
    query.using(AggregatedPortletMappingImpl_.fname, fname);
    portletMapping = query.load();
    if (portletMapping != null) {
        this.entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, portletMapping);
        return portletMapping;
    }
    return this.getTransactionOperations().execute(new TransactionCallback<AggregatedPortletMapping>() {

        @Override
        public AggregatedPortletMapping doInTransaction(TransactionStatus status) {
            final IPortletDefinition portletDefinition = portletDefinitionDao.getPortletDefinitionByFname(fname);
            final String name;
            if (portletDefinition != null) {
                name = portletDefinition.getName();
            } else {
                name = fname;
            }
            final AggregatedPortletMappingImpl aggregatedGroupMapping = new AggregatedPortletMappingImpl(name, fname);
            getEntityManager().persist(aggregatedGroupMapping);
            logger.debug("Created {}", aggregatedGroupMapping);
            entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, aggregatedGroupMapping);
            return aggregatedGroupMapping;
        }
    });
}
Also used : TransactionStatus(org.springframework.transaction.TransactionStatus) CacheKey(org.apereo.portal.utils.cache.CacheKey) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Example 62 with IPortletDefinition

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

the class PortletMarketplaceController method isPortletFavorited.

private boolean isPortletFavorited(IUserLayout layout, String fname) {
    List<IUserLayoutNodeDescription> favorites = FavoritesUtils.getFavoritePortlets(layout);
    for (IUserLayoutNodeDescription favorite : favorites) {
        if (favorite instanceof UserLayoutChannelDescription) {
            String channelId = ((UserLayoutChannelDescription) favorite).getChannelPublishId();
            IPortletDefinition portletDefinition = portletDefinitionRegistry.getPortletDefinition(channelId);
            String favFName = portletDefinition.getFName();
            if (fname != null && fname.equals(favFName)) {
                return true;
            }
        }
    }
    return false;
}
Also used : IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) UserLayoutChannelDescription(org.apereo.portal.layout.node.UserLayoutChannelDescription) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 63 with IPortletDefinition

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

the class DefinitionHeaderProvider method createHeader.

@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
    // Username
    final String username = getUsername(renderRequest);
    // Obtain the MarketplacePortletDefinition for this soffit
    final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
    final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
    final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
    final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
    final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);
    final IPerson user = personManager.getPerson(httpr);
    final Locale locale = getUserLocale(user);
    // Title
    final String title = mpdef.getTitle(locale.toString());
    // FName
    final String fname = mpdef.getFName();
    // Description
    final String description = mpdef.getDescription(locale.toString());
    // Categories
    List<String> categories = new ArrayList<>();
    for (PortletCategory pc : mpdef.getCategories()) {
        categories.add(pc.getName());
    }
    // Parameters
    Map<String, List<String>> parameters = new HashMap<>();
    for (IPortletDefinitionParameter param : mpdef.getParameters()) {
        parameters.put(param.getName(), Collections.singletonList(param.getValue()));
    }
    final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest));
    final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken());
    logger.debug("Produced the following {} header for username='{}':  {}", Headers.DEFINITION.getName(), username, rslt);
    return rslt;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Definition(org.apereo.portal.soffit.model.v1_0.Definition) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) ArrayList(java.util.ArrayList) List(java.util.List) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) BasicHeader(org.apache.http.message.BasicHeader) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 64 with IPortletDefinition

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

the class PortletEventCoordinatationService method isGlobalEvent.

protected boolean isGlobalEvent(HttpServletRequest request, IPortletWindowId sourceWindowId, Event event) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, sourceWindowId);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    final PortletApplicationDefinition parentPortletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId);
    final ContainerRuntimeOption globalEvents = parentPortletApplicationDescriptor.getContainerRuntimeOption(GLOBAL_EVENT__CONTAINER_OPTION);
    if (globalEvents != null) {
        final QName qName = event.getQName();
        final String qNameStr = qName.toString();
        for (final String globalEvent : globalEvents.getValues()) {
            if (qNameStr.equals(globalEvent)) {
                return true;
            }
        }
    }
    return false;
}
Also used : IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) QName(javax.xml.namespace.QName) ContainerRuntimeOption(org.apache.pluto.container.om.portlet.ContainerRuntimeOption) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 65 with IPortletDefinition

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

the class PortletExecutionManager method getPortletTitle.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#getPortletTitle(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public String getPortletTitle(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
    final IPortletDefinition portletDefinition = getPortletDefinition(portletWindowId, request);
    final IPortletDefinitionParameter disableDynamicTitle = portletDefinition.getParameter("disableDynamicTitle");
    if (disableDynamicTitle == null || !Boolean.parseBoolean(disableDynamicTitle.getValue())) {
        try {
            final PortletRenderResult portletRenderResult = getPortletRenderResult(portletWindowId, request, response);
            if (portletRenderResult != null) {
                final String title = portletRenderResult.getTitle();
                if (title != null) {
                    return title;
                }
            }
        } catch (Exception e) {
            logger.warn("unable to get portlet title, falling back to title defined in channel definition for portletWindowId " + portletWindowId);
        }
    }
    // we assume that response locale has been set to correct value
    String locale = response.getLocale().toString();
    // return portlet title from channel definition
    return portletDefinition.getTitle(locale);
}
Also used : IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) IOException(java.io.IOException) MaintenanceModeException(org.apereo.portal.portlets.error.MaintenanceModeException) 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