docs fixes
This commit is contained in:
parent
f50e3ae7d4
commit
b59817173f
@ -25,6 +25,7 @@ import cz.trask.migration.model.HttpResponse;
|
||||
import cz.trask.migration.model.TokenResponse;
|
||||
import cz.trask.migration.model.v32.ApiDefinition32;
|
||||
import cz.trask.migration.model.v32.Documents32;
|
||||
import cz.trask.migration.model.v32.Documents32.SourceTypeEnum;
|
||||
import cz.trask.migration.model.v32.HostInfo32;
|
||||
import cz.trask.migration.model.v45.ApiDefinition45;
|
||||
import cz.trask.migration.model.v45.Documents45;
|
||||
@ -183,6 +184,8 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
} else if (FileType.OPENAPI.toString().equals(amd.getGroupId())) {
|
||||
subDir = "Definitions/";
|
||||
contentStr = new String(content);
|
||||
} else if (FileType.WSDL.toString().equals(amd.getGroupId())) {
|
||||
subDir = "WSDL/";
|
||||
} else if (FileType.CERTIFICATE.toString().equals(amd.getGroupId())) {
|
||||
subDir = "Endpoint-certificates/";
|
||||
content = convertCertificateToEPCertificate(zos, baseDir + subDir, content);
|
||||
@ -195,10 +198,13 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
List<Documents32> docs = mapperYaml.readValue(content, new TypeReference<List<Documents32>>() {
|
||||
});
|
||||
for (Documents32 doc : docs) {
|
||||
convertAndAddDocument(zos, baseDir + subDir, doc);
|
||||
convertAndAddDocument(zos, baseDir + subDir, doc, ref);
|
||||
}
|
||||
}
|
||||
appendFile = false;
|
||||
} else if (FileType.DOCUMENTATION_FILE.toString().equals(amd.getGroupId())) {
|
||||
// Handled in convertAndAddDocument method
|
||||
appendFile = false;
|
||||
}
|
||||
|
||||
if (appendFile) {
|
||||
@ -222,7 +228,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
}
|
||||
}
|
||||
|
||||
private void convertAndAddDocument(ZipOutputStream zos, String subDir, Documents32 doc) throws Exception {
|
||||
private void convertAndAddDocument(ZipOutputStream zos, String subDir, Documents32 doc, List<ArtifactReference> ref) throws Exception {
|
||||
Documents45 doc45 = new Documents45();
|
||||
|
||||
Documents45.Data doc45Data = new Documents45.Data();
|
||||
@ -231,7 +237,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
doc45Data.setSummary(doc.getSummary());
|
||||
doc45Data.setSourceType(doc.getSourceType());
|
||||
doc45Data.setSourceUrl(doc.getSourceUrl());
|
||||
doc45Data.setFileName(doc.getFileName());
|
||||
doc45Data.setFileName(doc.getFilePath());
|
||||
doc45Data.setInlineContent(doc.getInlineContent());
|
||||
doc45Data.setOtherTypeName(doc.getOtherTypeName());
|
||||
doc45Data.setVisibility(doc.getVisibility());
|
||||
@ -242,6 +248,23 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
|
||||
doc45.setData(doc45Data);
|
||||
|
||||
if (doc45Data.getSourceType() == SourceTypeEnum.FILE && doc45Data.getFileName() != null) {
|
||||
for (ArtifactReference r : ref) {
|
||||
if (r.getName().equals(doc45Data.getFileName())) {
|
||||
log.info(" - Found document file reference: {}", r.getName());
|
||||
byte[] content = client.getContentByGlobalId(
|
||||
client.getArtifactMetaData(r.getGroupId(), r.getArtifactId()).getGlobalId())
|
||||
.readAllBytes();
|
||||
String docFilePath = subDir + doc.getName() + "/" + doc45Data.getFileName();
|
||||
log.info(" - Adding document file: {}", docFilePath);
|
||||
zos.putNextEntry(new ZipEntry(docFilePath));
|
||||
zos.write(content);
|
||||
zos.closeEntry();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String fileName = subDir + doc.getName() + "/" + DEFAULT_DOC_FILE_NAME;
|
||||
zos.putNextEntry(new ZipEntry(fileName));
|
||||
zos.write(mapperYaml.writeValueAsBytes(doc45));
|
||||
|
||||
@ -136,6 +136,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
data.setAdditionalPropertiesMap(mapAdditionalPropertiesMap(oldApi.getAdditionalProperties()));
|
||||
|
||||
// ---------- subscription ----------
|
||||
if (oldApi.getSubscriptionAvailability() != null)
|
||||
data.setSubscriptionAvailability(oldApi.getSubscriptionAvailability().toUpperCase());
|
||||
data.setSubscriptionAvailableTenants(Collections.emptyList());
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ public class Documents32 {
|
||||
private String summary = null;
|
||||
private SourceTypeEnum sourceType = null;
|
||||
private String sourceUrl = null;
|
||||
private String fileName = null;
|
||||
private String filePath = null;
|
||||
private String inlineContent = null;
|
||||
private String otherTypeName = null;
|
||||
private VisibilityEnum visibility = null;
|
||||
@ -49,7 +49,7 @@ public class Documents32 {
|
||||
return Objects.equals(id, document.id) && Objects.equals(name, document.name)
|
||||
&& Objects.equals(type, document.type) && Objects.equals(summary, document.summary)
|
||||
&& Objects.equals(sourceType, document.sourceType) && Objects.equals(sourceUrl, document.sourceUrl)
|
||||
&& Objects.equals(fileName, document.fileName) && Objects.equals(inlineContent, document.inlineContent)
|
||||
&& Objects.equals(filePath, document.filePath) && Objects.equals(inlineContent, document.inlineContent)
|
||||
&& Objects.equals(otherTypeName, document.otherTypeName)
|
||||
&& Objects.equals(visibility, document.visibility) && Objects.equals(createdTime, document.createdTime)
|
||||
&& Objects.equals(createdBy, document.createdBy)
|
||||
@ -59,7 +59,7 @@ public class Documents32 {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, type, summary, sourceType, sourceUrl, fileName, inlineContent, otherTypeName,
|
||||
return Objects.hash(id, name, type, summary, sourceType, sourceUrl, filePath, inlineContent, otherTypeName,
|
||||
visibility, createdTime, createdBy, lastUpdatedTime, lastUpdatedBy);
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class Documents32 {
|
||||
sb.append(" summary: ").append(toIndentedString(summary)).append("\n");
|
||||
sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n");
|
||||
sb.append(" sourceUrl: ").append(toIndentedString(sourceUrl)).append("\n");
|
||||
sb.append(" fileName: ").append(toIndentedString(fileName)).append("\n");
|
||||
sb.append(" filePath: ").append(toIndentedString(filePath)).append("\n");
|
||||
sb.append(" inlineContent: ").append(toIndentedString(inlineContent)).append("\n");
|
||||
sb.append(" otherTypeName: ").append(toIndentedString(otherTypeName)).append("\n");
|
||||
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user