Search in sources :

Example 6 with ProductAPIDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ProductAPIDTO in project carbon-apimgt by wso2.

the class ExportUtils method addDependentAPIsToArchive.

/**
 * Retrieve dependent APIs by checking the resources of the API Product and store those in the archive directory.
 *
 * @param archivePath           Temp location to save the API artifacts
 * @param apiProductDtoToReturn API Product DTO which the resources should be considered
 * @param userName              User name of the requester
 * @param provider              API Product Provider
 * @param exportFormat          Export format of the API meta data, could be yaml or json
 * @param isStatusPreserved     Whether API status is preserved while export
 * @param organization          Organization
 * @throws APIImportExportException If an error occurs while creating the directory or extracting the archive
 * @throws APIManagementException   If an error occurs while retrieving API related resources
 */
public static void addDependentAPIsToArchive(String archivePath, APIProductDTO apiProductDtoToReturn, ExportFormat exportFormat, APIProvider provider, String userName, Boolean isStatusPreserved, boolean preserveDocs, boolean preserveCredentials, String organization) throws APIImportExportException, APIManagementException {
    String apisDirectoryPath = archivePath + File.separator + ImportExportConstants.APIS_DIRECTORY;
    CommonUtil.createDirectory(apisDirectoryPath);
    List<ProductAPIDTO> apisList = apiProductDtoToReturn.getApis();
    for (ProductAPIDTO productAPIDTO : apisList) {
        String apiProductRequesterDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
        API api = provider.getAPIbyUUID(productAPIDTO.getApiId(), apiProductRequesterDomain);
        APIDTO apiDtoToReturn = APIMappingUtil.fromAPItoDTO(api, preserveCredentials, null);
        File dependentAPI = exportApi(provider, api.getId(), apiDtoToReturn, api, userName, exportFormat, isStatusPreserved, preserveDocs, StringUtils.EMPTY, organization);
        CommonUtil.extractArchive(dependentAPI, apisDirectoryPath);
    }
}
Also used : ProductAPIDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ProductAPIDTO) APIDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO) API(org.wso2.carbon.apimgt.api.model.API) ProductAPIDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ProductAPIDTO) ResourceFile(org.wso2.carbon.apimgt.api.model.ResourceFile) File(java.io.File)

Aggregations

ProductAPIDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ProductAPIDTO)5 API (org.wso2.carbon.apimgt.api.model.API)3 URITemplate (org.wso2.carbon.apimgt.api.model.URITemplate)3 APIDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO)3 APIOperationsDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIOperationsDTO)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)2 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)2 CORSConfiguration (org.wso2.carbon.apimgt.api.model.CORSConfiguration)2 Tier (org.wso2.carbon.apimgt.api.model.Tier)2 APICorsConfigurationDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APICorsConfigurationDTO)2 APIInfoAdditionalPropertiesDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIInfoAdditionalPropertiesDTO)2 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1