use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method testUserGroupEditByChangingDomain.
@Test
public void testUserGroupEditByChangingDomain() {
final String testName = "testUserGroupEditByChangingDomain - ";
createDefaultAuthnProvider(testName + DEFAULT_AUTH_PROVIDER_CREATION);
UserGroupCreateParam createParam = getDefaultUserGroupCreateParam();
ClientResponse clientUserGroupCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
UserGroupRestRep userGroupCreateResp = validateUserGroupCreateSuccess(createParam, clientUserGroupCreateResp);
UserGroup createdUserGroup = buildUserGroupFromRestRep(userGroupCreateResp);
UserGroupUpdateParam updateParam = getUserGroupUpdateParamFromRestRep(userGroupCreateResp);
// Clear both add and remove attributes. This should be successful.
updateParam.getAddAttributes().clear();
updateParam.getRemoveAttributes().clear();
// Change the domain.
updateParam.setDomain(getSecondDomain());
String testEditAPI = getTestEditApi(userGroupCreateResp.getId());
ClientResponse clientUserGroupEditResp = rSys.path(testEditAPI).put(ClientResponse.class, updateParam);
validateUserGroupEditSuccess(createdUserGroup, updateParam, clientUserGroupEditResp);
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method getUserGroupIds.
/**
* Gets the user group list (of URNs).
*
* @brief List active user group URNs
* @return All the user groups details as UserGroupList
* @see UserGroupList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UserGroupList getUserGroupIds() {
checkCompatibleVersion();
checkIfUserHasPermissions();
NamedElementQueryResultList userGroups = new NamedElementQueryResultList();
List<URI> uris = _dbClient.queryByType(UserGroup.class, true);
List<UserGroup> configs = _dbClient.queryObject(UserGroup.class, uris);
List<NamedElementQueryResultList.NamedElement> elements = new ArrayList<NamedElementQueryResultList.NamedElement>(configs.size());
for (UserGroup p : configs) {
elements.add(NamedElementQueryResultList.NamedElement.createElement(p.getId(), p.getLabel()));
}
userGroups.setResult(elements.iterator());
UserGroupList list = new UserGroupList();
list.getUserGroups().addAll(DbObjectMapper.map(ResourceTypeEnum.USER_GROUP, userGroups));
return list;
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupService method getUserGroupById.
/**
* @param id the URN of a ViPR UserGroup to get details from
* @param checkInactive If true, make sure that provider is not inactive
* @return UserGroup object for the given id
*/
private UserGroup getUserGroupById(URI id, boolean checkInactive) {
if (id == null) {
_log.debug("User Group ID is NULL");
return null;
}
_log.debug("User Group ID is {}", id.toString());
UserGroup userGroup = _permissionsHelper.getObjectById(id, UserGroup.class);
ArgValidator.checkEntity(userGroup, id, isIdEmbeddedInURL(id), checkInactive);
return userGroup;
}
use of com.emc.storageos.db.client.model.UserGroup in project coprhd-controller by CoprHD.
the class UserGroupMapper method map.
public static final UserGroup map(UserGroupCreateParam from) {
if (from == null) {
_log.info("Invalid user group create param");
return null;
}
UserGroup to = new UserGroup();
to.setDomain(from.getDomain());
to.setLabel(from.getLabel());
Map<String, UserAttributeParam> attributeParamMap = new TreeMap<String, UserAttributeParam>(String.CASE_INSENSITIVE_ORDER);
if (!CollectionUtils.isEmpty(from.getAttributes())) {
for (UserAttributeParam attribute : from.getAttributes()) {
UserAttributeParam userAttributeParam = attributeParamMap.get(attribute.getKey());
if (userAttributeParam == null) {
userAttributeParam = new UserAttributeParam(attribute.getKey(), attribute.getValues());
attributeParamMap.put(attribute.getKey(), userAttributeParam);
} else {
userAttributeParam.getValues().addAll(attribute.getValues());
}
}
} else {
_log.error("Empty attributes list in user group create param {}", from.getLabel());
}
if (!CollectionUtils.isEmpty(attributeParamMap)) {
for (UserAttributeParam attribute : attributeParamMap.values()) {
to.getAttributes().add(attribute.toString());
}
} else {
_log.warn("Mapping from UserGroupCreateParam {} to UserGroup did not create any attributes list", from.getLabel());
}
return to;
}
Aggregations