Removed force URL in factory

This commit is contained in:
Luca Frosini 2022-07-25 11:16:03 +02:00
parent 4ed56600d6
commit d7edafcd49
3 changed files with 7 additions and 19 deletions

View File

@ -26,21 +26,8 @@ public class ResourceRegistryQueryTemplateClientFactory {
return authorizationEntry.getContext();
}
private static String FORCED_URL = null;
protected static void forceToURL(String url){
FORCED_URL = url;
}
public static ResourceRegistryQueryTemplateClient create() {
String address = null;
if(FORCED_URL!=null){
address = FORCED_URL;
}else {
address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
}
String address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address);
return new ResourceRegistryQueryTemplateClientImpl(address);
}

View File

@ -80,10 +80,7 @@ public class ContextTest {
}
RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY);
if(RESOURCE_REGISTRY_URL!=null){
ResourceRegistryQueryTemplateClientFactory.forceToURL(RESOURCE_REGISTRY_URL);
}
}
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {

View File

@ -42,7 +42,11 @@ public class ResourceRegistryQueryTemplateClientTest extends ContextTest {
protected ResourceRegistryQueryTemplateClient resourceRegistryQueryTemplateClient;
public ResourceRegistryQueryTemplateClientTest() {
resourceRegistryQueryTemplateClient = ResourceRegistryQueryTemplateClientFactory.create();
if(ContextTest.RESOURCE_REGISTRY_URL !=null && !ContextTest.RESOURCE_REGISTRY_URL.isEmpty()) {
resourceRegistryQueryTemplateClient = new ResourceRegistryQueryTemplateClientImpl(ContextTest.RESOURCE_REGISTRY_URL);
}else {
resourceRegistryQueryTemplateClient = ResourceRegistryQueryTemplateClientFactory.create();
}
}
public static String getUser() {