2016-10-18 10:52:05 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2017-04-03 18:44:47 +02:00
|
|
|
package org.gcube.informationsystem.resourceregistry.client;
|
2016-10-18 10:52:05 +02:00
|
|
|
|
|
|
|
import java.io.StringWriter;
|
2017-04-03 18:44:47 +02:00
|
|
|
import java.net.MalformedURLException;
|
2017-02-24 11:00:12 +01:00
|
|
|
import java.util.HashMap;
|
2016-10-18 10:52:05 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2017-01-30 11:43:18 +01:00
|
|
|
import org.gcube.informationsystem.impl.utils.ISMapper;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.model.ER;
|
2017-01-25 15:34:53 +01:00
|
|
|
import org.gcube.informationsystem.model.ISManageable;
|
2017-11-07 18:45:36 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.Context;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.Entity;
|
2017-11-02 14:42:31 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.Facet;
|
2017-01-13 17:57:33 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.Resource;
|
2017-11-02 14:42:31 +01:00
|
|
|
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
2016-10-18 10:52:05 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
2017-11-07 18:45:36 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
2017-04-06 15:05:14 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
2016-10-18 10:52:05 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
2017-02-24 11:00:12 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
2017-11-02 14:42:31 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.utils.Utility;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.types.TypeBinder;
|
|
|
|
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
2016-10-18 10:52:05 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
|
|
|
public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|
|
|
|
2017-04-06 15:05:14 +02:00
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryClientImpl.class);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2016-10-18 10:52:05 +02:00
|
|
|
public static final String PATH_SEPARATOR = "/";
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
protected final String address;
|
2017-04-06 15:05:14 +02:00
|
|
|
protected HTTPCall httpCall;
|
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
public ResourceRegistryClientImpl(String address) {
|
|
|
|
this.address = address;
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
private HTTPCall getHTTPCall() throws MalformedURLException {
|
2017-04-06 15:05:14 +02:00
|
|
|
if (httpCall == null) {
|
2017-04-03 18:44:47 +02:00
|
|
|
httpCall = new HTTPCall(address, ResourceRegistryClient.class.getSimpleName());
|
|
|
|
}
|
|
|
|
return httpCall;
|
|
|
|
}
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-03-28 16:00:55 +02:00
|
|
|
@Override
|
|
|
|
public <ERType extends ER> void exists(Class<ERType> clazz, UUID uuid)
|
2017-04-06 15:05:14 +02:00
|
|
|
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
|
2017-11-02 14:42:31 +01:00
|
|
|
String type = Utility.getType(clazz);
|
2017-03-28 16:00:55 +02:00
|
|
|
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());
|
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
|
|
|
httpCall.call(clazz, stringWriter.toString(), HTTPMETHOD.HEAD);
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
logger.debug("{} with UUID {} exists", type, uuid);
|
2017-03-28 16:00:55 +02:00
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while checking if {} with UUID {} exists.", type, uuid,
|
|
|
|
// e);
|
2017-03-28 16:00:55 +02:00
|
|
|
throw e;
|
|
|
|
} catch (Exception e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while checking if {} with UUID {} exists.", type, uuid,
|
|
|
|
// e);
|
2017-04-03 18:44:47 +02:00
|
|
|
throw new RuntimeException(e);
|
2017-03-28 16:00:55 +02:00
|
|
|
}
|
|
|
|
}
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2016-10-18 10:52:05 +02:00
|
|
|
@Override
|
2017-01-12 16:39:53 +01:00
|
|
|
public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid)
|
2017-04-06 15:05:14 +02:00
|
|
|
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
|
2017-11-02 14:42:31 +01:00
|
|
|
String type = Utility.getType(clazz);
|
2016-10-18 10:52:05 +02:00
|
|
|
try {
|
2017-01-12 16:39:53 +01:00
|
|
|
logger.info("Going to get {} with UUID {}", type, uuid);
|
2016-10-18 10:52:05 +02:00
|
|
|
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);
|
2017-01-12 16:39:53 +01:00
|
|
|
stringWriter.append(type);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2016-10-18 10:52:05 +02:00
|
|
|
stringWriter.append(uuid.toString());
|
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
2017-04-06 15:05:14 +02:00
|
|
|
ERType erType = httpCall.call(clazz, stringWriter.toString(), HTTPMETHOD.GET);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
logger.debug("Got {} with UUID {} is {}", type, uuid, erType);
|
2017-01-12 16:39:53 +01:00
|
|
|
return erType;
|
2017-02-24 11:36:22 +01:00
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {} with UUID {}", type, uuid, e);
|
2017-02-24 11:36:22 +01:00
|
|
|
throw e;
|
2016-10-18 10:52:05 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {} with UUID {}", type, uuid, e);
|
2017-04-03 18:44:47 +02:00
|
|
|
throw new RuntimeException(e);
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-04-06 15:05:14 +02:00
|
|
|
public List<? extends Entity> getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
|
2016-10-18 10:52:05 +02:00
|
|
|
try {
|
2017-01-12 16:39:53 +01:00
|
|
|
logger.info("Going to get all instances of {} ", type);
|
2016-10-18 10:52:05 +02:00
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2017-01-13 18:19:48 +01:00
|
|
|
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
2016-10-18 10:52:05 +02:00
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2017-01-12 16:39:53 +01:00
|
|
|
stringWriter.append(type);
|
|
|
|
|
2017-02-24 11:00:12 +01:00
|
|
|
Map<String, String> parameters = new HashMap<>();
|
|
|
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
2017-04-06 15:05:14 +02:00
|
|
|
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
logger.debug("Got instances of {} are {}", type, ret);
|
2017-01-30 11:43:18 +01:00
|
|
|
return ISMapper.unmarshalList(Entity.class, ret);
|
2017-02-24 11:36:22 +01:00
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {} instances", type, e);
|
2017-02-24 11:36:22 +01:00
|
|
|
throw e;
|
2016-10-18 10:52:05 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {} instances", type, e);
|
2017-04-03 18:44:47 +02:00
|
|
|
throw new RuntimeException(e);
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-04-06 15:05:14 +02:00
|
|
|
public List<Resource> getInstancesFromEntity(String relationType, Boolean polymorphic, UUID reference,
|
2017-02-24 12:01:33 +01:00
|
|
|
Direction direction) throws ResourceRegistryException {
|
2016-10-18 10:52:05 +02:00
|
|
|
try {
|
2017-04-06 15:05:14 +02:00
|
|
|
logger.info("Going to get all instances of {} from/to {}", relationType, reference.toString());
|
2016-10-18 10:52:05 +02:00
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2017-01-13 18:19:48 +01:00
|
|
|
stringWriter.append(AccessPath.INSTANCES_PATH_PART);
|
2016-10-18 10:52:05 +02:00
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2017-01-13 18:19:48 +01:00
|
|
|
stringWriter.append(relationType);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-02-24 11:00:12 +01:00
|
|
|
Map<String, String> parameters = new HashMap<>();
|
|
|
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
|
|
|
parameters.put(AccessPath.REFERENCE, reference.toString());
|
|
|
|
parameters.put(AccessPath.DIRECTION, direction.toString());
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
|
|
|
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-06 15:05:14 +02:00
|
|
|
logger.debug("Got instances of {} from/to {} are {}", relationType, reference.toString(), ret);
|
2017-01-30 11:43:18 +01:00
|
|
|
return ISMapper.unmarshalList(Resource.class, ret);
|
2017-02-24 11:36:22 +01:00
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting instances of {} from/to {}", relationType,
|
|
|
|
// e);
|
2017-02-24 11:36:22 +01:00
|
|
|
throw e;
|
2016-10-18 10:52:05 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting instances of {} from/to {}", relationType,
|
|
|
|
// e);
|
2017-04-03 18:44:47 +02:00
|
|
|
throw new RuntimeException(e);
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-04-06 15:05:14 +02:00
|
|
|
public <ISM extends ISManageable> List<TypeDefinition> getSchema(Class<ISM> clazz, Boolean polymorphic)
|
2017-02-24 12:01:33 +01:00
|
|
|
throws SchemaNotFoundException, ResourceRegistryException {
|
2017-11-02 14:42:31 +01:00
|
|
|
String type = Utility.getType(clazz);
|
2016-10-18 10:52:05 +02:00
|
|
|
try {
|
2017-01-12 16:39:53 +01:00
|
|
|
logger.info("Going to get {} schema", type);
|
2016-10-18 10:52:05 +02:00
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.SCHEMA_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
2017-01-12 16:39:53 +01:00
|
|
|
stringWriter.append(type);
|
2016-10-18 10:52:05 +02:00
|
|
|
|
2017-02-24 11:00:12 +01:00
|
|
|
Map<String, String> parameters = new HashMap<>();
|
|
|
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
2017-11-02 14:42:31 +01:00
|
|
|
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
2017-01-12 16:39:53 +01:00
|
|
|
|
2017-11-02 14:42:31 +01:00
|
|
|
logger.debug("Got schema for {} is {}", type, json);
|
|
|
|
return TypeBinder.deserializeTypeDefinitions(json);
|
2017-02-24 12:01:33 +01:00
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {} schema for {}", polymorphic ?
|
|
|
|
// AccessPath.POLYMORPHIC_PARAM + " " : "",
|
|
|
|
// type, e);
|
2017-02-24 11:36:22 +01:00
|
|
|
throw e;
|
2016-10-18 10:52:05 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while getting {}schema for {}", polymorphic ?
|
|
|
|
// AccessPath.POLYMORPHIC_PARAM + " " : "",
|
|
|
|
// type, e);
|
2017-04-03 18:44:47 +02:00
|
|
|
throw new RuntimeException(e);
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String query(String query, int limit, String fetchPlan)
|
2017-04-03 18:44:47 +02:00
|
|
|
throws InvalidQueryException, ResourceRegistryException {
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
try {
|
2017-04-18 10:54:18 +02:00
|
|
|
logger.info("Going to query. {}", query);
|
2017-04-03 18:44:47 +02:00
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
Map<String, String> parameters = new HashMap<>();
|
|
|
|
parameters.put(AccessPath.QUERY_PARAM, query);
|
2017-04-06 15:05:14 +02:00
|
|
|
if (limit <= 0) {
|
2017-04-11 15:23:27 +02:00
|
|
|
limit = AccessPath.UNBOUNDED;
|
2017-04-03 18:44:47 +02:00
|
|
|
}
|
|
|
|
parameters.put(AccessPath.LIMIT_PARAM, Integer.toString(limit));
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
if (fetchPlan != null) {
|
|
|
|
parameters.put(AccessPath.FETCH_PLAN_PARAM, fetchPlan);
|
|
|
|
}
|
2017-04-06 15:05:14 +02:00
|
|
|
|
2017-04-03 18:44:47 +02:00
|
|
|
HTTPCall httpCall = getHTTPCall();
|
|
|
|
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
|
|
|
|
|
|
|
logger.debug("Query result is {}", ret);
|
|
|
|
return ret;
|
|
|
|
} catch (ResourceRegistryException e) {
|
2017-11-02 14:42:31 +01:00
|
|
|
// logger.trace("Error while querying", e);
|
|
|
|
throw e;
|
|
|
|
} catch (Exception e) {
|
|
|
|
// logger.trace("Error while querying", e);
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public <R extends Resource> List<R> getFilteredResources(Class<R> resourceClass,
|
|
|
|
@SuppressWarnings("rawtypes") Class<? extends ConsistsOf> consistsOfClass, Class<? extends Facet> facetClass,
|
|
|
|
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException {
|
|
|
|
String resourceType = Utility.getType(resourceClass);
|
|
|
|
String consistsOfType = Utility.getType(consistsOfClass);
|
|
|
|
String facetType = Utility.getType(facetClass);
|
|
|
|
return (List<R>) getFilteredResources(resourceType, consistsOfType, facetType, polymorphic, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Resource> getFilteredResources(String resourceType, String consistsOfType, String facetType,
|
|
|
|
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException {
|
|
|
|
try {
|
|
|
|
logger.info("Going to get Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
|
|
|
|
+ " having {}", resourceType, consistsOfType, facetType, map);
|
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.RESOURCE_INSTANCES_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(resourceType);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(consistsOfType);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(facetType);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
|
|
|
|
Map<String, Object> parameters = new HashMap<>(map);
|
|
|
|
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic);
|
|
|
|
|
|
|
|
HTTPCall httpCall = getHTTPCall();
|
|
|
|
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
|
|
|
|
|
|
|
|
logger.info("Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
|
|
|
|
+ " having {} are : {}", resourceType, consistsOfType, facetType, map, json);
|
|
|
|
return ISMapper.unmarshalList(Resource.class, json);
|
|
|
|
} catch (ResourceRegistryException e) {
|
2017-04-03 18:44:47 +02:00
|
|
|
throw e;
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
2016-10-18 10:52:05 +02:00
|
|
|
}
|
2017-11-07 18:45:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Context getContext(UUID uuid)
|
|
|
|
throws ContextNotFoundException, ResourceRegistryException {
|
|
|
|
try {
|
|
|
|
logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString());
|
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.ACCESS_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(AccessPath.CONTEXT_PATH_PART);
|
|
|
|
stringWriter.append(PATH_SEPARATOR);
|
|
|
|
stringWriter.append(uuid.toString());
|
|
|
|
|
|
|
|
HTTPCall httpCall = getHTTPCall();
|
|
|
|
Context context = httpCall.call(Context.class, stringWriter.toString(), HTTPMETHOD.GET);
|
|
|
|
|
|
|
|
logger.debug("Got Context is {}", ISMapper.marshal(context));
|
|
|
|
return context;
|
|
|
|
} catch (ResourceRegistryException e) {
|
|
|
|
// logger.trace("Error while getting {} schema for {}", polymorphic ?
|
|
|
|
// AccessPath.POLYMORPHIC_PARAM + " " : "",
|
|
|
|
// type, e);
|
|
|
|
throw e;
|
|
|
|
} catch (Exception e) {
|
|
|
|
// logger.trace("Error while getting {}schema for {}", polymorphic ?
|
|
|
|
// AccessPath.POLYMORPHIC_PARAM + " " : "",
|
|
|
|
// type, e);
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
2016-10-18 10:52:05 +02:00
|
|
|
|
|
|
|
}
|