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;
}
});
}
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;
}
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;
}
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;
}
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);
}
Aggregations