Removed the needs to pass the class to create/update methods
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@154781 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a9b8671c81
commit
04f7dac6d1
|
@ -18,17 +18,25 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resour
|
||||||
*/
|
*/
|
||||||
public interface ResourceRegistryPublisher {
|
public interface ResourceRegistryPublisher {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
||||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public <F extends Facet> F createFacet(F facet)
|
||||||
|
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createFacet(String facetType, String facet)
|
public String createFacet(String facetType, String facet)
|
||||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException;
|
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
||||||
throws FacetNotFoundException, ResourceRegistryException;
|
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(UUID uuid, String facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public String updateFacet(String facet) throws FacetNotFoundException, ResourceRegistryException;
|
public String updateFacet(String facet) throws FacetNotFoundException, ResourceRegistryException;
|
||||||
|
@ -37,17 +45,25 @@ public interface ResourceRegistryPublisher {
|
||||||
|
|
||||||
public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
|
public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public <R extends Resource> R createResource(R resource)
|
||||||
|
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createResource(String resourceType, String resource)
|
public String createResource(String resourceType, String resource)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
throws ResourceAlreadyPresentException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createResource(String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
|
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 updateResource(Class<R> resourceClass, R resource)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException;
|
throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public <R extends Resource> R updateResource(R resource)
|
||||||
|
throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public String updateResource(UUID uuid, String resource)
|
public String updateResource(UUID uuid, String resource)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException;
|
throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@ -59,9 +75,13 @@ public interface ResourceRegistryPublisher {
|
||||||
|
|
||||||
public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
|
public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
||||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
|
||||||
|
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createConsistsOf(String consistsOfType, String consistsOf)
|
public String createConsistsOf(String consistsOfType, String consistsOf)
|
||||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
@ -73,9 +93,13 @@ public interface ResourceRegistryPublisher {
|
||||||
|
|
||||||
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException;
|
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||||
Class<I> isRelatedToClass, I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException;
|
Class<I> isRelatedToClass, I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||||
|
I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException;
|
throws ResourceNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
||||||
throws FacetAlreadyPresentException, ResourceRegistryException {
|
throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String facetString = ISMapper.marshal(facet);
|
return createFacet(facet);
|
||||||
String facetType = facetClass.getSimpleName();
|
|
||||||
String res = createFacet(facetType, facetString);
|
|
||||||
return ISMapper.unmarshal(facetClass, res);
|
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Creating {}", facet, e);
|
// logger.trace("Error Creating {}", facet, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -78,6 +76,23 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <F extends Facet> F createFacet(F facet)
|
||||||
|
throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
String facetString = ISMapper.marshal(facet);
|
||||||
|
String facetType = Utility.getType(facet);
|
||||||
|
String res = createFacet(facetType, facetString);
|
||||||
|
return (F) ISMapper.unmarshal(Facet.class, res);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Creating {}", facet, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Creating {}", facet, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException {
|
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
@ -121,13 +136,29 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
||||||
throws FacetNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
return updateFacet(facet);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Updating {}", facet, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Updating {}", facet, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <F extends Facet> F updateFacet(F facet)
|
||||||
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String facetString = ISMapper.marshal(facet);
|
String facetString = ISMapper.marshal(facet);
|
||||||
UUID uuid = facet.getHeader().getUUID();
|
UUID uuid = facet.getHeader().getUUID();
|
||||||
String res = updateFacet(uuid, facetString);
|
String res = updateFacet(uuid, facetString);
|
||||||
return ISMapper.unmarshal(facetClass, res);
|
return (F) ISMapper.unmarshal(Facet.class, res);
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Updating {}", facet, e);
|
// logger.trace("Error Updating {}", facet, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -212,14 +243,31 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
return createResource(resource);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
|
throw e;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <R extends Resource> R createResource(R resource)
|
||||||
|
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String resourceString = ISMapper.marshal(resource);
|
String resourceString = ISMapper.marshal(resource);
|
||||||
String resourceType = resourceClass.getSimpleName();
|
String resourceType = Utility.getType(resource);
|
||||||
String res = createResource(resourceType, resourceString);
|
String res = createResource(resourceType, resourceString);
|
||||||
return ISMapper.unmarshal(resourceClass, res);
|
return (R) ISMapper.unmarshal(Resource.class, res);
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Creating {}", resource, e);
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -274,14 +322,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public <R extends Resource> R updateResource(Class<R> resourceClass, R resource)
|
public <R extends Resource> R updateResource(Class<R> resourceClass, R resource)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String resourceString = ISMapper.marshal(resource);
|
return updateResource(resource);
|
||||||
UUID uuid = resource.getHeader().getUUID();
|
|
||||||
String res = updateResource(uuid, resourceString);
|
|
||||||
return ISMapper.unmarshal(resourceClass, res);
|
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Creating {}", resource, e);
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -291,6 +337,25 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <R extends Resource> R updateResource(R resource)
|
||||||
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
String resourceString = ISMapper.marshal(resource);
|
||||||
|
UUID uuid = resource.getHeader().getUUID();
|
||||||
|
String res = updateResource(uuid, resourceString);
|
||||||
|
return (R) ISMapper.unmarshal(Resource.class, res);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Creating {}", resource, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String updateResource(String resource) throws ResourceNotFoundException, ResourceRegistryException {
|
public String updateResource(String resource) throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
UUID uuid = Utility.getUUIDFromJsonString(resource);
|
UUID uuid = Utility.getUUIDFromJsonString(resource);
|
||||||
|
@ -367,14 +432,30 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
||||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
return createConsistsOf(consistsOf);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Creating {}", consistsOf, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Creating {}", consistsOf, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
|
||||||
|
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String consistsOfString = ISMapper.marshal(consistsOf);
|
String consistsOfString = ISMapper.marshal(consistsOf);
|
||||||
String consistsOfType = consistsOfClass.getSimpleName();
|
String consistsOfType = Utility.getType(consistsOf);
|
||||||
String res = createConsistsOf(consistsOfType, consistsOfString);
|
String res = createConsistsOf(consistsOfType, consistsOfString);
|
||||||
return ISMapper.unmarshal(consistsOfClass, res);
|
return (C) ISMapper.unmarshal(ConsistsOf.class, res);
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Creating {}", consistsOf, e);
|
// logger.trace("Error Creating {}", consistsOf, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -399,6 +480,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String createConsistsOf(String consistsOfType, String consistsOf)
|
public String createConsistsOf(String consistsOfType, String consistsOf)
|
||||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
@ -447,7 +529,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException {
|
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
logger.info("Going to delete {} with UUID {}", ConsistsOf.NAME, uuid);
|
logger.info("Going to delete {} with UUID {}", ConsistsOf.NAME, uuid);
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
@ -475,15 +556,30 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||||
Class<I> isRelatedToClass, I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException {
|
Class<I> isRelatedToClass, I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
return createIsRelatedTo(isRelatedTo);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
// logger.trace("Error Creating {}", isRelatedTo, e);
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logger.trace("Error Creating {}", isRelatedTo, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||||
|
I isRelatedTo) throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String isRelatedToString = ISMapper.marshal(isRelatedTo);
|
String isRelatedToString = ISMapper.marshal(isRelatedTo);
|
||||||
String isRelatedToType = isRelatedToClass.getSimpleName();
|
String isRelatedToType = Utility.getType(isRelatedTo);
|
||||||
String res = createConsistsOf(isRelatedToType, isRelatedToString);
|
String res = createConsistsOf(isRelatedToType, isRelatedToString);
|
||||||
return ISMapper.unmarshal(isRelatedToClass, res);
|
return (I) ISMapper.unmarshal(IsRelatedTo.class, res);
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
// logger.trace("Error Creating {}", isRelatedTo, e);
|
// logger.trace("Error Creating {}", isRelatedTo, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -507,6 +603,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue