Search in sources :

Example 1 with CompositeAPI

use of org.wso2.carbon.apimgt.core.models.CompositeAPI in project carbon-apimgt by wso2.

the class ApiDAOImpl method getCompositeAPIs.

@Override
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING")
public List<CompositeAPI> getCompositeAPIs(Set<String> roles, String user, int offset, int limit) throws APIMgtDAOException {
    // TODO: 6/5/17 Implement pagination support when implementing pagination support for
    // other list operations.
    final String query = COMPOSITE_API_SUMMARY_SELECT + " WHERE API_TYPE_ID = " + "(SELECT TYPE_ID FROM AM_API_TYPES WHERE TYPE_NAME = ?) AND PROVIDER = ?";
    try (Connection connection = DAOUtil.getConnection();
        PreparedStatement statement = connection.prepareStatement(query)) {
        statement.setString(1, ApiType.COMPOSITE.toString());
        statement.setString(2, user);
        return getCompositeAPISummaryList(connection, statement);
    } catch (SQLException e) {
        throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting Composite APIs", e);
    }
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with CompositeAPI

use of org.wso2.carbon.apimgt.core.models.CompositeAPI in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method addCompositeAPI.

/**
 * @see APIGateway#addCompositeAPI(CompositeAPI api)
 */
@Override
public void addCompositeAPI(CompositeAPI api) throws GatewayException {
    // build the message to send
    APIEvent gatewayDTO = new APIEvent(APIMgtConstants.GatewayEventTypes.API_CREATE);
    gatewayDTO.setLabels(api.getLabels());
    APISummary apiSummary = new APISummary();
    apiSummary.setName(api.getName());
    apiSummary.setVersion(api.getVersion());
    apiSummary.setContext(api.getContext());
    apiSummary.setThreatProtectionPolicies(api.getThreatProtectionPolicies());
    gatewayDTO.setApiSummary(apiSummary);
    publishToPublisherTopic(gatewayDTO);
}
Also used : APISummary(org.wso2.carbon.apimgt.core.models.APISummary) APIEvent(org.wso2.carbon.apimgt.core.models.events.APIEvent)

Example 3 with CompositeAPI

use of org.wso2.carbon.apimgt.core.models.CompositeAPI in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method deleteCompositeAPI.

@Override
public void deleteCompositeAPI(CompositeAPI api) throws GatewayException {
    // build the message to send
    APIEvent gatewayDTO = new APIEvent(APIMgtConstants.GatewayEventTypes.API_DELETE);
    gatewayDTO.setLabels(api.getLabels());
    APISummary apiSummary = new APISummary();
    apiSummary.setName(api.getName());
    apiSummary.setVersion(api.getVersion());
    apiSummary.setContext(api.getContext());
    apiSummary.setThreatProtectionPolicies(api.getThreatProtectionPolicies());
    gatewayDTO.setApiSummary(apiSummary);
    publishToPublisherTopic(gatewayDTO);
}
Also used : APISummary(org.wso2.carbon.apimgt.core.models.APISummary) APIEvent(org.wso2.carbon.apimgt.core.models.events.APIEvent)

Example 4 with CompositeAPI

use of org.wso2.carbon.apimgt.core.models.CompositeAPI in project carbon-apimgt by wso2.

the class CompositeAPIMappingUtil method toCompositeAPIListDTO.

/**
 * Converts API list to CompositeAPIListDTO list.
 *
 * @param apisResult List of APIs
 * @return CompositeAPIListDTO object
 */
public static CompositeAPIListDTO toCompositeAPIListDTO(List<CompositeAPI> apisResult) {
    CompositeAPIListDTO apiListDTO = new CompositeAPIListDTO();
    apiListDTO.setCount(apisResult.size());
    // apiListDTO.setNext(next);
    // apiListDTO.setPrevious(previous);
    apiListDTO.setList(toCompositeAPIInfo(apisResult));
    return apiListDTO;
}
Also used : CompositeAPIListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIListDTO)

Example 5 with CompositeAPI

use of org.wso2.carbon.apimgt.core.models.CompositeAPI in project carbon-apimgt by wso2.

the class CompositeAPIMappingUtil method toCompositeAPIInfo.

/**
 * Converts {@link CompositeAPI} List to an {@link CompositeAPIInfoDTO} List.
 *
 * @param apiSummaryList
 * @return
 */
private static List<CompositeAPIInfoDTO> toCompositeAPIInfo(List<CompositeAPI> apiSummaryList) {
    List<CompositeAPIInfoDTO> apiInfoList = new ArrayList<>();
    for (CompositeAPI apiSummary : apiSummaryList) {
        CompositeAPIInfoDTO apiInfo = new CompositeAPIInfoDTO();
        apiInfo.setId(apiSummary.getId());
        apiInfo.setContext(apiSummary.getContext());
        apiInfo.setDescription(apiSummary.getDescription());
        apiInfo.setName(apiSummary.getName());
        apiInfo.setProvider(apiSummary.getProvider());
        apiInfo.setVersion(apiSummary.getVersion());
        apiInfo.setApplicationId(apiSummary.getApplicationId());
        apiInfoList.add(apiInfo);
    }
    return apiInfoList;
}
Also used : ArrayList(java.util.ArrayList) CompositeAPI(org.wso2.carbon.apimgt.core.models.CompositeAPI) CompositeAPIInfoDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIInfoDTO)

Aggregations

CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)19 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)9 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 BeforeTest (org.testng.annotations.BeforeTest)3 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)3 CompositeAPIDTO (org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIDTO)3 Request (org.wso2.msf4j.Request)3 IOException (java.io.IOException)2 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)2