use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryByType.
/**
* Get the GeoVisible resource IDs from the geosvc
*
* @param clazz the resource type to be queried
* @param activeOnly
* @return the ResourceIDsRespons response
* @throws Exception
*/
public <T extends GeoVisibleResource> Iterator<URI> queryByType(Class<T> clazz, boolean activeOnly) throws Exception {
WebResource rRoot = createRequest(GEOVISIBLE_URI + clazz.getName()).queryParam("active_only", Boolean.toString(activeOnly));
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).get(ClientResponse.class);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
@SuppressWarnings("rawtypes") ResourcesResponse resources = (ResourcesResponse) objInputStream.readObject();
@SuppressWarnings("unchecked") List<URI> ids = resources.getObjects();
return ids.iterator();
}
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();
}
use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryByType.
/**
* Query the GeoVisible resource IDs from the geosvc
*
* @param clazz the resource type to be queried
* @param activeOnly
* @param startId where the query starts, if it's null, start from the beginning
* @param maxCount if maxCount>0, the max number of IDs returned, otherwise use the default setting on the server side
* @return the ResourceIDsRespons response
* @throws Exception
*/
public <T extends GeoVisibleResource> List<URI> queryByType(Class<T> clazz, boolean activeOnly, URI startId, int maxCount) throws Exception {
WebResource rRoot = createRequest(GEOVISIBLE_URI + clazz.getName()).queryParam("active_only", Boolean.toString(activeOnly));
if (startId != null) {
rRoot = rRoot.queryParam("start_id", startId.toString());
}
if (maxCount > 0) {
rRoot = rRoot.queryParam("max_count", Integer.toString(maxCount));
}
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).get(ClientResponse.class);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
@SuppressWarnings("rawtypes") ResourcesResponse resources = (ResourcesResponse) objInputStream.readObject();
@SuppressWarnings("unchecked") List<URI> ids = resources.getObjects();
return ids;
}
use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryByConstraint.
/**
* Query the GeoVisible resources by conditions
*
* @param constraint the query condition
* @param result the query result
* @return list of resources
* @throws Exception
*/
@SuppressWarnings("unchecked")
public <T> void queryByConstraint(Constraint constraint, QueryResultList<T> result) throws Exception {
ConstraintDescriptor constrainDescriptor = constraint.toConstraintDescriptor();
WebResource rRoot = createRequest(GEOVISIBLE_URI + "constraint/" + result.getClass().getName());
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).post(ClientResponse.class, constrainDescriptor);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
ResourcesResponse<?> resources = (ResourcesResponse<?>) objInputStream.readObject();
List<Object> queryResult = (List<Object>) resources.getObjects();
List<T> ret = new ArrayList<T>();
for (Object obj : queryResult) {
ret.add((T) obj);
}
result.setResult(ret.iterator());
}
use of com.emc.storageos.geomodel.ResourcesResponse in project coprhd-controller by CoprHD.
the class GeoServiceClient method queryByConstraint.
/**
* Query the GeoVisible resources by conditions
*
* @param constraint the query condition
* @param result the query result
* @param startId where the query starts, if it's null, query starts at the beginning
* @param maxCount the max number of resources returned
* @throws Exception
*/
@SuppressWarnings("unchecked")
public <T> void queryByConstraint(Constraint constraint, QueryResultList<T> result, URI startId, int maxCount) throws Exception {
ConstraintDescriptor constrainDescriptor = constraint.toConstraintDescriptor();
WebResource rRoot = createRequest(GEOVISIBLE_URI + "constraint/" + result.getClass().getName());
if (startId != null) {
rRoot = rRoot.queryParam("start_id", startId.toString());
}
if (maxCount > 0) {
rRoot = rRoot.queryParam("max_count", Integer.toString(maxCount));
}
rRoot.accept(MediaType.APPLICATION_OCTET_STREAM);
ClientResponse resp = addSignature(rRoot).post(ClientResponse.class, constrainDescriptor);
InputStream input = resp.getEntityInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(input);
ResourcesResponse<?> resources = (ResourcesResponse<?>) objInputStream.readObject();
List<Object> queryResult = (List<Object>) resources.getObjects();
List<T> ret = new ArrayList<T>();
for (Object obj : queryResult) {
ret.add((T) obj);
}
result.setResult(ret.iterator());
}
Aggregations