Refs #11903: Use new REST interface in Resource Registry Publisher
Task-Url: https://support.d4science.org/issues/11903 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@169034 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9eb3aba0ae
commit
6e984b7acb
|
@ -2,10 +2,13 @@ package org.gcube.informationsystem.resourceregistry.publisher;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.ER;
|
||||
import org.gcube.informationsystem.model.entity.Facet;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.relation.IsRelatedTo;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
||||
|
@ -18,9 +21,35 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resour
|
|||
*/
|
||||
public interface ResourceRegistryPublisher {
|
||||
|
||||
@Deprecated
|
||||
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||
public <E extends ER> E create(E er)
|
||||
throws AlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
public String create(String erType, String er)
|
||||
throws AlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
public String create(String er) throws AlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <E extends ER> E read(E er) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String read(String erType, UUID uuid) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <E extends ER> E update(E er)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String update(String erType, String er) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String update(String er) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <E extends ER> boolean delete(E er) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean delete(String erType, UUID uuid) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
|
||||
public <F extends Facet> F createFacet(F facet)
|
||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||
|
@ -30,24 +59,25 @@ public interface ResourceRegistryPublisher {
|
|||
|
||||
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
@Deprecated
|
||||
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
||||
throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> F readFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String readFacet(String facetType, UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <F extends Facet> F updateFacet(F facet)
|
||||
throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateFacet(UUID uuid, String facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateFacet(String facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <F extends Facet> boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
|
||||
public boolean deleteFacet(String facetType, UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
@Deprecated
|
||||
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
||||
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> R createResource(R resource)
|
||||
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||
|
@ -57,45 +87,60 @@ public interface ResourceRegistryPublisher {
|
|||
|
||||
public String createResource(String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
@Deprecated
|
||||
public <R extends Resource> R updateResource(Class<R> resourceClass, R resource)
|
||||
|
||||
public <R extends Resource> R readResource(R resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String readResource(String resourceType, UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <R extends Resource> R updateResource(R resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateResource(UUID uuid, String resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateResource(String resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <R extends Resource> boolean deleteResource(R resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
|
||||
public boolean deleteResource(String resourceType, UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
@Deprecated
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
|
||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||
C consistsOf) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String createConsistsOf(String consistsOfType, String consistsOf)
|
||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String createConsistsOf(String consistsOf)
|
||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C readConsistsOf(
|
||||
C consistsOf) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String readConsistsOf(String consistsOfType, UUID uuid) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C updateConsistsOf(C consistsOf)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateConsistsOf(String consistsOf)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf)
|
||||
throws ResourceRegistryException;
|
||||
|
||||
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException;
|
||||
public boolean deleteConsistsOf(String consistsOfType, UUID uuid) throws ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
@Deprecated
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||
Class<I> isRelatedToClass, I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||
I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
@ -106,32 +151,106 @@ public interface ResourceRegistryPublisher {
|
|||
public String createIsRelatedTo(String isRelatedTo)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I readIsRelatedTo(
|
||||
I isRelatedTo) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String readIsRelatedTo(String isRelatedToType, UUID uuid) throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I updateIsRelatedTo(I isRelatedTo)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateIsRelatedTo(String isRelatedTo)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo)
|
||||
throws ResourceRegistryException;
|
||||
|
||||
public boolean deleteIsRelatedTo(UUID uuid) throws ResourceRegistryException;
|
||||
public boolean deleteIsRelatedTo(String isRelatedToType, UUID uuid) throws ResourceRegistryException;
|
||||
|
||||
public boolean addResourceToContext(UUID uuid)
|
||||
|
||||
/* ----- */
|
||||
|
||||
|
||||
public boolean addToContext(UUID contextUUID, String erType, UUID instanceUUID)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public <E extends ER> boolean addToContext(UUID contextUUID, E er)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean addToCurrentContext(String erType, UUID instanceUUID)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public <E extends ER> boolean addToCurrentContext(E er)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeFromContext(UUID contextUUID, String erType, UUID instanceUUID)
|
||||
throws NotFoundException, ResourceRegistryException;
|
||||
|
||||
public <E extends ER> boolean removeFromContext(UUID contextUUID, E er)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean addResourceToContext(R resource)
|
||||
public boolean removeFromCurrentContext(String erType, UUID instanceUUID)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean addFacetToContext(UUID uuid)
|
||||
public <E extends ER> boolean removeFromCurrentContext(E er)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
|
||||
public boolean addResourceToContext(UUID contextUUID, String resourceType, UUID resourceUUID)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean addResourceToContext(UUID contextUUID, R resource)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean addResourceToCurrentContext(String resourceType, UUID resourceUUID)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean addResourceToCurrentContext(R resource)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeResourceFromContext(UUID contextUUID, String resourceType, UUID resourceUUID)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean removeResourceFromContext(UUID contextUUID, R resource)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeResourceFromCurrentContext(String resourceType, UUID resourceUUID)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean removeResourceFromCurrentContext(R resource)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
|
||||
public boolean addFacetToContext(UUID contextUUID, String facetType, UUID facetUUID)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> boolean addFacetToContext(F facet)
|
||||
public <F extends Facet> boolean addFacetToContext(UUID contextUUID, F facet)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeResourceFromContext(UUID uuid)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> boolean removeResourceFromContext(R resource)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeFacetFromContext(UUID uuid)
|
||||
public boolean addFacetToCurrentContext(String facetType, UUID facetUUID)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> boolean removeFacetFromContext(F facet)
|
||||
public <F extends Facet> boolean addFacetToCurrentContext(F facet)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeFacetFromContext(UUID contextUUID, String facetType, UUID facetUUID)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> boolean removeFacetFromContext(UUID contextUUID, F facet)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public boolean removeFacetFromCurrentContext(String facetType, UUID facetUUID)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> boolean removeFacetFromCurrentContext(F facet)
|
||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -230,8 +230,7 @@ public class ERManagementTest extends ScopedTest {
|
|||
|
||||
eService.getFacets(SoftwareFacet.class).get(0).setVersion("1.2.0");
|
||||
|
||||
eServiceString = resourceRegistryPublisher.updateResource(eService.getHeader().getUUID(),
|
||||
ISMapper.marshal(eService));
|
||||
eServiceString = resourceRegistryPublisher.updateResource(ISMapper.marshal(eService));
|
||||
eService = ISMapper.unmarshal(EService.class, eServiceString);
|
||||
|
||||
Assert.assertTrue(eService.getFacets(SoftwareFacet.class).get(0).getVersion().compareTo("1.2.0") == 0);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class EntityManagementTest extends ScopedTest {
|
|||
String additionPropertyValue = "Test";
|
||||
createdCpuFacet.setAdditionalProperty(additionPropertyKey, additionPropertyValue);
|
||||
|
||||
String updatedCpuFacetString = resourceRegistryPublisher.updateFacet(createdCpuFacet.getHeader().getUUID(), ISMapper.marshal(createdCpuFacet));
|
||||
String updatedCpuFacetString = resourceRegistryPublisher.updateFacet(ISMapper.marshal(createdCpuFacet));
|
||||
|
||||
CPUFacet updatedCpuFacet = ISMapper.unmarshal(CPUFacet.class, updatedCpuFacetString);
|
||||
Assert.assertTrue(createdCpuFacet.getClockSpeed().compareTo(updatedCpuFacet.getClockSpeed())==0);
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.impl.entity.facet.AccessPointFacetImpl;
|
||||
|
@ -54,9 +49,6 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
|
@ -74,48 +66,6 @@ public class MultiContextTest extends ScopedTest {
|
|||
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void production() throws Exception {
|
||||
File src = new File("src");
|
||||
File test = new File(src, "test");
|
||||
File resources = new File(test, "resources");
|
||||
|
||||
File tokenFile = new File(resources, "production-tokens-is-exporter.json");
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(tokenFile);
|
||||
|
||||
Set<String> contexts = new HashSet<>();
|
||||
contexts.add("/d4science.research-infrastructures.eu/ParthenosVO");
|
||||
contexts.add("/d4science.research-infrastructures.eu/ParthenosVO/RubRIcA");
|
||||
contexts.add("/d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_Registry");
|
||||
|
||||
|
||||
String rootToken = jsonNode.get("/d4science.research-infrastructures.eu").asText();
|
||||
ScopedTest.setContext(rootToken);
|
||||
|
||||
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
||||
//ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||
|
||||
|
||||
List<String> uuids = new ArrayList<>();
|
||||
uuids.add("ac88cc20-9589-4e0b-9115-7af6e0bd7abc");
|
||||
uuids.add("38823ddc-0713-4e83-9670-79e472408b0c");
|
||||
|
||||
for(String context : contexts){
|
||||
String token = jsonNode.get(context).asText();
|
||||
ScopedTest.setContext(token);
|
||||
|
||||
for(String uuidString : uuids){
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
resourceRegistryPublisher.addResourceToContext(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEServiceHostingNode() throws Exception {
|
||||
EService eService = new EServiceImpl();
|
||||
|
@ -230,7 +180,7 @@ public class MultiContextTest extends ScopedTest {
|
|||
}
|
||||
|
||||
|
||||
boolean addedToContext = resourceRegistryPublisher.addResourceToContext(hostingNodeUUID);
|
||||
boolean addedToContext = resourceRegistryPublisher.addResourceToCurrentContext(createdHN);
|
||||
Assert.assertTrue(addedToContext);
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue