Search in sources :

Example 6 with APISummary

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

Example 7 with APISummary

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

the class APIPublisherImplTestCase method testGetLifeCycleEventsExceptionFindingApiSummaryResource.

@Test(description = "Exception finding APISummary Resource when getting lifecycle events list of an API", expectedExceptions = APIManagementException.class)
public void testGetLifeCycleEventsExceptionFindingApiSummaryResource() throws APIManagementException, LifecycleException {
    ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
    Mockito.when(apiDAO.getAPISummary(API_ID)).thenThrow(new APIMgtDAOException("Couldn't find APISummary Resource for ID " + API_ID));
    APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
    apiPublisher.getLifeCycleEvents(API_ID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 8 with APISummary

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

the class APIMappingUtil method toAPIInfo.

/**
 * Converts {@link API} List to an {@link APIInfoDTO} List.
 *
 * @param apiSummaryList List of APIs
 * @return List of APIInfoDTO
 */
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());
        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.store.dto.APIInfoDTO)

Example 9 with APISummary

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

the class ApiDAOImpl method getCompositeAPISummaryList.

private List<CompositeAPI> getCompositeAPISummaryList(Connection connection, PreparedStatement statement) throws SQLException, APIMgtDAOException {
    List<CompositeAPI> apiList = new ArrayList<>();
    try (ResultSet rs = statement.executeQuery()) {
        while (rs.next()) {
            String apiPrimaryKey = rs.getString("UUID");
            CompositeAPI apiSummary = new CompositeAPI.Builder().id(apiPrimaryKey).provider(rs.getString("PROVIDER")).name(rs.getString("NAME")).version(rs.getString("VERSION")).context(rs.getString("CONTEXT")).description(rs.getString("DESCRIPTION")).applicationId(getCompositeAPIApplicationId(connection, apiPrimaryKey)).workflowStatus(rs.getString("LC_WORKFLOW_STATUS")).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)

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