Search in sources :

Example 16 with ExportFormat

use of org.wso2.carbon.apimgt.impl.importexport.ExportFormat in project carbon-apimgt by wso2.

the class ImportExportAPIServiceImpl method exportAPI.

@Override
public File exportAPI(String apiId, String revisionUUID, boolean preserveStatus, ExportFormat format, boolean preserveDocs, boolean preserveCredentials, String organization) throws APIManagementException, APIImportExportException {
    APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
    String userName = RestApiCommonUtil.getLoggedInUsername();
    APIIdentifier apiIdentifier = APIMappingUtil.getAPIIdentifierFromUUID(apiId);
    API api = apiProvider.getAPIbyUUID(revisionUUID, organization);
    api.setUuid(apiId);
    apiIdentifier.setUuid(apiId);
    APIDTO apiDtoToReturn = APIMappingUtil.fromAPItoDTO(api, preserveCredentials, apiProvider);
    return ExportUtils.exportApi(apiProvider, apiIdentifier, apiDtoToReturn, api, userName, format, preserveStatus, preserveDocs, StringUtils.EMPTY, organization);
}
Also used : APIDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) ImportExportAPI(org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI) API(org.wso2.carbon.apimgt.api.model.API) APIProvider(org.wso2.carbon.apimgt.api.APIProvider)

Aggregations

APIImportExportException (org.wso2.carbon.apimgt.impl.importexport.APIImportExportException)10 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)9 IOException (java.io.IOException)8 File (java.io.File)7 ResourceFile (org.wso2.carbon.apimgt.api.model.ResourceFile)5 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 JsonArray (com.google.gson.JsonArray)3 API (org.wso2.carbon.apimgt.api.model.API)3 ExportFormat (org.wso2.carbon.apimgt.impl.importexport.ExportFormat)3 ImportExportAPI (org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI)3 JsonObject (com.google.gson.JsonObject)2 JSONObject (org.json.JSONObject)2 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)2 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)2 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)2 APIDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO)2 ExportedApplication (org.wso2.carbon.apimgt.rest.api.store.v1.models.ExportedApplication)2 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1