Skip to content

Commit

Permalink
Merge branch 'wso2:master' into resource_lvl_logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shnrndk authored Jul 19, 2023
2 parents c824e59 + 7c1c1c7 commit 23a7904
Show file tree
Hide file tree
Showing 172 changed files with 3,969 additions and 20,883 deletions.
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ public class APIConstants {
public static final String ENDPOINT_SECURITY = "endpoint_security";
public static final String ENDPOINT_SECURITY_PRODUCTION = "production";
public static final String ENDPOINT_SECURITY_SANDBOX = "sandbox";
public static final String ENDPOINT_CONFIG_SESSION_TIMEOUT = "sessionTimeOut";
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum ExceptionCodes implements ErrorHandler {

API_PRODUCT_CONTEXT_ALREADY_EXISTS(900275, "The API Product context already exists.", 409, "An API Product with context '%s' already exists"),

API_CONTEXT_MALFORMED_EXCEPTION(900253, "The API context is malformed.", 400, "'%s'"),
API_ALREADY_EXISTS(900300, "The API already exists.", 409, "The API already exists"),
APPLICATION_ALREADY_EXISTS(900301, "The application already exists.", 409, "The application already exists"),
APIMGT_DAO_EXCEPTION(900302, "Internal server error.", 500, "Error occurred while persisting/retrieving data"),
Expand Down Expand Up @@ -115,6 +116,7 @@ public enum ExceptionCodes implements ErrorHandler {
API_OR_API_PRODUCT_NOT_FOUND(900359, "API or API Product Not Found", 404, "Requested API or API Product with id '%s' not found"),
API_PRODUCT_NOT_FOUND(900360, "API Product Not Found", 404, "Requested API Product with id '%s' not found"),
SUB_ORGANIZATION_NOT_IDENTIFIED(900361, "User's Organization Not Identified", 403, "User's Organization is not identified"),
ERROR_WHILE_UPDATING_MANDATORY_PROPERTIES(903010, "Error while updating required properties", 400, "Error while updating required properties."),

//Lifecycle related codes
API_UPDATE_FORBIDDEN_PER_LC(900380, "Insufficient permission to update the API", 403,
Expand Down Expand Up @@ -163,6 +165,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,
Expand Down Expand Up @@ -504,28 +508,28 @@ public enum ExceptionCodes implements ErrorHandler {
INVALID_TENANT_CONFIG(902001, "Invalid tenant-config found", 400, "Invalid tenant-config found with error %s", false),

//Operation Policies related error codes
INVALID_OPERATION_POLICY(902005, "Cannot find the selected operation policy", 400,
"Selected operation policy is not found"),
INVALID_OPERATION_POLICY_SPECIFICATION(902006, "Invalid operation policy specification found", 400,
"Invalid operation policy specification. %s", false),

INVALID_OPERATION_POLICY_PARAMETERS(902007, "Missing required parameters for operation policy specification", 400,
"Required parameter(s) %s for operation policy specification %s are either missing or empty"),
OPERATION_POLICY_NOT_ALLOWED_IN_THE_APPLIED_FLOW(902008, "Operation policy is not allowed in the applied flow", 400,
INVALID_OPERATION_POLICY(902005, "Cannot find the selected api policy", 400,
"Selected api policy is not found"),
INVALID_OPERATION_POLICY_SPECIFICATION(902006, "Invalid api policy specification found", 400,
"Invalid api policy specification. %s", false),

INVALID_OPERATION_POLICY_PARAMETERS(902007, "Missing required parameters for api policy specification", 400,
"Required parameter(s) %s for api policy specification %s are either missing or empty"),
OPERATION_POLICY_NOT_ALLOWED_IN_THE_APPLIED_FLOW(902008, "API policy is not allowed in the applied flow", 400,
"%s policy is not allowed in response flow"),
MISSING_MANDATORY_POLICY_ATTRIBUTES(902009, "Missing mandatory operation policy attribute", 400,
"Required attributes(s) %s for operation policy specification %s are either missing or empty"),
OPERATION_POLICY_NOT_FOUND(902010, "Operation Policy Not Found", 404,
"Requested operation policy with id '%s' not found"),
MISSING_MANDATORY_POLICY_ATTRIBUTES(902009, "Missing mandatory api policy attribute", 400,
"Required attributes(s) %s for api policy specification %s are either missing or empty"),
OPERATION_POLICY_NOT_FOUND(902010, "API Policy Not Found", 404,
"Requested api policy with id '%s' not found"),

OPERATION_POLICY_ALREADY_EXISTS(903001, "The Operation Policy already exists.", 409, "An Operation Policy with name '%s' and version '%s' already exists"),
OPERATION_POLICY_ALREADY_EXISTS(903001, "The API Policy already exists.", 409, "An Operation Policy with name '%s' and version '%s' already exists"),

OPERATION_POLICY_NOT_FOUND_WITH_NAME_AND_VERSION(903004, "Operation Policy Not Found with given name and version", 404,
"Requested operation policy with name '%s' and version '%s not found"),
OPERATION_POLICY_NOT_FOUND_WITH_NAME_AND_VERSION(903004, "API Policy Not Found with given name and version", 404,
"Requested api policy with name '%s' and version '%s not found"),

OPERATION_POLICY_GATEWAY_ERROR(903008,
"Either Synapse or Choreo Gateway Definition files or both should be present", 400,
"Operation Policy cannot be imported due to the missing Gateway files."),
"API Policy cannot be imported due to the missing Gateway files."),
ERROR_VALIDATING_API_POLICY(902011, "Error while validating API policies enforced for the API", 400,
"Error while validating the API policies enforced for the API"),

Expand All @@ -535,7 +539,9 @@ public enum ExceptionCodes implements ErrorHandler {
INTERNAL_SERVER_ERROR_FROM_KEY_MANAGER(902004, "Internal Server Error from Key Manager", 500, "Internal Server Error from Key Manager.Error from Backend : %s", true),
REVISION_ALREADY_DEPLOYED(902005, "Revision deployment state conflicted", 409,
"Revision deployment request conflicted with the current deployment state of the revision %s. Please try again later", false),
INVALID_API_ID(902006, "Invalid API ID", 404, "The provided API ID is not found %s", false);
INVALID_API_ID(902006, "Invalid API ID", 404, "The provided API ID is not found %s", false),
INVALID_ENDPOINT_CONFIG(902012, "Endpoint config value(s) is(are) not valid", 400, "Endpoint config value(s) is(are) not valid"),
ARTIFACT_SYNC_HTTP_REQUEST_FAILED(903009, "Error while retrieving from remote endpoint", 500, "Error while executing HTTP request to retrieve from remote endpoint");

private final long errorCode;
private final String errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,32 @@ public String getEndpointConfig() {
}

public void setEndpointConfig(String endpointConfig) {
try {
if (endpointConfig != null && endpointConfig.contains(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT)) {
JSONParser parser = new JSONParser();
ObjectMapper objectMapper = new ObjectMapper();
JSONObject endpointConfigJson = (JSONObject) parser.parse(endpointConfig);

if (endpointConfigJson.containsKey(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT)) {
Object value = endpointConfigJson.get(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT);
if (value instanceof Integer) {
String strVal = value.toString();
endpointConfigJson.put(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT, strVal);
} else if (value instanceof Double) {
String strVal = String.valueOf(((Double) value).intValue());
endpointConfigJson.put(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT, strVal);
} else if (value instanceof String) {
if (((String) value).contains(".")) {
String strVal = String.valueOf(((String) value).split("\\.")[0]);
endpointConfigJson.put(APIConstants.ENDPOINT_CONFIG_SESSION_TIMEOUT, strVal);
}
}
endpointConfig = endpointConfigJson.toString();
}
}
} catch (ParseException e) {
log.error("Error while modifying sessionTimeout config for API : " + getUUID(), e);
}
this.endpointConfig = endpointConfig;
}

Expand Down Expand Up @@ -1437,4 +1463,14 @@ public String getAsyncTransportProtocols() {
public void setAsyncTransportProtocols(String asyncTransportProtocols) {
this.asyncTransportProtocols = asyncTransportProtocols;
}

public List<OperationPolicy> apiPolicies;

public List<OperationPolicy> getApiPolicies() {
return apiPolicies;
}

public void setApiPolicies(List<OperationPolicy> apiPolicies) {
this.apiPolicies = apiPolicies;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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]);
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
public class CommonAPIUtil {
public static final String STRICT = "Strict";
public static final String ALLOW_ALL = "AllowAll";
public static final String DEFAULT_AND_LOCALHOST = "DefaultAndLocalhost";
public static final String HOST_NAME_VERIFIER = "httpclient.hostnameVerifier";
public static final String HTTPS_PROTOCOL = "https";
public static final String HTTP_PROTOCOL = "http";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
7 changes: 6 additions & 1 deletion components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.28.126-SNAPSHOT</version>
<version>9.28.158-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -168,6 +168,10 @@
<groupId>org.wso2.carbon.mediation</groupId>
<artifactId>org.wso2.carbon.rest.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.mediation</groupId>
<artifactId>org.wso2.carbon.application.mgt.synapse</artifactId>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
Expand Down Expand Up @@ -463,6 +467,7 @@
org.wso2.carbon.sequences.stub.types,
org.wso2.carbon.localentry.stub.*,
org.wso2.carbon.context,
org.wso2.carbon.application.mgt.synapse.*; version="${carbon.mediation.imp.pkg.version}",
org.wso2.carbon.mediation.*; version="${carbon.mediation.imp.pkg.version}",
org.wso2.carbon.apimgt.tracing.*; version="${carbon.apimgt.imp.pkg.version}",
org.wso2.orbit.re2j.*; version="${re2j.version}",
Expand Down
Loading

0 comments on commit 23a7904

Please sign in to comment.