use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.
the class XalanAuthorizationHelperBean method canRender.
/* (non-Javadoc)
* @see org.apereo.portal.security.xslt.IAuthorizationHelper#canRender(java.lang.String, java.lang.String)
*/
@Override
public boolean canRender(final String userName, final String fname) {
if (userName == null || fname == null) {
return false;
}
final IAuthorizationPrincipal userPrincipal = this.getUserPrincipal(userName);
if (userPrincipal == null) {
return false;
}
final String portletId;
try {
final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinitionByFname(fname);
if (portletDefinition == null) {
if (this.logger.isInfoEnabled()) {
this.logger.info("No PortletDefinition for fname='" + fname + "', returning false.");
}
return false;
}
portletId = portletDefinition.getPortletDefinitionId().getStringId();
} catch (Exception e) {
this.logger.warn("Could not find PortletDefinition for fname='" + fname + "' while checking if user '" + userName + "' can render it. Returning FALSE.", e);
return false;
}
return userPrincipal.canRender(portletId);
}
use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.
the class XalanGroupMembershipHelperBean method isChannelDeepMemberOf.
/* (non-Javadoc)
* @see org.apereo.portal.security.xslt.IXalanGroupMembershipHelper#isChannelDeepMemberOf(java.lang.String, java.lang.String)
*/
@Override
public boolean isChannelDeepMemberOf(String fname, String groupKey) {
final IEntityGroup distinguishedGroup = GroupService.findGroup(groupKey);
if (distinguishedGroup == null) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("No group found for key '" + groupKey + "'");
}
return false;
}
final IPortletDefinition portletDefinition;
try {
portletDefinition = this.portletDefinitionRegistry.getPortletDefinitionByFname(fname);
} catch (Exception e) {
this.logger.warn("Caught exception while retrieving portlet definition for fname '" + fname + "'", e);
return false;
}
if (portletDefinition == null) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("No portlet found for key '" + fname + "'");
}
return false;
}
final String portletId = portletDefinition.getPortletDefinitionId().getStringId();
final IEntity entity = GroupService.getEntity(portletId, IPortletDefinition.class);
if (entity == null) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("No portlet found for id '" + portletId + "'");
}
return false;
}
return distinguishedGroup.deepContains(entity);
}
use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.
the class PortletExecutionManager method getPortletEventTimeout.
protected long getPortletEventTimeout(IPortletWindowId portletWindowId, HttpServletRequest request) {
if (this.ignoreTimeouts) {
return DEBUG_TIMEOUT;
}
final IPortletDefinition portletDefinition = getPortletDefinition(portletWindowId, request);
final Integer eventTimeout = portletDefinition.getEventTimeout();
if (eventTimeout != null) {
return getModifiedTimeout(portletDefinition, request, eventTimeout);
}
return getModifiedTimeout(portletDefinition, request, portletDefinition.getTimeout());
}
use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.
the class PortletExecutionManager method doPortletAction.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#doPortletAction(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void doPortletAction(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
final long timeout = getPortletActionTimeout(portletWindowId, request);
final IPortletExecutionWorker<Long> portletActionExecutionWorker = this.portletWorkerFactory.createActionWorker(request, response, portletWindowId);
portletActionExecutionWorker.submit();
try {
portletActionExecutionWorker.get(timeout);
} catch (Exception e) {
// put the exception into the error map for the session
final Map<IPortletWindowId, Exception> portletFailureMap = getPortletErrorMap(request);
portletFailureMap.put(portletWindowId, e);
}
//If the worker is still running add it to the hung-workers queue
if (!portletActionExecutionWorker.isComplete()) {
cancelWorker(request, portletActionExecutionWorker);
}
// Is this portlet permitted to emit events? (Or is it disablePortletEvents=true?)
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(request, portletWindowId);
IPortletDefinition portletDefinition = portletWindow.getPortletEntity().getPortletDefinition();
IPortletDefinitionParameter disablePortletEvents = portletDefinition.getParameter(DISABLE_PORTLET_EVENTS_PARAMETER);
if (disablePortletEvents != null && Boolean.parseBoolean(disablePortletEvents.getValue())) {
logger.info("Ignoring portlet events for portlet '{}' because they have been disabled.", portletDefinition.getFName());
} else {
// Proceed with events...
final PortletEventQueue portletEventQueue = this.eventCoordinationService.getPortletEventQueue(request);
this.doPortletEvents(portletEventQueue, request, response);
}
}
use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.
the class MarketplaceService method loadMarketplaceEntriesFor.
/**
* Load the list of marketplace entries for a user. Will load entries async. This method is
* primarily intended for seeding data. Most impls should call browseableMarketplaceEntriesFor()
* instead.
*
* <p>Note: Set is immutable since it is potentially shared between threads. If the set needs
* mutability, be sure to consider the thread safety implications. No protections have been
* provided against modifying the MarketplaceEntry itself, so be careful when modifying the
* entities contained in the list.
*
* @param user The non-null user
* @param categories Restricts the output to entries within the specified categories if
* non-empty
* @return a Future that will resolve to a set of MarketplaceEntry objects the requested user
* has browse access to.
* @throws java.lang.IllegalArgumentException if user is null
* @since 4.2
*/
@Async
public Future<ImmutableSet<MarketplaceEntry>> loadMarketplaceEntriesFor(final IPerson user, final Set<PortletCategory> categories) {
final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
List<IPortletDefinition> allDisplayablePortletDefinitions = this.portletDefinitionRegistry.getAllPortletDefinitions();
if (!categories.isEmpty()) {
// Indicates we plan to restrict portlets displayed in the Portlet
// Marketplace to those that belong to one or more specified groups.
Element portletDefinitionsElement = marketplaceCategoryCache.get(categories);
if (portletDefinitionsElement == null) {
/*
* Collection not in cache -- need to recreate it
*/
// Gather the complete collection of allowable categories (specified categories & their descendants)
final Set<PortletCategory> allSpecifiedAndDecendantCategories = new HashSet<>();
for (PortletCategory pc : categories) {
collectSpecifiedAndDescendantCategories(pc, allSpecifiedAndDecendantCategories);
}
// Filter portlets that match the criteria
Set<IPortletDefinition> filteredPortletDefinitions = new HashSet<>();
for (final IPortletDefinition portletDefinition : allDisplayablePortletDefinitions) {
final Set<PortletCategory> parents = portletCategoryRegistry.getParentCategories(portletDefinition);
for (final PortletCategory parent : parents) {
if (allSpecifiedAndDecendantCategories.contains(parent)) {
filteredPortletDefinitions.add(portletDefinition);
break;
}
}
}
portletDefinitionsElement = new Element(categories, new ArrayList<>(filteredPortletDefinitions));
marketplaceCategoryCache.put(portletDefinitionsElement);
}
allDisplayablePortletDefinitions = (List<IPortletDefinition>) portletDefinitionsElement.getObjectValue();
}
final Set<MarketplaceEntry> visiblePortletDefinitions = new HashSet<>();
for (final IPortletDefinition portletDefinition : allDisplayablePortletDefinitions) {
if (mayBrowsePortlet(principal, portletDefinition)) {
final MarketplacePortletDefinition marketplacePortletDefinition = getOrCreateMarketplacePortletDefinition(portletDefinition);
final MarketplaceEntry entry = new MarketplaceEntry(marketplacePortletDefinition, user);
// flag whether this use can add the portlet...
boolean canAdd = mayAddPortlet(user, portletDefinition);
entry.setCanAdd(canAdd);
visiblePortletDefinitions.add(entry);
}
}
logger.trace("These portlet definitions {} are browseable by {}.", visiblePortletDefinitions, user);
Future<ImmutableSet<MarketplaceEntry>> result = new AsyncResult<>(ImmutableSet.copyOf(visiblePortletDefinitions));
Element cacheElement = new Element(user.getUserName(), result);
marketplaceUserPortletDefinitionCache.put(cacheElement);
return result;
}
Aggregations