Added exists method which use HTTP HEAD method
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@146396 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ae306fb53b
commit
4ccf287add
|
@ -18,6 +18,10 @@ import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
||||||
*/
|
*/
|
||||||
public interface ResourceRegistryClient {
|
public interface ResourceRegistryClient {
|
||||||
|
|
||||||
|
public <ERType extends ER> void exists(
|
||||||
|
Class<ERType> clazz, UUID uuid) throws ERNotFoundException,
|
||||||
|
ResourceRegistryException;
|
||||||
|
|
||||||
public <ERType extends ER> ERType getInstance(
|
public <ERType extends ER> ERType getInstance(
|
||||||
Class<ERType> clazz, UUID uuid) throws ERNotFoundException,
|
Class<ERType> clazz, UUID uuid) throws ERNotFoundException,
|
||||||
ResourceRegistryException;
|
ResourceRegistryException;
|
||||||
|
|
|
@ -20,8 +20,7 @@ public class ResourceRegistryClientCall<C> implements Call<EndpointReference, C>
|
||||||
|
|
||||||
protected String getURLStringFromEndpointReference(
|
protected String getURLStringFromEndpointReference(
|
||||||
EndpointReference endpoint) throws IOException {
|
EndpointReference endpoint) throws IOException {
|
||||||
JaxRSEndpointReference jaxRSEndpointReference = new JaxRSEndpointReference(
|
JaxRSEndpointReference jaxRSEndpointReference = new JaxRSEndpointReference(endpoint);
|
||||||
endpoint);
|
|
||||||
return jaxRSEndpointReference.toString();
|
return jaxRSEndpointReference.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,38 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
this.delegate = new AsyncProxyDelegate<EndpointReference>(config);
|
this.delegate = new AsyncProxyDelegate<EndpointReference>(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <ERType extends ER> void exists(Class<ERType> clazz, UUID uuid)
|
||||||
|
throws ERNotFoundException, ResourceRegistryException {
|
||||||
|
String type = clazz.getSimpleName();
|
||||||
|
try {
|
||||||
|
logger.info("Going to check if {} with UUID {} exists", type, uuid);
|
||||||
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
||||||
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
stringWriter.append(AccessPath.INSTANCE_PATH_PART);
|
||||||
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
stringWriter.append(type);
|
||||||
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
stringWriter.append(uuid.toString());
|
||||||
|
|
||||||
|
HTTPCall<ERType> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||||
|
HTTPMETHOD.HEAD, null);
|
||||||
|
|
||||||
|
ResourceRegistryClientCall<ERType> call = new ResourceRegistryClientCall<>(
|
||||||
|
clazz, httpCall);
|
||||||
|
|
||||||
|
delegate.make(call);
|
||||||
|
logger.info("{} with UUID {} exists", type, uuid);
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid)
|
public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid)
|
||||||
throws ERNotFoundException, ResourceRegistryException {
|
throws ERNotFoundException, ResourceRegistryException {
|
||||||
|
|
Loading…
Reference in New Issue