Rationalised code
This commit is contained in:
parent
ad84724a3d
commit
3ea46fbac1
|
@ -60,66 +60,6 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
gxHTTPStringRequest.queryParams(queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get current {} ", Context.NAME);
|
||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||
gxHTTPStringRequest.path(AccessPath.CURRENT_CONTEXT);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||
|
||||
logger.debug("Got Context is {}", ElementMapper.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString());
|
||||
|
||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||
gxHTTPStringRequest.path(uuid.toString());
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||
|
||||
logger.debug("Got Context is {}", ElementMapper.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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Context> getAllContext() throws ContextNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
|
@ -148,6 +88,44 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
}
|
||||
}
|
||||
|
||||
protected Context getContext(String id) throws ContextNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get current {} ", Context.NAME);
|
||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||
gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName());
|
||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||
gxHTTPStringRequest.path(id);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||
|
||||
logger.debug("Got Context is {}", ElementMapper.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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
|
||||
return getContext(uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException {
|
||||
return getContext(AccessPath.CURRENT_CONTEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Element> List<Type> getSchema(Class<E> clazz, Boolean polymorphic)
|
||||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
|
|
Loading…
Reference in New Issue