refactor
This commit is contained in:
parent
6bc3b273b3
commit
03ad7c5cf4
@ -101,8 +101,7 @@ public abstract class AbstractProcess {
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", config.getTrustStore().getPassword());
|
||||
}
|
||||
|
||||
private SSLContext createSSLContext(String trustStorePath, String trustStorePassword)
|
||||
throws Exception {
|
||||
private SSLContext createSSLContext(String trustStorePath, String trustStorePassword) throws Exception {
|
||||
// Vytvoříme TrustStore
|
||||
KeyStore trustStore = KeyStore.getInstance("JKS");
|
||||
try (FileInputStream fis = new FileInputStream(trustStorePath)) {
|
||||
@ -120,10 +119,8 @@ public abstract class AbstractProcess {
|
||||
return sslContext;
|
||||
}
|
||||
|
||||
protected void configureHttpsConnection(HttpsURLConnection connection)
|
||||
throws Exception {
|
||||
SSLContext sslContext = createSSLContext(
|
||||
System.getProperty("javax.net.ssl.trustStore"),
|
||||
protected void configureHttpsConnection(HttpsURLConnection connection) throws Exception {
|
||||
SSLContext sslContext = createSSLContext(System.getProperty("javax.net.ssl.trustStore"),
|
||||
System.getProperty("javax.net.ssl.trustStorePassword"));
|
||||
connection.setSSLSocketFactory(sslContext.getSocketFactory());
|
||||
}
|
||||
@ -134,15 +131,14 @@ public abstract class AbstractProcess {
|
||||
String clientId = register.getClientId();
|
||||
log.info("Registered with clientId: {}", clientId);
|
||||
|
||||
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 apim:threat_protection_policy_create apim:threat_protection_policy_manage "+
|
||||
"apim:document_create apim:document_manage apim:mediation_policy_view apim:mediation_policy_create apim:mediation_policy_manage "+
|
||||
"apim:client_certificates_view apim:client_certificates_add apim:client_certificates_update apim:ep_certificates_view apim:ep_certificates_add "+
|
||||
"apim:ep_certificates_update apim:publisher_settings apim:pub_alert_manage apim:shared_scope_manage apim:app_import_export apim:api_import_export "+
|
||||
"apim:api_product_import_export apim:api_generate_key apim:common_operation_policy_view apim:common_operation_policy_manage apim:comment_write "+
|
||||
"apim:comment_view apim:admin apim:subscribe apim:api_key apim:app_manage apim:sub_manage apim:store_settings apim:sub_alert_manage");
|
||||
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 apim:threat_protection_policy_create apim:threat_protection_policy_manage "
|
||||
+ "apim:document_create apim:document_manage apim:mediation_policy_view apim:mediation_policy_create apim:mediation_policy_manage "
|
||||
+ "apim:client_certificates_view apim:client_certificates_add apim:client_certificates_update apim:ep_certificates_view apim:ep_certificates_add "
|
||||
+ "apim:ep_certificates_update apim:publisher_settings apim:pub_alert_manage apim:shared_scope_manage apim:app_import_export apim:api_import_export "
|
||||
+ "apim:api_product_import_export apim:api_generate_key apim:common_operation_policy_view apim:common_operation_policy_manage apim:comment_write "
|
||||
+ "apim:comment_view apim:admin apim:subscribe apim:api_key apim:app_manage apim:sub_manage apim:store_settings apim:sub_alert_manage");
|
||||
|
||||
log.debug("Access token received – {}", token.getAccess_token());
|
||||
|
||||
@ -516,8 +512,8 @@ public abstract class AbstractProcess {
|
||||
String username = decodedstringparts[0];
|
||||
String password = decodedstringparts[1];
|
||||
|
||||
httpHeaders.put("Authorization", "Basic ".concat(Base64.getEncoder()
|
||||
.encodeToString(username.concat(":").concat(password).getBytes())));
|
||||
httpHeaders.put("Authorization",
|
||||
"Basic ".concat(Base64.getEncoder().encodeToString(username.concat(":").concat(password).getBytes())));
|
||||
return httpHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,152 +27,147 @@ import lombok.extern.log4j.Log4j2;
|
||||
@Log4j2
|
||||
public class Wso2AppsToApicurio extends AbstractProcess {
|
||||
|
||||
private final AtomicInteger appCounter = new AtomicInteger(1);
|
||||
private final AtomicInteger appCounter = new AtomicInteger(1);
|
||||
|
||||
private final RegistryClient client;
|
||||
private final RegistryClient client;
|
||||
|
||||
public Wso2AppsToApicurio() throws Exception {
|
||||
this.client = RegistryClientFactory.create(config.getApicurio().getApiUrl());
|
||||
}
|
||||
public Wso2AppsToApicurio() throws Exception {
|
||||
this.client = RegistryClientFactory.create(config.getApicurio().getApiUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for the import process.
|
||||
*
|
||||
* @throws RuntimeException if any error occurs
|
||||
*/
|
||||
public void process() {
|
||||
try {
|
||||
log.info("Starting API import to Apicurio from WSO2...");
|
||||
/**
|
||||
* Main entry point for the import process.
|
||||
*
|
||||
* @throws RuntimeException if any error occurs
|
||||
*/
|
||||
public void process() {
|
||||
try {
|
||||
log.info("Starting API import to Apicurio from WSO2...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getSource());
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getSource());
|
||||
|
||||
ApplicationList apps = getApplicationList(config.getSource().getAdminApiUrl(), token);
|
||||
ApplicationList apps = getApplicationList(config.getSource().getAdminApiUrl(), token);
|
||||
|
||||
if (apps == null || apps.getList() == null || apps.getList().size() == 0) {
|
||||
throw new IllegalStateException(
|
||||
"No Applications to export that match your criteria! Check the name of the Application you want to export.");
|
||||
}
|
||||
if (apps == null || apps.getList() == null || apps.getList().size() == 0) {
|
||||
throw new IllegalStateException(
|
||||
"No Applications to export that match your criteria! Check the name of the Application you want to export.");
|
||||
}
|
||||
|
||||
log.info("Found {} Applications", apps.getCount());
|
||||
log.info("Found {} Applications", apps.getCount());
|
||||
|
||||
int maxThreads = config.getMaxThreads();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
|
||||
int maxThreads = config.getMaxThreads();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
|
||||
|
||||
for (ApplicationInfo app : apps.getList()) {
|
||||
final int index = appCounter.getAndIncrement();
|
||||
executor.submit(() -> processApplication(app, token, index, apps.getCount()));
|
||||
}
|
||||
for (ApplicationInfo app : apps.getList()) {
|
||||
final int index = appCounter.getAndIncrement();
|
||||
executor.submit(() -> processApplication(app, token, index, apps.getCount()));
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
if (!executor.awaitTermination(10, TimeUnit.MINUTES)) {
|
||||
log.warn("Timeout waiting for API import tasks to finish");
|
||||
}
|
||||
log.info("Finished processing Applications.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error while exporting Applications.", e);
|
||||
throw new RuntimeException("Export failed", e);
|
||||
}
|
||||
}
|
||||
executor.shutdown();
|
||||
if (!executor.awaitTermination(10, TimeUnit.MINUTES)) {
|
||||
log.warn("Timeout waiting for API import tasks to finish");
|
||||
}
|
||||
log.info("Finished processing Applications.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error while exporting Applications.", e);
|
||||
throw new RuntimeException("Export failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processApplication(ApplicationInfo app, TokenResponse tokenResponse, int index, int total) {
|
||||
long start = System.currentTimeMillis();
|
||||
private void processApplication(ApplicationInfo app, TokenResponse tokenResponse, int index, int total) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
log.info("Processing API {} of {}", index, total);
|
||||
try {
|
||||
log.info("Processing API {} of {}", index, total);
|
||||
|
||||
Map<String, String> httpHeaders = Collections.singletonMap("Authorization",
|
||||
"Bearer " + tokenResponse.getAccess_token());
|
||||
Map<String, String> httpHeaders = Collections.singletonMap("Authorization",
|
||||
"Bearer " + tokenResponse.getAccess_token());
|
||||
|
||||
HttpResponse exportedZip = makeRequest("GET",
|
||||
config.getSource().getAdminApiUrl() + "/export/applications?appName=" + app.getName() + "&appOwner="
|
||||
+ app.getOwner() + "&withKeys=true",
|
||||
httpHeaders,
|
||||
Collections.emptyMap(), true);
|
||||
HttpResponse exportedZip = makeRequest(
|
||||
"GET", config.getSource().getAdminApiUrl() + "/export/applications?appName=" + app.getName()
|
||||
+ "&appOwner=" + app.getOwner() + "&withKeys=true",
|
||||
httpHeaders, Collections.emptyMap(), true);
|
||||
|
||||
List<ZipEntryData> zipEntries = ZipUtils.extractFilesFromZip(exportedZip.getResponseBytes());
|
||||
List<ZipEntryData> zipEntries = ZipUtils.extractFilesFromZip(exportedZip.getResponseBytes());
|
||||
|
||||
for (ZipEntryData entry : zipEntries) {
|
||||
ApplicationDetail appDetail = mapper.readValue(entry.getContent(), ApplicationDetail.class);
|
||||
for (ZipEntryData entry : zipEntries) {
|
||||
ApplicationDetail appDetail = mapper.readValue(entry.getContent(), ApplicationDetail.class);
|
||||
|
||||
String group = ARTIFACT_GROUP_APPLICATIONS;
|
||||
String mainArtifactId = appDetail.getName() + "(" + appDetail.getOwner() + ")";
|
||||
String group = ARTIFACT_GROUP_APPLICATIONS;
|
||||
String mainArtifactId = appDetail.getName() + "(" + appDetail.getOwner() + ")";
|
||||
|
||||
VersionSearchResults existingArtifacts;
|
||||
try {
|
||||
existingArtifacts = client.listArtifactVersions(group, mainArtifactId, 0, Integer.MAX_VALUE);
|
||||
} catch (Exception e) {
|
||||
log.debug("No Application {} exists – will create it", mainArtifactId);
|
||||
existingArtifacts = null;
|
||||
}
|
||||
VersionSearchResults existingArtifacts;
|
||||
try {
|
||||
existingArtifacts = client.listArtifactVersions(group, mainArtifactId, 0, Integer.MAX_VALUE);
|
||||
} catch (Exception e) {
|
||||
log.debug("No Application {} exists – will create it", mainArtifactId);
|
||||
existingArtifacts = null;
|
||||
}
|
||||
|
||||
if (existingArtifacts == null || existingArtifacts.getCount() == 0) {
|
||||
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||
} else if (existingArtifacts != null && existingArtifacts.getCount() > 0
|
||||
&& config.getApicurio().isOverwriteExistingApplication()) {
|
||||
try {
|
||||
log.info("Deleting existing Application in Apicurio '{}' ({}).", appDetail.getName(),
|
||||
appDetail.getOwner());
|
||||
client.deleteArtifact(group, mainArtifactId);
|
||||
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||
} catch (Exception e) {
|
||||
log.error("Error deleting existing Application '{}' ({}): {}", appDetail.getName(),
|
||||
appDetail.getOwner(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (existingArtifacts == null || existingArtifacts.getCount() == 0) {
|
||||
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||
} else if (existingArtifacts != null && existingArtifacts.getCount() > 0
|
||||
&& config.getApicurio().isOverwriteExistingApplication()) {
|
||||
try {
|
||||
log.info("Deleting existing Application in Apicurio '{}' ({}).", appDetail.getName(),
|
||||
appDetail.getOwner());
|
||||
client.deleteArtifact(group, mainArtifactId);
|
||||
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||
} catch (Exception e) {
|
||||
log.error("Error deleting existing Application '{}' ({}): {}", appDetail.getName(),
|
||||
appDetail.getOwner(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Successfully imported Application '{}' ({}). Took {} ms", app.getName(), app.getOwner(),
|
||||
System.currentTimeMillis() - start);
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing Application {} of {}: {}", index, total, e.getMessage());
|
||||
}
|
||||
}
|
||||
log.info("Successfully imported Application '{}' ({}). Took {} ms", app.getName(), app.getOwner(),
|
||||
System.currentTimeMillis() - start);
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing Application {} of {}: {}", index, total, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void createApplicationInApicurio(ApplicationDetail appDetail, String group, String mainArtifactId,
|
||||
byte[] content)
|
||||
throws Exception {
|
||||
log.info("Creating new Application to Apicurio '{}' ({}).", appDetail.getName(),
|
||||
appDetail.getOwner());
|
||||
// Create new artifact
|
||||
ArtifactMetaData meta = client.createArtifact(group, mainArtifactId,
|
||||
ARTIFACT_APPLICATION_DEFAULT_VERSION, null, null,
|
||||
null,
|
||||
appDetail.getName(), appDetail.getName(), null, null, null,
|
||||
new ByteArrayInputStream(content), null);
|
||||
private void createApplicationInApicurio(ApplicationDetail appDetail, String group, String mainArtifactId,
|
||||
byte[] content) throws Exception {
|
||||
log.info("Creating new Application to Apicurio '{}' ({}).", appDetail.getName(), appDetail.getOwner());
|
||||
// Create new artifact
|
||||
ArtifactMetaData meta = client.createArtifact(group, mainArtifactId, ARTIFACT_APPLICATION_DEFAULT_VERSION, null,
|
||||
null, null, appDetail.getName(), appDetail.getName(), null, null, null,
|
||||
new ByteArrayInputStream(content), null);
|
||||
|
||||
// Create the three required rules
|
||||
createRule(meta, "NONE", RuleType.COMPATIBILITY);
|
||||
createRule(meta, "NONE", RuleType.VALIDITY);
|
||||
createRule(meta, "NONE", RuleType.INTEGRITY);
|
||||
}
|
||||
// Create the three required rules
|
||||
createRule(meta, "NONE", RuleType.COMPATIBILITY);
|
||||
createRule(meta, "NONE", RuleType.VALIDITY);
|
||||
createRule(meta, "NONE", RuleType.INTEGRITY);
|
||||
}
|
||||
|
||||
private ApplicationList getApplicationList(String adminApiUrl, TokenResponse tokenResponse) throws Exception {
|
||||
private ApplicationList getApplicationList(String adminApiUrl, TokenResponse tokenResponse) throws Exception {
|
||||
|
||||
ApplicationList listOfApps = null;
|
||||
ApplicationList listOfApps = null;
|
||||
|
||||
try {
|
||||
String url = adminApiUrl.concat(String.format("/applications"));
|
||||
try {
|
||||
String url = adminApiUrl.concat(String.format("/applications"));
|
||||
|
||||
log.debug("Getting Applications with token: '" + tokenResponse.getAccess_token() + "' URL: " + url);
|
||||
log.debug("Getting Applications with token: '" + tokenResponse.getAccess_token() + "' URL: " + url);
|
||||
|
||||
Map<String, String> httpHeaders = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> httpHeaders = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
httpHeaders.put("Authorization", "Bearer ".concat(tokenResponse.getAccess_token()));
|
||||
httpHeaders.put("Authorization", "Bearer ".concat(tokenResponse.getAccess_token()));
|
||||
|
||||
HttpResponse response = makeRequest("GET", url, httpHeaders, params);
|
||||
HttpResponse response = makeRequest("GET", url, httpHeaders, params);
|
||||
|
||||
log.debug("Listing APIs: HTTP Code " + response.getResponseCode() + " Data: " + response.getResponse());
|
||||
log.debug("Listing APIs: HTTP Code " + response.getResponseCode() + " Data: " + response.getResponse());
|
||||
|
||||
listOfApps = mapper.readValue(response.getResponse(), ApplicationList.class);
|
||||
listOfApps = mapper.readValue(response.getResponse(), ApplicationList.class);
|
||||
|
||||
if (response.getResponseCode() != 200)
|
||||
log.error("Cannot list API. Something bad happened.");
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot list API:" + e);
|
||||
throw new Exception("Cannot list API:" + e.getMessage());
|
||||
}
|
||||
return listOfApps;
|
||||
}
|
||||
if (response.getResponseCode() != 200)
|
||||
log.error("Cannot list API. Something bad happened.");
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot list API:" + e);
|
||||
throw new Exception("Cannot list API:" + e.getMessage());
|
||||
}
|
||||
return listOfApps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -148,8 +148,7 @@ public class ExportApisToWso2FromV32 extends AbstractProcess {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public byte[] prepareApiZipFile32to45(SearchedVersion ver, List<ArtifactReference> ref)
|
||||
throws Exception {
|
||||
public byte[] prepareApiZipFile32to45(SearchedVersion ver, List<ArtifactReference> ref) throws Exception {
|
||||
|
||||
String baseDir = ver.getName() + "-" + ver.getVersion() + "/";
|
||||
|
||||
|
||||
@ -28,285 +28,280 @@ import lombok.extern.log4j.Log4j2;
|
||||
@Log4j2
|
||||
public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
|
||||
private static final int DEFAULT_TIMEOUT_MINUTES = 10;
|
||||
private static final String APPLICATIONS_ENDPOINT_PATH = "/applications";
|
||||
private static final String CHANGE_OWNER_PATH = "/change-owner";
|
||||
private static final int DEFAULT_TIMEOUT_MINUTES = 10;
|
||||
private static final String APPLICATIONS_ENDPOINT_PATH = "/applications";
|
||||
private static final String CHANGE_OWNER_PATH = "/change-owner";
|
||||
|
||||
private final AtomicInteger appCounter = new AtomicInteger(1);
|
||||
private SearchedArtifact adminsDefaultApplication;
|
||||
private final AtomicInteger appCounter = new AtomicInteger(1);
|
||||
private SearchedArtifact adminsDefaultApplication;
|
||||
|
||||
/**
|
||||
* Main entry point for the export process.
|
||||
*
|
||||
* @throws RuntimeException if any error occurs
|
||||
*/
|
||||
public void process() {
|
||||
try {
|
||||
log.info("Starting App export to WSO2 from Apicurio...");
|
||||
/**
|
||||
* Main entry point for the export process.
|
||||
*
|
||||
* @throws RuntimeException if any error occurs
|
||||
*/
|
||||
public void process() {
|
||||
try {
|
||||
log.info("Starting App export to WSO2 from Apicurio...");
|
||||
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
|
||||
TokenResponse token = authenticateToWso2AndGetToken(config.getTarget());
|
||||
|
||||
ArtifactSearchResults apps = client.searchArtifacts(ARTIFACT_GROUP_APPLICATIONS, null, null,
|
||||
null, null, null, null, null, null);
|
||||
ArtifactSearchResults apps = client.searchArtifacts(ARTIFACT_GROUP_APPLICATIONS, null, null, null, null,
|
||||
null, null, null, null);
|
||||
|
||||
log.info("Found {} Apps", apps.getCount());
|
||||
log.info("Found {} Apps", apps.getCount());
|
||||
|
||||
processApplications(apps, token);
|
||||
processApplications(apps, token);
|
||||
|
||||
if (adminsDefaultApplication != null) {
|
||||
log.info("Found default application for admin: {}", adminsDefaultApplication.getName());
|
||||
processApp(adminsDefaultApplication, token, 1, 1, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while exporting Apps.", e);
|
||||
throw new RuntimeException("Export failed", e);
|
||||
}
|
||||
}
|
||||
if (adminsDefaultApplication != null) {
|
||||
log.info("Found default application for admin: {}", adminsDefaultApplication.getName());
|
||||
processApp(adminsDefaultApplication, token, 1, 1, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while exporting Apps.", e);
|
||||
throw new RuntimeException("Export failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processApplications(ArtifactSearchResults apps, TokenResponse token) throws InterruptedException {
|
||||
int maxThreads = config.getMaxThreads();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
|
||||
private void processApplications(ArtifactSearchResults apps, TokenResponse token) throws InterruptedException {
|
||||
int maxThreads = config.getMaxThreads();
|
||||
ExecutorService executor = Executors.newFixedThreadPool(maxThreads);
|
||||
|
||||
for (SearchedArtifact app : apps.getArtifacts()) {
|
||||
final int index = appCounter.getAndIncrement();
|
||||
executor.submit(() -> processApp(app, token, index, apps.getCount(), false));
|
||||
}
|
||||
for (SearchedArtifact app : apps.getArtifacts()) {
|
||||
final int index = appCounter.getAndIncrement();
|
||||
executor.submit(() -> processApp(app, token, index, apps.getCount(), false));
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
if (!executor.awaitTermination(DEFAULT_TIMEOUT_MINUTES, TimeUnit.MINUTES)) {
|
||||
log.warn("Timeout waiting for App export tasks to finish");
|
||||
}
|
||||
log.info("Finished processing Apps.");
|
||||
}
|
||||
executor.shutdown();
|
||||
if (!executor.awaitTermination(DEFAULT_TIMEOUT_MINUTES, TimeUnit.MINUTES)) {
|
||||
log.warn("Timeout waiting for App export tasks to finish");
|
||||
}
|
||||
log.info("Finished processing Apps.");
|
||||
}
|
||||
|
||||
private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total,
|
||||
boolean createAdminApp) {
|
||||
long start = System.currentTimeMillis();
|
||||
private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total,
|
||||
boolean createAdminApp) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
log.info("Processing App {} of {}", index, total);
|
||||
try {
|
||||
log.info("Processing App {} of {}", index, total);
|
||||
|
||||
VersionSearchResults versions = client.listArtifactVersions(ARTIFACT_GROUP_APPLICATIONS,
|
||||
app.getId(), null, null);
|
||||
VersionSearchResults versions = client.listArtifactVersions(ARTIFACT_GROUP_APPLICATIONS, app.getId(), null,
|
||||
null);
|
||||
|
||||
for (SearchedVersion ver : versions.getVersions()) {
|
||||
processAppVersion(app, tokenResponse, ver, createAdminApp);
|
||||
}
|
||||
for (SearchedVersion ver : versions.getVersions()) {
|
||||
processAppVersion(app, tokenResponse, ver, createAdminApp);
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Finished processing App {} of {} in {} ms", index, total, (end - start));
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while importing App {}: {}", app.getId(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Finished processing App {} of {} in {} ms", index, total, (end - start));
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while importing App {}: {}", app.getId(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processAppVersion(SearchedArtifact app, TokenResponse tokenResponse, SearchedVersion version,
|
||||
boolean createAdminApp) {
|
||||
try {
|
||||
log.info(" - Found version: {}", version.getVersion());
|
||||
private void processAppVersion(SearchedArtifact app, TokenResponse tokenResponse, SearchedVersion version,
|
||||
boolean createAdminApp) {
|
||||
try {
|
||||
log.info(" - Found version: {}", version.getVersion());
|
||||
|
||||
ArtifactMetaData amd = client.getArtifactMetaData(app.getGroupId(), app.getId());
|
||||
byte[] content = client.getContentByGlobalId(amd.getGlobalId()).readAllBytes();
|
||||
ArtifactMetaData amd = client.getArtifactMetaData(app.getGroupId(), app.getId());
|
||||
byte[] content = client.getContentByGlobalId(amd.getGlobalId()).readAllBytes();
|
||||
|
||||
if (content != null && content.length > 0) {
|
||||
ApplicationDetail appDetail = mapper.readValue(content, ApplicationDetail.class);
|
||||
if (content != null && content.length > 0) {
|
||||
ApplicationDetail appDetail = mapper.readValue(content, ApplicationDetail.class);
|
||||
|
||||
// Skip default admin application unless explicitly requested
|
||||
if (DEFAULT_APPLICATION_NAME.equals(appDetail.getName())
|
||||
&& ADMIN_USERNAME.equals(appDetail.getOwner()) && !createAdminApp) {
|
||||
adminsDefaultApplication = app;
|
||||
deleteWso2ApplicationIfExists(appDetail, tokenResponse);
|
||||
log.info(" - Skipping import of admins-default-application for now.");
|
||||
return;
|
||||
}
|
||||
// Skip default admin application unless explicitly requested
|
||||
if (DEFAULT_APPLICATION_NAME.equals(appDetail.getName()) && ADMIN_USERNAME.equals(appDetail.getOwner())
|
||||
&& !createAdminApp) {
|
||||
adminsDefaultApplication = app;
|
||||
deleteWso2ApplicationIfExists(appDetail, tokenResponse);
|
||||
log.info(" - Skipping import of admins-default-application for now.");
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationCreateRequest appCreateRequest = mapAppDetailToCreateRequest(appDetail);
|
||||
byte[] data = mapper.writeValueAsBytes(appCreateRequest);
|
||||
log.info(" - Application {} with owner {} prepared for WSO2 export", appDetail.getName(),
|
||||
appDetail.getOwner());
|
||||
ApplicationCreateRequest appCreateRequest = mapAppDetailToCreateRequest(appDetail);
|
||||
byte[] data = mapper.writeValueAsBytes(appCreateRequest);
|
||||
log.info(" - Application {} with owner {} prepared for WSO2 export", appDetail.getName(),
|
||||
appDetail.getOwner());
|
||||
|
||||
deleteWso2ApplicationIfExists(appDetail, tokenResponse);
|
||||
deleteWso2ApplicationIfExists(appDetail, tokenResponse);
|
||||
|
||||
HttpResponse response = publishAppToWso2(appDetail.getName(), data, tokenResponse);
|
||||
HttpResponse response = publishAppToWso2(appDetail.getName(), data, tokenResponse);
|
||||
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Application {} imported successfully", appDetail.getName());
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Application {} imported successfully", appDetail.getName());
|
||||
|
||||
ApplicationCreateResponse createdApp = mapper.readValue(response.getResponse(),
|
||||
ApplicationCreateResponse.class);
|
||||
log.info(" - Created Application ID in WSO2: {}", createdApp.getApplicationId());
|
||||
ApplicationCreateResponse createdApp = mapper.readValue(response.getResponse(),
|
||||
ApplicationCreateResponse.class);
|
||||
log.info(" - Created Application ID in WSO2: {}", createdApp.getApplicationId());
|
||||
|
||||
if (appDetail.getKeyManagerWiseOAuthApp() != null
|
||||
&& !appDetail.getKeyManagerWiseOAuthApp().isEmpty()) {
|
||||
log.info(" - Application {} has {} Key Mappings to create",
|
||||
appDetail.getName(), appDetail.getKeyManagerWiseOAuthApp().size());
|
||||
for (Entry<String, Map<String, KeyManagerApp>> entry : appDetail
|
||||
.getKeyManagerWiseOAuthApp().entrySet()) {
|
||||
String keyType = entry.getKey();
|
||||
if (appDetail.getKeyManagerWiseOAuthApp() != null
|
||||
&& !appDetail.getKeyManagerWiseOAuthApp().isEmpty()) {
|
||||
log.info(" - Application {} has {} Key Mappings to create", appDetail.getName(),
|
||||
appDetail.getKeyManagerWiseOAuthApp().size());
|
||||
for (Entry<String, Map<String, KeyManagerApp>> entry : appDetail.getKeyManagerWiseOAuthApp()
|
||||
.entrySet()) {
|
||||
String keyType = entry.getKey();
|
||||
|
||||
Map<String, KeyManagerApp> keyManagerApp = entry.getValue();
|
||||
Map<String, KeyManagerApp> keyManagerApp = entry.getValue();
|
||||
|
||||
for (Entry<String, KeyManagerApp> kmEntry : keyManagerApp.entrySet()) {
|
||||
String keyManager = kmEntry.getKey();
|
||||
KeyManagerApp oauthInfo = kmEntry.getValue();
|
||||
for (Entry<String, KeyManagerApp> kmEntry : keyManagerApp.entrySet()) {
|
||||
String keyManager = kmEntry.getKey();
|
||||
KeyManagerApp oauthInfo = kmEntry.getValue();
|
||||
|
||||
log.info(" - Creating Key Mapping for Key Manager: {}", keyManager);
|
||||
// Map to v4.5 request
|
||||
ApplicationKeyMappingRequest45 keyMappingRequest = ApplicationKeyMappingRequest45
|
||||
.builder()
|
||||
.consumerKey(oauthInfo.getClientId())
|
||||
.consumerSecret(oauthInfo.getClientSecret())
|
||||
.keyManager(keyManager)
|
||||
.keyType(ApplicationKeyMappingRequest45.KeyType
|
||||
.valueOf(keyType))
|
||||
.build();
|
||||
log.info(" - Creating Key Mapping for Key Manager: {}", keyManager);
|
||||
// Map to v4.5 request
|
||||
ApplicationKeyMappingRequest45 keyMappingRequest = ApplicationKeyMappingRequest45
|
||||
.builder().consumerKey(oauthInfo.getClientId())
|
||||
.consumerSecret(oauthInfo.getClientSecret()).keyManager(keyManager)
|
||||
.keyType(ApplicationKeyMappingRequest45.KeyType.valueOf(keyType)).build();
|
||||
|
||||
byte[] kmData = mapper.writeValueAsBytes(keyMappingRequest);
|
||||
publishApplicationKeyMappingToWso2(createdApp.getApplicationId(), kmData,
|
||||
tokenResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] kmData = mapper.writeValueAsBytes(keyMappingRequest);
|
||||
publishApplicationKeyMappingToWso2(createdApp.getApplicationId(), kmData,
|
||||
tokenResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!createdApp.getOwner().equals(appDetail.getOwner())) {
|
||||
log.info(" - Changing owner of Application {} to {}", createdApp.getApplicationId(),
|
||||
appDetail.getOwner());
|
||||
changeApplicationOwner(createdApp, appDetail.getOwner(), tokenResponse);
|
||||
}
|
||||
if (!createdApp.getOwner().equals(appDetail.getOwner())) {
|
||||
log.info(" - Changing owner of Application {} to {}", createdApp.getApplicationId(),
|
||||
appDetail.getOwner());
|
||||
changeApplicationOwner(createdApp, appDetail.getOwner(), tokenResponse);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing application version: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error processing application version: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishApplicationKeyMappingToWso2(String applicationId, byte[] kmData, TokenResponse tokenResponse) {
|
||||
try {
|
||||
// Publish the application key mapping data to WSO2
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
httpHeaders.put("Content-Type", "application/json");
|
||||
private void publishApplicationKeyMappingToWso2(String applicationId, byte[] kmData, TokenResponse tokenResponse) {
|
||||
try {
|
||||
// Publish the application key mapping data to WSO2
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
httpHeaders.put("Content-Type", "application/json");
|
||||
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications/" + applicationId
|
||||
+ "/map-keys";
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications/" + applicationId
|
||||
+ "/map-keys";
|
||||
|
||||
HttpResponse response = makeDataRequest(endpoint, httpHeaders, kmData);
|
||||
HttpResponse response = makeDataRequest(endpoint, httpHeaders, kmData);
|
||||
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Key Mapping for Application {} created successfully in WSO2", applicationId);
|
||||
} else {
|
||||
log.warn(" - Key Mapping for Application {} creation in WSO2 failed with response code {}",
|
||||
applicationId, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while creating Key Mapping for Application {}: {}", applicationId,
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Key Mapping for Application {} created successfully in WSO2", applicationId);
|
||||
} else {
|
||||
log.warn(" - Key Mapping for Application {} creation in WSO2 failed with response code {}",
|
||||
applicationId, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while creating Key Mapping for Application {}: {}", applicationId, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteWso2ApplicationIfExists(ApplicationDetail appDetail, TokenResponse tokenResponse) {
|
||||
// Resolve application id by name first (WSO2 Admin API works with applicationId
|
||||
// in paths)
|
||||
String resolvedAppId = getExistingApplicationId(config.getTarget().getAdminApiUrl(), appDetail, tokenResponse);
|
||||
private void deleteWso2ApplicationIfExists(ApplicationDetail appDetail, TokenResponse tokenResponse) {
|
||||
// Resolve application id by name first (WSO2 Admin API works with applicationId
|
||||
// in paths)
|
||||
String resolvedAppId = getExistingApplicationId(config.getTarget().getAdminApiUrl(), appDetail, tokenResponse);
|
||||
|
||||
if (resolvedAppId == null) {
|
||||
log.warn(" - Application {} not found in WSO2, cannot delete", appDetail.getName());
|
||||
return;
|
||||
}
|
||||
if (resolvedAppId == null) {
|
||||
log.warn(" - Application {} not found in WSO2, cannot delete", appDetail.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
String endpoint = config.getTarget().getAdminApiUrl() + APPLICATIONS_ENDPOINT_PATH + "/" + resolvedAppId;
|
||||
String endpoint = config.getTarget().getAdminApiUrl() + APPLICATIONS_ENDPOINT_PATH + "/" + resolvedAppId;
|
||||
|
||||
try {
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
try {
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
|
||||
HttpResponse response = makeRequest("DELETE", endpoint, httpHeaders, null);
|
||||
HttpResponse response = makeRequest("DELETE", endpoint, httpHeaders, null);
|
||||
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 204) {
|
||||
log.info(" - Application {} (id={}) deleted successfully from WSO2", appDetail.getName(),
|
||||
resolvedAppId);
|
||||
} else {
|
||||
log.info(" - Application {} (id={}) deletion from WSO2 returned response code {}",
|
||||
appDetail.getName(), resolvedAppId, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while deleting Application {} (id={}): {}", appDetail.getName(), resolvedAppId,
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 204) {
|
||||
log.info(" - Application {} (id={}) deleted successfully from WSO2", appDetail.getName(),
|
||||
resolvedAppId);
|
||||
} else {
|
||||
log.info(" - Application {} (id={}) deletion from WSO2 returned response code {}", appDetail.getName(),
|
||||
resolvedAppId, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while deleting Application {} (id={}): {}", appDetail.getName(), resolvedAppId,
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getExistingApplicationId(String adminApiUrl, ApplicationDetail appDetail,
|
||||
TokenResponse tokenResponse) {
|
||||
try {
|
||||
String url = adminApiUrl.concat(APPLICATIONS_ENDPOINT_PATH);
|
||||
private String getExistingApplicationId(String adminApiUrl, ApplicationDetail appDetail,
|
||||
TokenResponse tokenResponse) {
|
||||
try {
|
||||
String url = adminApiUrl.concat(APPLICATIONS_ENDPOINT_PATH);
|
||||
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
HttpResponse response = makeRequest("GET", url, httpHeaders, params);
|
||||
HttpResponse response = makeRequest("GET", url, httpHeaders, params);
|
||||
|
||||
if (response.getResponseCode() != 200) {
|
||||
log.warn("Cannot list Applications (HTTP {}). Will not attempt delete.", response.getResponseCode());
|
||||
return null;
|
||||
}
|
||||
if (response.getResponseCode() != 200) {
|
||||
log.warn("Cannot list Applications (HTTP {}). Will not attempt delete.", response.getResponseCode());
|
||||
return null;
|
||||
}
|
||||
|
||||
ApplicationListResponse45 listOfApps = mapper.readValue(response.getResponse(),
|
||||
ApplicationListResponse45.class);
|
||||
ApplicationListResponse45 listOfApps = mapper.readValue(response.getResponse(),
|
||||
ApplicationListResponse45.class);
|
||||
|
||||
if (listOfApps != null && listOfApps.getList() != null) {
|
||||
for (ApplicationListResponse45.Application info : listOfApps.getList()) {
|
||||
if (appDetail.getName().equals(info.getName()) && appDetail.getOwner().equals(info.getOwner())) {
|
||||
return info.getApplicationId();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while resolving Application id for name {}: {}", appDetail.getName(), e.getMessage(), e);
|
||||
}
|
||||
if (listOfApps != null && listOfApps.getList() != null) {
|
||||
for (ApplicationListResponse45.Application info : listOfApps.getList()) {
|
||||
if (appDetail.getName().equals(info.getName()) && appDetail.getOwner().equals(info.getOwner())) {
|
||||
return info.getApplicationId();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while resolving Application id for name {}: {}", appDetail.getName(), e.getMessage(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private HttpResponse publishAppToWso2(String name, byte[] data, TokenResponse tokenResponse) throws Exception {
|
||||
// Publish the application data to WSO2
|
||||
Map<String, String> httpHeaders = createBasicAuthHeaders(config.getTarget().getWso2User());
|
||||
httpHeaders.put("Content-Type", "application/json");
|
||||
private HttpResponse publishAppToWso2(String name, byte[] data, TokenResponse tokenResponse) throws Exception {
|
||||
// Publish the application data to WSO2
|
||||
Map<String, String> httpHeaders = createBasicAuthHeaders(config.getTarget().getWso2User());
|
||||
httpHeaders.put("Content-Type", "application/json");
|
||||
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications";
|
||||
String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications";
|
||||
|
||||
return makeDataRequest(endpoint, httpHeaders, data);
|
||||
}
|
||||
return makeDataRequest(endpoint, httpHeaders, data);
|
||||
}
|
||||
|
||||
private void changeApplicationOwner(ApplicationCreateResponse createdApp, String origOwner,
|
||||
TokenResponse tokenResponse) {
|
||||
String endpoint = config.getTarget().getAdminApiUrl() + APPLICATIONS_ENDPOINT_PATH + "/"
|
||||
+ createdApp.getApplicationId() + CHANGE_OWNER_PATH + "?owner=" + origOwner;
|
||||
private void changeApplicationOwner(ApplicationCreateResponse createdApp, String origOwner,
|
||||
TokenResponse tokenResponse) {
|
||||
String endpoint = config.getTarget().getAdminApiUrl() + APPLICATIONS_ENDPOINT_PATH + "/"
|
||||
+ createdApp.getApplicationId() + CHANGE_OWNER_PATH + "?owner=" + origOwner;
|
||||
|
||||
try {
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
try {
|
||||
Map<String, String> httpHeaders = createBearerAuthHeaders(tokenResponse);
|
||||
|
||||
HttpResponse response = makeRequest("POST", endpoint, httpHeaders, null);
|
||||
HttpResponse response = makeRequest("POST", endpoint, httpHeaders, null);
|
||||
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Application {} owner changed successfully to {}", createdApp.getApplicationId(),
|
||||
origOwner);
|
||||
} else {
|
||||
log.warn(" - Application {} owner change to {} failed with response code {}",
|
||||
createdApp.getApplicationId(), origOwner, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while changing owner of Application {}: {}", createdApp.getApplicationId(),
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (response.getResponseCode() == 200 || response.getResponseCode() == 201) {
|
||||
log.info(" - Application {} owner changed successfully to {}", createdApp.getApplicationId(),
|
||||
origOwner);
|
||||
} else {
|
||||
log.warn(" - Application {} owner change to {} failed with response code {}",
|
||||
createdApp.getApplicationId(), origOwner, response.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("IO error while changing owner of Application {}: {}", createdApp.getApplicationId(),
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private ApplicationCreateRequest mapAppDetailToCreateRequest(ApplicationDetail appDetail) {
|
||||
ApplicationCreateRequest request = new ApplicationCreateRequest();
|
||||
request.setName(appDetail.getName());
|
||||
request.setDescription(appDetail.getDescription());
|
||||
request.setThrottlingPolicy(appDetail.getTier());
|
||||
request.setTokenType(appDetail.getTokenType());
|
||||
request.setGroups(List.of(appDetail.getGroupId()));
|
||||
private ApplicationCreateRequest mapAppDetailToCreateRequest(ApplicationDetail appDetail) {
|
||||
ApplicationCreateRequest request = new ApplicationCreateRequest();
|
||||
request.setName(appDetail.getName());
|
||||
request.setDescription(appDetail.getDescription());
|
||||
request.setThrottlingPolicy(appDetail.getTier());
|
||||
request.setTokenType(appDetail.getTokenType());
|
||||
request.setGroups(List.of(appDetail.getGroupId()));
|
||||
|
||||
return request;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,8 @@ public class ApiDefinitionMapper32to45 {
|
||||
: "");
|
||||
data.setVersion(oldApi.getId() != null ? oldApi.getId().getVersion() : null);
|
||||
data.setProvider(oldApi.getId() != null ? oldApi.getId().getProviderName() : null);
|
||||
//data.setContext(swaggerData.get("basePath") != null ? swaggerData.get("basePath").toString() : "");
|
||||
// data.setContext(swaggerData.get("basePath") != null ?
|
||||
// swaggerData.get("basePath").toString() : "");
|
||||
data.setContext(oldApi.getContext());
|
||||
data.setLifeCycleStatus(oldApi.getStatus());
|
||||
data.setDefaultVersion(oldApi.isDefaultVersion());
|
||||
|
||||
@ -1,111 +1,111 @@
|
||||
package cz.trask.migration.model.v32;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ApplicationDetail {
|
||||
private int id;
|
||||
private String name;
|
||||
private String uuid;
|
||||
private Subscriber subscriber;
|
||||
private List<SubscribedAPI> subscribedAPIs;
|
||||
private List<?> keys;
|
||||
private Map<String, Map<String, KeyManagerApp>> keyManagerWiseOAuthApp;
|
||||
private String tier;
|
||||
private String description;
|
||||
private String status;
|
||||
private String groupId;
|
||||
private String owner;
|
||||
private Map<String, Object> applicationAttributes;
|
||||
private String tokenType;
|
||||
private int subscriptionCount;
|
||||
private int id;
|
||||
private String name;
|
||||
private String uuid;
|
||||
private Subscriber subscriber;
|
||||
private List<SubscribedAPI> subscribedAPIs;
|
||||
private List<?> keys;
|
||||
private Map<String, Map<String, KeyManagerApp>> keyManagerWiseOAuthApp;
|
||||
private String tier;
|
||||
private String description;
|
||||
private String status;
|
||||
private String groupId;
|
||||
private String owner;
|
||||
private Map<String, Object> applicationAttributes;
|
||||
private String tokenType;
|
||||
private int subscriptionCount;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Subscriber {
|
||||
private String name;
|
||||
private int id;
|
||||
private int tenantId;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Subscriber {
|
||||
private String name;
|
||||
private int id;
|
||||
private int tenantId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class SubscribedAPI {
|
||||
private int subscriptionId;
|
||||
private Tier tier;
|
||||
private Subscriber subscriber;
|
||||
private ApiId apiId;
|
||||
private Application application;
|
||||
private String subStatus;
|
||||
private String subCreatedStatus;
|
||||
private List<?> keys;
|
||||
private String uuid;
|
||||
private boolean isBlocked;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class SubscribedAPI {
|
||||
private int subscriptionId;
|
||||
private Tier tier;
|
||||
private Subscriber subscriber;
|
||||
private ApiId apiId;
|
||||
private Application application;
|
||||
private String subStatus;
|
||||
private String subCreatedStatus;
|
||||
private List<?> keys;
|
||||
private String uuid;
|
||||
private boolean isBlocked;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Tier {
|
||||
private String name;
|
||||
private String displayName;
|
||||
private int requestsPerMin;
|
||||
private int requestCount;
|
||||
private int unitTime;
|
||||
private String timeUnit;
|
||||
private boolean stopOnQuotaReached;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Tier {
|
||||
private String name;
|
||||
private String displayName;
|
||||
private int requestsPerMin;
|
||||
private int requestCount;
|
||||
private int unitTime;
|
||||
private String timeUnit;
|
||||
private boolean stopOnQuotaReached;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ApiId {
|
||||
private String providerName;
|
||||
private String apiName;
|
||||
private String version;
|
||||
private int id;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ApiId {
|
||||
private String providerName;
|
||||
private String apiName;
|
||||
private String version;
|
||||
private int id;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Application {
|
||||
private int id;
|
||||
private String name;
|
||||
private String uuid;
|
||||
private Subscriber subscriber;
|
||||
private List<?> subscribedAPIs;
|
||||
private List<?> keys;
|
||||
private Map<String, Object> keyManagerWiseOAuthApp;
|
||||
private Map<String, Object> applicationAttributes;
|
||||
private int subscriptionCount;
|
||||
}
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Application {
|
||||
private int id;
|
||||
private String name;
|
||||
private String uuid;
|
||||
private Subscriber subscriber;
|
||||
private List<?> subscribedAPIs;
|
||||
private List<?> keys;
|
||||
private Map<String, Object> keyManagerWiseOAuthApp;
|
||||
private Map<String, Object> applicationAttributes;
|
||||
private int subscriptionCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class KeyManagerApp {
|
||||
private String clientId;
|
||||
private String clientName;
|
||||
private String callBackURL;
|
||||
private String clientSecret;
|
||||
private Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
private boolean isSaasApplication;
|
||||
private String appOwner;
|
||||
private String jsonString;
|
||||
private Map<String, String> appAttributes = new HashMap<>();
|
||||
private String jsonAppAttribute;
|
||||
private String applicationUUID;
|
||||
private String tokenType;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class KeyManagerApp {
|
||||
private String clientId;
|
||||
private String clientName;
|
||||
private String callBackURL;
|
||||
private String clientSecret;
|
||||
private Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
private boolean isSaasApplication;
|
||||
private String appOwner;
|
||||
private String jsonString;
|
||||
private Map<String, String> appAttributes = new HashMap<>();
|
||||
private String jsonAppAttribute;
|
||||
private String applicationUUID;
|
||||
private String tokenType;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,19 +10,19 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ApplicationList {
|
||||
private int count;
|
||||
private String next;
|
||||
private String previous;
|
||||
private List<ApplicationInfo> list;
|
||||
private int count;
|
||||
private String next;
|
||||
private String previous;
|
||||
private List<ApplicationInfo> list;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ApplicationInfo {
|
||||
private String applicationId;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String status;
|
||||
private Object groupId;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ApplicationInfo {
|
||||
private String applicationId;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String status;
|
||||
private Object groupId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,28 +26,15 @@ public class Documents32 {
|
||||
private String lastUpdatedBy = null;
|
||||
|
||||
public enum TypeEnum {
|
||||
HOWTO,
|
||||
SAMPLES,
|
||||
PUBLIC_FORUM,
|
||||
SUPPORT_FORUM,
|
||||
API_MESSAGE_FORMAT,
|
||||
SWAGGER_DOC,
|
||||
OTHER
|
||||
HOWTO, SAMPLES, PUBLIC_FORUM, SUPPORT_FORUM, API_MESSAGE_FORMAT, SWAGGER_DOC, OTHER
|
||||
}
|
||||
|
||||
public enum SourceTypeEnum {
|
||||
INLINE,
|
||||
MARKDOWN,
|
||||
URL,
|
||||
FILE
|
||||
INLINE, MARKDOWN, URL, FILE
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum VisibilityEnum {
|
||||
OWNER_ONLY,
|
||||
PRIVATE,
|
||||
API_LEVEL
|
||||
OWNER_ONLY, PRIVATE, API_LEVEL
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,6 +3,7 @@ package cz.trask.migration.model.v32;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@ -1,51 +1,55 @@
|
||||
package cz.trask.migration.model.v45;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ApplicationCreateRequest {
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
private String name;
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
private String throttlingPolicy;
|
||||
@NotNull
|
||||
private String throttlingPolicy;
|
||||
|
||||
@Size(max = 512)
|
||||
private String description;
|
||||
@Size(max = 512)
|
||||
private String description;
|
||||
|
||||
@Pattern(regexp = "JWT|OAUTH")
|
||||
private String tokenType = "JWT";
|
||||
@Pattern(regexp = "JWT|OAUTH")
|
||||
private String tokenType = "JWT";
|
||||
|
||||
private List<String> groups;
|
||||
private List<String> groups;
|
||||
|
||||
private Map<String, Object> attributes;
|
||||
private Map<String, Object> attributes;
|
||||
|
||||
private List<SubscriptionScope> subscriptionScopes;
|
||||
private List<SubscriptionScope> subscriptionScopes;
|
||||
|
||||
@Pattern(regexp = "PRIVATE|SHARED_WITH_ORG")
|
||||
private String visibility;
|
||||
@Pattern(regexp = "PRIVATE|SHARED_WITH_ORG")
|
||||
private String visibility;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class SubscriptionScope {
|
||||
@NotNull
|
||||
private String key;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class SubscriptionScope {
|
||||
@NotNull
|
||||
private String key;
|
||||
|
||||
@NotNull
|
||||
private String name;
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
private List<String> roles;
|
||||
private List<String> roles;
|
||||
|
||||
private String description;
|
||||
}
|
||||
private String description;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,87 +1,88 @@
|
||||
package cz.trask.migration.model.v45;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ApplicationCreateResponse {
|
||||
@JsonProperty("applicationId")
|
||||
private String applicationId;
|
||||
@JsonProperty("applicationId")
|
||||
private String applicationId;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("throttlingPolicy")
|
||||
private String throttlingPolicy;
|
||||
@JsonProperty("throttlingPolicy")
|
||||
private String throttlingPolicy;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("tokenType")
|
||||
private String tokenType = "JWT";
|
||||
@JsonProperty("tokenType")
|
||||
private String tokenType = "JWT";
|
||||
|
||||
@JsonProperty("status")
|
||||
private String status = "";
|
||||
@JsonProperty("status")
|
||||
private String status = "";
|
||||
|
||||
@JsonProperty("groups")
|
||||
private List<String> groups;
|
||||
@JsonProperty("groups")
|
||||
private List<String> groups;
|
||||
|
||||
@JsonProperty("subscriptionCount")
|
||||
private Integer subscriptionCount;
|
||||
@JsonProperty("subscriptionCount")
|
||||
private Integer subscriptionCount;
|
||||
|
||||
@JsonProperty("keys")
|
||||
private List<ApplicationKey> keys;
|
||||
@JsonProperty("keys")
|
||||
private List<ApplicationKey> keys;
|
||||
|
||||
@JsonProperty("attributes")
|
||||
private Map<String, Object> attributes;
|
||||
@JsonProperty("attributes")
|
||||
private Map<String, Object> attributes;
|
||||
|
||||
@JsonProperty("subscriptionScopes")
|
||||
private List<SubscriptionScope> subscriptionScopes;
|
||||
@JsonProperty("subscriptionScopes")
|
||||
private List<SubscriptionScope> subscriptionScopes;
|
||||
|
||||
@JsonProperty("owner")
|
||||
private String owner;
|
||||
@JsonProperty("owner")
|
||||
private String owner;
|
||||
|
||||
@JsonProperty("hashEnabled")
|
||||
private Boolean hashEnabled;
|
||||
@JsonProperty("hashEnabled")
|
||||
private Boolean hashEnabled;
|
||||
|
||||
@JsonProperty("createdTime")
|
||||
private String createdTime;
|
||||
@JsonProperty("createdTime")
|
||||
private String createdTime;
|
||||
|
||||
@JsonProperty("updatedTime")
|
||||
private String updatedTime;
|
||||
@JsonProperty("updatedTime")
|
||||
private String updatedTime;
|
||||
|
||||
@JsonProperty("visibility")
|
||||
private String visibility;
|
||||
@JsonProperty("visibility")
|
||||
private String visibility;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ApplicationKey {
|
||||
@JsonProperty("key")
|
||||
private String key;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ApplicationKey {
|
||||
@JsonProperty("key")
|
||||
private String key;
|
||||
|
||||
@JsonProperty("keyType")
|
||||
private String keyType;
|
||||
@JsonProperty("keyType")
|
||||
private String keyType;
|
||||
|
||||
@JsonProperty("state")
|
||||
private String state;
|
||||
}
|
||||
@JsonProperty("state")
|
||||
private String state;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SubscriptionScope {
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SubscriptionScope {
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
}
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
}
|
||||
}
|
||||
@ -1,25 +1,26 @@
|
||||
package cz.trask.migration.model.v45;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class ApplicationKeyMappingRequest45 {
|
||||
@JsonProperty("consumerKey")
|
||||
private String consumerKey;
|
||||
@JsonProperty("consumerKey")
|
||||
private String consumerKey;
|
||||
|
||||
@JsonProperty("consumerSecret")
|
||||
private String consumerSecret;
|
||||
@JsonProperty("consumerSecret")
|
||||
private String consumerSecret;
|
||||
|
||||
@JsonProperty("keyManager")
|
||||
private String keyManager;
|
||||
@JsonProperty("keyManager")
|
||||
private String keyManager;
|
||||
|
||||
@JsonProperty("keyType")
|
||||
private KeyType keyType;
|
||||
@JsonProperty("keyType")
|
||||
private KeyType keyType;
|
||||
|
||||
public enum KeyType {
|
||||
PRODUCTION, SANDBOX
|
||||
}
|
||||
public enum KeyType {
|
||||
PRODUCTION, SANDBOX
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,61 +13,61 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ApplicationKeyMappingResponse45 {
|
||||
@JsonProperty("keyMappingId")
|
||||
private String keyMappingId;
|
||||
@JsonProperty("keyMappingId")
|
||||
private String keyMappingId;
|
||||
|
||||
@JsonProperty("keyManager")
|
||||
private String keyManager;
|
||||
@JsonProperty("keyManager")
|
||||
private String keyManager;
|
||||
|
||||
@JsonProperty("consumerKey")
|
||||
private String consumerKey;
|
||||
@JsonProperty("consumerKey")
|
||||
private String consumerKey;
|
||||
|
||||
@JsonProperty("consumerSecret")
|
||||
private String consumerSecret;
|
||||
@JsonProperty("consumerSecret")
|
||||
private String consumerSecret;
|
||||
|
||||
@JsonProperty("supportedGrantTypes")
|
||||
private List<String> supportedGrantTypes;
|
||||
@JsonProperty("supportedGrantTypes")
|
||||
private List<String> supportedGrantTypes;
|
||||
|
||||
@JsonProperty("callbackUrl")
|
||||
private String callbackUrl;
|
||||
@JsonProperty("callbackUrl")
|
||||
private String callbackUrl;
|
||||
|
||||
@JsonProperty("keyState")
|
||||
private String keyState;
|
||||
@JsonProperty("keyState")
|
||||
private String keyState;
|
||||
|
||||
@JsonProperty("keyType")
|
||||
private KeyType keyType;
|
||||
@JsonProperty("keyType")
|
||||
private KeyType keyType;
|
||||
|
||||
@JsonProperty("mode")
|
||||
private Mode mode;
|
||||
@JsonProperty("mode")
|
||||
private Mode mode;
|
||||
|
||||
@JsonProperty("groupId")
|
||||
private String groupId;
|
||||
@JsonProperty("groupId")
|
||||
private String groupId;
|
||||
|
||||
@JsonProperty("token")
|
||||
private Token token;
|
||||
@JsonProperty("token")
|
||||
private Token token;
|
||||
|
||||
@JsonProperty("additionalProperties")
|
||||
private Map<String, Object> additionalProperties;
|
||||
@JsonProperty("additionalProperties")
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Token {
|
||||
@JsonProperty("accessToken")
|
||||
private String accessToken;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Token {
|
||||
@JsonProperty("accessToken")
|
||||
private String accessToken;
|
||||
|
||||
@JsonProperty("tokenScopes")
|
||||
private List<String> tokenScopes;
|
||||
@JsonProperty("tokenScopes")
|
||||
private List<String> tokenScopes;
|
||||
|
||||
@JsonProperty("validityTime")
|
||||
private Long validityTime;
|
||||
}
|
||||
@JsonProperty("validityTime")
|
||||
private Long validityTime;
|
||||
}
|
||||
|
||||
enum Mode {
|
||||
MAPPED, CREATED
|
||||
}
|
||||
enum Mode {
|
||||
MAPPED, CREATED
|
||||
}
|
||||
|
||||
enum KeyType {
|
||||
PRODUCTION, SANDBOX
|
||||
}
|
||||
enum KeyType {
|
||||
PRODUCTION, SANDBOX
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package cz.trask.migration.model.v45;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@ -9,29 +9,29 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class ApplicationListResponse45 {
|
||||
|
||||
private int count;
|
||||
private Application[] list;
|
||||
private Pagination pagination;
|
||||
private int count;
|
||||
private Application[] list;
|
||||
private Pagination pagination;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Application {
|
||||
private String applicationId;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String status;
|
||||
private String groupId;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Application {
|
||||
private String applicationId;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String status;
|
||||
private String groupId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Pagination {
|
||||
private int offset;
|
||||
private int limit;
|
||||
private int total;
|
||||
private String next;
|
||||
private String previous;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Pagination {
|
||||
private int offset;
|
||||
private int limit;
|
||||
private int total;
|
||||
private String next;
|
||||
private String previous;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user