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