diff --git a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java index 4058874e53..1cd9c79446 100644 --- a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java +++ b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java @@ -626,4 +626,101 @@ public enum ENDPOINT_TIMEOUT_TYPE { ENDPOINT_TIMEOUT, GLOBAL_TIMEOUT, HTTP_CONNE public static final String ANALYTICS_METADATA = "ANALYTICS_METADATA"; + // Constants for the HTTP Connection + public static final String ENDPOINT_IDENTIFIER = "ep"; + public static final String BASIC_AUTH = "Basic Auth"; + public static final String OAUTH = "OAuth"; + public static final String OAUTH_GRANT_TYPE_AUTHORIZATION_CODE = "Authorization Code"; + public static final String OAUTH_GRANT_TYPE_CLIENT_CREDENTIALS = "Client Credentials"; + public static final String OAUTH_GRANT_TYPE_PASSWORD = "Password"; + + public static final String NAME = "name"; + public static final String BASE_URL = "baseUrl"; + public static final String CONNECTION_TYPE = "connectionType"; + public static final String CERTIFICATE_TYPE = "certificateType"; + public static final String AUTH_TYPE = "authType"; + public static final String OAUTH_AUTHORIZATION_MODE = "oauthAuthorizationMode"; + public static final String OAUTH_GRANT_TYPE = "oauthGrantType"; + public static final String BASIC_CREDENTIALS_USERNAME = "basicCredentialsUsername"; + public static final String BASIC_CREDENTIALS_PASSWORD = "basicCredentialsPassword"; + public static final String OAUTH_PASSWORD_GRANT_USERNAME = "oauthPasswordUsername"; + public static final String OAUTH_PASSWORD_GRANT_PASSWORD = "oauthPasswordPassword"; + public static final String OAUTH_PASSWORD_GRANT_CLIENT_ID = "oauthPasswordClientId"; + public static final String OAUTH_PASSWORD_GRANT_CLIENT_SECRET = "oauthPasswordClientSecret"; + public static final String OAUTH_PASSWORD_GRANT_TOKEN_URL = "oauthPasswordTokenUrl"; + public static final String OAUTH_PASSWORD_GRANT_ADDITIONAL_PROPERTIES = "oauthPasswordAdditionalProperties"; + + public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_ID = "oauthClientClientId"; + public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_SECRET = "oauthClientClientSecret"; + public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_TOKEN_URL = "oauthClientTokenUrl"; + public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_ADDITIONAL_PROPERTIES = "oauthClientAdditionalProperties"; + + public static final String OAUTH_AUTHORIZATION_GRANT_CLIENT_SECRET = "oauthAuthorizationClientSecret"; + public static final String OAUTH_AUTHORIZATION_GRANT_CLIENT_ID = "oauthAuthorizationClientId"; + public static final String OAUTH_AUTHORIZATION_GRANT_TOKEN_URL = "oauthAuthorizationTokenUrl"; + public static final String OAUTH_AUTHORIZATION_GRANT_REFRESH_TOKEN = "oauthAuthorizationRefreshToken"; + public static final String OAUTH_AUTHORIZATION_GRANT_ADDITIONAL_PROPERTIES = "oauthAuthorizationAdditionalProperties"; + + public static final String OAUTH_CLIENT_ID = "oauthClientId"; + public static final String TIMEOUT_DURATION = "timeoutDuration"; + public static final String TIMEOUT_ACTION = "timeoutAction"; + public static final String SUSPEND_ERROR_CODES = "suspendErrorCodes"; + public static final String SUSPEND_INITIAL_DURATION = "suspendInitialDuration"; + public static final String SUSPEND_MAXIMUM_DURATION = "suspendMaximumDuration"; + public static final String SUSPEND_PROGRESSION_FACTOR = "suspendProgressionFactor"; + public static final String RETRY_ERROR_CODES = "retryErrorCodes"; + public static final String RETRY_COUNT = "retryCount"; + public static final String RETRY_DELAY = "retryDelay"; + + public static final String TRACE = "trace"; + public static final String STATISTICS = "statistics"; + public static final String MISCELLANEOUS_DESCRIPTION = "miscellaneousDescription"; + public static final String MISCELLANEOUS_PROPERTIES = "miscellaneousProperties"; + public static final String QUALITY_OF_SERVICE_ADDRESS_OPTION = "qualityServiceAddressOption"; + public static final String QUALITY_OF_SERVICE_ADDRESS_VERSION = "qualityServiceAddressVersion"; + public static final String QUALITY_OF_SERVICE_ADDRESS_SEPARATE_LISTENER = "qualityServiceAddressSeparateListener"; + + public static final String QUALITY_OF_SERVICE_SECURITY_OPTION = "qualityServiceSecurityOption"; + public static final String QUALITY_OF_SERVICE_SECURITY_INBOUND_OUTBOUND_POLICY_OPTION = "qualityServiceSecurityInboundOutboundPolicyOption"; + public static final String QUALITY_OF_SERVICE_SECURITY_INBOUND_POLICY_KEY = "qualityServiceSecurityInboundPolicyKey"; + public static final String QUALITY_OF_SERVICE_SECURITY_OUTBOUND_POLICY_KEY = "qualityServiceSecurityOutboundPolicyKey"; + public static final String QUALITY_OF_SERVICE_SECURITY_POLICY_KEY = "qualityServiceSecurityPolicyKey"; + + public static final String ENDPOINT = "endpoint"; + public static final String HTTP = "http"; + public static final String ENABLE = "enable"; + public static final String URI_TEMPLATE = "uri-template"; + public static final String ENABLE_ADDRESSING = "enableAddressing"; + public static final String ENABLE_SECURITY = "enableSec"; + public static final String SEPARATE_LISTENER = "separateListener"; + public static final String VERSION = "version"; + public static final String POLICY = "policy"; + public static final String INBOUND_POLICY = "inboundPolicy"; + public static final String OUTBOUND_POLICY = "outboundPolicy"; + public static final String TIMEOUT = "timeout"; + public static final String DURATION = "duration"; + public static final String RESPONSE_ACTION = "responseAction"; + public static final String NEVER = "never"; + public static final String SUSPEND_ON_FAILURE = "suspendOnFailure"; + public static final String ERROR_CODES = "errorCodes"; + public static final String INITIAL_DURATION = "initialDuration"; + public static final String MAXIMUM_DURATION = "maximumDuration"; + public static final String PROGRESSION_FACTOR = "progressionFactor"; + public static final String MARK_FOR_SUSPENSION = "markForSuspension"; + public static final String RETRIES_BEFORE_SUSPENSION = "retriesBeforeSuspension"; + public static final String AUTHENTICATION = "authentication"; + public static final String DESCRIPTION = "description"; + public static final String AUTHORIZATION_CODE = "authorizationCode"; + public static final String PASSWORD_CREDENTIALS = "passwordCredentials"; + public static final String CLIENT_CREDENTIALS = "clientCredentials"; + public static final String TOKEN_URL = "tokenUrl"; + public static final String CLIENT_ID = "clientId"; + public static final String CLIENT_SECRET = "clientSecret"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String REFRESH_TOKEN = "refreshToken"; + public static final String AUTH_MODE = "authMode"; + public static final String REQUEST_PARAMETERS = "requestParameters"; + public static final String BASIC_AUTH_TAG = "basicAuth"; + public static final String OAUTH_TAG = "oauth"; } diff --git a/modules/core/src/main/java/org/apache/synapse/deployers/Constant.java b/modules/core/src/main/java/org/apache/synapse/deployers/Constant.java deleted file mode 100644 index 4171757959..0000000000 --- a/modules/core/src/main/java/org/apache/synapse/deployers/Constant.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.synapse.deployers; - -public class Constant { - - // Constants for the HTTP Endpoint - public static final String ENDPOINT_IDENTIFIER = "ep"; - public static final String BASIC_AUTH = "Basic Auth"; - public static final String OAUTH = "OAuth"; - public static final String OAUTH_GRANT_TYPE_AUTHORIZATION_CODE = "Authorization Code"; - public static final String OAUTH_GRANT_TYPE_CLIENT_CREDENTIALS = "Client Credentials"; - public static final String OAUTH_GRANT_TYPE_PASSWORD = "Password"; - - // Constants for the HTTP Connection - public static final String NAME = "name"; - public static final String BASE_URL = "baseUrl"; - public static final String TIMEOUT_DURATION = "timeoutDuration"; - public static final String TIMEOUT_ACTION = "timeoutAction"; - public static final String SUSPEND_ERROR_CODES = "suspendErrorCodes"; - public static final String SUSPEND_INITIAL_DURATION = "suspendInitialDuration"; - public static final String SUSPEND_MAXIMUM_DURATION = "suspendMaximumDuration"; - public static final String SUSPEND_PROGRESSION_FACTOR = "suspendProgressionFactor"; - public static final String RETRY_ERROR_CODES = "retryErrorCodes"; - public static final String RETRY_COUNT = "retryCount"; - public static final String RETRY_DELAY = "retryDelay"; -} diff --git a/modules/core/src/main/java/org/apache/synapse/deployers/HTTPConnectionRepresentation.java b/modules/core/src/main/java/org/apache/synapse/deployers/HTTPConnectionRepresentation.java index 6268b43fbd..de6c54a03e 100644 --- a/modules/core/src/main/java/org/apache/synapse/deployers/HTTPConnectionRepresentation.java +++ b/modules/core/src/main/java/org/apache/synapse/deployers/HTTPConnectionRepresentation.java @@ -23,6 +23,7 @@ import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory; import org.apache.commons.lang.StringUtils; +import org.apache.synapse.SynapseConstants; import java.util.ArrayList; import java.util.Iterator; @@ -79,120 +80,120 @@ public HTTPConnectionRepresentation(OMElement inputOMElement) { while (children.hasNext()) { OMElement child = (OMElement) children.next(); switch (child.getLocalName()) { - case "connectionType": + case SynapseConstants.CONNECTION_TYPE: this.connectionType = child.getText(); break; - case "baseUrl": + case SynapseConstants.BASE_URL: this.baseUrl = child.getText(); break; - case "certificateType": + case SynapseConstants.CERTIFICATE_TYPE: this.certificateType = child.getText(); break; - case "authType": + case SynapseConstants.AUTH_TYPE: this.authType = child.getText(); break; - case "basicCredentialsUsername": - case "oauthPasswordUsername": + case SynapseConstants.BASIC_CREDENTIALS_USERNAME: + case SynapseConstants.OAUTH_PASSWORD_GRANT_USERNAME: this.username = child.getText(); break; - case "basicCredentialsPassword": - case "oauthPasswordPassword": + case SynapseConstants.BASIC_CREDENTIALS_PASSWORD: + case SynapseConstants.OAUTH_PASSWORD_GRANT_PASSWORD: this.password = child.getText(); break; - case "oauthAuthorizationMode": + case SynapseConstants.OAUTH_AUTHORIZATION_MODE: this.oauthAuthorizationMode = child.getText(); break; - case "oauthGrantType": + case SynapseConstants.OAUTH_GRANT_TYPE: this.oauthGrantType = child.getText(); break; - case "oauthAuthorizationClientId": - case "oauthClientClientId": - case "oauthPasswordClientId": + case SynapseConstants.OAUTH_AUTHORIZATION_GRANT_CLIENT_ID: + case SynapseConstants.OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_ID: + case SynapseConstants.OAUTH_PASSWORD_GRANT_CLIENT_ID: this.clientId = child.getText(); break; - case "oauthAuthorizationClientSecret": - case "oauthClientClientSecret": - case "oauthPasswordClientSecret": + case SynapseConstants.OAUTH_AUTHORIZATION_GRANT_CLIENT_SECRET: + case SynapseConstants.OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_SECRET: + case SynapseConstants.OAUTH_PASSWORD_GRANT_CLIENT_SECRET: this.clientSecret = child.getText(); break; - case "oauthAuthorizationTokenUrl": - case "oauthClientTokenUrl": - case "oauthPasswordTokenUrl": + case SynapseConstants.OAUTH_AUTHORIZATION_GRANT_TOKEN_URL: + case SynapseConstants.OAUTH_CLIENT_CREDENTIALS_GRANT_TOKEN_URL: + case SynapseConstants.OAUTH_PASSWORD_GRANT_TOKEN_URL: this.tokenUrl = child.getText(); break; - case "oauthAuthorizationRefreshToken": + case SynapseConstants.OAUTH_AUTHORIZATION_GRANT_REFRESH_TOKEN: this.refreshToken = child.getText(); break; - case "oauthAuthorizationAdditionalProperties": - case "oauthClientAdditionalProperties": - case "oauthPasswordAdditionalProperties": + case SynapseConstants.OAUTH_AUTHORIZATION_GRANT_ADDITIONAL_PROPERTIES: + case SynapseConstants.OAUTH_CLIENT_CREDENTIALS_GRANT_ADDITIONAL_PROPERTIES: + case SynapseConstants.OAUTH_PASSWORD_GRANT_ADDITIONAL_PROPERTIES: this.oauthAdditionalProperties = child.getText(); break; - case "timeoutDuration": + case SynapseConstants.TIMEOUT_DURATION: this.timeoutDuration = child.getText(); break; - case "timeoutAction": + case SynapseConstants.TIMEOUT_ACTION: this.timeoutAction = child.getText(); break; - case "suspendErrorCodes": + case SynapseConstants.SUSPEND_ERROR_CODES: this.suspendErrorCodes = child.getText(); break; - case "suspendInitialDuration": + case SynapseConstants.SUSPEND_INITIAL_DURATION: this.suspendInitialDuration = child.getText(); break; - case "suspendMaximumDuration": + case SynapseConstants.SUSPEND_MAXIMUM_DURATION: this.suspendMaximumDuration = child.getText(); break; - case "suspendProgressionFactor": + case SynapseConstants.SUSPEND_PROGRESSION_FACTOR: this.suspendProgressionFactor = child.getText(); break; - case "retryErrorCodes": + case SynapseConstants.RETRY_ERROR_CODES: this.retryErrorCodes = child.getText(); break; - case "retryCount": + case SynapseConstants.RETRY_COUNT: this.retryCount = child.getText(); break; - case "retryDelay": + case SynapseConstants.RETRY_DELAY: this.retryDelay = child.getText(); break; - case "name": + case SynapseConstants.NAME: this.name = child.getText(); - this.endpointName = child.getText() + Constant.ENDPOINT_IDENTIFIER; + this.endpointName = child.getText() + SynapseConstants.ENDPOINT_IDENTIFIER; break; - case "trace": + case SynapseConstants.TRACE: this.trace = child.getText(); break; - case "statistics": + case SynapseConstants.STATISTICS: this.statistics = child.getText(); break; - case "miscellaneousDescription": + case SynapseConstants.MISCELLANEOUS_DESCRIPTION: this.miscellaneousDescription = child.getText(); break; - case "miscellaneousProperties": + case SynapseConstants.MISCELLANEOUS_PROPERTIES: this.miscellaneousProperties = child.getText(); break; - case "qualityServiceAddressOption": + case SynapseConstants.QUALITY_OF_SERVICE_ADDRESS_OPTION: this.qualityServiceAddressOption = child.getText(); break; - case "qualityServiceAddressVersion": + case SynapseConstants.QUALITY_OF_SERVICE_ADDRESS_VERSION: this.qualityServiceAddressVersion = child.getText(); break; - case "qualityServiceAddressSeparateListener": + case SynapseConstants.QUALITY_OF_SERVICE_ADDRESS_SEPARATE_LISTENER: this.qualityServiceAddressSeparateListener = child.getText(); break; - case "qualityServiceSecurityOption": + case SynapseConstants.QUALITY_OF_SERVICE_SECURITY_OPTION: this.qualityServiceSecurityOption = child.getText(); break; - case "qualityServiceSecurityInboundOutboundPolicyOption": + case SynapseConstants.QUALITY_OF_SERVICE_SECURITY_INBOUND_OUTBOUND_POLICY_OPTION: this.qualityServiceSecurityInboundOutboundPolicyOption = child.getText(); break; - case "qualityServiceSecurityPolicyKey": + case SynapseConstants.QUALITY_OF_SERVICE_SECURITY_POLICY_KEY: this.qualityServiceSecurityPolicyKey = child.getText(); break; - case "qualityServiceSecurityInboundPolicyKey": + case SynapseConstants.QUALITY_OF_SERVICE_SECURITY_INBOUND_POLICY_KEY: this.qualityServiceSecurityInboundPolicyKey = child.getText(); break; - case "qualityServiceSecurityOutboundPolicyKey": + case SynapseConstants.QUALITY_OF_SERVICE_SECURITY_OUTBOUND_POLICY_KEY: this.qualityServiceSecurityOutboundPolicyKey = child.getText(); break; default: @@ -205,57 +206,57 @@ public OMElement generateEndpointOMElement() { OMFactory factory = new OMLinkedListImplFactory(); OMNamespace synapseNS = factory.createOMNamespace("http://ws.apache.org/ns/synapse", ""); - OMElement endpoint = factory.createOMElement("endpoint", synapseNS); - endpoint.addAttribute("name", endpointName, null); + OMElement endpoint = factory.createOMElement(SynapseConstants.ENDPOINT, synapseNS); + endpoint.addAttribute(SynapseConstants.NAME, endpointName, null); - OMElement http = factory.createOMElement("http", synapseNS); - if (StringUtils.isNotEmpty(this.trace) && this.trace.equalsIgnoreCase("enable")) { - http.addAttribute("trace", "enable", null); + OMElement http = factory.createOMElement(SynapseConstants.HTTP, synapseNS); + if (StringUtils.isNotEmpty(this.trace) && this.trace.equalsIgnoreCase(SynapseConstants.ENABLE)) { + http.addAttribute(SynapseConstants.TRACE, SynapseConstants.ENABLE, null); } - if (StringUtils.isNotEmpty(this.statistics) && this.statistics.equalsIgnoreCase("enable")) { - http.addAttribute("statistics", "enable", null); + if (StringUtils.isNotEmpty(this.statistics) && this.statistics.equalsIgnoreCase(SynapseConstants.ENABLE)) { + http.addAttribute(SynapseConstants.STATISTICS, SynapseConstants.ENABLE, null); } - http.addAttribute("uri-template", "{uri.var.base}{+uri.var.path}{+uri.var.query}", null); + http.addAttribute(SynapseConstants.URI_TEMPLATE, "{uri.var.base}{+uri.var.path}{+uri.var.query}", null); - if (StringUtils.isNotEmpty(this.qualityServiceAddressOption) && this.qualityServiceAddressOption.equalsIgnoreCase("enable")) { - OMElement enableAddressing = factory.createOMElement("enableAddressing", synapseNS); + if (StringUtils.isNotEmpty(this.qualityServiceAddressOption) && this.qualityServiceAddressOption.equalsIgnoreCase(SynapseConstants.ENABLE)) { + OMElement enableAddressing = factory.createOMElement(SynapseConstants.ENABLE_ADDRESSING, synapseNS); if (StringUtils.isNotEmpty(this.qualityServiceAddressSeparateListener) && - this.qualityServiceAddressSeparateListener.equalsIgnoreCase("enable")) { - enableAddressing.addAttribute("separateListener", "true", null); + this.qualityServiceAddressSeparateListener.equalsIgnoreCase(SynapseConstants.ENABLE)) { + enableAddressing.addAttribute(SynapseConstants.SEPARATE_LISTENER, "true", null); } if (StringUtils.isNotEmpty(this.qualityServiceAddressVersion)) { - enableAddressing.addAttribute("version", this.qualityServiceAddressVersion, null); + enableAddressing.addAttribute(SynapseConstants.VERSION, this.qualityServiceAddressVersion, null); } http.addChild(enableAddressing); } - if (StringUtils.isNotEmpty(this.qualityServiceSecurityOption) && this.qualityServiceSecurityOption.equalsIgnoreCase("enable")) { - OMElement enableSecurity = factory.createOMElement("enableSec", synapseNS); + if (StringUtils.isNotEmpty(this.qualityServiceSecurityOption) && this.qualityServiceSecurityOption.equalsIgnoreCase(SynapseConstants.ENABLE)) { + OMElement enableSecurity = factory.createOMElement(SynapseConstants.ENABLE_SECURITY, synapseNS); if (StringUtils.isNotEmpty(this.qualityServiceSecurityInboundOutboundPolicyOption) && - this.qualityServiceSecurityInboundOutboundPolicyOption.equalsIgnoreCase("enable")) { + this.qualityServiceSecurityInboundOutboundPolicyOption.equalsIgnoreCase(SynapseConstants.ENABLE)) { if (StringUtils.isNotEmpty(this.qualityServiceSecurityInboundPolicyKey)) { - enableSecurity.addAttribute("inboundPolicy", this.qualityServiceSecurityInboundPolicyKey, null); + enableSecurity.addAttribute(SynapseConstants.INBOUND_POLICY, this.qualityServiceSecurityInboundPolicyKey, null); } if (StringUtils.isNotEmpty(this.qualityServiceSecurityOutboundPolicyKey)) { - enableSecurity.addAttribute("outboundPolicy", this.qualityServiceSecurityOutboundPolicyKey, null); + enableSecurity.addAttribute(SynapseConstants.OUTBOUND_POLICY, this.qualityServiceSecurityOutboundPolicyKey, null); } } else { if (StringUtils.isNotEmpty(this.qualityServiceSecurityPolicyKey)) { - enableSecurity.addAttribute("policy", this.qualityServiceSecurityPolicyKey, null); + enableSecurity.addAttribute(SynapseConstants.POLICY, this.qualityServiceSecurityPolicyKey, null); } } http.addChild(enableSecurity); } if (StringUtils.isNotEmpty(this.timeoutDuration) || StringUtils.isNotEmpty(this.timeoutAction)) { - OMElement timeout = factory.createOMElement("timeout", synapseNS); + OMElement timeout = factory.createOMElement(SynapseConstants.TIMEOUT, synapseNS); if (StringUtils.isNotEmpty(this.timeoutDuration)) { - OMElement duration = factory.createOMElement("duration", synapseNS); + OMElement duration = factory.createOMElement(SynapseConstants.DURATION, synapseNS); duration.setText(String.valueOf(this.timeoutDuration)); timeout.addChild(duration); } - if (StringUtils.isNotEmpty(this.timeoutAction) && !this.timeoutAction.equalsIgnoreCase("never")) { - OMElement responseAction = factory.createOMElement("responseAction", synapseNS); + if (StringUtils.isNotEmpty(this.timeoutAction) && !this.timeoutAction.equalsIgnoreCase(SynapseConstants.NEVER)) { + OMElement responseAction = factory.createOMElement(SynapseConstants.RESPONSE_ACTION, synapseNS); responseAction.setText(this.timeoutAction); timeout.addChild(responseAction); } @@ -264,24 +265,24 @@ public OMElement generateEndpointOMElement() { if (StringUtils.isNotEmpty(this.suspendErrorCodes) || StringUtils.isNotEmpty(this.suspendInitialDuration) || StringUtils.isNotEmpty(this.suspendProgressionFactor) || StringUtils.isNotEmpty(this.suspendMaximumDuration)) { - OMElement suspendOnFailure = factory.createOMElement("suspendOnFailure", synapseNS); + OMElement suspendOnFailure = factory.createOMElement(SynapseConstants.SUSPEND_ON_FAILURE, synapseNS); if (StringUtils.isNotEmpty(this.suspendErrorCodes)) { - OMElement errorCodes = factory.createOMElement("errorCodes", synapseNS); + OMElement errorCodes = factory.createOMElement(SynapseConstants.ERROR_CODES, synapseNS); errorCodes.setText(this.suspendErrorCodes); suspendOnFailure.addChild(errorCodes); } if (StringUtils.isNotEmpty(this.suspendInitialDuration)) { - OMElement initialDuration = factory.createOMElement("initialDuration", synapseNS); + OMElement initialDuration = factory.createOMElement(SynapseConstants.INITIAL_DURATION, synapseNS); initialDuration.setText(String.valueOf(this.suspendInitialDuration)); suspendOnFailure.addChild(initialDuration); } if (StringUtils.isNotEmpty(this.suspendProgressionFactor)) { - OMElement progressionFactor = factory.createOMElement("progressionFactor", synapseNS); + OMElement progressionFactor = factory.createOMElement(SynapseConstants.PROGRESSION_FACTOR, synapseNS); progressionFactor.setText(String.valueOf(this.suspendProgressionFactor)); suspendOnFailure.addChild(progressionFactor); } if (StringUtils.isNotEmpty(this.suspendMaximumDuration)) { - OMElement maximumDuration = factory.createOMElement("maximumDuration", synapseNS); + OMElement maximumDuration = factory.createOMElement(SynapseConstants.MAXIMUM_DURATION, synapseNS); maximumDuration.setText(String.valueOf(this.suspendMaximumDuration)); suspendOnFailure.addChild(maximumDuration); } @@ -290,19 +291,19 @@ public OMElement generateEndpointOMElement() { if (StringUtils.isNotEmpty(this.retryErrorCodes) || StringUtils.isNotEmpty(this.retryCount) || StringUtils.isNotEmpty(this.retryDelay)) { - OMElement markForSuspension = factory.createOMElement("markForSuspension", synapseNS); + OMElement markForSuspension = factory.createOMElement(SynapseConstants.MARK_FOR_SUSPENSION, synapseNS); if (StringUtils.isNotEmpty(this.retryErrorCodes)) { - OMElement retryErrorCodes = factory.createOMElement("errorCodes", synapseNS); + OMElement retryErrorCodes = factory.createOMElement(SynapseConstants.ERROR_CODES, synapseNS); retryErrorCodes.setText(this.retryErrorCodes); markForSuspension.addChild(retryErrorCodes); } if (StringUtils.isNotEmpty(this.retryCount)) { - OMElement retriesBeforeSuspension = factory.createOMElement("retriesBeforeSuspension", synapseNS); + OMElement retriesBeforeSuspension = factory.createOMElement(SynapseConstants.RETRIES_BEFORE_SUSPENSION, synapseNS); retriesBeforeSuspension.setText(String.valueOf(this.retryCount)); markForSuspension.addChild(retriesBeforeSuspension); } if (StringUtils.isNotEmpty(this.retryDelay)) { - OMElement retryDelay = factory.createOMElement("retryDelay", synapseNS); + OMElement retryDelay = factory.createOMElement(SynapseConstants.RETRY_DELAY, synapseNS); retryDelay.setText(String.valueOf(this.retryDelay)); markForSuspension.addChild(retryDelay); } @@ -310,25 +311,25 @@ public OMElement generateEndpointOMElement() { } if (StringUtils.isNotEmpty(authType)) { - if (authType.equalsIgnoreCase(Constant.BASIC_AUTH)) { - OMElement authentication = factory.createOMElement("authentication", synapseNS); + if (authType.equalsIgnoreCase(SynapseConstants.BASIC_AUTH)) { + OMElement authentication = factory.createOMElement(SynapseConstants.AUTHENTICATION, synapseNS); OMElement basicAuth = generateBasicAuthenticationElement(factory, synapseNS); authentication.addChild(basicAuth); http.addChild(authentication); - } else if (authType.equalsIgnoreCase(Constant.OAUTH)) { - OMElement authentication = factory.createOMElement("authentication", synapseNS); - OMElement oauth = factory.createOMElement("oauth", synapseNS); - if (oauthGrantType.equalsIgnoreCase(Constant.OAUTH_GRANT_TYPE_AUTHORIZATION_CODE)) { + } else if (authType.equalsIgnoreCase(SynapseConstants.OAUTH)) { + OMElement authentication = factory.createOMElement(SynapseConstants.AUTHENTICATION, synapseNS); + OMElement oauth = factory.createOMElement(SynapseConstants.OAUTH_TAG, synapseNS); + if (oauthGrantType.equalsIgnoreCase(SynapseConstants.OAUTH_GRANT_TYPE_AUTHORIZATION_CODE)) { OMElement authorizationCode = generateOAuthAuthorizatonCodeElement(factory, synapseNS); oauth.addChild(authorizationCode); authentication.addChild(oauth); http.addChild(authentication); - } else if (oauthGrantType.equalsIgnoreCase(Constant.OAUTH_GRANT_TYPE_CLIENT_CREDENTIALS)) { + } else if (oauthGrantType.equalsIgnoreCase(SynapseConstants.OAUTH_GRANT_TYPE_CLIENT_CREDENTIALS)) { OMElement clientCredentials = generateOAuthClientCredentialsElement(factory, synapseNS); oauth.addChild(clientCredentials); authentication.addChild(oauth); http.addChild(authentication); - } else if (oauthGrantType.equalsIgnoreCase(Constant.OAUTH_GRANT_TYPE_PASSWORD)) { + } else if (oauthGrantType.equalsIgnoreCase(SynapseConstants.OAUTH_GRANT_TYPE_PASSWORD)) { OMElement passwordCredentials = generateOAuthPasswordCredentialsElement(factory, synapseNS); oauth.addChild(passwordCredentials); authentication.addChild(oauth); @@ -344,7 +345,7 @@ public OMElement generateEndpointOMElement() { } } if (StringUtils.isNotEmpty(miscellaneousDescription)) { - OMElement description = factory.createOMElement("description", synapseNS); + OMElement description = factory.createOMElement(SynapseConstants.DESCRIPTION, synapseNS); description.setText(this.miscellaneousDescription); endpoint.addChild(description); } @@ -353,7 +354,7 @@ public OMElement generateEndpointOMElement() { private OMElement generateOAuthPasswordCredentialsElement(OMFactory factory, OMNamespace synapseNS) { - OMElement passwordCredentials = factory.createOMElement("passwordCredentials", synapseNS); + OMElement passwordCredentials = factory.createOMElement(SynapseConstants.PASSWORD_CREDENTIALS, synapseNS); OMElement username = generateAuthUsernameElement(factory, synapseNS); OMElement password = generateAuthPasswordElement(factory, synapseNS); @@ -378,21 +379,21 @@ private OMElement generateOAuthPasswordCredentialsElement(OMFactory factory, OMN private OMElement generateOAuthTokenUrlElement(OMFactory factory, OMNamespace synapseNS) { - OMElement oauthTokenUrl = factory.createOMElement("tokenUrl", synapseNS); + OMElement oauthTokenUrl = factory.createOMElement(SynapseConstants.TOKEN_URL, synapseNS); oauthTokenUrl.setText(this.tokenUrl); return oauthTokenUrl; } private OMElement generateAuthUsernameElement(OMFactory factory, OMNamespace synapseNS) { - OMElement authUsername = factory.createOMElement("username", synapseNS); + OMElement authUsername = factory.createOMElement(SynapseConstants.USERNAME, synapseNS); authUsername.setText(this.username); return authUsername; } private OMElement generateOAuthClientCredentialsElement(OMFactory factory, OMNamespace synapseNS) { - OMElement clientCredentials = factory.createOMElement("clientCredentials", synapseNS); + OMElement clientCredentials = factory.createOMElement(SynapseConstants.CLIENT_CREDENTIALS, synapseNS); OMElement clientId = generateOAuthClientIDElement(factory, synapseNS); OMElement clientSecret = generateOAuthClientSecretElement(factory, synapseNS); @@ -413,7 +414,7 @@ private OMElement generateOAuthClientCredentialsElement(OMFactory factory, OMNam private OMElement generateOAuthAuthorizatonCodeElement(OMFactory factory, OMNamespace synapseNS) { - OMElement authorizationCode = factory.createOMElement("authorizationCode", synapseNS); + OMElement authorizationCode = factory.createOMElement(SynapseConstants.AUTHORIZATION_CODE, synapseNS); OMElement refreshToken = generateOAuthRefreshTokenElement(factory, synapseNS); OMElement clientId = generateOAuthClientIDElement(factory, synapseNS); @@ -436,35 +437,35 @@ private OMElement generateOAuthAuthorizatonCodeElement(OMFactory factory, OMName private OMElement generateOAuthRefreshTokenElement(OMFactory factory, OMNamespace synapseNS) { - OMElement oauthRefreshToken = factory.createOMElement("refreshToken", synapseNS); + OMElement oauthRefreshToken = factory.createOMElement(SynapseConstants.REFRESH_TOKEN, synapseNS); oauthRefreshToken.setText(this.refreshToken); return oauthRefreshToken; } private OMElement generateOAuthClientSecretElement(OMFactory factory, OMNamespace synapseNS) { - OMElement oauthClientSecret = factory.createOMElement("clientSecret", synapseNS); + OMElement oauthClientSecret = factory.createOMElement(SynapseConstants.CLIENT_SECRET, synapseNS); oauthClientSecret.setText(this.clientSecret); return oauthClientSecret; } private OMElement generateOAuthClientIDElement(OMFactory factory, OMNamespace synapseNS) { - OMElement oauthClientID = factory.createOMElement("clientId", synapseNS); + OMElement oauthClientID = factory.createOMElement(SynapseConstants.CLIENT_ID, synapseNS); oauthClientID.setText(this.clientId); return oauthClientID; } private OMElement generateOAuthAuthorizationModeElement(OMFactory factory, OMNamespace synapseNS) { - OMElement authMode = factory.createOMElement("authMode", synapseNS); + OMElement authMode = factory.createOMElement(SynapseConstants.AUTH_MODE, synapseNS); authMode.setText(this.oauthAuthorizationMode); return authMode; } private OMElement generateBasicAuthenticationElement(OMFactory factory, OMNamespace synapseNS) { - OMElement basicAuth = factory.createOMElement("basicAuth", synapseNS); + OMElement basicAuth = factory.createOMElement(SynapseConstants.BASIC_AUTH_TAG, synapseNS); OMElement username = generateAuthUsernameElement(factory, synapseNS); OMElement password = generateAuthPasswordElement(factory, synapseNS); @@ -476,7 +477,7 @@ private OMElement generateBasicAuthenticationElement(OMFactory factory, OMNamesp private OMElement generateAuthPasswordElement(OMFactory factory, OMNamespace synapseNS) { - OMElement authPassword = factory.createOMElement("password", synapseNS); + OMElement authPassword = factory.createOMElement(SynapseConstants.PASSWORD, synapseNS); authPassword.setText(this.password); return authPassword; } @@ -499,7 +500,7 @@ private List generateMiscellaneousPropertiesElement(OMFactory factory private OMElement generateOAuthAdditionalPropertiesElement(OMFactory factory, OMNamespace synapseNS) { - OMElement additionalProperties = factory.createOMElement("requestParameters", synapseNS); + OMElement additionalProperties = factory.createOMElement(SynapseConstants.REQUEST_PARAMETERS, synapseNS); for (String additionalProperty : this.oauthAdditionalProperties.split(",")) { String[] keyValue = additionalProperty.split(":"); if (keyValue.length == 2) {