Search in sources :

Example 6 with BulkIdParam

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();
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) BulkIdParam(com.emc.storageos.model.BulkIdParam) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) WebResource(com.sun.jersey.api.client.WebResource) ResourcesResponse(com.emc.storageos.geomodel.ResourcesResponse) ObjectInputStream(java.io.ObjectInputStream)

Example 7 with BulkIdParam

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();
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) BulkIdParam(com.emc.storageos.model.BulkIdParam) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) WebResource(com.sun.jersey.api.client.WebResource) ResourcesResponse(com.emc.storageos.geomodel.ResourcesResponse) ObjectInputStream(java.io.ObjectInputStream)

Example 8 with BulkIdParam

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());
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam) UriBuilder(javax.ws.rs.core.UriBuilder)

Example 9 with BulkIdParam

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;
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam)

Example 10 with BulkIdParam

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);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) BulkIdParam(com.emc.storageos.model.BulkIdParam) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

BulkIdParam (com.emc.storageos.model.BulkIdParam)15 URI (java.net.URI)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ResourcesResponse (com.emc.storageos.geomodel.ResourcesResponse)2 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 WebResource (com.sun.jersey.api.client.WebResource)2 InputStream (java.io.InputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 MapCustomConfig (com.emc.storageos.api.mapper.functions.MapCustomConfig)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 ComputeFabricUplinkPort (com.emc.storageos.db.client.model.ComputeFabricUplinkPort)1