api type for soap without wsdl fixed
This commit is contained in:
parent
a118cf6c0b
commit
59b0cde730
@ -69,7 +69,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
// ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
|
||||
|
||||
// AutosweepIntegrationPPE/AutosweepIntegrationPPE/v1
|
||||
int skipCount = 23;
|
||||
int skipCount = 31;
|
||||
|
||||
for (SearchedArtifact api : sortedArtifacts) {
|
||||
final int index = apiCounter.getAndIncrement();
|
||||
@ -154,6 +154,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
|
||||
ApiDefinition32 apiDef = null;
|
||||
String contentStr = null;
|
||||
boolean hasWsdl = false;
|
||||
|
||||
for (ArtifactReference r : ref) {
|
||||
log.info(" - Reference: {} {} {}", r.getGroupId(), r.getArtifactId(), r.getVersion());
|
||||
@ -178,6 +179,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
contentStr = new String(content);
|
||||
} else if (FileType.WSDL.toString().equals(amd.getGroupId())) {
|
||||
subDir = "WSDL/";
|
||||
hasWsdl = true;
|
||||
} else if (FileType.CERTIFICATE.toString().equals(amd.getGroupId())) {
|
||||
subDir = "Endpoint-certificates/";
|
||||
content = convertCertificateToEPCertificate(zos, baseDir + subDir, content);
|
||||
@ -218,7 +220,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
}
|
||||
}
|
||||
if (apiDef != null && contentStr != null) {
|
||||
ApiDefinition45 apiDef45 = ApiDefinitionMapper32to45.map(apiDef, contentStr);
|
||||
ApiDefinition45 apiDef45 = ApiDefinitionMapper32to45.map(apiDef, contentStr, hasWsdl);
|
||||
byte[] content = mapperYaml.writeValueAsBytes(apiDef45);
|
||||
zos.putNextEntry(new ZipEntry(baseDir.concat("api.yaml")));
|
||||
zos.write(content);
|
||||
|
||||
@ -24,7 +24,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
|
||||
private static final String CONTEXT_VERSION_TEMPLATE = "/{version}";
|
||||
|
||||
public static ApiDefinition45 map(ApiDefinition32 oldApi, String swagger) throws Exception {
|
||||
public static ApiDefinition45 map(ApiDefinition32 oldApi, String swagger, boolean hasWsdl) throws Exception {
|
||||
if (oldApi == null)
|
||||
return null;
|
||||
|
||||
@ -65,8 +65,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
data.setAccessControl("NONE");
|
||||
// data.setAccessControlRoles(Collections.emptyList());
|
||||
data.setOrganizationPolicies(Collections.emptyList());
|
||||
data.setType(
|
||||
oldApi.getType() != null && !oldApi.getType().toLowerCase().equals("null") ? oldApi.getType() : "HTTP");
|
||||
data.setType(getApiType(oldApi.getType(), hasWsdl));
|
||||
data.setAudiences(Arrays.asList("all"));
|
||||
|
||||
List<String> policies = new ArrayList<>();
|
||||
@ -161,6 +160,17 @@ public class ApiDefinitionMapper32to45 {
|
||||
return newApi;
|
||||
}
|
||||
|
||||
private static String getApiType(String type, boolean hasWsdl) {
|
||||
if (type != null && type.equalsIgnoreCase("SOAP"))
|
||||
if (hasWsdl)
|
||||
return "SOAP";
|
||||
else
|
||||
return "HTTP";
|
||||
if (type != null && !type.equalsIgnoreCase("null"))
|
||||
return type;
|
||||
return "HTTP";
|
||||
}
|
||||
|
||||
private static String getContext(String context, String contextTemplate, String version) {
|
||||
if (contextTemplate != null && !contextTemplate.isEmpty()) {
|
||||
return contextTemplate.replace(CONTEXT_VERSION_TEMPLATE, "");
|
||||
@ -184,7 +194,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
endpointProd.remove("config");
|
||||
}
|
||||
}
|
||||
if (endpointProd != null && endpointProd.containsKey("url") && endpointProd.get("url") != null) {
|
||||
if (endpointProd != null && endpointProd.containsKey("url") && endpointProd.get("url") != null) {
|
||||
String url = endpointProd.get("url").toString();
|
||||
try {
|
||||
URL u = new URL(url);
|
||||
@ -193,11 +203,12 @@ public class ApiDefinitionMapper32to45 {
|
||||
if (!url.startsWith("http"))
|
||||
url = "http://" + url;
|
||||
endpointProd.put("url", url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (endpointConfig.get("sandbox_endpoints") != null && (endpointConfig.get("sandbox_endpoints") instanceof Map)) {
|
||||
if (endpointConfig.get("sandbox_endpoints") != null
|
||||
&& (endpointConfig.get("sandbox_endpoints") instanceof Map)) {
|
||||
Map<String, Object> endpointSand = (Map<String, Object>) endpointConfig.get("sandbox_endpoints");
|
||||
if (endpointSand != null && endpointSand.containsKey("config")) {
|
||||
Object value = endpointSand.get("config");
|
||||
@ -218,7 +229,8 @@ public class ApiDefinitionMapper32to45 {
|
||||
}
|
||||
}
|
||||
|
||||
if (endpointConfig.get("endpoint_security") != null && (endpointConfig.get("endpoint_security") instanceof Map)) {
|
||||
if (endpointConfig.get("endpoint_security") != null
|
||||
&& (endpointConfig.get("endpoint_security") instanceof Map)) {
|
||||
Map<String, Object> endpointSecurity = (Map<String, Object>) endpointConfig.get("endpoint_security");
|
||||
Map<String, Object> sandbox = endpointSecurity.get("sandbox") != null
|
||||
&& endpointSecurity.get("sandbox") instanceof Map
|
||||
@ -233,7 +245,8 @@ public class ApiDefinitionMapper32to45 {
|
||||
String encodedSecret = sandbox.get("clientSecret").toString();
|
||||
sandbox.put("clientSecret", CredentialsDecoder.decodeCredentials(encodedSecret));
|
||||
}
|
||||
if (production != null && production.containsKey("clientSecret") && production.get("clientSecret") != null) {
|
||||
if (production != null && production.containsKey("clientSecret")
|
||||
&& production.get("clientSecret") != null) {
|
||||
String encodedSecret = production.get("clientSecret").toString();
|
||||
production.put("clientSecret", CredentialsDecoder.decodeCredentials(encodedSecret));
|
||||
}
|
||||
@ -241,7 +254,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
try {
|
||||
String customParamsStr = sandbox.get("customParameters").toString();
|
||||
Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class);
|
||||
sandbox.put("customParameters", customParams!=null?customParams:Collections.emptyMap());
|
||||
sandbox.put("customParameters", customParams != null ? customParams : Collections.emptyMap());
|
||||
} catch (Exception e) {
|
||||
sandbox.put("customParameters", Collections.emptyMap());
|
||||
}
|
||||
@ -250,7 +263,7 @@ public class ApiDefinitionMapper32to45 {
|
||||
try {
|
||||
String customParamsStr = production.get("customParameters").toString();
|
||||
Map<String, Object> customParams = AbstractProcess.mapperYaml.readValue(customParamsStr, Map.class);
|
||||
production.put("customParameters", customParams!=null?customParams:Collections.emptyMap());
|
||||
production.put("customParameters", customParams != null ? customParams : Collections.emptyMap());
|
||||
} catch (Exception e) {
|
||||
production.put("customParameters", Collections.emptyMap());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user