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 {
|
||||
|
||||
@Deprecated
|
||||
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
public <F extends Facet> F createFacet(F facet)
|
||||
throws FacetAlreadyPresentException, ResourceRegistryException;
|
||||
|
||||
public String createFacet(String facetType, 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)
|
||||
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;
|
||||
|
@ -37,17 +45,25 @@ public interface ResourceRegistryPublisher {
|
|||
|
||||
public boolean deleteFacet(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;
|
||||
|
||||
public String createResource(String resourceType, 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)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public <R extends Resource> R updateResource(R resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
public String updateResource(UUID uuid, String resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
@ -59,8 +75,12 @@ public interface ResourceRegistryPublisher {
|
|||
|
||||
public boolean deleteResource(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;
|
||||
|
||||
public String createConsistsOf(String consistsOfType, String consistsOf)
|
||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
|
||||
|
@ -73,9 +93,13 @@ public interface ResourceRegistryPublisher {
|
|||
|
||||
public boolean deleteConsistsOf(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;
|
||||
|
||||
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
||||
throws ResourceNotFoundException, ResourceRegistryException;
|
||||
|
||||
|
|
|
@ -62,13 +62,29 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <F extends Facet> F createFacet(Class<F> facetClass, F facet)
|
||||
throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
String facetString = ISMapper.marshal(facet);
|
||||
String facetType = facetClass.getSimpleName();
|
||||
String res = createFacet(facetType, facetString);
|
||||
return ISMapper.unmarshal(facetClass, res);
|
||||
return createFacet(facet);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", facet, e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// logger.trace("Error Creating {}", facet, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
|
@ -77,7 +93,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
|
@ -121,13 +136,29 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <F extends Facet> F updateFacet(Class<F> facetClass, F facet)
|
||||
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 {
|
||||
String facetString = ISMapper.marshal(facet);
|
||||
UUID uuid = facet.getHeader().getUUID();
|
||||
String res = updateFacet(uuid, facetString);
|
||||
return ISMapper.unmarshal(facetClass, res);
|
||||
return (F) ISMapper.unmarshal(Facet.class, res);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Updating {}", facet, e);
|
||||
throw e;
|
||||
|
@ -212,14 +243,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <R extends Resource> R createResource(Class<R> resourceClass, R resource)
|
||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
String resourceString = ISMapper.marshal(resource);
|
||||
String resourceType = resourceClass.getSimpleName();
|
||||
String res = createResource(resourceType, resourceString);
|
||||
return ISMapper.unmarshal(resourceClass, res);
|
||||
return createResource(resource);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", resource, e);
|
||||
throw e;
|
||||
|
@ -230,6 +259,25 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <R extends Resource> R createResource(R resource)
|
||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
String resourceString = ISMapper.marshal(resource);
|
||||
String resourceType = Utility.getType(resource);
|
||||
String res = createResource(resourceType, 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 createResource(String resource) throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
|
@ -274,14 +322,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <R extends Resource> R updateResource(Class<R> resourceClass, R resource)
|
||||
throws ResourceNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
String resourceString = ISMapper.marshal(resource);
|
||||
UUID uuid = resource.getHeader().getUUID();
|
||||
String res = updateResource(uuid, resourceString);
|
||||
return ISMapper.unmarshal(resourceClass, res);
|
||||
return updateResource(resource);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", resource, e);
|
||||
throw e;
|
||||
|
@ -290,7 +336,26 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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 {
|
||||
try {
|
||||
UUID uuid = Utility.getUUIDFromJsonString(resource);
|
||||
|
@ -367,14 +432,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass,
|
||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
String consistsOfString = ISMapper.marshal(consistsOf);
|
||||
String consistsOfType = consistsOfClass.getSimpleName();
|
||||
String res = createConsistsOf(consistsOfType, consistsOfString);
|
||||
return ISMapper.unmarshal(consistsOfClass, res);
|
||||
return createConsistsOf(consistsOf);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", consistsOf, e);
|
||||
throw e;
|
||||
|
@ -384,6 +447,24 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
|
||||
C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
String consistsOfString = ISMapper.marshal(consistsOf);
|
||||
String consistsOfType = Utility.getType(consistsOf);
|
||||
String res = createConsistsOf(consistsOfType, consistsOfString);
|
||||
return (C) ISMapper.unmarshal(ConsistsOf.class, res);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", consistsOf, e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// logger.trace("Error Creating {}", consistsOf, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createConsistsOf(String consistsOf)
|
||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||
|
@ -399,6 +480,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createConsistsOf(String consistsOfType, String consistsOf)
|
||||
throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
|
@ -447,7 +529,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
@Override
|
||||
public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException {
|
||||
try {
|
||||
|
||||
logger.info("Going to delete {} with UUID {}", ConsistsOf.NAME, uuid);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
stringWriter.append(PATH_SEPARATOR);
|
||||
|
@ -475,15 +556,30 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||
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 {
|
||||
String isRelatedToString = ISMapper.marshal(isRelatedTo);
|
||||
String isRelatedToType = isRelatedToClass.getSimpleName();
|
||||
String isRelatedToType = Utility.getType(isRelatedTo);
|
||||
String res = createConsistsOf(isRelatedToType, isRelatedToString);
|
||||
return ISMapper.unmarshal(isRelatedToClass, res);
|
||||
return (I) ISMapper.unmarshal(IsRelatedTo.class, res);
|
||||
} catch (ResourceRegistryException e) {
|
||||
// logger.trace("Error Creating {}", isRelatedTo, e);
|
||||
throw e;
|
||||
|
@ -507,6 +603,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createIsRelatedTo(String isRelatedToType, String isRelatedTo)
|
||||
throws ResourceNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue