Fixing exception management
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@144251 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d4f5dc2db5
commit
2bbeb736ea
|
@ -8,10 +8,8 @@ import org.gcube.informationsystem.model.ISManageable;
|
|||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
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;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
||||
|
||||
|
@ -26,16 +24,16 @@ public interface ResourceRegistryClient {
|
|||
|
||||
public List<? extends Entity> getInstances(
|
||||
String type, Boolean polymorphic) throws
|
||||
ERException, SchemaException, ResourceRegistryException;
|
||||
ResourceRegistryException;
|
||||
|
||||
public List<Resource> getInstancesFromEntity(
|
||||
String relationType, Boolean polymorphic,
|
||||
UUID reference, Direction direction) throws
|
||||
ERException, SchemaException, ResourceRegistryException;
|
||||
ResourceRegistryException;
|
||||
|
||||
public <ISM extends ISManageable> List<TypeDefinition> getSchema(
|
||||
Class<ISM> clazz, Boolean polymorphic)
|
||||
throws SchemaNotFoundException;
|
||||
throws SchemaNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String query(final String query, final int limit,
|
||||
final String fetchPlan) throws InvalidQueryException;
|
||||
|
|
|
@ -20,10 +20,8 @@ import org.gcube.informationsystem.model.ISManageable;
|
|||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
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;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall;
|
||||
|
@ -85,8 +83,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
|
||||
@Override
|
||||
public List<? extends Entity> getInstances(String type,
|
||||
Boolean polymorphic) throws ERNotFoundException,
|
||||
ResourceRegistryException {
|
||||
Boolean polymorphic) throws ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get all instances of {} ", type);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
|
@ -123,8 +120,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
@Override
|
||||
public List<Resource> getInstancesFromEntity(
|
||||
String relationType, Boolean polymorphic, UUID reference,
|
||||
Direction direction) throws ERException, SchemaException,
|
||||
ResourceRegistryException {
|
||||
Direction direction) throws ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get all instances of {} from/to {}", relationType,
|
||||
reference.toString());
|
||||
|
@ -165,7 +161,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
@Override
|
||||
public <ISM extends ISManageable> List<TypeDefinition> getSchema(
|
||||
Class<ISM> clazz, Boolean polymorphic)
|
||||
throws SchemaNotFoundException {
|
||||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
|
||||
String type = clazz.getSimpleName();
|
||||
try {
|
||||
|
@ -191,7 +187,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
|
||||
return TypeBinder.deserializeTypeDefinitions(schema);
|
||||
|
||||
} catch (SchemaNotFoundException e) {
|
||||
} catch (ResourceRegistryException e) {
|
||||
logger.error("Error while getting {}schema for {}",
|
||||
polymorphic ? AccessPath.POLYMORPHIC_PARAM + " " : "",
|
||||
type, e);
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
|
||||
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
||||
import org.gcube.informationsystem.model.entity.resource.Service;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
||||
|
@ -36,13 +37,13 @@ public class ResourceRegistryClientTest extends ScopedTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetFacetSchema() throws SchemaNotFoundException {
|
||||
public void testGetFacetSchema() throws SchemaNotFoundException, ResourceRegistryException {
|
||||
List<TypeDefinition> typeDefinitions = resourceRegistryClient.getSchema(ContactFacet.class, true);
|
||||
logger.trace("{}", typeDefinitions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetResourceSchema() throws SchemaNotFoundException {
|
||||
public void testGetResourceSchema() throws SchemaNotFoundException, ResourceRegistryException {
|
||||
List<TypeDefinition> typeDefinitions = resourceRegistryClient.getSchema(HostingNode.class, true);
|
||||
logger.trace("{}", typeDefinitions);
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ public class ResourceRegistryClientTest extends ScopedTest {
|
|||
}
|
||||
|
||||
@Test(expected=SchemaNotFoundException.class)
|
||||
public void testException() throws SchemaNotFoundException {
|
||||
public void testException() throws SchemaNotFoundException, ResourceRegistryException {
|
||||
resourceRegistryClient.getSchema(Aux.class, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue