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