diff --git a/src/main/java/cz/trask/migration/AbstractProcess.java b/src/main/java/cz/trask/migration/AbstractProcess.java index f064dc8..7ea4960 100644 --- a/src/main/java/cz/trask/migration/AbstractProcess.java +++ b/src/main/java/cz/trask/migration/AbstractProcess.java @@ -461,7 +461,7 @@ public abstract class AbstractProcess { InputStream in; int responseCode = con.getResponseCode(); - if (responseCode == 200 || responseCode == 201) { + if (responseCode >= 200 || responseCode <= 299) { in = con.getInputStream(); } else { in = con.getErrorStream(); diff --git a/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java b/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java index 9691986..b31462e 100644 --- a/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java +++ b/src/main/java/cz/trask/migration/impl/v45/ExportApisToWso2FromV32.java @@ -1,6 +1,7 @@ package cz.trask.migration.impl.v45; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.HashMap; @@ -95,11 +96,14 @@ public class ExportApisToWso2FromV32 extends AbstractProcess { byte[] data = prepareApiZipFile32to45(ver, ref); String fileName = api.getName() + "-" + ver.getVersion() + ".zip"; - FileOutputStream fos = new FileOutputStream(fileName); - fos.write(data); - fos.flush(); - fos.close(); - // System.exit(0); + if (config.isStoreMigratedArtifacts()) { + File tmpFile = new File("tmp/api/", fileName); + log.info(" - Storing migrated Api file: {}", tmpFile.getAbsolutePath()); + FileOutputStream fos = new FileOutputStream(tmpFile); + fos.write(data); + fos.flush(); + fos.close(); + } if (data != null && data.length > 0 && fileName != null && !fileName.isEmpty()) { int responseCode = publishApiToWso2(fileName, data, tokenResponse); diff --git a/src/main/java/cz/trask/migration/impl/v45/ExportAppsToWso2FromV32.java b/src/main/java/cz/trask/migration/impl/v45/ExportAppsToWso2FromV32.java index fbd80aa..cad067a 100644 --- a/src/main/java/cz/trask/migration/impl/v45/ExportAppsToWso2FromV32.java +++ b/src/main/java/cz/trask/migration/impl/v45/ExportAppsToWso2FromV32.java @@ -1,23 +1,26 @@ package cz.trask.migration.impl.v45; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; +import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import cz.trask.migration.AbstractProcess; import cz.trask.migration.model.HttpResponse; import cz.trask.migration.model.TokenResponse; import cz.trask.migration.model.v32.ApplicationDetail; -import cz.trask.migration.model.v32.ApplicationDetail.KeyManagerApp; -import cz.trask.migration.model.v45.ApplicationCreateRequest; -import cz.trask.migration.model.v45.ApplicationCreateResponse; -import cz.trask.migration.model.v45.ApplicationKeyMappingRequest45; -import cz.trask.migration.model.v45.ApplicationListResponse45; +import cz.trask.migration.model.v45.ApplicationDetail45; import io.apicurio.registry.rest.v2.beans.ArtifactMetaData; import io.apicurio.registry.rest.v2.beans.ArtifactSearchResults; import io.apicurio.registry.rest.v2.beans.SearchedArtifact; @@ -29,11 +32,8 @@ import lombok.extern.log4j.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 final AtomicInteger appCounter = new AtomicInteger(1); - private SearchedArtifact adminsDefaultApplication; /** * Main entry point for the export process. @@ -53,10 +53,6 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { 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); @@ -69,7 +65,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { for (SearchedArtifact app : apps.getArtifacts()) { final int index = appCounter.getAndIncrement(); - executor.submit(() -> processApp(app, token, index, apps.getCount(), false)); + executor.submit(() -> processApp(app, token, index, apps.getCount())); } executor.shutdown(); @@ -79,8 +75,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { log.info("Finished processing Apps."); } - private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total, - boolean createAdminApp) { + private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total) { long start = System.currentTimeMillis(); try { @@ -90,7 +85,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { null); for (SearchedVersion ver : versions.getVersions()) { - processAppVersion(app, tokenResponse, ver, createAdminApp); + processAppVersion(app, tokenResponse, ver); } long end = System.currentTimeMillis(); @@ -100,8 +95,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { } } - private void processAppVersion(SearchedArtifact app, TokenResponse tokenResponse, SearchedVersion version, - boolean createAdminApp) { + private void processAppVersion(SearchedArtifact app, TokenResponse tokenResponse, SearchedVersion version) { try { log.info(" - Found version: {}", version.getVersion()); @@ -111,197 +105,193 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess { 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; + ApplicationDetail45 yamlApp = mapFromJsonToYaml(appDetail); + + byte[] data = prepareAppZipFile32to45(yamlApp); + + String fileName = yamlApp.getData().getApplicationInfo().getName() + "-" + + yamlApp.getData().getApplicationInfo().getOwner() + "-v45.zip"; + + if (config.isStoreMigratedArtifacts()) { + File tmpFile = new File("tmp/app/", fileName); + log.info(" - Storing migrated App file: {}", tmpFile.getAbsolutePath()); + FileOutputStream fos = new FileOutputStream(tmpFile); + fos.write(data); + fos.flush(); + fos.close(); } - 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); - - HttpResponse response = publishAppToWso2(appDetail.getName(), data, tokenResponse); - - 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()); - - if (appDetail.getKeyManagerWiseOAuthApp() != null - && !appDetail.getKeyManagerWiseOAuthApp().isEmpty()) { - log.info(" - Application {} has {} Key Mappings to create", appDetail.getName(), - appDetail.getKeyManagerWiseOAuthApp().size()); - for (Entry> entry : appDetail.getKeyManagerWiseOAuthApp() - .entrySet()) { - String keyType = entry.getKey(); - - Map keyManagerApp = entry.getValue(); - - for (Entry 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(); - - byte[] kmData = mapper.writeValueAsBytes(keyMappingRequest); - publishApplicationKeyMappingToWso2(createdApp.getApplicationId(), kmData, - tokenResponse); - } - } + if (data != null && data.length > 0 && fileName != null && !fileName.isEmpty()) { + int responseCode = publishAppToWso2(fileName, data, tokenResponse); + if (responseCode == 200 || responseCode == 201) { + log.info(" - Application {} imported successfully with response code: {}", appDetail.getName(), responseCode); + } else { + log.warn(" - Application {} import failed with response code: {}", appDetail.getName(), + responseCode); } - - 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); } } - private void publishApplicationKeyMappingToWso2(String applicationId, byte[] kmData, TokenResponse tokenResponse) { - try { - // Publish the application key mapping data to WSO2 - Map httpHeaders = createBearerAuthHeaders(tokenResponse); - httpHeaders.put("Content-Type", "application/json"); + public byte[] prepareAppZipFile32to45(ApplicationDetail45 yamlApp) throws Exception { - String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications/" + applicationId - + "/map-keys"; + String baseDir = yamlApp.getData().getApplicationInfo().getOwner() + "-" + + yamlApp.getData().getApplicationInfo().getName() + "/"; - HttpResponse response = makeDataRequest(endpoint, httpHeaders, kmData); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ZipOutputStream zos = new ZipOutputStream(baos)) { - 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); + byte[] content = mapperYaml.writeValueAsBytes(yamlApp); + zos.putNextEntry(new ZipEntry(baseDir.concat("application.yaml"))); + zos.write(content); + zos.closeEntry(); + + zos.finish(); + return baos.toByteArray(); } } - 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); + public ApplicationDetail45 mapFromJsonToYaml(ApplicationDetail jsonApp) { + ApplicationDetail45 yamlApp = new ApplicationDetail45(); + yamlApp.setType("application"); + yamlApp.setVersion("v4.5.0"); - if (resolvedAppId == null) { - log.warn(" - Application {} not found in WSO2, cannot delete", appDetail.getName()); - return; - } + ApplicationDetail45.Data yamlData = new ApplicationDetail45.Data(); - String endpoint = config.getTarget().getAdminApiUrl() + APPLICATIONS_ENDPOINT_PATH + "/" + resolvedAppId; + ApplicationDetail45.ApplicationInfo yamlAppInfo = new ApplicationDetail45.ApplicationInfo(); - try { - Map httpHeaders = createBearerAuthHeaders(tokenResponse); + yamlAppInfo.setApplicationId(jsonApp.getUuid()); + yamlAppInfo.setName(jsonApp.getName()); + yamlAppInfo.setThrottlingPolicy(jsonApp.getTier()); + yamlAppInfo.setDescription(jsonApp.getDescription()); + yamlAppInfo.setTokenType(jsonApp.getTokenType()); + yamlAppInfo.setStatus(jsonApp.getStatus()); + yamlAppInfo.setGroups(jsonApp.getGroupId() != null ? List.of(jsonApp.getGroupId()) : Collections.emptyList()); + yamlAppInfo.setSubscriptionCount(jsonApp.getSubscribedAPIs() != null ? jsonApp.getSubscribedAPIs().size() : 0); + yamlAppInfo.setAttributes(jsonApp.getApplicationAttributes()); + yamlAppInfo.setOwner(jsonApp.getOwner()); + yamlAppInfo.setVisibility("PRIVATE"); + yamlAppInfo.setCreatedTime("" + System.currentTimeMillis()); + yamlAppInfo.setUpdatedTime("" + System.currentTimeMillis()); + yamlAppInfo.setSubscriptionScopes(Collections.emptyList()); - HttpResponse response = makeRequest("DELETE", endpoint, httpHeaders, null); + List yamlKeys = new ArrayList<>(); - 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 (jsonApp.getKeyManagerWiseOAuthApp() != null) { + for (Map.Entry> outerEntry : jsonApp + .getKeyManagerWiseOAuthApp().entrySet()) { + String keyType = outerEntry.getKey(); + Map innerMap = outerEntry.getValue(); - private String getExistingApplicationId(String adminApiUrl, ApplicationDetail appDetail, - TokenResponse tokenResponse) { - try { - String url = adminApiUrl.concat(APPLICATIONS_ENDPOINT_PATH); + if (innerMap != null) { + for (Map.Entry innerEntry : innerMap.entrySet()) { + ApplicationDetail.KeyManagerApp keyManagerApp = innerEntry.getValue(); - Map httpHeaders = createBearerAuthHeaders(tokenResponse); - Map params = new HashMap<>(); + String keyManagerType = innerEntry.getKey(); - HttpResponse response = makeRequest("GET", url, httpHeaders, params); + ApplicationDetail45.Key yamlKey = new ApplicationDetail45.Key(); + yamlKey.setKeyMappingId(UUID.randomUUID().toString()); + yamlKey.setKeyManager(keyManagerType); + yamlKey.setConsumerKey(keyManagerApp.getClientId()); + yamlKey.setConsumerSecret(keyManagerApp.getClientSecret()); + String grantTypes = keyManagerApp.getParameters() != null + ? (String) keyManagerApp.getParameters().get("grant_types") + : null; + if (grantTypes != null && !grantTypes.isEmpty()) { + String[] grantsArray = grantTypes.split(" "); + yamlKey.setSupportedGrantTypes(List.of(grantsArray)); + } else { + yamlKey.setSupportedGrantTypes(List.of()); + } + yamlKey.setCallbackUrl(keyManagerApp.getCallBackURL()); + yamlKey.setKeyState("COMPLETED"); + yamlKey.setKeyType(keyType.toUpperCase()); + yamlKey.setMode("CREATED"); - if (response.getResponseCode() != 200) { - log.warn("Cannot list Applications (HTTP {}). Will not attempt delete.", response.getResponseCode()); - return null; - } + ApplicationDetail45.Token token = new ApplicationDetail45.Token(); + token.setTokenScopes(List.of()); + token.setValidityTime(0); + yamlKey.setToken(token); - ApplicationListResponse45 listOfApps = mapper.readValue(response.getResponse(), - ApplicationListResponse45.class); + Map additionalProps = Map.of("id_token_expiry_time", 3600, + "application_access_token_expiry_time", 3600, "user_access_token_expiry_time", 3600, + "bypassClientCredentials", false, "pkceMandatory", false, "pkceSupportPlain", false, + "refresh_token_expiry_time", 86400); + yamlKey.setAdditionalProperties(additionalProps); - 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(); + yamlKeys.add(yamlKey); } } } - } catch (Exception e) { - log.error("Error while resolving Application id for name {}: {}", appDetail.getName(), e.getMessage(), e); } - return null; + yamlAppInfo.setKeys(yamlKeys); + + yamlData.setApplicationInfo(yamlAppInfo); + + List yamlSubscribedAPIs = new ArrayList<>(); + + if (jsonApp.getSubscribedAPIs() != null) { + for (ApplicationDetail.SubscribedAPI jsonApi : jsonApp.getSubscribedAPIs()) { + ApplicationDetail45.SubscribedAPI yamlApi = new ApplicationDetail45.SubscribedAPI(); + + if (jsonApi.getApiId() != null) { + ApplicationDetail45.ApiId yamlApiId = new ApplicationDetail45.ApiId(); + yamlApiId.setProviderName(jsonApi.getApiId().getProviderName()); + yamlApiId.setApiName(jsonApi.getApiId().getApiName()); + yamlApiId.setVersion(jsonApi.getApiId().getVersion()); + yamlApiId.setUuid(jsonApi.getUuid()); + yamlApiId.setId(jsonApi.getApiId().getId()); + yamlApi.setApiId(yamlApiId); + } + + if (jsonApi.getSubscriber() != null) { + ApplicationDetail45.Subscriber yamlSubscriber = new ApplicationDetail45.Subscriber(); + yamlSubscriber.setName(jsonApi.getSubscriber().getName()); + yamlSubscriber.setId(jsonApi.getSubscriber().getId()); + yamlSubscriber.setTenantId(jsonApi.getSubscriber().getTenantId()); + yamlApi.setSubscriber(yamlSubscriber); + } + + yamlApi.setThrottlingPolicy(jsonApi.getTier() != null ? jsonApi.getTier().getName() : "Unlimited"); + yamlSubscribedAPIs.add(yamlApi); + } + } + + yamlData.setSubscribedAPIs(yamlSubscribedAPIs); + + yamlApp.setData(yamlData); + + return yamlApp; } - private HttpResponse publishAppToWso2(String name, byte[] data, TokenResponse tokenResponse) throws Exception { - // Publish the application data to WSO2 - Map httpHeaders = createBasicAuthHeaders(config.getTarget().getWso2User()); - httpHeaders.put("Content-Type", "application/json"); - - String endpoint = config.getTarget().getDevPortalApiUrl() + "/v3/applications"; - - 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 int publishAppToWso2(String fileName, byte[] data, TokenResponse tokenResponse) { + int responseCode = -1; try { - Map httpHeaders = createBearerAuthHeaders(tokenResponse); + String url = config.getTarget().getDevPortalApiUrl().concat(String.format( + "/v3/applications/import?preserveOwner=true&skipSubscriptions=false&skipApplicationKeys=false&update=true")); - HttpResponse response = makeRequest("POST", endpoint, httpHeaders, null); + log.info("App Import URL: " + url); - 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()); + Map httpHeaders = new HashMap<>(); + + httpHeaders.put("Authorization", "Bearer " + tokenResponse.getAccess_token()); + + HttpResponse response = makeFileRequest("POST", url, httpHeaders, data, fileName); + + responseCode = response.getResponseCode(); + + if (response.getResponseCode() < 200 || response.getResponseCode() > 299) { + log.info("Cannot import App file: " + fileName + ", response code: " + response.getResponseCode()); } } catch (Exception e) { - log.error("IO error while changing owner of Application {}: {}", createdApp.getApplicationId(), - e.getMessage(), e); + log.error("IO error while importing App file: " + fileName + ", error: " + e.getMessage(), e); } + return responseCode; } - 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; - } } \ No newline at end of file diff --git a/src/main/java/cz/trask/migration/model/ApplicationConfig.java b/src/main/java/cz/trask/migration/model/ApplicationConfig.java index 097ffd9..5e9b565 100644 --- a/src/main/java/cz/trask/migration/model/ApplicationConfig.java +++ b/src/main/java/cz/trask/migration/model/ApplicationConfig.java @@ -19,6 +19,8 @@ public class ApplicationConfig { private Apicurio apicurio; @JsonProperty("max_threads") private int maxThreads; + @JsonProperty("store_migrated_artifacts") + private boolean storeMigratedArtifacts = false; @Data public static class TrustStore { diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationCreateRequest.java b/src/main/java/cz/trask/migration/model/v45/ApplicationCreateRequest.java deleted file mode 100644 index 95d8f99..0000000 --- a/src/main/java/cz/trask/migration/model/v45/ApplicationCreateRequest.java +++ /dev/null @@ -1,55 +0,0 @@ -package cz.trask.migration.model.v45; - -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 - private String throttlingPolicy; - - @Size(max = 512) - private String description; - - @Pattern(regexp = "JWT|OAUTH") - private String tokenType = "JWT"; - - private List groups; - - private Map attributes; - - private List subscriptionScopes; - - @Pattern(regexp = "PRIVATE|SHARED_WITH_ORG") - private String visibility; - - @Data - @AllArgsConstructor - @NoArgsConstructor - public static class SubscriptionScope { - @NotNull - private String key; - - @NotNull - private String name; - - private List roles; - - private String description; - } -} diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationCreateResponse.java b/src/main/java/cz/trask/migration/model/v45/ApplicationCreateResponse.java deleted file mode 100644 index 30e30c0..0000000 --- a/src/main/java/cz/trask/migration/model/v45/ApplicationCreateResponse.java +++ /dev/null @@ -1,88 +0,0 @@ -package cz.trask.migration.model.v45; - -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("name") - private String name; - - @JsonProperty("throttlingPolicy") - private String throttlingPolicy; - - @JsonProperty("description") - private String description; - - @JsonProperty("tokenType") - private String tokenType = "JWT"; - - @JsonProperty("status") - private String status = ""; - - @JsonProperty("groups") - private List groups; - - @JsonProperty("subscriptionCount") - private Integer subscriptionCount; - - @JsonProperty("keys") - private List keys; - - @JsonProperty("attributes") - private Map attributes; - - @JsonProperty("subscriptionScopes") - private List subscriptionScopes; - - @JsonProperty("owner") - private String owner; - - @JsonProperty("hashEnabled") - private Boolean hashEnabled; - - @JsonProperty("createdTime") - private String createdTime; - - @JsonProperty("updatedTime") - private String updatedTime; - - @JsonProperty("visibility") - private String visibility; - - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class ApplicationKey { - @JsonProperty("key") - private String key; - - @JsonProperty("keyType") - private String keyType; - - @JsonProperty("state") - private String state; - } - - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class SubscriptionScope { - @JsonProperty("name") - private String name; - - @JsonProperty("description") - private String description; - } -} \ No newline at end of file diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationDetail45.java b/src/main/java/cz/trask/migration/model/v45/ApplicationDetail45.java new file mode 100644 index 0000000..0e144c6 --- /dev/null +++ b/src/main/java/cz/trask/migration/model/v45/ApplicationDetail45.java @@ -0,0 +1,149 @@ +package cz.trask.migration.model.v45; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ApplicationDetail45 { + + private String type; + private String version; + + @JsonProperty("data") + private Data data; + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Data { + @JsonProperty("applicationInfo") + private ApplicationInfo applicationInfo; + + @JsonProperty("subscribedAPIs") + private List subscribedAPIs; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ApplicationInfo { + @JsonProperty("applicationId") + private String applicationId; + + private String name; + + @JsonProperty("throttlingPolicy") + private String throttlingPolicy; + + private String description; + + @JsonProperty("tokenType") + private String tokenType; + + private String status; + + private List groups; + + private List keys; + + private Map attributes; + + private Integer subscriptionCount; + + @JsonProperty("subscriptionScopes") + private List subscriptionScopes; + + private String owner; + + @JsonProperty("createdTime") + private String createdTime; + + @JsonProperty("updatedTime") + private String updatedTime; + + private String visibility; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Key { + @JsonProperty("keyMappingId") + private String keyMappingId; + + @JsonProperty("keyManager") + private String keyManager; + + @JsonProperty("consumerKey") + private String consumerKey; + + @JsonProperty("consumerSecret") + private String consumerSecret; + + @JsonProperty("supportedGrantTypes") + private List supportedGrantTypes; + + @JsonProperty("callbackUrl") + private String callbackUrl; + + @JsonProperty("keyState") + private String keyState; + + @JsonProperty("keyType") + private String keyType; + + private String mode; + + private Token token; + + @JsonProperty("additionalProperties") + private Map additionalProperties; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Token { + private List tokenScopes; + + @JsonProperty("validityTime") + private Integer validityTime; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class SubscribedAPI { + @JsonProperty("apiId") + private ApiId apiId; + + @JsonProperty("subscriber") + private Subscriber subscriber; + + @JsonProperty("throttlingPolicy") + private String throttlingPolicy; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ApiId { + @JsonProperty("providerName") + private String providerName; + + @JsonProperty("apiName") + private String apiName; + + private String version; + private String uuid; + private Integer id; + } + + @lombok.Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Subscriber { + private String name; + private Integer id; + private Integer tenantId; + } +} \ No newline at end of file diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingRequest45.java b/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingRequest45.java deleted file mode 100644 index 6fc5b6c..0000000 --- a/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingRequest45.java +++ /dev/null @@ -1,26 +0,0 @@ -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("consumerSecret") - private String consumerSecret; - - @JsonProperty("keyManager") - private String keyManager; - - @JsonProperty("keyType") - private KeyType keyType; - - public enum KeyType { - PRODUCTION, SANDBOX - } -} diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingResponse45.java b/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingResponse45.java deleted file mode 100644 index b327339..0000000 --- a/src/main/java/cz/trask/migration/model/v45/ApplicationKeyMappingResponse45.java +++ /dev/null @@ -1,73 +0,0 @@ -package cz.trask.migration.model.v45; - -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class ApplicationKeyMappingResponse45 { - @JsonProperty("keyMappingId") - private String keyMappingId; - - @JsonProperty("keyManager") - private String keyManager; - - @JsonProperty("consumerKey") - private String consumerKey; - - @JsonProperty("consumerSecret") - private String consumerSecret; - - @JsonProperty("supportedGrantTypes") - private List supportedGrantTypes; - - @JsonProperty("callbackUrl") - private String callbackUrl; - - @JsonProperty("keyState") - private String keyState; - - @JsonProperty("keyType") - private KeyType keyType; - - @JsonProperty("mode") - private Mode mode; - - @JsonProperty("groupId") - private String groupId; - - @JsonProperty("token") - private Token token; - - @JsonProperty("additionalProperties") - private Map additionalProperties; - - @Data - @AllArgsConstructor - @NoArgsConstructor - public static class Token { - @JsonProperty("accessToken") - private String accessToken; - - @JsonProperty("tokenScopes") - private List tokenScopes; - - @JsonProperty("validityTime") - private Long validityTime; - } - - enum Mode { - MAPPED, CREATED - } - - enum KeyType { - PRODUCTION, SANDBOX - } -} \ No newline at end of file diff --git a/src/main/java/cz/trask/migration/model/v45/ApplicationListResponse45.java b/src/main/java/cz/trask/migration/model/v45/ApplicationListResponse45.java deleted file mode 100644 index 33668c8..0000000 --- a/src/main/java/cz/trask/migration/model/v45/ApplicationListResponse45.java +++ /dev/null @@ -1,37 +0,0 @@ -package cz.trask.migration.model.v45; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class ApplicationListResponse45 { - - 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 Pagination { - private int offset; - private int limit; - private int total; - private String next; - private String previous; - } -} \ No newline at end of file diff --git a/src/main/resources/apicurio-migrator.yaml b/src/main/resources/apicurio-migrator.yaml index 3471bba..8ecaca0 100644 --- a/src/main/resources/apicurio-migrator.yaml +++ b/src/main/resources/apicurio-migrator.yaml @@ -27,4 +27,6 @@ apicurio: default_api_group: api overwrite_existing_application: true -max_threads: 1 \ No newline at end of file +max_threads: 1 + +store_migrated_artifacts: true \ No newline at end of file