Search in sources :

Example 1 with RequestCache

use of org.apereo.portal.concurrency.caching.RequestCache in project uPortal by Jasig.

the class PortletWindowRegistryImpl method getAllLayoutPortletWindows.

@Override
@RequestCache(keyMask = { false })
public Set<IPortletWindow> getAllLayoutPortletWindows(HttpServletRequest request) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    final Set<String> allSubscribedChannels = userLayoutManager.getAllSubscribedChannels();
    final Set<IPortletWindow> allLayoutWindows = new LinkedHashSet<IPortletWindow>(allSubscribedChannels.size());
    for (final String channelSubscribeId : allSubscribedChannels) {
        final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, channelSubscribeId);
        if (portletEntity == null) {
            this.logger.debug("No portlet entity found for layout node {} for user {}", channelSubscribeId, userInstance.getPerson().getUserName());
            continue;
        }
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        final IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindow(request, portletEntityId);
        if (portletWindow == null) {
            this.logger.debug("No portlet window found for {}", portletEntity);
            continue;
        }
        allLayoutWindows.add(portletWindow);
    }
    return allLayoutWindows;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) LinkedHashSet(java.util.LinkedHashSet) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Example 2 with RequestCache

use of org.apereo.portal.concurrency.caching.RequestCache in project uPortal by Jasig.

the class AuthorizationImpl method canPrincipalConfigure.

