From c0e6fcbe332fe20d9998c5249b6d8cdd43391219 Mon Sep 17 00:00:00 2001 From: BLasan Date: Sun, 18 Aug 2024 01:14:02 +0530 Subject: [PATCH] Revamp: Endpoint Config update for API import via APICTL and REST --- .../java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java | 3 ++- .../api/publisher/v1/common/mappings/ImportUtils.java | 4 ++-- .../v1/common/mappings/PublisherCommonUtils.java | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java index 23babe28d8da..10073f920086 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java @@ -2915,7 +2915,8 @@ public static void validateAPIEndpointConfig(Object endpointConfigObject, String if (endpointConfigMap.containsKey("endpoint_type") && APIConstants.ENDPOINT_TYPE_SEQUENCE.equals( endpointConfigMap.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE)) && !APIConstants.APITransportType.GRAPHQL.toString().equalsIgnoreCase(apiType) - && !APIConstants.API_TYPE_HTTP.equalsIgnoreCase(apiType)) { + && !APIConstants.API_TYPE_HTTP.equalsIgnoreCase(apiType) + && !APIConstants.API_TYPE_SOAPTOREST.equalsIgnoreCase(apiType)) { throw new APIManagementException("Invalid endpoint configuration provided for the API " + apiName); } } diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ImportUtils.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ImportUtils.java index 9b9b87acd031..894e37804950 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ImportUtils.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/ImportUtils.java @@ -273,9 +273,9 @@ public static ImportedAPIDTO importApi(String extractedFolderPath, APIDTO import // if a valid one then update the sequence file path if (endpointConfig != null && APIConstants.ENDPOINT_TYPE_SEQUENCE.equals( endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) { - String sequenceFileName = endpointConfig.get("sequence").toString(); + String sequenceFileName = endpointConfig.get("sequence_path").toString(); String path = extractedFolderPath + File.separator + sequenceFileName; - endpointConfig.put("sequence", path); + endpointConfig.put("sequence_path", path); importedApiDTO.setEndpointConfig(endpointConfig); } diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java index b6b7e7e88e4d..b6519772dba2 100755 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java @@ -281,8 +281,8 @@ private static API prepareForUpdateApi(API originalAPI, APIDTO apiDtoToUpdate, A if (APIConstants.ENDPOINT_TYPE_SEQUENCE.equals( endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) { try { - if (endpointConfig.get("sequence") != null) { - String pathToSequence = endpointConfig.get("sequence").toString(); + if (endpointConfig.get("sequence_path") != null) { + String pathToSequence = endpointConfig.get("sequence_path").toString(); String sequence = FileUtils.readFileToString(new File(pathToSequence), Charset.defaultCharset()); endpointConfig.put("sequence", sequence); @@ -951,8 +951,8 @@ public static API addAPIWithGeneratedSwaggerDefinition(APIDTO apiDto, String oas if (APIConstants.ENDPOINT_TYPE_SEQUENCE.equals( endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) { try { - if (endpointConfig.get("sequence") != null) { - String pathToSequence = endpointConfig.get("sequence").toString(); + if (endpointConfig.get("sequence_path") != null) { + String pathToSequence = endpointConfig.get("sequence_path").toString(); String sequence = FileUtils.readFileToString(new File(pathToSequence), Charset.defaultCharset()); endpointConfig.put("sequence", sequence);