Aligned Interface and class APIs

This commit is contained in:
Luca Frosini 2021-09-09 10:19:00 +02:00
parent bee21362e2
commit 242d41f07b
2 changed files with 113 additions and 113 deletions

View File

@ -33,7 +33,15 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema
* @author Luca Frosini (ISTI - CNR)
*/
public interface ResourceRegistryPublisher {
public List<Context> getAllContext() throws ResourceRegistryException;
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException;
/* ----- */
public <ERElem extends ERElement> List<ERElem> list(Class<ERElem> clazz, Boolean polymorphic)
throws ResourceRegistryException;
@ -56,8 +64,8 @@ public interface ResourceRegistryPublisher {
public boolean exists(String type, UUID uuid)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
public <ERElem extends ERElement> ERElem read(ERElem er)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
@ -80,7 +88,6 @@ public interface ResourceRegistryPublisher {
public String update(String type, String json, UUID uuid)
throws SchemaViolationException, NotFoundException, ResourceRegistryException;
public <ERElem extends ERElement> boolean delete(ERElem er)
throws SchemaViolationException, NotFoundException, ResourceRegistryException;
@ -136,10 +143,10 @@ public interface ResourceRegistryPublisher {
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException;
public <R extends Resource> boolean deleteResource(R resource)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException;
throws ResourceNotFoundException, ResourceRegistryException;
public boolean deleteResource(String resourceType, UUID uuid)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException;
throws ResourceNotFoundException, ResourceRegistryException;
/* ----- */
@ -218,7 +225,7 @@ public interface ResourceRegistryPublisher {
public List<ERElement> removeFromCurrentContext(ERElement er, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException;
public Set<UUID> getElementContexts(String type, UUID instanceUUID)
throws NotFoundException, ResourceRegistryException;
@ -289,12 +296,4 @@ public interface ResourceRegistryPublisher {
public <F extends Facet> Set<UUID> getFacetContexts(F facet)
throws FacetNotFoundException, ResourceRegistryException;
/* ----- */
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException;
public List<Context> getAllContext() throws ResourceRegistryException;
}

View File

@ -30,8 +30,14 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
@ -492,7 +498,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public String update(String type, String json, UUID uuid)
throws SchemaViolationException, AlreadyPresentException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
try {
logger.trace("Going to create {} : {}", type, json);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
@ -627,13 +633,14 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
}
@Override
public <R extends Resource> R readResource(R resource) throws ResourceNotFoundException, ResourceRegistryException {
public <R extends Resource> R readResource(R resource)
throws ResourceNotFoundException, ResourceAvailableInAnotherContextException, ResourceRegistryException {
return read(resource);
}
@Override
public String readResource(String resourceType, UUID uuid)
throws ResourceNotFoundException, ResourceRegistryException {
throws ResourceNotFoundException, ResourceAvailableInAnotherContextException, ResourceRegistryException {
return read(resourceType, uuid);
}
@ -651,114 +658,115 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <R extends Resource> boolean deleteResource(R resource)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException {
throws ResourceNotFoundException, ResourceRegistryException {
return delete(resource);
}
@Override
public boolean deleteResource(String resourceType, UUID uuid)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException {
throws ResourceNotFoundException, ResourceRegistryException {
return delete(resourceType, uuid);
}
@Override
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(C consistsOf)
throws SchemaViolationException, ConsistsOfAlreadyPresentException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfAlreadyPresentException, ResourceNotFoundException, ResourceRegistryException {
return create(consistsOf);
}
@Override
public String createConsistsOf(String consistsOf)
throws SchemaViolationException, ConsistsOfAlreadyPresentException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfAlreadyPresentException, ResourceNotFoundException, ResourceRegistryException {
return create(consistsOf);
}
@Override
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C readConsistsOf(C consistsOf)
throws NotFoundException, ResourceRegistryException {
throws ConsistsOfNotFoundException, ConsistsOfAvailableInAnotherContextException, ResourceRegistryException {
return read(consistsOf);
}
@Override
public String readConsistsOf(String consistsOfType, UUID uuid) throws NotFoundException, ResourceRegistryException {
public String readConsistsOf(String consistsOfType, UUID uuid)
throws ConsistsOfNotFoundException, ConsistsOfAvailableInAnotherContextException, ResourceRegistryException {
return read(consistsOfType, uuid);
}
@Override
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C updateConsistsOf(C consistsOf)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfNotFoundException, ResourceRegistryException {
return update(consistsOf);
}
@Override
public String updateConsistsOf(String consistsOf)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfNotFoundException, ResourceRegistryException {
return update(consistsOf);
}
@Override
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf)
throws SchemaViolationException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfNotFoundException, ResourceRegistryException {
return delete(consistsOf);
}
@Override
public boolean deleteConsistsOf(String consistsOfType, UUID uuid)
throws SchemaViolationException, ResourceRegistryException {
throws SchemaViolationException, ConsistsOfNotFoundException, ResourceRegistryException {
return delete(consistsOfType, uuid);
}
@Override
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(I isRelatedTo)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException {
throws SchemaViolationException, IsRelatedToAlreadyPresentException, ResourceNotFoundException, ResourceRegistryException {
return create(isRelatedTo);
}
@Override
public String createIsRelatedTo(String isRelatedTo)
throws SchemaViolationException, ResourceNotFoundException, ResourceRegistryException {
throws SchemaViolationException, IsRelatedToAlreadyPresentException, ResourceNotFoundException, ResourceRegistryException {
return create(isRelatedTo);
}
@Override
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I readIsRelatedTo(I isRelatedTo)
throws NotFoundException, ResourceRegistryException {
throws IsRelatedToNotFoundException, IsRelatedToAvailableInAnotherContextException, ResourceRegistryException {
return read(isRelatedTo);
}
@Override
public String readIsRelatedTo(String isRelatedToType, UUID uuid)
throws NotFoundException, ResourceRegistryException {
throws IsRelatedToNotFoundException, IsRelatedToAvailableInAnotherContextException, ResourceRegistryException {
return read(isRelatedToType, uuid);
}
@Override
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I updateIsRelatedTo(I isRelatedTo)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, IsRelatedToNotFoundException, ResourceRegistryException {
return update(isRelatedTo);
}
@Override
public String updateIsRelatedTo(String isRelatedTo)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, IsRelatedToNotFoundException, ResourceRegistryException {
return update(isRelatedTo);
}
@Override
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo)
throws SchemaViolationException, ResourceRegistryException {
throws IsRelatedToNotFoundException, ResourceRegistryException {
return delete(isRelatedTo);
}
@Override
public boolean deleteIsRelatedTo(String isRelatedToType, UUID uuid)
throws SchemaViolationException, ResourceRegistryException {
throws IsRelatedToNotFoundException, ResourceRegistryException {
return delete(isRelatedToType, uuid);
}
@Override
public List<ERElement> addToContext(String type, UUID instanceUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
logger.trace("Going to add {} with UUID {} to {} with UUID {} ", type, instanceUUID, Context.NAME,
contextUUID);
@ -796,7 +804,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public List<ERElement> addToContext(ERElement er, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
String type = org.gcube.informationsystem.resourceregistry.api.utils.Utility
.getTypeName(er);
@ -813,21 +821,21 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public List<ERElement> addToCurrentContext(String type, UUID instanceUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
UUID contextUUID = getCurrentContextUUID();
return addToContext(type, instanceUUID, contextUUID, dryRun);
}
@Override
public List<ERElement> addToCurrentContext(ERElement er, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
UUID contextUUID = getCurrentContextUUID();
return addToContext(er, contextUUID, dryRun);
}
@Override
public List<ERElement> removeFromContext(String type, UUID instanceUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
logger.trace("Going to add {} with UUID {} to {} with UUID {} ", type, instanceUUID, Context.NAME,
contextUUID);
@ -865,8 +873,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public List<ERElement> removeFromContext(ERElement er, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
String type = org.gcube.informationsystem.resourceregistry.api.utils.Utility
.getTypeName(er);
@ -882,8 +889,8 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
}
@Override
public List<ERElement> removeFromCurrentContext(String type, UUID instanceUUID, Boolean dryRun) throws SchemaViolationException,
ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
public List<ERElement> removeFromCurrentContext(String type, UUID instanceUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
UUID contextUUID = getCurrentContextUUID();
return removeFromContext(type, instanceUUID, contextUUID, dryRun);
}
@ -898,7 +905,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public Set<UUID> getElementContexts(String type, UUID instanceUUID)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws NotFoundException, ResourceRegistryException {
try {
logger.trace("Going to get contexts of {} with UUID {}", type, instanceUUID);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
@ -927,7 +934,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <ERElem extends ERElement> Set<UUID> getElementContexts(ERElem er)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws NotFoundException, ResourceRegistryException {
String type = org.gcube.informationsystem.resourceregistry.api.utils.Utility.getTypeName(er);
UUID instanceUUID = er.getHeader().getUUID();
return getElementContexts(type, instanceUUID);
@ -935,48 +942,43 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public List<ERElement> addResourceToContext(String resourceType, UUID resourceUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(resourceType, resourceUUID, contextUUID, dryRun);
}
@Override
public <R extends Resource> List<ERElement> addResourceToContext(R resource, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(resource, contextUUID, dryRun);
}
@Override
public List<ERElement> addResourceToCurrentContext(String resourceType, UUID resourceUUID, Boolean dryRun) throws SchemaViolationException,
ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
public List<ERElement> addResourceToCurrentContext(String resourceType, UUID resourceUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(resourceType, resourceUUID, dryRun);
}
@Override
public <R extends Resource> List<ERElement> addResourceToCurrentContext(R resource, Boolean dryRun) throws SchemaViolationException,
ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
public <R extends Resource> List<ERElement> addResourceToCurrentContext(R resource, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(resource, dryRun);
}
@Override
public List<ERElement> removeResourceFromContext(String resourceType, UUID resourceUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromContext(resourceType, resourceUUID, contextUUID, dryRun);
}
@Override
public <R extends Resource> List<ERElement> removeResourceFromContext(R resource, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromContext(resource, contextUUID, dryRun);
}
@Override
public List<ERElement> removeResourceFromCurrentContext(String resourceType, UUID resourceUUID, Boolean dryRun)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromCurrentContext(resourceType, resourceUUID, dryRun);
}
@ -986,76 +988,75 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
return removeFromCurrentContext(resource, dryRun);
}
@Override
public List<ERElement> addFacetToContext(String facetType, UUID facetUUID, UUID contextUUID, Boolean dryRun)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(facetType, facetUUID, contextUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> addFacetToContext(F facet, UUID contextUUID, Boolean dryRun)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(facet, contextUUID, dryRun);
}
@Override
public List<ERElement> addFacetToCurrentContext(String facetType, UUID facetUUID, Boolean dryRun)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(facetType, facetUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> addFacetToCurrentContext(F facet, Boolean dryRun)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(facet, dryRun);
}
@Override
public List<ERElement> removeFacetFromContext(String facetType, UUID facetUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException,
ResourceRegistryException {
return removeFromContext(facetType, facetUUID, contextUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> removeFacetFromContext(F facet, UUID contextUUID, Boolean dryRun) throws SchemaViolationException,
FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromContext(facet, contextUUID, dryRun);
}
@Override
public List<ERElement> removeFacetFromCurrentContext(String facetType, UUID facetUUID, Boolean dryRun) throws SchemaViolationException,
FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromCurrentContext(facetType, facetUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> removeFacetFromCurrentContext(F facet, Boolean dryRun) throws SchemaViolationException,
FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromCurrentContext(facet, dryRun);
}
@Override
public Set<UUID> getResourceContexts(String resourceType, UUID resourceUUID)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws ResourceNotFoundException, ResourceRegistryException {
return getElementContexts(resourceType, resourceUUID);
}
@Override
public <R extends Resource> Set<UUID> getResourceContexts(R resource)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws ResourceNotFoundException, ResourceRegistryException {
return getElementContexts(resource);
}
@Override
public List<ERElement> addFacetToContext(String facetType, UUID facetUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(facetType, facetUUID, contextUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> addFacetToContext(F facet, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToContext(facet, contextUUID, dryRun);
}
@Override
public List<ERElement> addFacetToCurrentContext(String facetType, UUID facetUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(facetType, facetUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> addFacetToCurrentContext(F facet, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return addToCurrentContext(facet, dryRun);
}
@Override
public List<ERElement> removeFacetFromContext(String facetType, UUID facetUUID, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromContext(facetType, facetUUID, contextUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> removeFacetFromContext(F facet, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromContext(facet, contextUUID, dryRun);
}
@Override
public List<ERElement> removeFacetFromCurrentContext(String facetType, UUID facetUUID, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromCurrentContext(facetType, facetUUID, dryRun);
}
@Override
public <F extends Facet> List<ERElement> removeFacetFromCurrentContext(F facet, Boolean dryRun)
throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
return removeFromCurrentContext(facet, dryRun);
}
@Override
public Set<UUID> getFacetContexts(String facetType, UUID facetUUID)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws FacetNotFoundException, ResourceRegistryException {
return getElementContexts(facetType, facetUUID);
}
@Override
public <F extends Facet> Set<UUID> getFacetContexts(F facet)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
throws FacetNotFoundException, ResourceRegistryException {
return getElementContexts(facet);
}