Source:
public static File exportApiProduct(APIProvider apiProvider, APIProductIdentifier apiProductIdentifier, APIProductDTO apiProductDtoToReturn, String userName, ExportFormat exportFormat, Boolean preserveStatus,boolean preserveDocs,boolean preserveCredentials) throws APIManagementException, APIImportExportException { int tenantId = 0; try { File exportFolder = CommonUtil.createTempDirectory(apiProductIdentifier); String exportAPIBasePath = exportFolder.toString(); String archivePath = exportAPIBasePath.concat(File.separator + apiProductIdentifier.getName() + "-" + apiProductIdentifier.getVersion()); tenantId = APIUtil.getTenantId(userName); UserRegistry registry = ServiceReferenceHolder.getInstance().getRegistryService(). getGovernanceSystemRegistry(tenantId); APIProduct apiProduct = APIMappingUtil.fromDTOtoAPIProduct(apiProductDtoToReturn, userName); CommonUtil.createDirectory(archivePath); if (preserveDocs){ addThumbnailToArchive(archivePath, apiProductIdentifier, registry); addDocumentationToArchive(archivePath, apiProductIdentifier, registry, exportFormat, apiProvider); } addAPIProductMetaInformationToArchive(archivePath, apiProductDtoToReturn, exportFormat, apiProvider, userName); addDependentAPIsToArchive(archivePath, apiProductDtoToReturn, exportFormat, apiProvider, userName, preserveStatus, preserveDocs, preserveCredentials); if (apiProvider.isClientCertificateBasedAuthenticationConfigured()) { if (log.isDebugEnabled()) { log.debug("Mutual SSL enabled. Exporting client certificates."); } addClientCertificatesToArchive(archivePath, apiProductIdentifier, tenantId, apiProvider, exportFormat); } CommonUtil.archiveDirectory(exportAPIBasePath); FileUtils.deleteQuietly(new File(exportAPIBasePath)); return new File(exportAPIBasePath + APIConstants.ZIP_FILE_EXTENSION); } catch (RegistryException e) { String errorMessage = "Error while getting governance registry for tenant: " + tenantId; throw new APIManagementException(errorMessage, e); } }

Target:
public static File exportApiProduct(APIProvider apiProvider, APIProductIdentifier apiProductIdentifier, APIProductDTO apiProductDtoToReturn, String userName, ExportFormat exportFormat, Boolean preserveStatus, boolean preserveDocs, boolean preserveCredentials) throws APIManagementException, APIImportExportException { int tenantId = 0; try { File exportFolder = CommonUtil.createTempDirectory(apiProductIdentifier); String exportAPIBasePath = exportFolder.toString(); String archivePath = exportAPIBasePath .concat(File.separator + apiProductIdentifier.getName() + "-" + apiProductIdentifier.getVersion()); tenantId = APIUtil.getTenantId(userName); UserRegistry registry = ServiceReferenceHolder.getInstance().getRegistryService(). getGovernanceSystemRegistry(tenantId); CommonUtil.createDirectory(archivePath); if (preserveDocs) { addThumbnailToArchive(archivePath, apiProductIdentifier, apiProvider, APIConstants.API_PRODUCT_IDENTIFIER_TYPE); addDocumentationToArchive(archivePath, apiProductIdentifier, registry, exportFormat, apiProvider); } addAPIProductMetaInformationToArchive(archivePath, apiProductDtoToReturn, exportFormat, apiProvider); addDependentAPIsToArchive(archivePath, apiProductDtoToReturn, exportFormat, apiProvider, userName, preserveStatus, preserveDocs, preserveCredentials); if (apiProvider.isClientCertificateBasedAuthenticationConfigured()) { if (log.isDebugEnabled()) { log.debug("Mutual SSL enabled. Exporting client certificates."); } addClientCertificatesToArchive(archivePath, apiProductIdentifier, tenantId, apiProvider, exportFormat); } CommonUtil.archiveDirectory(exportAPIBasePath); FileUtils.deleteQuietly(new File(exportAPIBasePath)); return new File(exportAPIBasePath + APIConstants.ZIP_FILE_EXTENSION); } catch (RegistryException e) { throw new APIManagementException("Error while getting governance registry for tenant: " + tenantId, e); } }