diff --git a/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java b/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java index e44099d..e9e502f 100644 --- a/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java +++ b/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java @@ -58,7 +58,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess { ArtifactSearchResults apis = client.searchArtifacts(config.getApicurio().getDefaultApiGroup(), null, null, null, null, SortBy.name, SortOrder.asc, null, 9999); - + List sortedArtifacts = apis.getArtifacts().stream() .sorted(Comparator.comparing(SearchedArtifact::getId)) .collect(Collectors.toList()); @@ -66,24 +66,25 @@ public class ExportApisToWso2FromV32 extends AbstractProcess { log.info("Found {} APIs", sortedArtifacts.size()); int maxThreads = config.getMaxThreads(); - //ExecutorService executor = Executors.newFixedThreadPool(maxThreads); - - int skipCount = 9; + // ExecutorService executor = Executors.newFixedThreadPool(maxThreads); + + // AutosweepIntegrationPPE/AutosweepIntegrationPPE/v1 + int skipCount = 23; for (SearchedArtifact api : sortedArtifacts) { final int index = apiCounter.getAndIncrement(); - if (index <= skipCount) { - log.info("Skipping API {} of {}: {}", index, apis.getCount(), api.getName()); - continue; + if (index <= skipCount) { + log.info("Skipping API {} of {}: {}", index, apis.getCount(), api.getName()); + continue; } - //executor.submit(() -> processApi(api, token, index, apis.getCount())); + // executor.submit(() -> processApi(api, token, index, apis.getCount())); processApi(api, token, index, apis.getCount()); } -// executor.shutdown(); -// if (!executor.awaitTermination(10, TimeUnit.MINUTES)) { -// log.warn("Timeout waiting for API import tasks to finish"); -// } + // executor.shutdown(); + // if (!executor.awaitTermination(10, TimeUnit.MINUTES)) { + // log.warn("Timeout waiting for API import tasks to finish"); + // } log.info("Finished processing APIs."); } catch (Exception e) { log.error("Error while exporting APIs.", e); @@ -186,10 +187,18 @@ public class ExportApisToWso2FromV32 extends AbstractProcess { } else if (FileType.DOCUMENTATION.toString().equals(amd.getGroupId())) { subDir = "Docs/"; if (content != null && content.length > 0) { - List docs = mapperYaml.readValue(content, new TypeReference>() { - }); - for (Documents32 doc : docs) { - convertAndAddDocument(zos, baseDir + subDir, doc, ref); + if (r.getName().endsWith(".yaml") || r.getName().endsWith(".yml")) { + List docs = mapperYaml.readValue(content, + new TypeReference>() { + }); + for (Documents32 doc : docs) { + convertAndAddDocument(zos, baseDir + subDir, doc, ref); + } + } else { + String fileName = baseDir + subDir + r.getName() + "/" + r.getName(); + zos.putNextEntry(new ZipEntry(fileName)); + zos.write(content); + zos.closeEntry(); } } appendFile = false; @@ -221,7 +230,8 @@ public class ExportApisToWso2FromV32 extends AbstractProcess { } } - private void convertAndAddDocument(ZipOutputStream zos, String subDir, Documents32 doc, List ref) throws Exception { + private void convertAndAddDocument(ZipOutputStream zos, String subDir, Documents32 doc, List ref) + throws Exception { Documents45 doc45 = new Documents45(); Documents45.Data doc45Data = new Documents45.Data();