use of com.emc.storageos.model.BulkIdParam in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryObjectsField.
/**
* Get the GeoVisible resources specific field with given ids
*
* @param clazz the resource type to be queried
* @param fieldName the feild to be get
* @param ids List of the resource IDs
* @return list of resources
* @throws Exception
*/
public <T extends GeoVisibleResource> Iterator<T> queryObjectsField(Class<T> clazz, String fieldName, List<URI> ids) throws Exception {
BulkIdParam param = new BulkIdParam();
param.setIds(ids);
WebResource rRoot = createRequest(GEOVISIBLE_URI + clazz.getName() + "/field/" + fieldName);
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).post(ClientResponse.class, param);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
@SuppressWarnings("unchecked") ResourcesResponse<T> resources = (ResourcesResponse<T>) objInputStream.readObject();
List<T> list = resources.getObjects();
return list.iterator();
}
use of com.emc.storageos.model.BulkIdParam in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryObjects.
/**
* Get the GeoVisible resources with given ids
*
* @param clazz the resource type to be queried
* @param ids List of the resource IDs
* @return list of resources
* @throws Exception
*/
public <T extends GeoVisibleResource> Iterator<T> queryObjects(Class<T> clazz, List<URI> ids) throws Exception {
BulkIdParam param = new BulkIdParam();
param.setIds(ids);
WebResource rRoot = createRequest(GEOVISIBLE_URI + clazz.getName() + "/objects");
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).post(ClientResponse.class, param);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
@SuppressWarnings("unchecked") ResourcesResponse<T> resources = (ResourcesResponse<T>) objInputStream.readObject();
List<T> list = resources.getObjects();
return list.iterator();
}
use of com.emc.storageos.model.BulkIdParam in project coprhd-controller by CoprHD.
the class WFDirectoryClient method getAll.
public WFBulkRep getAll() {
UriBuilder builder = client.uriBuilder(PathConstants.WF_DIRECTORY_BULK);
BulkIdParam bulkIdParam = client.getURI(BulkIdParam.class, builder.build());
return client.postURI(WFBulkRep.class, bulkIdParam, builder.build());
}
use of com.emc.storageos.model.BulkIdParam in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method validateUserGroupBulkGetSuccess.
private BulkIdParam validateUserGroupBulkGetSuccess(ClientResponse actual, long expectedIDCount) {
Assert.assertEquals(HttpStatus.SC_OK, actual.getStatus());
BulkIdParam resp = actual.getEntity(BulkIdParam.class);
Assert.assertNotNull(resp);
Assert.assertTrue(expectedIDCount <= resp.getIds().size());
return resp;
}
use of com.emc.storageos.model.BulkIdParam in project coprhd-controller by CoprHD.
the class ApiTestUserGroup method testUserGroupBulkApi.
private void testUserGroupBulkApi(BalancedWebResource user, boolean expectGetSuccess, boolean expectPostSuccess) {
String testBulkApi = getTestBulkApi();
UserGroupCreateParam createParam = getDefaultUserGroupCreateParam();
ClientResponse clientUserGroupCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
UserGroupRestRep userGroupRestRep = validateUserGroupCreateSuccess(createParam, clientUserGroupCreateResp);
List<URI> bulkIds = new ArrayList<URI>();
bulkIds.add(userGroupRestRep.getId());
createParam = getDefaultUserGroupCreateParam();
// Change the name something different and keep the same
// attributes key but with different values for each key.
// This should be successful.
createParam.setLabel(NEW_NAME);
Iterator<UserAttributeParam> it = createParam.getAttributes().iterator();
while (it.hasNext()) {
UserAttributeParam userAttributeParam = it.next();
if (userAttributeParam != null) {
userAttributeParam.getValues().clear();
userAttributeParam.getValues().add("NewValue");
}
}
clientUserGroupCreateResp = rSys.path(getTestApi()).post(ClientResponse.class, createParam);
userGroupRestRep = validateUserGroupCreateSuccess(createParam, clientUserGroupCreateResp);
bulkIds.add(userGroupRestRep.getId());
// Get all the ids of UserGroup configured in the system.
ClientResponse clientUserGroupBulkResp = user.path(testBulkApi).get(ClientResponse.class);
if (!expectGetSuccess) {
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, clientUserGroupBulkResp.getStatus());
return;
}
BulkIdParam bulkIdParam = null;
if (expectGetSuccess) {
bulkIdParam = validateUserGroupBulkGetSuccess(clientUserGroupBulkResp, bulkIds.size());
} else {
bulkIdParam = new BulkIdParam();
bulkIdParam.setIds(bulkIds);
}
int expectedPostReqCount = bulkIdParam.getIds().size();
if (!expectPostSuccess) {
expectedPostReqCount = 0;
}
// Get the details of all the UserGroups configured in the system.
// By passing the same set of ids received in the response of get request.
clientUserGroupBulkResp = user.path(testBulkApi).post(ClientResponse.class, bulkIdParam);
validateUserGroupBulkPostSuccess(clientUserGroupBulkResp, expectedPostReqCount);
}
Aggregations