Skip to content

Commit

Permalink
Fix: Commented Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Sep 23, 2024
1 parent 6d288b6 commit 36c3c1c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,28 @@ public interface APIProvider extends APIManager {
Comment getComment(ApiTypeWrapper apiTypeWrapper, String commentId, Integer replyLimit, Integer replyOffset) throws
APIManagementException;

/**
* This method is to delete Sequence Backend by type
*
* @param apiUUID API Id
* @param type Key type
* @throws APIManagementException If failed to delete Sequence Backend
*/
void deleteCustomBackendByID(String apiUUID, String type) throws APIManagementException;

/**
* This method is to delete all Sequence Backends by APIID
* @param apiUUID API ID
* @throws APIManagementException If failed to delete Sequence Backend
*/
void deleteCustomBackendByAPIID(String apiUUID) throws APIManagementException;

/**
* This method is to delete Sequence Backends of a specific revision
* @param apiUUID API Id
* @param revisionId Revision Id
* @throws APIManagementException If failed to delete Sequence Backend
*/
void deleteSequenceBackendByRevision(String apiUUID, String revisionId) throws APIManagementException;

/**
Expand Down Expand Up @@ -320,16 +340,37 @@ List<SubscribedAPI> getSubscriptionsOfAPI(String apiName, String apiVersion, Str
*/
API updateAPI(API api, API existingAPI) throws APIManagementException, FaultGatewaysException;

/**
* This method is to update Sequence Backend
*
* @param api API
* @param type Key Type
* @param sequence Sequence Content
* @param seqName Sequence Name
* @param customBackendUUID Sequence Id
* @throws APIManagementException If not updated
*/
void updateCustomBackend(String api, String type, InputStream sequence, String seqName, String customBackendUUID)
throws APIManagementException;

Map<String, Object> getCustomBackendOfAPIByUUID(String customBackendUUID, String apiUUID, String type,
boolean isInfoOnly) throws APIManagementException;

String getCustomBackendSequenceOfAPIByUUID(String apiUUID, String type) throws APIManagementException;

/**
* THis method is to retrieve Sequence Backend data
*
* @param apiUUID API Id
* @param type Key Type
* @return SequenceBackendData object
* @throws APIManagementException If data is not properly retrieved
*/
SequenceBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException;

/**
* This method is to retrieve all Sequence Backends of an API
*
* @param apiUUID API Id
* @return List of Sequence Backends
* @throws APIManagementException If not found
*/

List<SequenceBackendData> getAllSequenceBackendsByAPIUUID(String apiUUID) throws APIManagementException;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.wso2.carbon.apimgt.api.model;

public class SequenceBackendData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.axis2.Constants;
Expand Down Expand Up @@ -1051,18 +1050,6 @@ public void updateCustomBackend(String apiUUID, String type, InputStream sequenc
apiMgtDAO.updateCustomBackend(apiUUID, seqName, sequence, type, customBackendUUID);
}

@Override
public Map<String, Object> getCustomBackendOfAPIByUUID(String customBackendUUID, String apiUUID,
String type, boolean isInfoOnly) throws APIManagementException {
return apiMgtDAO.getCustomBackendOfAPIByUUID(customBackendUUID, apiUUID, type, isInfoOnly);
}

@Override
public String getCustomBackendSequenceOfAPIByUUID(String apiUUID, String type)
throws APIManagementException {
return apiMgtDAO.getCustomBackendSequenceOfAPIByUUID(apiUUID, type);
}

@Override
public SequenceBackendData getCustomBackendByAPIUUID(String apiUUID, String type) throws APIManagementException {
return apiMgtDAO.getCustomBackendByAPIUUID(apiUUID, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21250,27 +21250,8 @@ private void revisionCustomBackend(APIRevision apiRevision, Connection connectio
addPstmt.setString(6, rs.getString("NAME"));
addPstmt.addBatch();
count++;

// CustomBackendData customBackendData = new CustomBackendData();
// customBackendData.setId(rs.getString("ID"));
// customBackendData.setName(rs.getString("NAME"));
// customBackendData.setApiUUID(apiRevision.getApiUUID());
// customBackendData.setRevisionUUID(apiRevision.getRevisionUUID());
// customBackendData.setSequence(rs.getBinaryStream("SEQUENCE"));
// customBackendData.setType(rs.getString("TYPE"));
// customBackendDataList.add(customBackendData);
}
}

// for(CustomBackendData customBackendData: customBackendDataList) {
// addPstmt.setString(1, customBackendData.getId());
// addPstmt.setString(2, customBackendData.getApiUUID());
// addPstmt.setBinaryStream(3, customBackendData.getSequence());
// addPstmt.setString(4, customBackendData.getType());
// addPstmt.setString(5, customBackendData.getRevisionUUID());
// addPstmt.setString(6, customBackendData.getName());
// addPstmt.addBatch();
// }
}
}

if (count > 0) {
addPstmt.executeBatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10033,15 +10033,16 @@ public static InputStream getCustomBackendSequence(String extractedFolderPath, S
customBackendFileName = customBackendFileName + fileExtension;
}
String fileName = extractedFolderPath + File.separator + customBackendFileName;
InputStream inputStream = null;
if (checkFileExistence(fileName)) {
try {
inputStream = new FileInputStream(fileName);
try (InputStream inputStream = new FileInputStream(fileName)) {
return inputStream;
}
} catch (IOException ex) {
handleException("Error reading Custom Backend " + customBackendFileName);
}
}
return inputStream;
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ public static GatewayAPIDTO retrieveGatewayAPIDto(API api, Environment environme
String endpointConfigString = api.getEndpointConfig();
if (StringUtils.isNotBlank(endpointConfigString)) {
try {
// Avoid number format issues in Endpoint Configuration
JsonObject endpointConf = JsonParser.parseString(api.getEndpointConfig()).getAsJsonObject();
if (endpointConf != null && APIConstants.ENDPOINT_TYPE_SEQUENCE.equals(
endpointConf.get(API_ENDPOINT_CONFIG_PROTOCOL_TYPE).getAsString()) && StringUtils.equals(
Expand Down Expand Up @@ -562,7 +563,8 @@ public static GatewayAPIDTO retrieveGatewayAPIDto(API api, Environment environme
}
}
} catch (IOException | ParseException ex) {
throw new APIManagementException("Error when updating Endpoint Configuration", ex);
throw new APIManagementException("Error when updating Endpoint Configuration of API: " + api.getUuid(),
ex);
}
}

Expand Down

0 comments on commit 36c3c1c

Please sign in to comment.