@Override
@RequestCache
public boolean canPrincipalConfigure(IAuthorizationPrincipal principal, String portletDefinitionId) throws AuthorizationException {
    String owner = IPermission.PORTAL_PUBLISH;
    String target = IPermission.PORTLET_PREFIX + portletDefinitionId;
    // retrieve the indicated channel from the channel registry store and
    // determine its current lifecycle state
    IPortletDefinition portlet = this.portletDefinitionRegistry.getPortletDefinition(portletDefinitionId);
    if (portlet == null) {
        throw new AuthorizationException("Unable to locate portlet " + portletDefinitionId);
    }
    final String activity = IPermission.PORTLET_MODE_CONFIG;
    return doesPrincipalHavePermission(principal, owner, activity, target);
}
Also used : AuthorizationException(org.apereo.portal.AuthorizationException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Example 3 with RequestCache

use of org.apereo.portal.concurrency.caching.RequestCache in project uPortal by Jasig.

the class AuthorizationImpl method canPrincipalManage.

/**
     * This checks if the framework has granted principal a right to publish. DO WE WANT SOMETHING
     * THIS COARSE (de)?
     *
     * @param principal IAuthorizationPrincipal
     * @return boolean
     */
@RequestCache
public boolean canPrincipalManage(IAuthorizationPrincipal principal, PortletLifecycleState state, String categoryId) throws AuthorizationException {
    //    return doesPrincipalHavePermission
    //      (principal, IPermission.PORTAL_FRAMEWORK, IPermission.CHANNEL_PUBLISHER_ACTIVITY, null);
    String owner = IPermission.PORTAL_PUBLISH;
    // retrieve the indicated channel from the channel registry store and
    // determine its current lifecycle state
    PortletCategory category = PortletCategoryRegistryLocator.getPortletCategoryRegistry().getPortletCategory(categoryId);
    if (category == null) {
        //				IPermission.CHANNEL_MANAGER_APPROVED_ACTIVITY, target);
        throw new AuthorizationException("Unable to locate category " + categoryId);
    }
    int order = state.getOrder();
    String activity = IPermission.PORTLET_MANAGER_MAINTENANCE_ACTIVITY;
    if (order <= PortletLifecycleState.MAINTENANCE.getOrder() && doesPrincipalHavePermission(principal, owner, activity, categoryId)) {
        return true;
    }
    activity = IPermission.PORTLET_MANAGER_EXPIRED_ACTIVITY;
    if (order <= PortletLifecycleState.EXPIRED.getOrder() && doesPrincipalHavePermission(principal, owner, activity, categoryId)) {
        return true;
    }
    activity = IPermission.PORTLET_MANAGER_ACTIVITY;
    if (order <= PortletLifecycleState.PUBLISHED.getOrder() && doesPrincipalHavePermission(principal, owner, activity, categoryId)) {
        return true;
    }
    activity = IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY;
    if (order <= PortletLifecycleState.APPROVED.getOrder() && doesPrincipalHavePermission(principal, owner, activity, categoryId)) {
        return true;
    }
    activity = IPermission.PORTLET_MANAGER_CREATED_ACTIVITY;
    if (order <= PortletLifecycleState.CREATED.getOrder() && doesPrincipalHavePermission(principal, owner, activity, categoryId)) {
        return true;
    }
    return false;
}
Also used : AuthorizationException(org.apereo.portal.AuthorizationException) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Example 4 with RequestCache

use of org.apereo.portal.concurrency.caching.RequestCache in project uPortal by Jasig.

the class SingleTabUrlNodeSyntaxHelper method getFolderNameForPortlet.

@RequestCache(keyMask = { false, true })
@Override
public String getFolderNameForPortlet(HttpServletRequest request, IPortletWindowId portletWindowId) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final String fname = portletDefinition.getFName();
    final String layoutNodeId = portletEntity.getLayoutNodeId();
    //Build the targeted portlet string (fname + subscribeId)
    return fname + PORTLET_PATH_ELEMENT_SEPERATOR + layoutNodeId;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Example 5 with RequestCache

use of org.apereo.portal.concurrency.caching.RequestCache in project uPortal by Jasig.

the class SingleTabUrlNodeSyntaxHelper method getFolderNamesForLayoutNode.

@RequestCache(keyMask = { false, true })
@Override
public List<String> getFolderNamesForLayoutNode(HttpServletRequest request, String layoutNodeId) {
    /*
         * Implementation note:
         * While the API allows one or more folder names, this implementation will only ever return
         * a List with zero or one element.  It's not entirely clear that a List with zero members
         * was allowed by the interface definition, but this implementation will return an empty
         * list if the layoutNodeId cannot be found in the layout.
         */
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    final IUserLayout userLayout = userLayoutManager.getUserLayout();
    final String tabId = userLayout.findNodeId(new PortletTabIdResolver(layoutNodeId));
    if (StringUtils.isEmpty(tabId)) {
        return Collections.emptyList();
    }
    String externalId = stylesheetUserPreferencesService.getLayoutAttribute(request, PreferencesScope.STRUCTURE, tabId, EXTERNAL_ID_ATTR);
    if (externalId != null) {
        final Map<String, String> allNodesAndValuesForAttribute = stylesheetUserPreferencesService.getAllNodesAndValuesForAttribute(request, PreferencesScope.STRUCTURE, EXTERNAL_ID_ATTR);
        boolean appendNodeId = false;
        for (final Entry<String, String> nodeAttributeEntry : allNodesAndValuesForAttribute.entrySet()) {
            final String entryNodeId = nodeAttributeEntry.getKey();
            final String entryValue = nodeAttributeEntry.getValue();
            if (!tabId.equals(entryNodeId) && externalId.equals(entryValue)) {
                appendNodeId = true;
                break;
            }
        }
        if (!FunctionalNameType.isValid(externalId)) {
            logger.warn("ExternalId {} for tab {} is not a valid fname. It will be converted for use in the URL but this results in additional overhead", externalId, tabId);
            externalId = FunctionalNameType.makeValid(externalId);
        }
        if (appendNodeId) {
            externalId = externalId + PORTLET_PATH_ELEMENT_SEPERATOR + layoutNodeId;
        }
        logger.trace("Tab identified by {} resolved to externalId {} " + "so returning that externalId as the sole folder name for node.", layoutNodeId, externalId);
        return Arrays.asList(externalId);
    } else {
        logger.trace("Tab identified by {} had no externalId " + "so returning just {} as the sole folder name for node {}.", layoutNodeId, tabId, layoutNodeId);
        return Arrays.asList(tabId);
    }
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) PortletTabIdResolver(org.apereo.portal.layout.PortletTabIdResolver) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayout(org.apereo.portal.layout.IUserLayout) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) RequestCache(org.apereo.portal.concurrency.caching.RequestCache)

Aggregations

RequestCache (org.apereo.portal.concurrency.caching.RequestCache)9 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)5 AuthorizationException (org.apereo.portal.AuthorizationException)3 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)3 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)3 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)2 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)2 PortletLifecycleState (org.apereo.portal.portlet.om.PortletLifecycleState)2 IUserInstance (org.apereo.portal.user.IUserInstance)2 Serializable (java.io.Serializable)1 LinkedHashSet (java.util.LinkedHashSet)1 Element (net.sf.ehcache.Element)1 IUserLayout (org.apereo.portal.layout.IUserLayout)1 PortletTabIdResolver (org.apereo.portal.layout.PortletTabIdResolver)1 IPermissionActivity (org.apereo.portal.permission.IPermissionActivity)1 IPermissionOwner (org.apereo.portal.permission.IPermissionOwner)1 IPermissionTarget (org.apereo.portal.permission.target.IPermissionTarget)1 IPermissionTargetProvider (org.apereo.portal.permission.target.IPermissionTargetProvider)1 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)1 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)1