Search in sources :

Example 1 with APISummary

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

the class ApiDAOImpl method constructAPISummaryList.

private List<API> constructAPISummaryList(Connection connection, PreparedStatement statement) throws SQLException {
    List<API> apiList = new ArrayList<>();
    try (ResultSet rs = statement.executeQuery()) {
        while (rs.next()) {
            String apiPrimaryKey = rs.getString("UUID");
            API apiSummary = new API.APIBuilder(rs.getString("PROVIDER"), rs.getString("NAME"), rs.getString("VERSION")).id(apiPrimaryKey).context(rs.getString("CONTEXT")).description(rs.getString("DESCRIPTION")).lifeCycleStatus(rs.getString("CURRENT_LC_STATUS")).lifecycleInstanceId(rs.getString("LIFECYCLE_INSTANCE_ID")).workflowStatus(rs.getString("LC_WORKFLOW_STATUS")).securityScheme(rs.getInt("SECURITY_SCHEME")).threatProtectionPolicies(getThreatProtectionPolicies(connection, apiPrimaryKey)).build();
            apiList.add(apiSummary);
        }
    }
    return apiList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) CompositeAPI(org.wso2.carbon.apimgt.core.models.CompositeAPI) API(org.wso2.carbon.apimgt.core.models.API)

Example 2 with APISummary

use of org.wso2.carbon.apimgt.core.models.APISummary 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 APISummary

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

the class APIGatewayPublisherImpl method toAPISummary.

/**
 * Convert API definition into APISummary
 *
 * @param api API definition
 * @return The summary of the API
 */
private APISummary toAPISummary(API api) {
    APISummary apiSummary = new APISummary();
    apiSummary.setId(api.getId());
    apiSummary.setName(api.getName());
    apiSummary.setVersion(api.getVersion());
    apiSummary.setContext(api.getContext());
    apiSummary.setLifeCycleStatus(api.getLifeCycleStatus());
    apiSummary.setLifeCycleStatus(api.getLifeCycleStatus());
    apiSummary.setCreatedTime(api.getCreatedTime());
    apiSummary.setLastUpdatedTime(api.getLastUpdatedTime());
    apiSummary.setSecurityScheme(api.getSecurityScheme());
    apiSummary.setThreatProtectionPolicies(api.getThreatProtectionPolicies());
    return apiSummary;
}
Also used : APISummary(org.wso2.carbon.apimgt.core.models.APISummary)

Example 4 with APISummary

use of org.wso2.carbon.apimgt.core.models.APISummary 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 5 with APISummary

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

the class MappingUtil method toAPIInfo.

/**
 * Converts {@link API} List to an {@link APIInfoDTO} List.
 *
 * @param apiSummaryList
 * @return
 */
private static List<APIInfoDTO> toAPIInfo(List<API> apiSummaryList) {
    List<APIInfoDTO> apiInfoList = new ArrayList<APIInfoDTO>();
    for (API apiSummary : apiSummaryList) {
        APIInfoDTO apiInfo = new APIInfoDTO();
        apiInfo.setId(apiSummary.getId());
        apiInfo.setContext(apiSummary.getContext());
        apiInfo.setDescription(apiSummary.getDescription());
        apiInfo.setName(apiSummary.getName());
        apiInfo.setProvider(apiSummary.getProvider());
        apiInfo.setLifeCycleStatus(apiSummary.getLifeCycleStatus());
        apiInfo.setVersion(apiSummary.getVersion());
        apiInfo.setWorkflowStatus(apiSummary.getWorkflowStatus());
        apiInfo.setSecurityScheme(mapSecuritySchemeIntToList(apiSummary.getSecurityScheme()));
        apiInfoList.add(apiInfo);
    }
    return apiInfoList;
}
Also used : ArrayList(java.util.ArrayList) API(org.wso2.carbon.apimgt.core.models.API) APIInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO)

Aggregations

ArrayList (java.util.ArrayList)5 API (org.wso2.carbon.apimgt.core.models.API)3 APISummary (org.wso2.carbon.apimgt.core.models.APISummary)3 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)3 ResultSet (java.sql.ResultSet)2 APIEvent (org.wso2.carbon.apimgt.core.models.events.APIEvent)2 Test (org.testng.annotations.Test)1 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)1 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)1 APIInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO)1 APIInfoDTO (org.wso2.carbon.apimgt.rest.api.store.dto.APIInfoDTO)1 CompositeAPIInfoDTO (org.wso2.carbon.apimgt.rest.api.store.dto.CompositeAPIInfoDTO)1