Fixed context cache renew
This commit is contained in:
parent
88ef977959
commit
179013ec5b
|
@ -107,47 +107,59 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
|
||||||
|
|
||||||
private void addHierarchicalMode(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addHierarchicalMode(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
if(hierarchicalMode) {
|
if(hierarchicalMode) {
|
||||||
queryParams.put(AccessPath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(hierarchicalMode));
|
queryParams.put(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(hierarchicalMode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncludeContexts(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addIncludeContexts(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
if(includeContexts) {
|
if(includeContexts) {
|
||||||
queryParams.put(AccessPath.INCLUDE_CONTEXTS_QUERY_PARAMETER, Boolean.toString(includeContexts));
|
queryParams.put(InstancePath.INCLUDE_CONTEXTS_QUERY_PARAMETER, Boolean.toString(includeContexts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncludeMeta(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addIncludeMeta(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
|
addIncludeMeta(queryParams, includeMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIncludeMeta(Map<String,String> queryParams, boolean includeMeta) throws UnsupportedEncodingException{
|
||||||
if(includeMeta) {
|
if(includeMeta) {
|
||||||
queryParams.put(AccessPath.INCLUDE_META_QUERY_PARAMETER, Boolean.toString(includeMeta));
|
queryParams.put(InstancePath.INCLUDE_META_QUERY_PARAMETER, Boolean.toString(includeMeta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncludeAllMeta(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addIncludeAllMeta(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
if(allMeta) {
|
if(allMeta) {
|
||||||
queryParams.put(AccessPath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta));
|
queryParams.put(InstancePath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOffset(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addOffset(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
|
addOffset(queryParams, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOffset(Map<String,String> queryParams, Integer offset) throws UnsupportedEncodingException{
|
||||||
if(offset!=null) {
|
if(offset!=null) {
|
||||||
queryParams.put(AccessPath.OFFSET_QUERY_PARAMETER, offset.toString());
|
queryParams.put(InstancePath.OFFSET_QUERY_PARAMETER, offset.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLimit(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
private void addLimit(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||||
|
addLimit(queryParams, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addLimit(Map<String,String> queryParams, Integer limit) throws UnsupportedEncodingException{
|
||||||
if(limit!=null) {
|
if(limit!=null) {
|
||||||
queryParams.put(AccessPath.LIMIT_QUERY_PARAMETER, limit.toString());
|
queryParams.put(InstancePath.LIMIT_QUERY_PARAMETER, limit.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Context> renew() throws ResourceRegistryException {
|
public List<Context> renew() throws ResourceRegistryException {
|
||||||
return getContextsFromServer();
|
return getAllContextFromServer(true, 0, BaseRequestInfo.UNBOUNDED_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,16 +198,22 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
|
||||||
* @return All Contexts read from server
|
* @return All Contexts read from server
|
||||||
* @throws ResourceRegistryException
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
public List<Context> getContextsFromServer() throws ResourceRegistryException {
|
public List<Context> getAllContextFromServer() throws ResourceRegistryException {
|
||||||
|
return getAllContextFromServer(includeMeta, offset, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<Context> getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit) throws ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
logger.info("Going to read all {}s", Context.NAME);
|
logger.info("Going to read all {}s", Context.NAME);
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = getGXHTTPStringRequest();
|
GXHTTPStringRequest gxHTTPStringRequest = getGXHTTPStringRequest();
|
||||||
gxHTTPStringRequest.header(ACCEPT_HTTP_HEADER_KEY, GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
gxHTTPStringRequest.header(ACCEPT_HTTP_HEADER_KEY, GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||||
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||||
|
|
||||||
Map<String,String> parameters = new HashMap<>();
|
Map<String,String> parameters = new HashMap<>();
|
||||||
addIncludeMeta(parameters);
|
addIncludeMeta(parameters, includeMeta);
|
||||||
|
addOffset(parameters, offset);
|
||||||
|
addLimit(parameters, limit);
|
||||||
gxHTTPStringRequest.queryParams(parameters);
|
gxHTTPStringRequest.queryParams(parameters);
|
||||||
|
|
||||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
|
Loading…
Reference in New Issue