Backported service instance predictive URL
This commit is contained in:
parent
c253696868
commit
aa501ed35d
|
@ -0,0 +1,27 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.api.rest;
|
||||||
|
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
public abstract class ServiceInstance {
|
||||||
|
|
||||||
|
private static final String PROD_ROOT_SCOPE = "/d4science.research-infrastructures.eu";
|
||||||
|
|
||||||
|
public static final String BASE_URL = "https://url.d4science.org";
|
||||||
|
|
||||||
|
public static String getServiceURL() {
|
||||||
|
String context = ScopeProvider.instance.get();
|
||||||
|
return getServiceURL(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getServiceURL(String context) {
|
||||||
|
if(context.startsWith(PROD_ROOT_SCOPE)) {
|
||||||
|
return BASE_URL;
|
||||||
|
}
|
||||||
|
String root = context.split("/")[1];
|
||||||
|
return BASE_URL.replace("url", "url." + root.replaceAll("\\.", "-"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue