|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|
|
|
|
import org.gcube.common.gxhttp.reference.GXConnection;
|
|
|
|
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
|
|
|
|
import org.gcube.informationsystem.base.reference.Element;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
|
|
|
@ -76,6 +77,45 @@ public class ResourceRegistrySchemaClientImpl implements ResourceRegistrySchemaC
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <E extends Element> boolean exist(Class<E> clz) throws ResourceRegistryException {
|
|
|
|
|
try {
|
|
|
|
|
String typeName = Utility.getTypeName(clz);
|
|
|
|
|
return exist(typeName);
|
|
|
|
|
} catch(ResourceRegistryException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean exist(String typeName) throws ResourceRegistryException {
|
|
|
|
|
try {
|
|
|
|
|
logger.info("Going to get {} schema", typeName);
|
|
|
|
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
|
|
|
|
gxHTTPStringRequest.from(ResourceRegistrySchemaClient.class.getSimpleName());
|
|
|
|
|
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
|
|
|
|
gxHTTPStringRequest.path(TypePath.TYPES_PATH_PART);
|
|
|
|
|
gxHTTPStringRequest.path(typeName);
|
|
|
|
|
|
|
|
|
|
Map<String,String> parameters = new HashMap<>();
|
|
|
|
|
parameters.put(TypePath.POLYMORPHIC_PARAM, Boolean.FALSE.toString());
|
|
|
|
|
gxHTTPStringRequest.queryParams(parameters);
|
|
|
|
|
|
|
|
|
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
|
|
|
|
HTTPUtility.getResponse(String.class, httpURLConnection);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
|
return false;
|
|
|
|
|
} catch(ResourceRegistryException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <E extends Element> List<Type> read(Class<E> clz, Boolean polymorphic)
|
|
|
|
|