use of org.sbolstandard.core2.Collection in project libSBOLj by SynBioDex.
the class SynBioHubFrontend method getSubCollectionMetadata.
/**
* Search the default store for Collections that are members of the specified Collection
*
* @param parentCollectionUri URI for Collection to search for member Collections
* @return An ArrayList of CollectionMetaData objects with a summary of all matching Collections.
*
* @throws SynBioHubException if there was an error communicating with the SynBioHub
*/
public ArrayList<IdentifiedMetadata> getSubCollectionMetadata(URI parentCollectionUri) throws SynBioHubException {
if (!parentCollectionUri.toString().startsWith(uriPrefix)) {
throw new SynBioHubException("Object URI does not start with correct URI prefix for this repository.");
}
String url = parentCollectionUri + "/subCollections";
url = url.replace(uriPrefix, backendUrl);
Gson gson = new Gson();
HttpGet request = new HttpGet(url);
request.setHeader("X-authorization", user);
request.setHeader("Accept", "text/plain");
try {
HttpResponse response = client.execute(request);
checkResponseCode(response);
InputStream inputStream = response.getEntity().getContent();
ArrayList<IdentifiedMetadata> metadataList = gson.fromJson(new InputStreamReader(inputStream), new TypeToken<ArrayList<IdentifiedMetadata>>() {
}.getType());
return metadataList;
} catch (Exception e) {
throw new SynBioHubException(e);
} finally {
request.releaseConnection();
}
}
Aggregations