Search in sources :

Example 6 with RuntimeAuthorizationException

use of org.apereo.portal.security.RuntimeAuthorizationException in project uPortal by Jasig.

the class GroupAdministrationHelper method deleteGroup.

/**
     * Delete a group from the group store
     *
     * @param key key of the group to be deleted
     * @param user performing the delete operation
     */
public void deleteGroup(String key, IPerson deleter) {
    if (!canDeleteGroup(deleter, key)) {
        throw new RuntimeAuthorizationException(deleter, IPermission.DELETE_GROUP_ACTIVITY, key);
    }
    log.info("Deleting group with key " + key);
    // find the current version of this group entity
    IEntityGroup group = GroupService.findGroup(key);
    // groups
    for (IEntityGroup parent : group.getParentGroups()) {
        parent.removeChild(group);
        parent.updateMembers();
    }
    // delete the group
    group.delete();
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) RuntimeAuthorizationException(org.apereo.portal.security.RuntimeAuthorizationException)

Example 7 with RuntimeAuthorizationException

use of org.apereo.portal.security.RuntimeAuthorizationException in project uPortal by Jasig.

the class GroupAdministrationHelper method updateGroupDetails.

/**
     * Update the title and description of an existing group in the group store.
     *
     * @param groupForm Form representing the new group configuration
     * @param updater Updating user
     */
public void updateGroupDetails(GroupForm groupForm, IPerson updater) {
    if (!canEditGroup(updater, groupForm.getKey())) {
        throw new RuntimeAuthorizationException(updater, IPermission.EDIT_GROUP_ACTIVITY, groupForm.getKey());
    }
    if (log.isDebugEnabled()) {
        log.debug("Updating group for group form [" + groupForm.toString() + "]");
    }
    // find the current version of this group entity
    IEntityGroup group = GroupService.findGroup(groupForm.getKey());
    group.setName(groupForm.getName());
    group.setDescription(groupForm.getDescription());
    // save the group, updating both its basic information and group
    // membership
    group.update();
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) RuntimeAuthorizationException(org.apereo.portal.security.RuntimeAuthorizationException)

Aggregations

RuntimeAuthorizationException (org.apereo.portal.security.RuntimeAuthorizationException)7 IEntityGroup (org.apereo.portal.groups.IEntityGroup)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 EntityIdentifier (org.apereo.portal.EntityIdentifier)2 IGroupMember (org.apereo.portal.groups.IGroupMember)2 IPersonAttributesGroupDefinition (org.apereo.portal.groups.pags.dao.IPersonAttributesGroupDefinition)2 IPersonAttributesGroupTestGroupDefinition (org.apereo.portal.groups.pags.dao.IPersonAttributesGroupTestGroupDefinition)2 PersonAttributesGroupDefinitionImpl (org.apereo.portal.groups.pags.dao.jpa.PersonAttributesGroupDefinitionImpl)2 JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)2 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)2 IPerson (org.apereo.portal.security.IPerson)2 HashSet (java.util.HashSet)1