API versioning fixed
This commit is contained in:
parent
fe4f766459
commit
c066535843
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ bin
|
||||
/api.yaml
|
||||
*.zip
|
||||
apis
|
||||
tmp
|
||||
Binary file not shown.
1
pom.xml
1
pom.xml
@ -42,7 +42,6 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
|
||||
@ -5,6 +5,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -87,8 +88,6 @@ public abstract class AbstractProcess {
|
||||
|
||||
config = ConfigManager.getInstance().getConfig();
|
||||
|
||||
this.client = RegistryClientFactory.create(config.getApicurio().getApiUrl());
|
||||
|
||||
setTrustStoreCredentials();
|
||||
|
||||
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
|
||||
@ -96,6 +95,21 @@ public abstract class AbstractProcess {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Map<String, Object> clientConfigs = new HashMap<>();
|
||||
try {
|
||||
SSLContext sslContext = createSSLContext(
|
||||
config.getTrustStore().getPath(),
|
||||
config.getTrustStore().getPassword()
|
||||
);
|
||||
clientConfigs.put("io.apicurio.rest.client.jdk.sslContext", sslContext);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to initialize SSL context for Apicurio client", e);
|
||||
}
|
||||
|
||||
this.client = RegistryClientFactory.create(config.getApicurio().getApiUrl(), clientConfigs);
|
||||
client.listConfigProperties();
|
||||
|
||||
}
|
||||
|
||||
protected void setTrustStoreCredentials() {
|
||||
@ -388,7 +402,8 @@ public abstract class AbstractProcess {
|
||||
APIList listOfApis = null;
|
||||
|
||||
try {
|
||||
String url = publisherurl.concat(String.format("/apis?limit=9999&offset=0"));
|
||||
//String url = publisherurl.concat(String.format("/apis?limit=10&offset=0&query=name:%s", "PTSPaymentHubCZSIT*"));
|
||||
String url = publisherurl.concat("/apis?limit=9999&offset=0");
|
||||
|
||||
log.debug("Getting APIs with token: '" + tokenResponse.getAccess_token() + "' URL: " + url);
|
||||
|
||||
@ -558,6 +573,12 @@ public abstract class AbstractProcess {
|
||||
|
||||
log.debug("Creating artifact reference for entry: {} with artifactId: {}", entry.getName(), artifactId);
|
||||
|
||||
File tmpFile = new File("tmp/api/", entry.getName());
|
||||
FileOutputStream fos = new FileOutputStream(tmpFile);
|
||||
fos.write(entry.getContent());
|
||||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
try (ByteArrayInputStream is = new ByteArrayInputStream(entry.getContent())) {
|
||||
ArtifactMetaData meta = client.createArtifactWithVersion(entry.getType().toString(), artifactId, api.getVersion(), is);
|
||||
Map<String, String> props = new LinkedHashMap<>();
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cz.trask.migration.impl.v32;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -108,6 +110,15 @@ public class Wso2v32ToApicurio extends AbstractProcess {
|
||||
config.getSource().getPublisherApiUrl() + "/apis/export?apiId=" + api.getId(), httpHeaders,
|
||||
Collections.emptyMap(), true);
|
||||
|
||||
if (config.isStoreMigratedArtifacts()) {
|
||||
File tmpFile = new File("tmp/api/", api.getName() + "_" + api.getVersion() + ".zip");
|
||||
log.info(" - Storing migrated Api file: {}", tmpFile.getAbsolutePath());
|
||||
FileOutputStream fos = new FileOutputStream(tmpFile);
|
||||
fos.write(exportedZip.getResponseBytes());
|
||||
fos.flush();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
List<ZipEntryData> zipEntries = ZipUtils.extractFilesFromZip(exportedZip.getResponseBytes());
|
||||
|
||||
String swagger = null;
|
||||
@ -149,6 +160,9 @@ public class Wso2v32ToApicurio extends AbstractProcess {
|
||||
ObjectNode swaggerObj = mapperYaml.valueToTree(swaggerMap);
|
||||
updateSwagger(swaggerObj, apiMap, fullDesc);
|
||||
|
||||
api.setName((String)apiMap.get("name"));
|
||||
api.setContext((String)apiMap.get("context"));
|
||||
|
||||
// 7) Prepare artifact creation/update
|
||||
String group = config.getApicurio().getDefaultApiGroup();
|
||||
String mainArtifactId = api.getName() + api.getContext();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
source:
|
||||
registration_api_url: https://localhost:9444/client-registration/v0.17/register
|
||||
publisher_api_url: https://localhost:9444/api/am/publisher
|
||||
admin_api_url: https://localhost:9444/api/am/admin/v1
|
||||
devportal_api_url: https://localhost:9444/api/am/store
|
||||
publisher_token_url: https://localhost:9444/oauth2/token
|
||||
wso2_user: YWRtaW46YWRtaW4=
|
||||
registration_api_url: https://developerstest.jtfg.com/client-registration/v0.17/register
|
||||
publisher_api_url: https://developerstest.jtfg.com/api/am/publisher
|
||||
admin_api_url: https://developerstest.jtfg.com/api/am/admin/v1
|
||||
devportal_api_url: https://developerstest.jtfg.com/api/am/store
|
||||
publisher_token_url: https://developerstest.jtfg.com/oauth2/token
|
||||
wso2_user: YWRtaW46UkllSTVBeGN4LXZRQVZsSA==
|
||||
wso2_apis_dir: apis
|
||||
|
||||
target:
|
||||
@ -20,14 +20,14 @@ truststore:
|
||||
password: wso2carbon
|
||||
|
||||
patterns:
|
||||
publisher_url_pattern: https://api-developers.dev.koop.appl.services/publisher/apis/{API_ID}/overview
|
||||
devportal_url_pattern: https://api-developers.dev.koop.appl.services/devportal/apis/{API_ID}/overview
|
||||
publisher_url_pattern: https://developers/publisher/apis/{API_ID}/overview
|
||||
devportal_url_pattern: https://developers/devportal/apis/{API_ID}/overview
|
||||
|
||||
apicurio:
|
||||
api_url: http://apicurio:8095/apis/registry/v2
|
||||
api_url: https://apim-apicurio-app-apim-wso2.apps.oshift-akc.jtfg.com/apis/registry/v2
|
||||
default_api_group: api
|
||||
overwrite_existing_application: true
|
||||
|
||||
max_threads: 1
|
||||
max_threads: 8
|
||||
|
||||
store_migrated_artifacts: true
|
||||
Loading…
x
Reference in New Issue
Block a user