Reordered methods
This commit is contained in:
parent
192bb0adf5
commit
79f4fe330b
|
@ -25,6 +25,11 @@ import org.gcube.informationsystem.types.reference.Type;
|
||||||
*/
|
*/
|
||||||
public interface ResourceRegistryClient {
|
public interface ResourceRegistryClient {
|
||||||
|
|
||||||
|
public <IE extends IdentifiableElement, R extends Resource> List<R> getInstances(Class<IE> clazz, Boolean polymorphic)
|
||||||
|
throws ResourceRegistryException;
|
||||||
|
|
||||||
|
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException;
|
||||||
|
|
||||||
public <IE extends IdentifiableElement> boolean exists(Class<IE> clazz, UUID uuid)
|
public <IE extends IdentifiableElement> boolean exists(Class<IE> clazz, UUID uuid)
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@ -37,12 +42,6 @@ public interface ResourceRegistryClient {
|
||||||
public String getInstance(String type, UUID uuid)
|
public String getInstance(String type, UUID uuid)
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public <IE extends IdentifiableElement, R extends Resource> List<R> getInstances(Class<IE> clazz, Boolean polymorphic)
|
|
||||||
throws ResourceRegistryException;
|
|
||||||
|
|
||||||
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException;
|
|
||||||
|
|
||||||
|
|
||||||
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getResourcesFromReferenceFacet(
|
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getResourcesFromReferenceFacet(
|
||||||
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, F referenceFacet,
|
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, F referenceFacet,
|
||||||
boolean polymorphic) throws ResourceRegistryException;
|
boolean polymorphic) throws ResourceRegistryException;
|
||||||
|
|
|
@ -216,6 +216,49 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <IE extends IdentifiableElement, R extends Resource> List<R> getInstances(Class<IE> clazz, Boolean polymorphic)
|
||||||
|
throws ResourceRegistryException {
|
||||||
|
String type = Utility.getTypeName(clazz);
|
||||||
|
String ret = getInstances(type, polymorphic);
|
||||||
|
try {
|
||||||
|
return (List<R>) ElementMapper.unmarshalList(Resource.class, ret);
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
logger.info("Going to get all instances of {} ", type);
|
||||||
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
|
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
|
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
|
||||||
|
gxHTTPStringRequest.path(type);
|
||||||
|
|
||||||
|
Map<String,String> parameters = new HashMap<>();
|
||||||
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||||
|
includeAdditionalQueryParameters(gxHTTPStringRequest, parameters);
|
||||||
|
|
||||||
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
|
||||||
|
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
|
logger.debug("Got instances of {} are {}", type, ret);
|
||||||
|
return ret;
|
||||||
|
} catch(ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error while getting {} instances", type, e);
|
||||||
|
throw e;
|
||||||
|
} catch(Exception e) {
|
||||||
|
// logger.trace("Error while getting {} instances", type, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <IE extends IdentifiableElement> boolean exists(Class<IE> clazz, UUID uuid)
|
public <IE extends IdentifiableElement> boolean exists(Class<IE> clazz, UUID uuid)
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
|
@ -294,49 +337,6 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public <IE extends IdentifiableElement, R extends Resource> List<R> getInstances(Class<IE> clazz, Boolean polymorphic)
|
|
||||||
throws ResourceRegistryException {
|
|
||||||
String type = Utility.getTypeName(clazz);
|
|
||||||
String ret = getInstances(type, polymorphic);
|
|
||||||
try {
|
|
||||||
return (List<R>) ElementMapper.unmarshalList(Resource.class, ret);
|
|
||||||
} catch(Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
|
|
||||||
try {
|
|
||||||
logger.info("Going to get all instances of {} ", type);
|
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
|
||||||
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
|
||||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
|
||||||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
|
||||||
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
|
|
||||||
gxHTTPStringRequest.path(type);
|
|
||||||
|
|
||||||
Map<String,String> parameters = new HashMap<>();
|
|
||||||
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
|
||||||
includeAdditionalQueryParameters(gxHTTPStringRequest, parameters);
|
|
||||||
|
|
||||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
|
||||||
|
|
||||||
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
|
||||||
|
|
||||||
logger.debug("Got instances of {} are {}", type, ret);
|
|
||||||
return ret;
|
|
||||||
} catch(ResourceRegistryException e) {
|
|
||||||
// logger.trace("Error while getting {} instances", type, e);
|
|
||||||
throw e;
|
|
||||||
} catch(Exception e) {
|
|
||||||
// logger.trace("Error while getting {} instances", type, e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String query(String query, int limit, String fetchPlan)
|
public String query(String query, int limit, String fetchPlan)
|
||||||
throws InvalidQueryException, ResourceRegistryException {
|
throws InvalidQueryException, ResourceRegistryException {
|
||||||
|
|
Loading…
Reference in New Issue