|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
package org.gcube.resourcemanagement.manager.webapp.context;
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
import org.gcube.informationsystem.model.reference.entities.Context;
|
|
|
|
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
|
|
|
|
@ -42,18 +44,21 @@ final class Queries {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests if the given context exists
|
|
|
|
|
* Returns {@code true} if the provided context exists
|
|
|
|
|
* otherwise returns {@code false}.
|
|
|
|
|
*
|
|
|
|
|
* @param context
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* @return {@code true} if the provided context exists
|
|
|
|
|
* otherwise {@code false}
|
|
|
|
|
* */
|
|
|
|
|
protected boolean contextExists(UUID context) {
|
|
|
|
|
try {
|
|
|
|
|
return this.cclient.read(context) != null;
|
|
|
|
|
} catch (ResourceRegistryException e) {
|
|
|
|
|
logger.warn("Failed to query the Resource Registry: " + e.getMessage());
|
|
|
|
|
Context results = this.cclient.read(context);
|
|
|
|
|
return Objects.nonNull(results);
|
|
|
|
|
} catch (ContextNotFoundException e) {
|
|
|
|
|
logger.warn("Context not found: " + e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}catch (RuntimeException e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.warn("Failed to query the Resource Registry: " + e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|