|
68 | 68 | import org.wso2.carbon.apimgt.api.model.DocumentationContent;
|
69 | 69 | import org.wso2.carbon.apimgt.api.model.DocumentationType;
|
70 | 70 | import org.wso2.carbon.apimgt.api.model.Environment;
|
| 71 | +import org.wso2.carbon.apimgt.api.model.GatewayAgentConfiguration; |
| 72 | +import org.wso2.carbon.apimgt.api.model.GatewayDeployer; |
71 | 73 | import org.wso2.carbon.apimgt.api.model.Identifier;
|
72 | 74 | import org.wso2.carbon.apimgt.api.model.KeyManager;
|
73 | 75 | import org.wso2.carbon.apimgt.api.model.KeyManagerApplicationInfo;
|
|
89 | 91 | import org.wso2.carbon.apimgt.api.model.policy.PolicyConstants;
|
90 | 92 | import org.wso2.carbon.apimgt.api.model.webhooks.Subscription;
|
91 | 93 | import org.wso2.carbon.apimgt.api.model.webhooks.Topic;
|
92 |
| -import org.wso2.carbon.apimgt.impl.deployer.ExternalGatewayDeployer; |
93 | 94 | import org.wso2.carbon.apimgt.impl.deployer.exceptions.DeployerException;
|
94 | 95 | import org.wso2.carbon.apimgt.impl.dto.ai.ApiChatConfigurationDTO;
|
95 | 96 | import org.wso2.carbon.apimgt.impl.caching.CacheProvider;
|
@@ -3443,9 +3444,10 @@ private String getOpenAPIDefinitionForDeployment(API api, String environmentName
|
3443 | 3444 | hostsWithSchemes = getHostWithSchemeMappingForEnvironment(api, apiTenantDomain, environmentName);
|
3444 | 3445 |
|
3445 | 3446 | Environment environment = APIUtil.getEnvironments().get(environmentName);
|
3446 |
| - Map<String, ExternalGatewayDeployer> externalGatewayDeployers = ServiceReferenceHolder.getInstance().getExternalGatewayDeployers(); |
3447 |
| - ExternalGatewayDeployer gatewayDeployer = externalGatewayDeployers.get(environment.getGatewayType()); |
3448 |
| - if (gatewayDeployer != null) { |
| 3447 | + Map<String, GatewayAgentConfiguration> gatewayConfigurations = ServiceReferenceHolder.getInstance() |
| 3448 | + .getExternalGatewayConnectorConfigurations(); |
| 3449 | + GatewayAgentConfiguration gatewayConfiguration = gatewayConfigurations.get(environment.getGatewayType()); |
| 3450 | + if (gatewayConfiguration != null) { |
3449 | 3451 | api.setContext("");
|
3450 | 3452 | updatedDefinition = oasParser.getOASDefinitionForStore(api, definition, hostsWithSchemes, kmId);
|
3451 | 3453 | } else {
|
@@ -3622,26 +3624,32 @@ private Map<String, String> getHostWithSchemeMappingForEnvironment(API api, Stri
|
3622 | 3624 | }
|
3623 | 3625 |
|
3624 | 3626 | VHost vhost = VHostUtils.getVhostFromEnvironment(environment, host);
|
3625 |
| - Map<String, ExternalGatewayDeployer> externalGatewayDeployers = ServiceReferenceHolder.getInstance().getExternalGatewayDeployers(); |
3626 |
| - ExternalGatewayDeployer gatewayDeployer = externalGatewayDeployers.get(environment.getGatewayType()); |
| 3627 | + Map<String, GatewayAgentConfiguration> gatewayConfigurations = |
| 3628 | + ServiceReferenceHolder.getInstance().getExternalGatewayConnectorConfigurations(); |
| 3629 | + GatewayAgentConfiguration gatewayConfiguration = gatewayConfigurations.get(environment.getGatewayType()); |
3627 | 3630 | try {
|
| 3631 | + boolean isExternalGateway = false; |
| 3632 | + GatewayDeployer gatewayDeployer = null; |
| 3633 | + if (gatewayConfiguration != null && StringUtils.isNotEmpty(gatewayConfiguration.getImplementation())) { |
| 3634 | + gatewayDeployer = (GatewayDeployer) Class.forName( |
| 3635 | + gatewayConfiguration.getImplementation()).getDeclaredConstructor().newInstance(); |
| 3636 | + isExternalGateway = true; |
| 3637 | + } |
| 3638 | + |
3628 | 3639 | if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTP_PROTOCOL)
|
3629 | 3640 | && vhost.getHttpPort() != -1) {
|
3630 |
| - String httpUrl = gatewayDeployer != null ? |
3631 |
| - gatewayDeployer.getAPIExecutionURL(vhost.getHttpUrl(), environment, |
3632 |
| - APIUtil.getApiExternalApiMappingReferenceByApiId(api.getUuid(), environment.getUuid())) : |
| 3641 | + String httpUrl = isExternalGateway ? gatewayDeployer.getAPIExecutionURL(api.getUuid()) : |
3633 | 3642 | vhost.getHttpUrl();
|
3634 | 3643 | hostsWithSchemes.put(APIConstants.HTTP_PROTOCOL, httpUrl);
|
3635 | 3644 | }
|
3636 | 3645 | if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTPS_PROTOCOL)
|
3637 | 3646 | && vhost.getHttpsPort() != -1) {
|
3638 |
| - String httpsUrl = gatewayDeployer != null ? |
3639 |
| - gatewayDeployer.getAPIExecutionURL(vhost.getHttpsUrl(), environment, |
3640 |
| - APIUtil.getApiExternalApiMappingReferenceByApiId(api.getUuid(), environment.getUuid())) : |
| 3647 | + String httpsUrl = isExternalGateway ? gatewayDeployer.getAPIExecutionURL(api.getUuid()) : |
3641 | 3648 | vhost.getHttpsUrl();
|
3642 | 3649 | hostsWithSchemes.put(APIConstants.HTTPS_PROTOCOL, httpsUrl);
|
3643 | 3650 | }
|
3644 |
| - } catch (DeployerException e) { |
| 3651 | + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException |
| 3652 | + | InvocationTargetException e) { |
3645 | 3653 | throw new APIManagementException(e.getMessage());
|
3646 | 3654 | }
|
3647 | 3655 | }
|
|
0 commit comments