Refs #11455: Integrate GX REST in resource-registry client libraries
Task-Url: https://support.d4science.org/issues/11455 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@176626 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c8df3b6caa
commit
dd2300d1a9
4
pom.xml
4
pom.xml
|
@ -53,6 +53,10 @@
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>gxHTTP</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.information-system</groupId>
|
<groupId>org.gcube.information-system</groupId>
|
||||||
<artifactId>resource-registry-api</artifactId>
|
<artifactId>resource-registry-api</artifactId>
|
||||||
|
|
|
@ -56,10 +56,10 @@ public interface ResourceRegistryClient {
|
||||||
|
|
||||||
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getFilteredResources(
|
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getFilteredResources(
|
||||||
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
|
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
|
||||||
Map<String,Object> map) throws ResourceRegistryException;
|
Map<String,String> map) throws ResourceRegistryException;
|
||||||
|
|
||||||
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
|
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
|
||||||
boolean polymorphic, Map<String,Object> map) throws ResourceRegistryException;
|
boolean polymorphic, Map<String,String> map) throws ResourceRegistryException;
|
||||||
|
|
||||||
|
|
||||||
public <R extends Resource, I extends IsRelatedTo<?,?>, RR extends Resource> List<R> getRelatedResourcesFromReferenceResource(
|
public <R extends Resource, I extends IsRelatedTo<?,?>, RR extends Resource> List<R> getRelatedResourcesFromReferenceResource(
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.client;
|
package org.gcube.informationsystem.resourceregistry.client;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||||
import org.gcube.informationsystem.model.impl.utils.ISMapper;
|
import org.gcube.informationsystem.model.impl.utils.ISMapper;
|
||||||
import org.gcube.informationsystem.model.reference.ER;
|
import org.gcube.informationsystem.model.reference.ER;
|
||||||
import org.gcube.informationsystem.model.reference.ISManageable;
|
import org.gcube.informationsystem.model.reference.ISManageable;
|
||||||
|
@ -24,8 +24,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.context.Conte
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall;
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.utils.Utility;
|
import org.gcube.informationsystem.resourceregistry.api.utils.Utility;
|
||||||
import org.gcube.informationsystem.types.TypeBinder;
|
import org.gcube.informationsystem.types.TypeBinder;
|
||||||
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
||||||
|
@ -39,37 +38,24 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryClientImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryClientImpl.class);
|
||||||
|
|
||||||
public static final String PATH_SEPARATOR = "/";
|
|
||||||
|
|
||||||
protected final String address;
|
protected final String address;
|
||||||
protected HTTPCall httpCall;
|
|
||||||
|
|
||||||
public ResourceRegistryClientImpl(String address) {
|
public ResourceRegistryClientImpl(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private HTTPCall getHTTPCall() throws MalformedURLException {
|
|
||||||
if(httpCall == null) {
|
|
||||||
httpCall = new HTTPCall(address, ResourceRegistryClient.class.getSimpleName());
|
|
||||||
}
|
|
||||||
return httpCall;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException {
|
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to get current {} ", Context.NAME);
|
logger.info("Going to get current {} ", Context.NAME);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||||
stringWriter.append(AccessPath.CONTEXTS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.CURRENT_CONTEXT);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(AccessPath.CURRENT_CONTEXT);
|
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
Context context = httpCall.call(Context.class, stringWriter.toString(), HTTPMETHOD.GET);
|
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got Context is {}", ISMapper.marshal(context));
|
logger.debug("Got Context is {}", ISMapper.marshal(context));
|
||||||
return context;
|
return context;
|
||||||
|
@ -91,16 +77,15 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
|
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString());
|
logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString());
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(AccessPath.CONTEXTS_PATH_PART);
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(uuid.toString());
|
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
Context context = httpCall.call(Context.class, stringWriter.toString(), HTTPMETHOD.GET);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
|
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||||
|
gxHTTPStringRequest.path(uuid.toString());
|
||||||
|
|
||||||
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got Context is {}", ISMapper.marshal(context));
|
logger.debug("Got Context is {}", ISMapper.marshal(context));
|
||||||
return context;
|
return context;
|
||||||
|
@ -121,14 +106,13 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
public List<Context> getAllContext() throws ContextNotFoundException, ResourceRegistryException {
|
public List<Context> getAllContext() throws ContextNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to read all {}s", Context.NAME);
|
logger.info("Going to read all {}s", Context.NAME);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||||
stringWriter.append(AccessPath.CONTEXTS_PATH_PART);
|
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET);
|
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got Contexts are {}", ret);
|
logger.debug("Got Contexts are {}", ret);
|
||||||
return ISMapper.unmarshalList(Context.class, ret);
|
return ISMapper.unmarshalList(Context.class, ret);
|
||||||
|
@ -151,20 +135,19 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
String type = Utility.getType(clazz);
|
String type = Utility.getType(clazz);
|
||||||
try {
|
try {
|
||||||
logger.info("Going to get {} schema", type);
|
logger.info("Going to get {} schema", type);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.TYPES_PATH_PART);
|
||||||
stringWriter.append(AccessPath.TYPES_PATH_PART);
|
gxHTTPStringRequest.path(type);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(type);
|
|
||||||
|
|
||||||
Map<String,String> parameters = new HashMap<>();
|
Map<String,String> parameters = new HashMap<>();
|
||||||
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||||
|
gxHTTPStringRequest.queryParams(parameters);
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
String json = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got schema for {} is {}", type, json);
|
logger.debug("Got schema for {} is {}", type, json);
|
||||||
return TypeBinder.deserializeTypeDefinitions(json);
|
return TypeBinder.deserializeTypeDefinitions(json);
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
|
@ -191,18 +174,15 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to check if {} with UUID {} exists", type, uuid);
|
logger.info("Going to check if {} with UUID {} exists", type, uuid);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
|
||||||
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
gxHTTPStringRequest.path(type);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(uuid.toString());
|
||||||
stringWriter.append(type);
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(uuid.toString());
|
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.head();
|
||||||
httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.HEAD);
|
HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("{} with UUID {} exists", type, uuid);
|
logger.debug("{} with UUID {} exists", type, uuid);
|
||||||
return true;
|
return true;
|
||||||
|
@ -233,18 +213,15 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to get {} with UUID {}", type, uuid);
|
logger.info("Going to get {} with UUID {}", type, uuid);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
|
||||||
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
gxHTTPStringRequest.path(type);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(uuid.toString());
|
||||||
stringWriter.append(type);
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(uuid.toString());
|
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET);
|
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got {} with UUID {} is {}", type, uuid, ret);
|
logger.debug("Got {} with UUID {} is {}", type, uuid, ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -274,19 +251,19 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
|
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to get all instances of {} ", type);
|
logger.info("Going to get all instances of {} ", type);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
|
||||||
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
gxHTTPStringRequest.path(type);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(type);
|
|
||||||
|
|
||||||
Map<String,String> parameters = new HashMap<>();
|
Map<String,String> parameters = new HashMap<>();
|
||||||
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||||
|
gxHTTPStringRequest.queryParams(parameters);
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
|
||||||
|
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Got instances of {} are {}", type, ret);
|
logger.debug("Got instances of {} are {}", type, ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -305,11 +282,10 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("Going to query. {}", query);
|
logger.info("Going to query. {}", query);
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.QUERY_PATH_PART);
|
||||||
stringWriter.append(AccessPath.QUERY_PATH_PART);
|
|
||||||
|
|
||||||
Map<String,String> parameters = new HashMap<>();
|
Map<String,String> parameters = new HashMap<>();
|
||||||
parameters.put(AccessPath.QUERY_PARAM, query);
|
parameters.put(AccessPath.QUERY_PARAM, query);
|
||||||
|
@ -322,8 +298,10 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
parameters.put(AccessPath.FETCH_PLAN_PARAM, fetchPlan);
|
parameters.put(AccessPath.FETCH_PLAN_PARAM, fetchPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
gxHTTPStringRequest.queryParams(parameters);
|
||||||
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
|
||||||
|
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
logger.debug("Query result is {}", ret);
|
logger.debug("Query result is {}", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -337,25 +315,21 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRelated(String entityType, String relationType, String referenceEntityType,
|
protected String getRelated(String entityType, String relationType, String referenceEntityType,
|
||||||
UUID referenceEntity, Direction direction, boolean polymorphic, Map<String,Object> map)
|
UUID referenceEntity, Direction direction, Boolean polymorphic, Map<String,String> map)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StringWriter stringWriter = new StringWriter();
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(AccessPath.QUERY_PATH_PART);
|
||||||
stringWriter.append(AccessPath.QUERY_PATH_PART);
|
gxHTTPStringRequest.path(entityType);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
gxHTTPStringRequest.path(relationType);
|
||||||
stringWriter.append(entityType);
|
gxHTTPStringRequest.path(referenceEntityType);
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(relationType);
|
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
|
||||||
stringWriter.append(referenceEntityType);
|
|
||||||
|
|
||||||
Map<String,Object> parameters = new HashMap<>();
|
Map<String,String> parameters = new HashMap<>();
|
||||||
parameters.put(AccessPath.DIRECTION_PARAM, direction);
|
parameters.put(AccessPath.DIRECTION_PARAM, direction.name());
|
||||||
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic);
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||||
|
|
||||||
if(referenceEntity == null) {
|
if(referenceEntity == null) {
|
||||||
if(map != null && map.size() > 0) {
|
if(map != null && map.size() > 0) {
|
||||||
|
@ -372,8 +346,10 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
parameters.put(AccessPath.REFERENCE_PARAM, referenceEntity.toString());
|
parameters.put(AccessPath.REFERENCE_PARAM, referenceEntity.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPCall httpCall = getHTTPCall();
|
gxHTTPStringRequest.queryParams(parameters);
|
||||||
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
|
||||||
|
String json = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||||
|
|
||||||
if(referenceEntity == null) {
|
if(referenceEntity == null) {
|
||||||
logger.info("{} linked by {} to/from {} having {} are {}", entityType, relationType,
|
logger.info("{} linked by {} to/from {} having {} are {}", entityType, relationType,
|
||||||
|
@ -428,7 +404,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
@Override
|
@Override
|
||||||
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getFilteredResources(
|
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getFilteredResources(
|
||||||
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
|
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
|
||||||
Map<String,Object> map) throws ResourceRegistryException {
|
Map<String,String> map) throws ResourceRegistryException {
|
||||||
String resourceType = Utility.getType(resourceClass);
|
String resourceType = Utility.getType(resourceClass);
|
||||||
String consistsOfType = Utility.getType(consistsOfClass);
|
String consistsOfType = Utility.getType(consistsOfClass);
|
||||||
String facetType = Utility.getType(facetClass);
|
String facetType = Utility.getType(facetClass);
|
||||||
|
@ -442,7 +418,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
|
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
|
||||||
boolean polymorphic, Map<String,Object> map) throws ResourceRegistryException {
|
boolean polymorphic, Map<String,String> map) throws ResourceRegistryException {
|
||||||
return getRelated(resourceType, consistsOfType, facetType, Direction.out, polymorphic, map);
|
return getRelated(resourceType, consistsOfType, facetType, Direction.out, polymorphic, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +482,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
// @Override
|
// @Override
|
||||||
protected <E extends Entity, R extends Relation<?,?>, RE extends Entity> List<E> getRelated(Class<E> entityClass,
|
protected <E extends Entity, R extends Relation<?,?>, RE extends Entity> List<E> getRelated(Class<E> entityClass,
|
||||||
Class<R> relationClass, Class<RE> referenceEntityClass, Direction direction, boolean polymorphic,
|
Class<R> relationClass, Class<RE> referenceEntityClass, Direction direction, boolean polymorphic,
|
||||||
Map<String,Object> map) throws ResourceRegistryException {
|
Map<String,String> map) throws ResourceRegistryException {
|
||||||
String entityType = Utility.getType(entityClass);
|
String entityType = Utility.getType(entityClass);
|
||||||
String relationType = Utility.getType(relationClass);
|
String relationType = Utility.getType(relationClass);
|
||||||
String referenceEntityType = Utility.getType(referenceEntityClass);
|
String referenceEntityType = Utility.getType(referenceEntityClass);
|
||||||
|
@ -520,7 +496,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
protected String getRelated(String entityType, String relationType, String referenceEntityType, Direction direction,
|
protected String getRelated(String entityType, String relationType, String referenceEntityType, Direction direction,
|
||||||
boolean polymorphic, Map<String,Object> map) throws ResourceRegistryException {
|
boolean polymorphic, Map<String,String> map) throws ResourceRegistryException {
|
||||||
return getRelated(entityType, relationType, referenceEntityType, null, direction, polymorphic, map);
|
return getRelated(entityType, relationType, referenceEntityType, null, direction, polymorphic, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class ResourceRegistryClientTest extends ScopedTest {
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testGetFilteredResourcesByClasses() throws ResourceRegistryException, JsonProcessingException {
|
public void testGetFilteredResourcesByClasses() throws ResourceRegistryException, JsonProcessingException {
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("group", "VREManagement");
|
map.put("group", "VREManagement");
|
||||||
map.put("name", "SmartExecutor");
|
map.put("name", "SmartExecutor");
|
||||||
List<EService> eServices = resourceRegistryClient.getFilteredResources(EService.class, IsIdentifiedBy.class,
|
List<EService> eServices = resourceRegistryClient.getFilteredResources(EService.class, IsIdentifiedBy.class,
|
||||||
|
|
Loading…
Reference in New Issue