diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIProvider.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIProvider.java index d7573b75f1e7..916492f6edb3 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIProvider.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIProvider.java @@ -66,7 +66,7 @@ public interface APIProvider extends APIManager { Comment getComment(ApiTypeWrapper apiTypeWrapper, String commentId, Integer replyLimit, Integer replyOffset) throws APIManagementException; - void deleteCustomBackendByID(String backendUUID, String apiUUID, String type) throws APIManagementException; + void deleteCustomBackendByID(String apiUUID, String type) throws APIManagementException; void deleteCustomBackendByAPIID(String apiUUID) throws APIManagementException; /** @@ -327,7 +327,9 @@ Map getCustomBackendOfAPIByUUID(String customBackendUUID, String String getCustomBackendSequenceOfAPIByUUID(String apiUUID, String type) throws APIManagementException; - CustomBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException; + SequenceBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException; + + List getAllSequenceBackendsByAPIUUID(String apiUUID) throws APIManagementException; /** * Create a new version of the api, with version newVersion diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java index f8f6067562b4..fac110a81287 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/ExceptionCodes.java @@ -533,8 +533,8 @@ public enum ExceptionCodes implements ErrorHandler { "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"), - CUSTOM_BACKEND_NOT_FOUND(903250, "Custom Backend not found", - 404, "Requested Custom Backend with id '%s' not found"), + CUSTOM_BACKEND_NOT_FOUND(903250, "Sequence Backend not found", + 404, "Requested Sequence Backend of API '%s' not found"), OPERATION_POLICY_ALREADY_EXISTS(903001, "The API Policy already exists.", 409, "An Operation Policy with name '%s' and version '%s' already exists"), diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/CustomBackendData.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/SequenceBackendData.java similarity index 96% rename from components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/CustomBackendData.java rename to components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/SequenceBackendData.java index ab9576002c28..5cccbbbbc433 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/CustomBackendData.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/SequenceBackendData.java @@ -1,6 +1,6 @@ package org.wso2.carbon.apimgt.api.model; -public class CustomBackendData { +public class SequenceBackendData { private String Id; private String sequence; private String type; diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index dfeb1cc79bb1..1d475bcea20b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -71,7 +71,7 @@ import org.wso2.carbon.apimgt.api.model.BlockConditionsDTO; import org.wso2.carbon.apimgt.api.model.Comment; import org.wso2.carbon.apimgt.api.model.CommentList; -import org.wso2.carbon.apimgt.api.model.CustomBackendData; +import org.wso2.carbon.apimgt.api.model.SequenceBackendData; import org.wso2.carbon.apimgt.api.model.DeployedAPIRevision; import org.wso2.carbon.apimgt.api.model.Documentation; import org.wso2.carbon.apimgt.api.model.Documentation.DocumentSourceType; @@ -1061,18 +1061,21 @@ public String getCustomBackendSequenceOfAPIByUUID(String apiUUID, String type) } @Override - public CustomBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException { + public SequenceBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException { return apiMgtDAO.getCustomBackendByAPIUUID(apiUUID, type); } + public List getAllSequenceBackendsByAPIUUID(String apiUUID) throws APIManagementException { + return apiMgtDAO.getSequenceBackendsByAPIUUID(apiUUID); + } + @Override public void deleteCustomBackendByAPIID(String apiUUID) throws APIManagementException { apiMgtDAO.deleteCustomBackendByAPIID(apiUUID); } @Override - public void deleteCustomBackendByID(String backendUUID, String apiUUID, String type) - throws APIManagementException { - apiMgtDAO.deleteCustomBackend(apiUUID, backendUUID, type); + public void deleteCustomBackendByID(String apiUUID, String type) throws APIManagementException { + apiMgtDAO.deleteCustomBackend(apiUUID, type); } private void validateKeyManagers(API api) throws APIManagementException { diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java index a4c304706031..35f024d73971 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java @@ -59,7 +59,7 @@ import org.wso2.carbon.apimgt.api.model.BlockConditionsDTO; import org.wso2.carbon.apimgt.api.model.Comment; import org.wso2.carbon.apimgt.api.model.CommentList; -import org.wso2.carbon.apimgt.api.model.CustomBackendData; +import org.wso2.carbon.apimgt.api.model.SequenceBackendData; import org.wso2.carbon.apimgt.api.model.DeployedAPIRevision; import org.wso2.carbon.apimgt.api.model.Environment; import org.wso2.carbon.apimgt.api.model.GatewayPolicyData; @@ -11194,27 +11194,49 @@ public Map retrieveCustomBackendOfAPIRevision(String apiUUID, St return map; } - public CustomBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException { + public SequenceBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException { String sqlQuery = SQLConstants.CustomBackendConstants.GET_API_SPECIFIC_CUSTOM_BACKEND_FROM_SEQUENCE_ID; - CustomBackendData customBackendData = null; + SequenceBackendData sequenceBackendData = null; try (Connection con = APIMgtDBUtil.getConnection(); PreparedStatement ps = con.prepareStatement(sqlQuery)) { ps.setString(1, apiUUID); ps.setString(2, type); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { - customBackendData = new CustomBackendData(); - customBackendData.setApiUUID(apiUUID); - customBackendData.setRevisionUUID("0"); - customBackendData.setSequence(IOUtils.toString(rs.getBinaryStream("SEQUENCE"))); - customBackendData.setId(rs.getString("ID")); - customBackendData.setName(rs.getString("NAME")); - customBackendData.setType(type); + sequenceBackendData = new SequenceBackendData(); + sequenceBackendData.setApiUUID(apiUUID); + sequenceBackendData.setRevisionUUID("0"); + sequenceBackendData.setSequence(IOUtils.toString(rs.getBinaryStream("SEQUENCE"))); + sequenceBackendData.setId(rs.getString("ID")); + sequenceBackendData.setName(rs.getString("NAME")); + sequenceBackendData.setType(type); } } } catch (SQLException | IOException ex) { handleException("Error when fetching Custom Backend data for API: " + apiUUID, ex); } - return customBackendData; + return sequenceBackendData; + } + + public List getSequenceBackendsByAPIUUID(String apiUUID) throws APIManagementException { + String sqlQuery = SQLConstants.CustomBackendConstants.GET_ALL_API_SPECIFIC_CUSTOM_BACKENDS; + List backendDataList = new ArrayList<>(); + try (Connection con = APIMgtDBUtil.getConnection(); PreparedStatement ps = con.prepareStatement(sqlQuery)) { + ps.setString(1, apiUUID); + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + SequenceBackendData sqBackend = new SequenceBackendData(); + sqBackend.setApiUUID(apiUUID); + sqBackend.setId(rs.getString("ID")); + sqBackend.setName(rs.getString("NAME")); + sqBackend.setType(rs.getString("TYPE")); + backendDataList.add(sqBackend); + } + } + return backendDataList; + } catch (SQLException ex) { + handleException("Error when retrieving Sequence Backends of API: " + apiUUID, ex); + } + return null; } public String getCustomBackendSequenceOfAPIByUUID(String apiUUID, String type) throws APIManagementException { @@ -20919,14 +20941,13 @@ public void updateCustomBackend(String apiUUID, String sequenceName, InputStream } } - public void deleteCustomBackend(String apiUUID, String type, String backendUUID) throws APIManagementException { + public void deleteCustomBackend(String apiUUID, String type) throws APIManagementException { String deleteCustomBackedQuery = SQLConstants.CustomBackendConstants.DELETE_CUSTOM_BACKEND; try (Connection connection = APIMgtDBUtil.getConnection(); PreparedStatement prepStmt = connection.prepareStatement(deleteCustomBackedQuery)) { connection.setAutoCommit(false); prepStmt.setString(1, apiUUID); - prepStmt.setString(2, backendUUID); - prepStmt.setString(3, type); + prepStmt.setString(2, type); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { @@ -21210,7 +21231,7 @@ private void revisionCustomBackend(APIRevision apiRevision, Connection connectio PreparedStatement addPstmt = connection.prepareStatement(addCBSqlQuery)) { connection.setAutoCommit(false); getPstmt.setString(1, apiRevision.getApiUUID()); - List customBackendDataList = new ArrayList<>(); + List sequenceBackendDataList = new ArrayList<>(); int count = 0; try (ResultSet rs = getPstmt.executeQuery()) { diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java index 89bdad683ff9..f80bd85a028d 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java @@ -4406,7 +4406,7 @@ public static class CustomBackendConstants { "INSERT INTO AM_API_CUSTOM_BACKEND (ID,API_UUID,SEQUENCE,TYPE,REVISION_UUID,NAME) " + "VALUES (?,?,?,?,?,?)"; public static final String DELETE_WORKING_COPY_OF_CUSTOM_BACKEND = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND REVISION_UUID = '0'"; - public static final String DELETE_CUSTOM_BACKEND = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND TYPE = ? AND ID = ? AND REVISION_UUID = '0'"; + public static final String DELETE_CUSTOM_BACKEND = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND TYPE = ? AND REVISION_UUID = '0'"; public static final String DELETE_CUSTOM_BACKEND_BY_API_AND_TYPE = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND TYPE = ? AND REVISION_UUID = '0'"; public static final String DELETE_CUSTOM_BACKEND_BY_REVISION = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND REVISION_UUID = ?"; public static final String DELETE_CUSTOM_BACKEND_BY_API = "DELETE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ?"; @@ -4414,12 +4414,7 @@ public static class CustomBackendConstants { public static final String GET_CUSTOM_BACKEND_OF_API_DEFAULT_REVISION = "SELECT ACB.NAME, ACB.TYPE FROM AM_API_CUSTOM_BACKEND WHERE API_UUID = ? AND REVISION_UUID = '0'"; public static final String GET_REVISION_SPECIFIC_CUSTOM_BACKEND_FROM_SEQUENCE_ID = "SELECT ACB.ID, ACB.NAME, ACB.SEQUENCE, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.ID = ? AND ACB.REVISION_UUID = ? AND ACB.TYPE = ?"; public static final String GET_API_SPECIFIC_CUSTOM_BACKEND_FROM_SEQUENCE_ID = "SELECT ACB.ID, ACB.NAME, ACB.SEQUENCE, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.API_UUID = ? AND ACB.REVISION_UUID = '0' AND ACB.TYPE = ?"; - public static final String GET_CUSTOM_BACKEND_FROM_API_AND_REVISION_UUID = "SELECT ACB.ID, ACB.NAME, ACB.SEQUENCE, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.API_UUID = ? AND ACB.REVISION_UUID = ? AND ACB.TYPE = ?"; public static final String GET_ALL_API_SPECIFIC_CUSTOM_BACKENDS = "SELECT ACB.ID, ACB.NAME, ACB.SEQUENCE, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.API_UUID = ? AND ACB.REVISION_UUID = '0'"; - public static final String GET_REVISION_SPECIFIC_CUSTOM_BACKEND_META_DATA_FROM_SEQUENCE_ID = "SELECT ACB.ID, ACB.NAME, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.ID = ? AND ACB.REVISION_UUID = ?"; - public static final String GET_API_SPECIFIC_CUSTOM_BACKEND_META_DATA_FROM_SEQUENCE_ID = "SELECT ACB.ID, ACB.NAME, ACB.TYPE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.ID = ? AND API_UUID = ?"; - public static final String GET_API_SPECIFIC_CUSTOM_BACKEND_SEQUENCE_FROM_SEQUENCE_ID = "SELECT ACB.SEQUENCE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.ID = ? AND API_UUID = ?"; - public static final String GET_REVISION_SPECIFIC_CUSTOM_BACKEND_SEQUENCE_FROM_SEQUENCE_ID = "SELECT ACB.SEQUENCE FROM AM_API_CUSTOM_BACKEND ACB WHERE ACB.ID = ? AND ACB.REVISION_UUID = ?"; } } diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml index 425dfb6eff11..43d1ad0dbf4b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml @@ -582,8 +582,8 @@ paths: get: tags: - APIs - summary: Get Custom Backends of the API - description: This operation can be used to get Custom Backend data of the API + summary: Get Sequence Backends of the API + description: This operation can be used to get Sequence Backend data of the API operationId: getSequenceBackendData parameters: - $ref: '#/components/parameters/apiId' @@ -591,7 +591,7 @@ paths: 200: description: | OK. - Requested API Custom Backend is returned + Requested API Sequence Backend is returned headers: Content-Type: description: | @@ -655,7 +655,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SequenceBackend' + $ref: '#/components/schemas/API' 400: $ref: '#/components/responses/BadRequest' 403: 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/APIMappingUtil.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/APIMappingUtil.java index ea653cfe901f..c5aa85b00d2b 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/APIMappingUtil.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/APIMappingUtil.java @@ -53,6 +53,7 @@ import org.wso2.carbon.apimgt.api.model.OperationPolicy; import org.wso2.carbon.apimgt.api.model.ResourcePath; import org.wso2.carbon.apimgt.api.model.Scope; +import org.wso2.carbon.apimgt.api.model.SequenceBackendData; import org.wso2.carbon.apimgt.api.model.ServiceEntry; import org.wso2.carbon.apimgt.api.model.Tier; import org.wso2.carbon.apimgt.api.model.URITemplate; @@ -114,6 +115,8 @@ import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyInfoDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ScopeDTO; +import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SequenceBackendDTO; +import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SequenceBackendListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLInfoDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLValidationResponseDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLValidationResponseWsdlInfoDTO; @@ -503,6 +506,22 @@ public static MockResponsePayloadInfoDTO fromMockPayloadToDTO(APIResourceMediati return mockResponsePayloadInfoDTO; } + public static SequenceBackendListDTO fromSequenceDataToDTO(List list) { + SequenceBackendListDTO res = new SequenceBackendListDTO(); + res.setCount(list.size()); + List backends = new ArrayList<>(); + + for (SequenceBackendData backend : list) { + SequenceBackendDTO dto = new SequenceBackendDTO(); + dto.sequenceId(backend.getId()); + dto.setSequenceName(backend.getName()); + dto.setSequenceType(backend.getType()); + backends.add(dto); + } + res.setList(backends); + return res; + } + /** * This method creates the API monetization information DTO. * 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/ExportUtils.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/ExportUtils.java index 3dcceebe0974..6c870190c540 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/ExportUtils.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/ExportUtils.java @@ -46,7 +46,7 @@ import org.wso2.carbon.apimgt.api.model.APIProductIdentifier; import org.wso2.carbon.apimgt.api.model.APIRevision; import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; -import org.wso2.carbon.apimgt.api.model.CustomBackendData; +import org.wso2.carbon.apimgt.api.model.SequenceBackendData; import org.wso2.carbon.apimgt.api.model.Documentation; import org.wso2.carbon.apimgt.api.model.DocumentationContent; import org.wso2.carbon.apimgt.api.model.Identifier; @@ -218,11 +218,10 @@ public static File exportApi(APIProvider apiProvider, APIIdentifier apiIdentifie addOperationPoliciesToArchive(archivePath, tenantDomain, exportFormat, apiProvider, api, currentApiUuid); - // TODO: Add Custom Backend to the Archive JsonObject endpointConfig = JsonParser.parseString(api.getEndpointConfig()).getAsJsonObject(); if (APIConstants.ENDPOINT_TYPE_SEQUENCE.equals( endpointConfig.get(API_ENDPOINT_CONFIG_PROTOCOL_TYPE).getAsString())) { - addCustomBackendToArchive(archivePath, apiProvider, currentApiUuid, endpointConfig); + addCustomBackendToArchive(archivePath, apiProvider, currentApiUuid); } addGatewayEnvironmentsToArchive(archivePath, apiDtoToReturn.getId(), exportFormat, apiProvider); @@ -637,20 +636,21 @@ public static void addEndpointCertificatesToArchive(String archivePath, APIDTO a } } - public static void addCustomBackendToArchive(String archivePath, APIProvider apiProvider, String apiUUID, - JsonObject endpointConfig) throws APIManagementException { + public static void addCustomBackendToArchive(String archivePath, APIProvider apiProvider, String apiUUID) + throws APIManagementException { try { CommonUtil.createDirectory(archivePath + File.separator + ImportExportConstants.CUSTOM_BACKEND_DIRECTORY); // Add production Backend Sequences - CustomBackendData data = apiProvider.getCustomBackendByAPIUUID(apiUUID, APIConstants.API_KEY_TYPE_PRODUCTION); - if(data != null) { + SequenceBackendData data = apiProvider.getCustomBackendByAPIUUID(apiUUID, + APIConstants.API_KEY_TYPE_PRODUCTION); + if (data != null) { exportCustomBackend(data.getName(), data.getSequence(), archivePath); } // Add sandbox Backend Sequences data = apiProvider.getCustomBackendByAPIUUID(apiUUID, APIConstants.API_KEY_TYPE_SANDBOX); - if(data != null) { + if (data != null) { exportCustomBackend(data.getName(), data.getSequence(), archivePath); } 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 da933e6779f4..f9bd2111af74 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 @@ -18,7 +18,6 @@ package org.wso2.carbon.apimgt.rest.api.publisher.v1.common.mappings; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -696,7 +695,8 @@ public static void updateAPIWithCustomBackend(API api, String extractedFolderPat String seqName = APIUtil.getCustomBackendName(api.getUuid(), APIConstants.API_KEY_TYPE_PRODUCTION); String seqId = UUID.randomUUID().toString(); InputStream seq = APIUtil.getCustomBackendSequence(customBackendDir, seqFile, ".xml"); - apiProvider.updateCustomBackend(api.getUuid(), APIConstants.API_KEY_TYPE_PRODUCTION, seq, seqName, seqId); + apiProvider.updateCustomBackend(api.getUuid(), APIConstants.API_KEY_TYPE_PRODUCTION, seq, seqName, + seqId); } } } 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 d273ff6a0286..a0702427f5d4 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 @@ -196,7 +196,6 @@ public static API updateApi(API originalAPI, APIDTO apiDtoToUpdate, APIProvider * @param endpointType Endpoint Type of the Custom Backend (SANDBOX, PRODUCTION) * @param customBackend Custom Backend * @param contentDecomp Header Content of the Request - * @return Custom Backend File Name * @throws APIManagementException If an error occurs while updating the API and API definition */ public static void updateCustomBackend(API api, APIProvider apiProvider, String endpointType, diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java index de78a60c201f..b7e7ba99c886 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java @@ -40,18 +40,21 @@ import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePathListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyInfoDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyListDTO; -import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SequenceBackendDTO; +import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SequenceBackendListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ThrottlingPolicyDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.TopicListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLInfoDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLValidationResponseDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO; +import org.wso2.carbon.apimgt.rest.api.publisher.v1.ApisApiService; import org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl; import org.wso2.carbon.apimgt.api.APIManagementException; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.inject.Inject; import io.swagger.annotations.*; import java.io.InputStream; @@ -60,6 +63,8 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.util.Map; +import java.util.List; import javax.validation.constraints.*; @Path("/apis") @@ -373,49 +378,6 @@ public Response createNewAPIVersion( @NotNull @Size(max=30) @ApiParam(value = "V return delegate.createNewAPIVersion(newVersion, apiId, defaultVersion, serviceVersion, securityContext); } - @DELETE - @Path("/{apiId}/custom-backend/{customBackendId}") - - @Produces({ "application/json" }) - @ApiOperation(value = "Delete Custom Backend of the API", notes = "This operation can be used to remove the Custom Backend of the API", response = Void.class, authorizations = { - @Authorization(value = "OAuth2Security", scopes = { - @AuthorizationScope(scope = "apim:api_delete", description = "Delete API"), - @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), - @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations") - }) - }, tags={ "APIs", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. Resource successfully deleted. ", response = Void.class), - @ApiResponse(code = 403, message = "Forbidden. The request must be conditional but no condition has been specified.", response = ErrorDTO.class), - @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), - @ApiResponse(code = 409, message = "Conflict. Specified resource already exists.", response = ErrorDTO.class), - @ApiResponse(code = 412, message = "Precondition Failed. The request has not been performed because one of the preconditions is not met.", response = ErrorDTO.class) }) - public Response customBackendDelete( @NotNull @Size(max=15) @ApiParam(value = "Type of the Endpoint. SANDBOX or PRODUCTION ",required=true) @QueryParam("type") String type, @ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId, @ApiParam(value = "Custom Backend ID ",required=true) @PathParam("customBackendId") String customBackendId) throws APIManagementException{ - return delegate.customBackendDelete(type, apiId, customBackendId, securityContext); - } - - @PUT - @Path("/{apiId}/custom-backend") - @Consumes({ "multipart/form-data" }) - @Produces({ "application/json" }) - @ApiOperation(value = "Upload Custom Sequence as the Endpoint of the API", notes = "This operation can be used to change the endpoint of the API to Custom Sequence", response = APIDTO.class, authorizations = { - @Authorization(value = "OAuth2Security", scopes = { - @AuthorizationScope(scope = "apim:api_create", description = "Create API"), - @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), - @AuthorizationScope(scope = "apim:api_publish", description = "Publish API") - }) - }, tags={ "APIs", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. Successful response with updated API object ", response = APIDTO.class), - @ApiResponse(code = 400, message = "Bad Request. Invalid request or validation error.", response = ErrorDTO.class), - @ApiResponse(code = 403, message = "Forbidden. The request must be conditional but no condition has been specified.", response = ErrorDTO.class), - @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), - @ApiResponse(code = 409, message = "Conflict. Specified resource already exists.", response = ErrorDTO.class), - @ApiResponse(code = 412, message = "Precondition Failed. The request has not been performed because one of the preconditions is not met.", response = ErrorDTO.class) }) - public Response customBackendUpdate(@ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId, @Multipart(value = "sequence", required = false) InputStream sequenceInputStream, @Multipart(value = "sequence" , required = false) Attachment sequenceDetail, @Multipart(value = "type", required = false) String type) throws APIManagementException{ - return delegate.customBackendUpdate(apiId, sequenceInputStream, sequenceDetail, type, securityContext); - } - @DELETE @Path("/{apiId}") @@ -1327,48 +1289,6 @@ public Response getAuditReportOfAPI(@ApiParam(value = "**API ID** consisting of return delegate.getCommentOfAPI(commentId, apiId, xWSO2Tenant, ifNoneMatch, includeCommenterInfo, replyLimit, replyOffset, securityContext); } - @GET - @Path("/{apiId}/custom-backend/{customBackendId}") - - @Produces({ "application/json" }) - @ApiOperation(value = "Get Custom Backend of the API", notes = "This operation can be used to get Custom Backend data of the API", response = SequenceBackendDTO.class, authorizations = { - @Authorization(value = "OAuth2Security", scopes = { - @AuthorizationScope(scope = "apim:api_view", description = "View API"), - @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), - @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations"), - @AuthorizationScope(scope = "apim:api_product_import_export", description = "Import and export API Products related operations") - }) - }, tags={ "APIs", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. Requested API Custom Backend is returned ", response = SequenceBackendDTO.class), - @ApiResponse(code = 304, message = "Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). ", response = Void.class), - @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), - @ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported.", response = ErrorDTO.class) }) - public Response getCustomBackendData( @NotNull @Size(max=15) @ApiParam(value = "Type of the Endpoint. SANDBOX or PRODUCTION ",required=true) @QueryParam("type") String type, @ApiParam(value = "Custom Backend ID ",required=true) @PathParam("customBackendId") String customBackendId, @ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId) throws APIManagementException{ - return delegate.getCustomBackendData(type, customBackendId, apiId, securityContext); - } - - @GET - @Path("/{apiId}/custom-backend/{customBackendId}/content") - - @Produces({ "application/zip", "application/json" }) - @ApiOperation(value = "Get Sequence of Custom Backend", notes = "This operation can be used to get Sequence of the Custom Backend", response = File.class, authorizations = { - @Authorization(value = "OAuth2Security", scopes = { - @AuthorizationScope(scope = "apim:api_view", description = "View API"), - @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), - @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations"), - @AuthorizationScope(scope = "apim:api_product_import_export", description = "Import and export API Products related operations") - }) - }, tags={ "APIs", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. Requested API Custom Backend is returned ", response = File.class), - @ApiResponse(code = 304, message = "Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). ", response = Void.class), - @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), - @ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported.", response = ErrorDTO.class) }) - public Response getCustomBackendDataContent( @NotNull @Size(max=15) @ApiParam(value = "Type of the Endpoint. SANDBOX or PRODUCTION ",required=true) @QueryParam("type") String type, @ApiParam(value = "Custom Backend ID ",required=true) @PathParam("customBackendId") String customBackendId, @ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId) throws APIManagementException{ - return delegate.getCustomBackendDataContent(type, customBackendId, apiId, securityContext); - } - @GET @Path("/{apiId}/generated-mock-scripts") @@ -1469,6 +1389,46 @@ public Response getOperationPolicyForAPIByPolicyId(@ApiParam(value = "**API ID** return delegate.getRepliesOfComment(commentId, apiId, xWSO2Tenant, limit, offset, ifNoneMatch, includeCommenterInfo, securityContext); } + @GET + @Path("/{apiId}/sequence-backend/{type}/content") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get Sequence of Custom Backend", notes = "This operation can be used to get Sequence of the Custom Backend", response = File.class, authorizations = { + @Authorization(value = "OAuth2Security", scopes = { + @AuthorizationScope(scope = "apim:api_view", description = "View API"), + @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), + @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations"), + @AuthorizationScope(scope = "apim:api_product_import_export", description = "Import and export API Products related operations") + }) + }, tags={ "APIs", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. Requested API Custom Backend is returned ", response = File.class), + @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), + @ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported.", response = ErrorDTO.class) }) + public Response getSequenceBackendContent( @NotNull @Size(max=15) @ApiParam(value = "Type of the Endpoint. SANDBOX or PRODUCTION ",required=true) @QueryParam("type") String type, @ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId) throws APIManagementException{ + return delegate.getSequenceBackendContent(type, apiId, securityContext); + } + + @GET + @Path("/{apiId}/sequence-backend") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get Sequence Backends of the API", notes = "This operation can be used to get Sequence Backend data of the API", response = SequenceBackendListDTO.class, authorizations = { + @Authorization(value = "OAuth2Security", scopes = { + @AuthorizationScope(scope = "apim:api_view", description = "View API"), + @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), + @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations"), + @AuthorizationScope(scope = "apim:api_product_import_export", description = "Import and export API Products related operations") + }) + }, tags={ "APIs", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. Requested API Sequence Backend is returned ", response = SequenceBackendListDTO.class), + @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), + @ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported.", response = ErrorDTO.class) }) + public Response getSequenceBackendData(@ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId) throws APIManagementException{ + return delegate.getSequenceBackendData(apiId, securityContext); + } + @GET @Path("/{apiId}/wsdl-info") @@ -1670,6 +1630,49 @@ public Response restoreAPIRevision(@ApiParam(value = "**API ID** consisting of t return delegate.restoreAPIRevision(apiId, revisionId, securityContext); } + @DELETE + @Path("/{apiId}/sequence-backend/{type}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete Sequence Backend of the API", notes = "This operation can be used to remove the Sequence Backend of the API", response = Void.class, authorizations = { + @Authorization(value = "OAuth2Security", scopes = { + @AuthorizationScope(scope = "apim:api_delete", description = "Delete API"), + @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), + @AuthorizationScope(scope = "apim:api_import_export", description = "Import and export APIs related operations") + }) + }, tags={ "APIs", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. Resource successfully deleted. ", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden. The request must be conditional but no condition has been specified.", response = ErrorDTO.class), + @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), + @ApiResponse(code = 409, message = "Conflict. Specified resource already exists.", response = ErrorDTO.class), + @ApiResponse(code = 412, message = "Precondition Failed. The request has not been performed because one of the preconditions is not met.", response = ErrorDTO.class) }) + public Response sequenceBackendDelete( @Size(max=15)@ApiParam(value = "Type of the Endpoint. SANDBOX or PRODUCTION ",required=true) @PathParam("type") String type, @ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId) throws APIManagementException{ + return delegate.sequenceBackendDelete(type, apiId, securityContext); + } + + @PUT + @Path("/{apiId}/sequence-backend") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Upload Sequence Sequence as the Endpoint of the API", notes = "This operation can be used to change the endpoint of the API to Sequence Backend", response = APIDTO.class, authorizations = { + @Authorization(value = "OAuth2Security", scopes = { + @AuthorizationScope(scope = "apim:api_create", description = "Create API"), + @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), + @AuthorizationScope(scope = "apim:api_publish", description = "Publish API") + }) + }, tags={ "APIs", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. Successful response with updated API object ", response = APIDTO.class), + @ApiResponse(code = 400, message = "Bad Request. Invalid request or validation error.", response = ErrorDTO.class), + @ApiResponse(code = 403, message = "Forbidden. The request must be conditional but no condition has been specified.", response = ErrorDTO.class), + @ApiResponse(code = 404, message = "Not Found. The specified resource does not exist.", response = ErrorDTO.class), + @ApiResponse(code = 409, message = "Conflict. Specified resource already exists.", response = ErrorDTO.class), + @ApiResponse(code = 412, message = "Precondition Failed. The request has not been performed because one of the preconditions is not met.", response = ErrorDTO.class) }) + public Response sequenceBackendUpdate(@ApiParam(value = "**API ID** consisting of the **UUID** of the API. ",required=true) @PathParam("apiId") String apiId, @Multipart(value = "sequence", required = false) InputStream sequenceInputStream, @Multipart(value = "sequence" , required = false) Attachment sequenceDetail, @Multipart(value = "type", required = false) String type) throws APIManagementException{ + return delegate.sequenceBackendUpdate(apiId, sequenceInputStream, sequenceDetail, type, securityContext); + } + @POST @Path("/{apiId}/undeploy-revision") @Consumes({ "application/json" }) diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java index 3689bd7900cf..43ae632361ce 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java @@ -27,7 +27,6 @@ import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ClientCertificatesDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.CommentDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.CommentListDTO; -import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.CustomBackendDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.DocumentDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.DocumentListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorDTO; @@ -50,6 +49,7 @@ import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePathListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyInfoDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePolicyListDTO; +import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SequenceBackendListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ThrottlingPolicyDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.TopicListDTO; import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WSDLInfoDTO; @@ -80,8 +80,6 @@ public interface ApisApiService { public Response createAPI(APIDTO APIDTO, String openAPIVersion, MessageContext messageContext) throws APIManagementException; public Response createAPIRevision(String apiId, APIRevisionDTO apIRevisionDTO, MessageContext messageContext) throws APIManagementException; public Response createNewAPIVersion(String newVersion, String apiId, Boolean defaultVersion, String serviceVersion, MessageContext messageContext) throws APIManagementException; - public Response customBackendDelete(String type, String apiId, String customBackendId, MessageContext messageContext) throws APIManagementException; - public Response customBackendUpdate(String apiId, InputStream sequenceInputStream, Attachment sequenceDetail, String type, MessageContext messageContext) throws APIManagementException; public Response deleteAPI(String apiId, String ifMatch, MessageContext messageContext) throws APIManagementException; public Response deleteAPIClientCertificateByAlias(String alias, String apiId, MessageContext messageContext) throws APIManagementException; public Response deleteAPIClientCertificateByKeyTypeAndAlias(String keyType, String alias, String apiId, MessageContext messageContext) throws APIManagementException; @@ -128,13 +126,13 @@ public interface ApisApiService { public Response getAmazonResourceNamesOfAPI(String apiId, MessageContext messageContext) throws APIManagementException; public Response getAuditReportOfAPI(String apiId, String accept, MessageContext messageContext) throws APIManagementException; public Response getCommentOfAPI(String commentId, String apiId, String xWSO2Tenant, String ifNoneMatch, Boolean includeCommenterInfo, Integer replyLimit, Integer replyOffset, MessageContext messageContext) throws APIManagementException; - public Response getCustomBackendData(String type, String customBackendId, String apiId, MessageContext messageContext) throws APIManagementException; - public Response getCustomBackendDataContent(String type, String customBackendId, String apiId, MessageContext messageContext) throws APIManagementException; public Response getGeneratedMockScriptsOfAPI(String apiId, String ifNoneMatch, MessageContext messageContext) throws APIManagementException; public Response getGraphQLPolicyComplexityOfAPI(String apiId, MessageContext messageContext) throws APIManagementException; public Response getGraphQLPolicyComplexityTypesOfAPI(String apiId, MessageContext messageContext) throws APIManagementException; public Response getOperationPolicyForAPIByPolicyId(String apiId, String operationPolicyId, MessageContext messageContext) throws APIManagementException; public Response getRepliesOfComment(String commentId, String apiId, String xWSO2Tenant, Integer limit, Integer offset, String ifNoneMatch, Boolean includeCommenterInfo, MessageContext messageContext) throws APIManagementException; + public Response getSequenceBackendContent(String type, String apiId, MessageContext messageContext) throws APIManagementException; + public Response getSequenceBackendData(String apiId, MessageContext messageContext) throws APIManagementException; public Response getWSDLInfoOfAPI(String apiId, MessageContext messageContext) throws APIManagementException; public Response getWSDLOfAPI(String apiId, String ifNoneMatch, MessageContext messageContext) throws APIManagementException; public Response importAPI(InputStream fileInputStream, Attachment fileDetail, Boolean preserveProvider, Boolean rotateRevision, Boolean overwrite, Boolean preservePortalConfigurations, String accept, MessageContext messageContext) throws APIManagementException; @@ -146,6 +144,8 @@ public interface ApisApiService { public Response publishAPIToExternalStores(String apiId, String externalStoreIds, String ifMatch, MessageContext messageContext) throws APIManagementException; public Response reimportServiceFromCatalog(String apiId, MessageContext messageContext) throws APIManagementException; public Response restoreAPIRevision(String apiId, String revisionId, MessageContext messageContext) throws APIManagementException; + public Response sequenceBackendDelete(String type, String apiId, MessageContext messageContext) throws APIManagementException; + public Response sequenceBackendUpdate(String apiId, InputStream sequenceInputStream, Attachment sequenceDetail, String type, MessageContext messageContext) throws APIManagementException; public Response undeployAPIRevision(String apiId, String revisionId, String revisionNumber, Boolean allEnvironments, List apIRevisionDeploymentDTO, MessageContext messageContext) throws APIManagementException; public Response updateAPI(String apiId, APIDTO APIDTO, String ifMatch, MessageContext messageContext) throws APIManagementException; public Response updateAPIClientCertificateByAlias(String alias, String apiId, InputStream certificateInputStream, Attachment certificateDetail, String tier, MessageContext messageContext) throws APIManagementException; diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java index c7f968c11529..d6216a641003 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java @@ -164,35 +164,31 @@ public Response getAllAPIs(Integer limit, Integer offset, String sortBy, String } @Override - public Response getCustomBackendData(String type, String customBackendId, String apiId, - MessageContext messageContext) throws APIManagementException { + public Response getSequenceBackendData(String apiId, MessageContext messageContext) throws APIManagementException { APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider(); //validate if api exists CommonUtils.validateAPIExistence(apiId); - CustomBackendData data = apiProvider.getCustomBackendByAPIUUID(apiId, type); + List data = apiProvider.getAllSequenceBackendsByAPIUUID(apiId); if (data == null) { throw new APIMgtResourceNotFoundException( - "Couldn't retrieve an existing Custom Backend with ID: " + customBackendId + " for API " + apiId, - ExceptionCodes.from(ExceptionCodes.CUSTOM_BACKEND_NOT_FOUND, customBackendId)); + "Couldn't retrieve an existing Sequence Backend for API " + apiId, + ExceptionCodes.from(ExceptionCodes.CUSTOM_BACKEND_NOT_FOUND, apiId)); } - SequenceBackendDTO backendDTO = new SequenceBackendDTO(); - backendDTO.setSequenceName(data.getName()); - backendDTO.setSequenceId(data.getId()); - return Response.ok().entity(backendDTO).build(); + SequenceBackendListDTO respObj = APIMappingUtil.fromSequenceDataToDTO(data); + return Response.ok().entity(respObj).build(); } @Override - public Response getCustomBackendDataContent(String type, String customBackendId, String apiId, - MessageContext messageContext) throws APIManagementException { + public Response getSequenceBackendContent(String type, String apiId, MessageContext messageContext) throws APIManagementException { APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider(); CommonUtils.validateAPIExistence(apiId); - CustomBackendData data = apiProvider.getCustomBackendByAPIUUID(apiId, type); + SequenceBackendData data = apiProvider.getCustomBackendByAPIUUID(apiId, type); if (data == null) { throw new APIMgtResourceNotFoundException( - "Couldn't retrieve an existing Custom Backend with ID: " + customBackendId + " for API " + apiId, - ExceptionCodes.from(ExceptionCodes.CUSTOM_BACKEND_NOT_FOUND, customBackendId)); + "Couldn't retrieve an existing Sequence Backend for API: " + apiId, + ExceptionCodes.from(ExceptionCodes.CUSTOM_BACKEND_NOT_FOUND, apiId)); } File file = RestApiPublisherUtils.exportCustomBackendData(data.getSequence(), data.getName()); return Response.ok(file) @@ -201,12 +197,11 @@ public Response getCustomBackendDataContent(String type, String customBackendId, } @Override - public Response customBackendDelete(String type, String apiId, String customBackendId, - MessageContext messageContext) throws APIManagementException { + public Response sequenceBackendDelete(String type, String apiId, MessageContext messageContext) throws APIManagementException { APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider(); //validate if api exists CommonUtils.validateAPIExistence(apiId); - apiProvider.deleteCustomBackendByID(apiId, customBackendId, type); + apiProvider.deleteCustomBackendByID(apiId, type); return Response.ok().build(); } @@ -246,7 +241,7 @@ public Response getAPI(String apiId, String xWSO2Tenant, String ifNoneMatch, } @Override - public Response customBackendUpdate(String apiId, InputStream sequenceInputStream, + public Response sequenceBackendUpdate(String apiId, InputStream sequenceInputStream, Attachment sequenceDetail, String type, MessageContext messageContext) throws APIManagementException { String username = RestApiCommonUtil.getLoggedInUsername(); APIProvider apiProvider = RestApiCommonUtil.getProvider(username);