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);
}
}
Aggregations