Fixed REST path
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@141577 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1140ac31ad
commit
e8c3009208
|
@ -6,7 +6,6 @@ import java.util.UUID;
|
|||
import org.gcube.informationsystem.model.ER;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.relation.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
|
||||
|
@ -24,12 +23,12 @@ public interface ResourceRegistryClient {
|
|||
Class<ERType> clazz, UUID uuid) throws ERNotFoundException,
|
||||
ResourceRegistryException;
|
||||
|
||||
public <ERType extends ER> List<? extends Entity> getInstances(
|
||||
Class<ERType> clazz, Boolean polymorphic) throws
|
||||
public List<? extends Entity> getInstances(
|
||||
String type, Boolean polymorphic) throws
|
||||
ERException, SchemaException, ResourceRegistryException;
|
||||
|
||||
public <R extends Relation<Entity, Entity>> List<Resource> getInstancesFromEntity(
|
||||
Class<R> clazz, Boolean polymorphic,
|
||||
public List<Resource> getInstancesFromEntity(
|
||||
String relationType, Boolean polymorphic,
|
||||
UUID reference, Direction direction) throws
|
||||
ERException, SchemaException, ResourceRegistryException;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.gcube.informationsystem.impl.utils.Entities;
|
|||
import org.gcube.informationsystem.model.ER;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.relation.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
|
||||
|
@ -302,17 +301,16 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <ERType extends ER> List<? extends Entity> getInstances(Class<ERType> clazz,
|
||||
public List<? extends Entity> getInstances(String type,
|
||||
Boolean polymorphic) throws ERNotFoundException,
|
||||
ResourceRegistryException {
|
||||
String type = clazz.getSimpleName();
|
||||
try {
|
||||
logger.info("Going to get all instances of {} ", type);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(AccessPath.INSTANCE_PATH_PART);
|
||||
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(type);
|
||||
|
||||
|
@ -338,21 +336,20 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <R extends Relation<Entity, Entity>> List<Resource> getInstancesFromEntity(
|
||||
Class<R> clazz, Boolean polymorphic, UUID reference,
|
||||
public List<Resource> getInstancesFromEntity(
|
||||
String relationType, Boolean polymorphic, UUID reference,
|
||||
Direction direction) throws ERException, SchemaException,
|
||||
ResourceRegistryException {
|
||||
String type = clazz.getSimpleName();
|
||||
try {
|
||||
logger.info("Going to get all instances of {} from/to {}", type,
|
||||
logger.info("Going to get all instances of {} from/to {}", relationType,
|
||||
reference.toString());
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(AccessPath.INSTANCE_PATH_PART);
|
||||
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(type);
|
||||
stringWriter.append(relationType);
|
||||
|
||||
List<Entry<String, String>> parameters = new ArrayList<>();
|
||||
parameters.add(new RREntry<String, String>(
|
||||
|
@ -369,13 +366,13 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
String.class, httpInputs);
|
||||
|
||||
String ret = delegate.make(call);
|
||||
logger.info("Got instances of {} from/to {} are {}", type,
|
||||
logger.info("Got instances of {} from/to {} are {}", relationType,
|
||||
reference.toString(), ret);
|
||||
|
||||
return Entities.unmarshalList(Resource.class, ret);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while getting instances of {} from/to {}", type, e);
|
||||
logger.error("Error while getting instances of {} from/to {}", relationType, e);
|
||||
throw new ResourceRegistryException(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue