|
88 | 88 | import org.wso2.carbon.apimgt.api.model.policy.PolicyConstants;
|
89 | 89 | import org.wso2.carbon.apimgt.api.model.webhooks.Subscription;
|
90 | 90 | import org.wso2.carbon.apimgt.api.model.webhooks.Topic;
|
| 91 | +import org.wso2.carbon.apimgt.impl.deployer.ExternalGatewayDeployer; |
| 92 | +import org.wso2.carbon.apimgt.impl.deployer.exceptions.DeployerException; |
91 | 93 | import org.wso2.carbon.apimgt.impl.dto.ai.ApiChatConfigurationDTO;
|
92 | 94 | import org.wso2.carbon.apimgt.impl.caching.CacheProvider;
|
93 | 95 | import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO;
|
@@ -3435,8 +3437,17 @@ private String getOpenAPIDefinitionForDeployment(API api, String environmentName
|
3435 | 3437 | apiTenantDomain = MultitenantUtils.getTenantDomain(
|
3436 | 3438 | APIUtil.replaceEmailDomainBack(api.getId().getProviderName()));
|
3437 | 3439 | hostsWithSchemes = getHostWithSchemeMappingForEnvironment(api, apiTenantDomain, environmentName);
|
3438 |
| - api.setContext(getBasePath(apiTenantDomain, api.getContext())); |
3439 |
| - updatedDefinition = oasParser.getOASDefinitionForStore(api, definition, hostsWithSchemes, kmId); |
| 3440 | + |
| 3441 | + Environment environment = APIUtil.getEnvironments().get(environmentName); |
| 3442 | + Map<String, ExternalGatewayDeployer> externalGatewayDeployers = ServiceReferenceHolder.getInstance().getExternalGatewayDeployers(); |
| 3443 | + ExternalGatewayDeployer gatewayDeployer = externalGatewayDeployers.get(environment.getProvider()); |
| 3444 | + if (gatewayDeployer != null) { |
| 3445 | + api.setContext(""); |
| 3446 | + updatedDefinition = oasParser.getOASDefinitionForStore(api, definition, hostsWithSchemes, kmId); |
| 3447 | + } else { |
| 3448 | + api.setContext(getBasePath(apiTenantDomain, api.getContext())); |
| 3449 | + updatedDefinition = oasParser.getOASDefinitionForStore(api, definition, hostsWithSchemes, kmId); |
| 3450 | + } |
3440 | 3451 | return updatedDefinition;
|
3441 | 3452 | }
|
3442 | 3453 |
|
@@ -3607,13 +3618,25 @@ private Map<String, String> getHostWithSchemeMappingForEnvironment(API api, Stri
|
3607 | 3618 | }
|
3608 | 3619 |
|
3609 | 3620 | VHost vhost = VHostUtils.getVhostFromEnvironment(environment, host);
|
3610 |
| - if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTP_PROTOCOL) |
3611 |
| - && vhost.getHttpPort() != -1) { |
3612 |
| - hostsWithSchemes.put(APIConstants.HTTP_PROTOCOL, vhost.getHttpUrl()); |
3613 |
| - } |
3614 |
| - if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTPS_PROTOCOL) |
3615 |
| - && vhost.getHttpsPort() != -1) { |
3616 |
| - hostsWithSchemes.put(APIConstants.HTTPS_PROTOCOL, vhost.getHttpsUrl()); |
| 3621 | + Map<String, ExternalGatewayDeployer> externalGatewayDeployers = ServiceReferenceHolder.getInstance().getExternalGatewayDeployers(); |
| 3622 | + ExternalGatewayDeployer gatewayDeployer = externalGatewayDeployers.get(environment.getProvider()); |
| 3623 | + try { |
| 3624 | + if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTP_PROTOCOL) |
| 3625 | + && vhost.getHttpPort() != -1) { |
| 3626 | + String httpUrl = gatewayDeployer != null ? |
| 3627 | + gatewayDeployer.getResolvedAPIInvocationUrl(api.getUuid(), vhost.getHttpUrl(), environment) : |
| 3628 | + vhost.getHttpUrl(); |
| 3629 | + hostsWithSchemes.put(APIConstants.HTTP_PROTOCOL, httpUrl); |
| 3630 | + } |
| 3631 | + if (StringUtils.containsIgnoreCase(api.getTransports(), APIConstants.HTTPS_PROTOCOL) |
| 3632 | + && vhost.getHttpsPort() != -1) { |
| 3633 | + String httpsUrl = gatewayDeployer != null ? |
| 3634 | + gatewayDeployer.getResolvedAPIInvocationUrl(api.getUuid(), vhost.getHttpsUrl(), environment) : |
| 3635 | + vhost.getHttpsUrl(); |
| 3636 | + hostsWithSchemes.put(APIConstants.HTTPS_PROTOCOL, httpsUrl); |
| 3637 | + } |
| 3638 | + } catch (DeployerException e) { |
| 3639 | + throw new APIManagementException(e.getMessage()); |
3617 | 3640 | }
|
3618 | 3641 | }
|
3619 | 3642 | return hostsWithSchemes;
|
|
0 commit comments