diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
index 18194ffa01d1..81f7996557e0 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
@@ -11,7 +11,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java
index d229e7f4067d..3608867380bb 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java
+++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java
@@ -163,6 +163,8 @@ public enum ExceptionCodes implements ErrorHandler {
400, "Name of the gateway is read only"),
GATEWAY_ENVIRONMENT_VHOST_NOT_PROVIDED(900511, "Gateway Environment virtual hosts name not provided",
400, "Gateway Environment VHOST name not provided"),
+ INVALID_VHOST(900512, "Invalid virtual host name provided",
+ 400, "Virtual host with provided vhost name does not exist"),
// Workflow related codes
WORKFLOW_EXCEPTION(900550, "Workflow error", 500,
diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/VHost.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/VHost.java
index 482cb73dee5e..a726850d3bbd 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/VHost.java
+++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/VHost.java
@@ -27,12 +27,15 @@
* This class represent an Virtual Host
*/
public class VHost {
+ // host name from the http endpoint
private String host;
private String httpContext = "";
private Integer httpPort = -1;
private Integer httpsPort = -1;
private Integer wsPort = DEFAULT_WS_PORT;
+ private String wsHost;
private Integer wssPort = DEFAULT_WSS_PORT;
+ private String wssHost;
private Integer websubHttpPort = DEFAULT_WEBSUB_HTTP_PORT;
private Integer websubHttpsPort = DEFAULT_WEBSUB_HTTPS_PORT;
@@ -95,6 +98,14 @@ public void setWsPort(Integer wsPort) {
this.wsPort = wsPort;
}
+ public String getWsHost() {
+ return wsHost;
+ }
+
+ public void setWsHost(String wsHost) {
+ this.wsHost = wsHost;
+ }
+
public Integer getWssPort() {
return wssPort;
}
@@ -103,6 +114,14 @@ public void setWssPort(Integer wssPort) {
this.wssPort = wssPort;
}
+ public String getWssHost() {
+ return wssHost;
+ }
+
+ public void setWssHost(String wssHost) {
+ this.wssHost = wssHost;
+ }
+
public Integer getWebsubHttpPort() {
return websubHttpPort;
}
@@ -120,27 +139,27 @@ public void setWebsubHttpsPort(Integer websubHttpsPort) {
}
public String getHttpUrl() {
- return getUrl("http", httpPort == DEFAULT_HTTP_PORT ? "" : ":" + httpPort, httpContext);
+ return getUrl("http", host, httpPort == DEFAULT_HTTP_PORT ? "" : ":" + httpPort, httpContext);
}
public String getHttpsUrl() {
- return getUrl("https", httpsPort == DEFAULT_HTTPS_PORT ? "" : ":" + httpsPort, httpContext);
+ return getUrl("https", host, httpsPort == DEFAULT_HTTPS_PORT ? "" : ":" + httpsPort, httpContext);
}
public String getWsUrl() {
- return getUrl("ws", wsPort == DEFAULT_HTTP_PORT ? "" : ":" + wsPort, "");
+ return getUrl("ws", wsHost, wsPort == DEFAULT_HTTP_PORT ? "" : ":" + wsPort, "");
}
public String getWssUrl() {
- return getUrl("wss", wssPort == DEFAULT_HTTPS_PORT ? "" : ":" + wssPort, "");
+ return getUrl("wss", wssHost, wssPort == DEFAULT_HTTPS_PORT ? "" : ":" + wssPort, "");
}
- private String getUrl(String protocol, String port, String context) {
+ private String getUrl(String protocol, String hostName, String port, String context) {
// {protocol}://{host}{port}{context}
if (StringUtils.isNotEmpty(context) && !context.startsWith("/")) {
context = "/" + context;
}
- return String.format("%s://%s%s%s", protocol, host, port, context);
+ return String.format("%s://%s%s%s", protocol, hostName, port, context);
}
public static VHost fromEndpointUrls(String[] endpoints) throws APIManagementException {
@@ -178,11 +197,13 @@ public static VHost fromEndpointUrls(String[] endpoints) throws APIManagementExc
// URL is not parsing for wss protocols, hence change to https
url = new URL(HTTPS_PROTOCOL + PROTOCOL_SEPARATOR + elem[1]);
vhost.setWssPort(url.getPort() < 0 ? DEFAULT_WSS_PORT : url.getPort());
+ vhost.setWssHost(url.getHost());
break;
case WS_PROTOCOL:
// URL is not parsing for ws protocols, hence change to http
url = new URL(HTTP_PROTOCOL + PROTOCOL_SEPARATOR + elem[1]);
vhost.setWsPort(url.getPort() < 0 ? DEFAULT_WS_PORT : url.getPort());
+ vhost.setWsHost(url.getHost());
break;
case WEBSUB_HTTP_PROTOCOL:
url = new URL(HTTP_PROTOCOL + PROTOCOL_SEPARATOR + elem[1]);
@@ -203,6 +224,14 @@ public static VHost fromEndpointUrls(String[] endpoints) throws APIManagementExc
throw new APIManagementException("Error while building VHost, missing required HTTP or HTTPS endpoint");
}
+ // If WebSocket host name of Vhost is empty, use HTTP/HTTPS endpoint hostname
+ if ((vhost.getWsHost() == null) || (StringUtils.isEmpty(vhost.getWsHost()))) {
+ vhost.setWsHost(vhost.getHost());
+ }
+ if ((vhost.getWssHost() == null) || (StringUtils.isEmpty(vhost.getWssHost()))) {
+ vhost.setWssHost(vhost.getHost());
+ }
+
return vhost;
}
diff --git a/components/apimgt/org.wso2.carbon.apimgt.broker.lifecycle/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.broker.lifecycle/pom.xml
index ab5e3779b77c..da0962c2eed5 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.broker.lifecycle/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.broker.lifecycle/pom.xml
@@ -4,7 +4,7 @@
apimgt
org.wso2.carbon.apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.cache.invalidation/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.cache.invalidation/pom.xml
index df07243a8f40..958afea8c5a7 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.cache.invalidation/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.cache.invalidation/pom.xml
@@ -19,7 +19,7 @@
apimgt
org.wso2.carbon.apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
4.0.0
diff --git a/components/apimgt/org.wso2.carbon.apimgt.cleanup.service/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.cleanup.service/pom.xml
index dec9a7a283ff..f1c7e0ccbba1 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.cleanup.service/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.cleanup.service/pom.xml
@@ -19,7 +19,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.common.analytics/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.common.analytics/pom.xml
index 90b70df7d32d..1ee5147d2387 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.common.analytics/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.common.analytics/pom.xml
@@ -3,7 +3,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
4.0.0
diff --git a/components/apimgt/org.wso2.carbon.apimgt.common.gateway/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.common.gateway/pom.xml
index 0e351975f756..74d11cf905b3 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.common.gateway/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.common.gateway/pom.xml
@@ -3,7 +3,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
4.0.0
diff --git a/components/apimgt/org.wso2.carbon.apimgt.common.jms/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.common.jms/pom.xml
index 7777977ba84b..e1094b940933 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.common.jms/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.common.jms/pom.xml
@@ -4,7 +4,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
4.0.0
diff --git a/components/apimgt/org.wso2.carbon.apimgt.core/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.core/pom.xml
index 7c53c0e5398e..7e326d7e7230 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.core/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.core/pom.xml
@@ -5,7 +5,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.devops.impl/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.devops.impl/pom.xml
index 71e0f5578f35..4cf37eb17c2c 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.devops.impl/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.devops.impl/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.eventing.hub/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.eventing.hub/pom.xml
index 76bbec3a12a4..eea8d9639cc9 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.eventing.hub/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.eventing.hub/pom.xml
@@ -20,7 +20,7 @@
apimgt
org.wso2.carbon.apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml
index 03b508e16fe7..54a861dfbf60 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml
@@ -20,7 +20,7 @@
apimgt
org.wso2.carbon.apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
index b5cfe106d545..328e082749db 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
+++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
@@ -19,7 +19,7 @@
org.wso2.carbon.apimgt
apimgt
- 9.28.152-SNAPSHOT
+ 9.28.154-SNAPSHOT
../pom.xml
diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APILoggerManager.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APILoggerManager.java
index 91e6e93a8e5a..8133bfeca1d0 100644
--- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APILoggerManager.java
+++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APILoggerManager.java
@@ -21,9 +21,8 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
@@ -49,8 +48,6 @@ public class APILoggerManager {
private Map