diff options
Diffstat (limited to 'apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java')
-rw-r--r-- | apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java index ae60f50..5f9557f 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/RouteUtil.java @@ -294,14 +294,24 @@ public class RouteUtil { * @return * @return String */ - public static String getRouteNameByns(String consul_serviceName, String namespace) { + public static String getRouteNameByns(String consul_serviceName, String version, String namespace) { String serviceName = consul_serviceName; - if (StringUtils.isNotBlank(namespace)) { + // Remove version and namespace from consul service name + // Consul_serviceName Format: serviceName-version-namespace + if (StringUtils.isNotBlank(version) && StringUtils.isNotBlank(namespace)) { + if (consul_serviceName.endsWith("-" + version + "-" + namespace)) { + serviceName = consul_serviceName.substring(0, + consul_serviceName.length() - version.length() - namespace.length() - 2); + } + } else if (StringUtils.isNotBlank(version)) { + if (consul_serviceName.endsWith("-" + version)) { + serviceName = consul_serviceName.substring(0, consul_serviceName.length() - version.length() - 1); + } + } else if (StringUtils.isNotBlank(namespace)) { if (consul_serviceName.endsWith("-" + namespace)) { serviceName = consul_serviceName.substring(0, consul_serviceName.length() - namespace.length() - 1); } } - return serviceName; } |