endpoint config fix
This commit is contained in:
parent
b59817173f
commit
d44dbfabc7
@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -13,6 +14,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@ -36,6 +38,8 @@ import io.apicurio.registry.rest.v2.beans.ArtifactReference;
|
||||
import io.apicurio.registry.rest.v2.beans.ArtifactSearchResults;
|
||||
import io.apicurio.registry.rest.v2.beans.SearchedArtifact;
|
||||
import io.apicurio.registry.rest.v2.beans.SearchedVersion;
|
||||
import io.apicurio.registry.rest.v2.beans.SortBy;
|
||||
import io.apicurio.registry.rest.v2.beans.SortOrder;
|
||||
import io.apicurio.registry.rest.v2.beans.VersionSearchResults;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
@ -56,7 +60,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
|
||||
|
||||
ArtifactSearchResults apis = client.searchArtifacts(config.getApicurio().getDefaultApiGroup(), null, null,
|
||||
null, null, null, null, null, null);
|
||||
null, null, SortBy.name, SortOrder.asc, null, null);
|
||||
|
||||
log.info("Found {} APIs", apis.getCount());
|
||||
|
||||
@ -88,7 +92,11 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
VersionSearchResults versions = client.listArtifactVersions(config.getApicurio().getDefaultApiGroup(),
|
||||
api.getId(), null, null);
|
||||
|
||||
for (SearchedVersion ver : versions.getVersions()) {
|
||||
List<SearchedVersion> sortedVersions = versions.getVersions().stream()
|
||||
.sorted(Comparator.comparing(SearchedVersion::getVersion))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (SearchedVersion ver : sortedVersions) {
|
||||
log.info(" - Found version: {}", ver.getVersion());
|
||||
List<ArtifactReference> ref = client.getArtifactReferencesByCoordinates(
|
||||
config.getApicurio().getDefaultApiGroup(), api.getId(), ver.getVersion());
|
||||
|
||||
@ -59,7 +59,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
data.setAccessControl("NONE");
|
||||
data.setAccessControlRoles(Collections.emptyList());
|
||||
data.setOrganizationPolicies(Collections.emptyList());
|
||||
data.setType(oldApi.getType());
|
||||
data.setType(oldApi.getType()!=null && !oldApi.getType().toLowerCase().equals("null") ? oldApi.getType() : "HTTP");
|
||||
data.setAudiences(Arrays.asList("all"));
|
||||
|
||||
List<String> policies = new ArrayList<>();
|
||||
@ -101,7 +101,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
data.setCorsConfiguration(mapCors(oldApi.getCorsConfiguration()));
|
||||
|
||||
// ---------- endpoint ----------
|
||||
data.setEndpointConfig(oldApi.getEndpointConfig());
|
||||
data.setEndpointConfig(fixEndpointConfig(oldApi.getEndpointConfig()));
|
||||
data.setEndpointImplementationType(oldApi.getImplementation());
|
||||
|
||||
// ---------- API policies ----------
|
||||
@ -154,6 +154,29 @@ public class ApiDefinitionMapper32to45 {
|
||||
return newApi;
|
||||
}
|
||||
|
||||
private static Map fixEndpointConfig(Map endpointConfig) {
|
||||
if (endpointConfig == null || endpointConfig.isEmpty())
|
||||
return new HashMap();
|
||||
|
||||
Map<String, Object> endpointProd = (Map<String, Object>) endpointConfig.get("production_endpoints");
|
||||
if (endpointProd.containsKey("config")) {
|
||||
Object value = endpointProd.get("config");
|
||||
if (value==null) {
|
||||
endpointProd.remove("config");
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> endpointSand = (Map<String, Object>) endpointConfig.get("sandbox_endpoints");
|
||||
if (endpointSand.containsKey("config")) {
|
||||
Object value = endpointSand.get("config");
|
||||
if (value==null) {
|
||||
endpointSand.remove("config");
|
||||
}
|
||||
}
|
||||
|
||||
return endpointConfig;
|
||||
}
|
||||
|
||||
private static List<Object> mapAdditionalProperties(Map<String, Object> additionalProperties) {
|
||||
if (additionalProperties != null && !additionalProperties.isEmpty()) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user