use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method getUserGroup.
/**
* Gets the details of one user group.
*
* @param id of the user group to be returned.
* @brief Show details of a user group
* @return The user groups details as UserGroupRestRep
* @see UserGroupRestRep
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public UserGroupRestRep getUserGroup(@PathParam("id") URI id) {
checkCompatibleVersion();
checkIfUserHasPermissions();
UserGroup userGroup = getUserGroupById(id, false);
ArgValidator.checkEntityNotNull(userGroup, id, isIdEmbeddedInURL(id));
return map(userGroup);
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method checkForOverlappingUserGroup.
private void checkForOverlappingUserGroup(UserGroup userGroup) {
if (userGroup == null) {
_log.error("Invalid user group to compare");
return;
}
List<UserGroup> userGroupList = _permissionsHelper.getAllUserGroupForDomain(userGroup.getDomain());
if (CollectionUtils.isEmpty(userGroupList)) {
_log.debug("No user group found for the domain {}", userGroup.getDomain());
return;
}
Set<String> overlappingGroups = new HashSet<String>();
for (UserGroup existingUserGroup : userGroupList) {
if (existingUserGroup == null) {
_log.info("Invalid user group found in db");
continue;
}
if ((!userGroup.getLabel().equalsIgnoreCase(existingUserGroup.getLabel())) && userGroup.overlap(existingUserGroup)) {
overlappingGroups.add(existingUserGroup.getLabel());
}
if ((!userGroup.getLabel().equalsIgnoreCase(existingUserGroup.getLabel())) && existingUserGroup.overlap(userGroup)) {
overlappingGroups.add(existingUserGroup.getLabel());
}
}
if (!CollectionUtils.isEmpty(overlappingGroups)) {
throw APIException.badRequests.overlappingAttributesNotAllowed(userGroup.getLabel(), overlappingGroups);
}
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method createUserGroup.
/**
* Creates user group.
* The submitted user group element values will be validated.
* <p>
* The minimal set of parameters include: name, domain, attributes (key and values pair).
* <p>
*
* @param param Representation of UserGroup with all necessary elements
*
* @brief Create a user group
* @return Newly created User Group details as UserGroupRestRep
* @see UserGroupCreateParam
* @see UserGroupRestRep
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN })
public UserGroupRestRep createUserGroup(UserGroupCreateParam param) {
checkCompatibleVersion();
validateUserGroupCreateParam(param);
// Check for active UserGroup with same name
checkDuplicateLabel(UserGroup.class, param.getLabel());
UserGroup userGroup = map(param);
URI id = URIUtil.createId(UserGroup.class);
userGroup.setId(id);
_log.debug("Saving the UserGroup: {}: {}", userGroup.getId(), userGroup.toString());
// Check if there is any existing user group with same set of properties.
checkForOverlappingUserGroup(userGroup);
_dbClient.createObject(userGroup);
auditOp(OperationTypeEnum.CREATE_USERGROUP, true, null, userGroup.toString(), userGroup.getId().toString());
return map(getUserGroupById(id, false));
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method deleteUserGroup.
/**
* Deletes the active user group.
*
* @param id of the user group to be deleted.
* @brief Delete a user group
* @return Ok if deletion is successful otherwise valid exception.
*/
@DELETE
@CheckPermission(roles = { Role.SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public Response deleteUserGroup(@PathParam("id") URI id) {
checkCompatibleVersion();
UserGroup userGroup = getUserGroupById(id, false);
ArgValidator.checkEntityNotNull(userGroup, id, isIdEmbeddedInURL(id));
// check that there are no active resources that uses this user group.
checkForActiveUsageOfUserGroup(userGroup.getDomain(), userGroup.getLabel());
_dbClient.removeObject(userGroup);
auditOp(OperationTypeEnum.DELETE_USERGROUP, true, null, userGroup.getId().toString());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method updateUserGroup.
/**
* Updates user group.
* The submitted user group element values will be validated.
* <p>
* The minimal set of parameters include: name, domain, attributes (key and values pair).
* <p>
*
* @param param Representation of UserGroup with all necessary elements
*
* @brief Update a user group
* @return The updated User Group details as UserGroupRestRep
* @see UserGroupUpdateParam
* @see UserGroupRestRep
*/
@PUT
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN })
public UserGroupRestRep updateUserGroup(@PathParam("id") URI id, UserGroupUpdateParam param) {
checkCompatibleVersion();
UserGroup userGroup = getUserGroupById(id, false);
ArgValidator.checkEntityNotNull(userGroup, id, isIdEmbeddedInURL(id));
validateUserGroupUpdateParam(param);
// Update the db object with new information.
overlayUserGroup(userGroup, param);
// Check if there is any existing user group with same set of properties.
checkForOverlappingUserGroup(userGroup);
_dbClient.persistObject(userGroup);
auditOp(OperationTypeEnum.UPDATE_USERGROUP, true, null, userGroup.toString(), userGroup.getId().toString());
return map(getUserGroupById(id, false));
}
Aggregations