Upgraded version
This commit is contained in:
parent
d651f8251e
commit
5477715aa1
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-client</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<name>Resource Registry Client</name>
|
||||
<description>Resource Registry Client is a library designed to interact with idempotent Resource Registry APIs</description>
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.gcube.informationsystem.resourceregistry.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
|
@ -24,28 +22,27 @@ public class ResourceRegistryClientFactory {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryClientFactory.class);
|
||||
|
||||
protected static Map<String, ResourceRegistryClient> clients;
|
||||
protected static boolean HIERARCHICAL_MODE;
|
||||
|
||||
protected static List<String> addresses;
|
||||
protected static boolean hierarchicalMode;
|
||||
|
||||
public static boolean isHierarchicalMode() {
|
||||
return ResourceRegistryClientFactory.hierarchicalMode;
|
||||
return ResourceRegistryClientFactory.HIERARCHICAL_MODE;
|
||||
}
|
||||
|
||||
public static void setHierarchicalMode(boolean hierarchicalMode) {
|
||||
ResourceRegistryClientFactory.hierarchicalMode = hierarchicalMode;
|
||||
ResourceRegistryClientFactory.HIERARCHICAL_MODE = hierarchicalMode;
|
||||
}
|
||||
|
||||
|
||||
protected static List<String> addresses;
|
||||
|
||||
static {
|
||||
clients = new HashMap<>();
|
||||
addresses = new ArrayList<>();
|
||||
}
|
||||
|
||||
private static String FORCED_URL = null;
|
||||
|
||||
protected static void forceToURL(String url){
|
||||
FORCED_URL = url;
|
||||
hierarchicalMode = false;
|
||||
HIERARCHICAL_MODE = false;
|
||||
}
|
||||
|
||||
private static String classFormat = "$resource/Profile/ServiceClass/text() eq '%1s'";
|
||||
|
@ -108,8 +105,6 @@ public class ResourceRegistryClientFactory {
|
|||
return addresses;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static ResourceRegistryClient create() {
|
||||
String address = null;
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
|
||||
protected final String address;
|
||||
|
||||
public ResourceRegistryClientImpl(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
private void checkHierarchicalMode(GXHTTPStringRequest gxHTTPStringRequest) throws UnsupportedEncodingException{
|
||||
checkHierarchicalMode(gxHTTPStringRequest, null);
|
||||
}
|
||||
|
@ -62,6 +58,21 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
gxHTTPStringRequest.queryParams(queryParams);
|
||||
}
|
||||
|
||||
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
|
||||
@Override
|
||||
public List<Context> renew() throws ResourceRegistryException {
|
||||
return getAllContextFromServer();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public ResourceRegistryClientImpl(String address) {
|
||||
this.address = address;
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
contextCache.setContextCacheRenewal(contextCacheRenewal);
|
||||
}
|
||||
|
||||
public List<Context> getAllContextFromServer() throws ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to read all {}s", Context.NAME);
|
||||
|
@ -92,16 +103,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
|
||||
@Override
|
||||
public List<Context> getAllContext() throws ResourceRegistryException {
|
||||
ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
|
||||
@Override
|
||||
public List<Context> renew() throws ResourceRegistryException {
|
||||
return getAllContextFromServer();
|
||||
}
|
||||
|
||||
};
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
contextCache.setContextCacheRenewal(contextCacheRenewal);
|
||||
return contextCache.getContexts();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue