config fixed, import apps - draft
This commit is contained in:
parent
ba02eb001c
commit
c15d12de91
@ -31,6 +31,7 @@ import cz.trask.migration.model.ApplicationConfig;
|
||||
import cz.trask.migration.model.HttpResponse;
|
||||
import cz.trask.migration.model.RegisterResponse;
|
||||
import cz.trask.migration.model.TokenResponse;
|
||||
import cz.trask.migration.model.ApplicationConfig.Wso2Endpoints;
|
||||
import io.apicurio.registry.rest.client.RegistryClient;
|
||||
import io.apicurio.registry.rest.client.RegistryClientFactory;
|
||||
import io.apicurio.registry.rest.v2.beans.ArtifactMetaData;
|
||||
@ -124,14 +125,13 @@ public abstract class AbstractProcess {
|
||||
connection.setSSLSocketFactory(sslContext.getSocketFactory());
|
||||
}
|
||||
|
||||
protected TokenResponse authenticateToWso2AndGetToken() throws Exception {
|
||||
RegisterResponse register = register(config.getSource().getRegistrationApiUrl(),
|
||||
config.getSource().getWso2User());
|
||||
protected TokenResponse authenticateToWso2AndGetToken(Wso2Endpoints endpoints) throws Exception {
|
||||
RegisterResponse register = register(endpoints.getRegistrationApiUrl(), endpoints.getWso2User());
|
||||
|
||||
String clientId = register.getClientId();
|
||||
log.info("Registered with clientId: {}", clientId);
|
||||
|
||||
TokenResponse token = getToken(config.getSource().getPublisherTokenUrl(), config.getSource().getWso2User(),
|
||||
TokenResponse token = getToken(endpoints.getPublisherTokenUrl(), endpoints.getWso2User(),
|
||||
register,
|
||||
"apim:api_view apim:api_create apim:api_manage apim:api_delete apim:api_publish "
|
||||
+ "apim:subscription_view apim:subscription_block apim:subscription_manage apim:external_services_discover "
|
||||
|
||||
@ -44,7 +44,7 @@ public class Wso2AppsToApicurio extends AbstractProcess {
|
||||
try {
|
||||
log.info("Starting API import to Apicurio from WSO2...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken();
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getSource());
|
||||
|
||||
ApplicationList apps = getApplicationList(config.getSource().getAdminApiUrl(), token);
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ public class Wso2v32ToApicurio extends AbstractProcess {
|
||||
try {
|
||||
log.info("Starting API import to Apicurio from WSO2...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken();
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getSource());
|
||||
|
||||
APIList apis = getList(config.getSource().getPublisherApiUrl(), token);
|
||||
if (apis == null || apis.getList() == null || apis.getList().length == 0) {
|
||||
|
||||
@ -51,7 +51,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
try {
|
||||
log.info("Starting API export to WSO2 from Apicurio...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken();
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
|
||||
|
||||
ArtifactSearchResults apis = client.searchArtifacts(config.getApicurio().getDefaultApiGroup(), null, null,
|
||||
null, null, null, null, null, null);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cz.trask.migration.impl.v45;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -16,7 +15,6 @@ import cz.trask.migration.model.TokenResponse;
|
||||
import cz.trask.migration.model.v32.ApplicationDetail;
|
||||
import cz.trask.migration.model.v45.ApplicationCreateRequest;
|
||||
import io.apicurio.registry.rest.v2.beans.ArtifactMetaData;
|
||||
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;
|
||||
@ -37,7 +35,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
try {
|
||||
log.info("Starting App export to WSO2 from Apicurio...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken();
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
|
||||
|
||||
ArtifactSearchResults apps = client.searchArtifacts(ARTIFACT_GROUP_APPLICATIONS, null, null,
|
||||
null, null, null, null, null, null);
|
||||
@ -66,7 +64,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl()+ "/v3/applications";
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications";
|
||||
|
||||
try {
|
||||
log.info("Processing App {} of {}", index, total);
|
||||
|
||||
@ -8,9 +8,9 @@ import lombok.Data;
|
||||
public class ApplicationConfig {
|
||||
|
||||
@JsonProperty("source")
|
||||
private Source source;
|
||||
private Wso2Endpoints source;
|
||||
@JsonProperty("target")
|
||||
private Target target;
|
||||
private Wso2Endpoints target;
|
||||
@JsonProperty("truststore")
|
||||
private TrustStore trustStore;
|
||||
@JsonProperty("patterns")
|
||||
@ -20,23 +20,6 @@ public class ApplicationConfig {
|
||||
@JsonProperty("max_threads")
|
||||
private int maxThreads;
|
||||
|
||||
@Data
|
||||
public static class Source {
|
||||
@JsonProperty("registration_api_url")
|
||||
private String registrationApiUrl;
|
||||
@JsonProperty("publisher_api_url")
|
||||
private String publisherApiUrl;
|
||||
@JsonProperty("admin_api_url")
|
||||
private String adminApiUrl;
|
||||
@JsonProperty("devportal_api_url")
|
||||
private String devPortalApiUrl;
|
||||
@JsonProperty("publisher_token_url")
|
||||
private String publisherTokenUrl;
|
||||
@JsonProperty("wso2_user")
|
||||
private String wso2User;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrustStore {
|
||||
@JsonProperty("path")
|
||||
@ -64,11 +47,13 @@ public class ApplicationConfig {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Target {
|
||||
public static class Wso2Endpoints {
|
||||
@JsonProperty("registration_api_url")
|
||||
private String registrationApiUrl;
|
||||
@JsonProperty("publisher_api_url")
|
||||
private String publisherApiUrl;
|
||||
@JsonProperty("admin_api_url")
|
||||
private String adminApiUrl;
|
||||
@JsonProperty("devportal_api_url")
|
||||
private String devPortalApiUrl;
|
||||
@JsonProperty("publisher_token_url")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user