Search in sources :

Example 11 with AuthorizationService

use of org.apereo.portal.services.AuthorizationService in project uPortal by Jasig.

the class PopularPortletsController method buildEventCounts.

private List<PortletUsage> buildEventCounts(Integer days, IPerson user, Locale locale) {
    final DateTime end = new DateTime();
    final DateTime begin = end.minusDays(days);
    final IEntityGroup everyone = GroupService.getRootGroup(IPerson.class);
    final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping(everyone.getKey());
    final List<PortletLayoutAggregation> aggregations = portletLayoutDao.getAggregationsForAllPortlets(begin, end, AGGREGATION_INTERVAL, group);
    final EntityIdentifier ei = user.getEntityIdentifier();
    final AuthorizationService authService = AuthorizationService.instance();
    final IAuthorizationPrincipal ap = authService.newPrincipal(ei.getKey(), ei.getType());
    final Map<String, PortletUsage> resultBuilder = new HashMap<String, PortletUsage>();
    for (final PortletLayoutAggregation aggregation : aggregations) {
        final AggregatedPortletMapping portlet = aggregation.getPortletMapping();
        final String fname = portlet.getFname();
        PortletUsage portletUsage = resultBuilder.get(fname);
        if (portletUsage == null) {
            final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinitionByFname(fname);
            if (portletDefinition == null || !ap.canSubscribe(portletDefinition.getPortletDefinitionId().getStringId())) {
                //Skip portlets that no longer exist or cannot be subscribed to
                continue;
            }
            portletUsage = new PortletUsage(portletDefinition.getPortletDefinitionId().getLongId(), fname, portletDefinition.getTitle(locale.toString()), portletDefinition.getDescription(locale.toString()));
            resultBuilder.put(fname, portletUsage);
        }
        portletUsage.incrementCount(aggregation.getAddCount());
    }
    final ArrayList<PortletUsage> results = new ArrayList<PortletUsage>(resultBuilder.values());
    Collections.sort(results);
    return results;
}
Also used : HashMap(java.util.HashMap) PortletLayoutAggregation(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) ArrayList(java.util.ArrayList) EntityIdentifier(org.apereo.portal.EntityIdentifier) DateTime(org.joda.time.DateTime) IEntityGroup(org.apereo.portal.groups.IEntityGroup) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) AuthorizationService(org.apereo.portal.services.AuthorizationService) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 12 with AuthorizationService

use of org.apereo.portal.services.AuthorizationService in project uPortal by Jasig.

the class XalanAuthorizationHelperBean method getUserPrincipal.

protected IAuthorizationPrincipal getUserPrincipal(final String userName) {
    final IEntity user = GroupService.getEntity(userName, IPerson.class);
    if (user == null) {
        return null;
    }
    final AuthorizationService authService = AuthorizationService.instance();
    return authService.newPrincipal(user);
}
Also used : IEntity(org.apereo.portal.groups.IEntity) AuthorizationService(org.apereo.portal.services.AuthorizationService)

Aggregations

AuthorizationService (org.apereo.portal.services.AuthorizationService)12 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)9 IEntity (org.apereo.portal.groups.IEntity)4 IEntityGroup (org.apereo.portal.groups.IEntityGroup)4 ArrayList (java.util.ArrayList)3 EntityIdentifier (org.apereo.portal.EntityIdentifier)3 IGroupMember (org.apereo.portal.groups.IGroupMember)3 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)3 HashMap (java.util.HashMap)2 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)2 IPermission (org.apereo.portal.security.IPermission)2 IPerson (org.apereo.portal.security.IPerson)2 IUpdatingPermissionManager (org.apereo.portal.security.IUpdatingPermissionManager)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 PortletMode (javax.portlet.PortletMode)1 AuthorizationException (org.apereo.portal.AuthorizationException)1 AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)1 PortletLayoutAggregation (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation)1