Search in sources :

Example 26 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class ImportExportController method deleteEntity.

/**
     * Delete an uPortal database object. This method provides a REST interface for uPortal database
     * object deletion.
     *
     * <p>The path for this method is /entity/type/identifier. The identifier generally a string
     * that may be used as a unique identifier, but is dependent on the entity type. For example, to
     * delete the "demo" user one might use the path /entity/user/demo.
     */
@RequestMapping(value = "/entity/{entityType}/{entityId}", method = RequestMethod.DELETE)
public void deleteEntity(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityId, HttpServletRequest request, HttpServletResponse response) throws IOException {
    final IPerson person = personManager.getPerson(request);
    final EntityIdentifier ei = person.getEntityIdentifier();
    final IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
    if (!ap.hasPermission(IPermission.PORTAL_SYSTEM, IPermission.DELETE_ACTIVITY, entityType)) {
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return;
    }
    // get the task associated with exporting this entity type
    portalDataHandlerService.deleteData(entityType, entityId);
    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
Also used : IPerson(org.apereo.portal.security.IPerson) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class PersonImpl method setAttribute.

@Override
public void setAttribute(String key, List<Object> value) {
    if (userAttributes == null) {
        userAttributes = new ConcurrentHashMap<String, List<Object>>();
    }
    if (value != null) {
        userAttributes.put(key, value);
    } else {
        userAttributes.remove(key);
    }
    if (key.equals(IPerson.USERNAME)) {
        final Object userName = value != null && value.size() > 0 ? value.get(0) : null;
        m_eid = new EntityIdentifier(String.valueOf(userName), IPerson.class);
    }
}
Also used : IPerson(org.apereo.portal.security.IPerson) List(java.util.List) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 28 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class EntityGroupImpl method primRemoveMember.

/**
     * Removes the <code>IGroupMember</code> key from the appropriate key cache, by copying the
     * cache, removing the key from the copy and replacing the original with the copy. At this
     * point, <code>gm</code> still has <code>this</code> in its containing groups cache. That cache
     * entry is not removed until update(), when changes are committed to the store.
     *
     * @param gm org.apereo.portal.groups.IGroupMember
     */
private void primRemoveMember(IGroupMember gm) throws GroupsException {
    final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
    Element element = childrenCache.get(cacheKey);
    @SuppressWarnings("unchecked") final Set<IGroupMember> set = element != null ? (Set<IGroupMember>) element.getObjectValue() : buildChildrenSet();
    final Set<IGroupMember> children = new HashSet<>(set);
    children.remove(gm);
    childrenCache.put(new Element(cacheKey, children));
}
Also used : Element(net.sf.ehcache.Element) EntityIdentifier(org.apereo.portal.EntityIdentifier) HashSet(java.util.HashSet)

Example 29 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class EntityGroupImpl method getChildren.

/**
     * Returns an <code>Iterator</code> over the <code>GroupMembers</code> in our member <code>
     * Collection</code>. Reflects pending changes.
     *
     * @return Iterator
     */
@Override
public Set<IGroupMember> getChildren() throws GroupsException {
    final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
    Element element = childrenCache.get(cacheKey);
    if (element == null) {
        final Set<IGroupMember> children = buildChildrenSet();
        element = new Element(cacheKey, children);
        childrenCache.put(element);
    }
    @SuppressWarnings("unchecked") final Set<IGroupMember> rslt = (Set<IGroupMember>) element.getObjectValue();
    return rslt;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Element(net.sf.ehcache.Element) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Example 30 with EntityIdentifier

use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.

the class GroupMemberImpl method getParentGroups.

/**
     * Returns an <code>Iterator</code> over this <code>IGroupMember's</code> parent groups.
     * Synchronize the collection of keys with adds and removes.
     *
     * @return Iterator
     */
@Override
public Set<IEntityGroup> getParentGroups() throws GroupsException {
    final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
    Element element = parentGroupsCache.get(cacheKey);
    if (element == null) {
        final Set<IEntityGroup> groups = buildParentGroupsSet();
        element = new Element(cacheKey, groups);
        parentGroupsCache.put(element);
    }
    @SuppressWarnings("unchecked") final Set<IEntityGroup> rslt = (Set<IEntityGroup>) element.getObjectValue();
    return rslt;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Element(net.sf.ehcache.Element) EntityIdentifier(org.apereo.portal.EntityIdentifier)

Aggregations

EntityIdentifier (org.apereo.portal.EntityIdentifier)79 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)31 HashSet (java.util.HashSet)20 IPerson (org.apereo.portal.security.IPerson)17 ArrayList (java.util.ArrayList)15 IEntityGroup (org.apereo.portal.groups.IEntityGroup)13 IGroupMember (org.apereo.portal.groups.IGroupMember)12 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)12 Set (java.util.Set)9 GroupsException (org.apereo.portal.groups.GroupsException)9 Iterator (java.util.Iterator)7 Element (net.sf.ehcache.Element)6 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)6 HashMap (java.util.HashMap)4 List (java.util.List)4 LinkedHashSet (java.util.LinkedHashSet)3 LinkedList (java.util.LinkedList)2 Locale (java.util.Locale)2 Map (java.util.Map)2 SortedSet (java.util.SortedSet)2