Search in sources :

Example 6 with ResourcesResponse

use of com.emc.storageos.geomodel.ResourcesResponse 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 7 with ResourcesResponse

use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.

the class QueryService method genResourcesResponse.

private Response genResourcesResponse(QueryResultList<?> queryResult) {
    ResourcesResponse<Object> resp = new ResourcesResponse();
    int count = 0;
    Iterator<?> it = queryResult.iterator();
    while (it.hasNext()) {
        count++;
        resp.add(it.next());
    }
    resp.setSize(count);
    return Response.ok(getStreamingOutput(resp), MediaType.APPLICATION_OCTET_STREAM).build();
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) ResourcesResponse(com.emc.storageos.geomodel.ResourcesResponse) Constraint(com.emc.storageos.db.client.constraint.Constraint)

Example 8 with ResourcesResponse

use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.

the class QueryService method genResourcesResponse.

private <T> Response genResourcesResponse(Iterator<T> objs) {
    ResourcesResponse<T> resp = new ResourcesResponse();
    int count = 0;
    while (objs.hasNext()) {
        count++;
        resp.add(objs.next());
    }
    resp.setSize(count);
    return Response.ok(getStreamingOutput(resp), MediaType.APPLICATION_OCTET_STREAM).build();
}
Also used : ResourcesResponse(com.emc.storageos.geomodel.ResourcesResponse) Constraint(com.emc.storageos.db.client.constraint.Constraint)

Aggregations

ResourcesResponse (com.emc.storageos.geomodel.ResourcesResponse)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)6 WebResource (com.sun.jersey.api.client.WebResource)6 InputStream (java.io.InputStream)6 ObjectInputStream (java.io.ObjectInputStream)6 DataObject (com.emc.storageos.db.client.model.DataObject)3 Constraint (com.emc.storageos.db.client.constraint.Constraint)2 ConstraintDescriptor (com.emc.storageos.db.client.constraint.ConstraintDescriptor)2 QueryResultList (com.emc.storageos.db.client.constraint.QueryResultList)2 BulkIdParam (com.emc.storageos.model.BulkIdParam)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2