create apps
This commit is contained in:
parent
8d16d21dc7
commit
5fa3786c89
@ -54,6 +54,9 @@ public abstract class AbstractProcess {
|
||||
public static final String ARTIFACT_GROUP_APPLICATIONS = "APPLICATIONS";
|
||||
public static final String ARTIFACT_APPLICATION_DEFAULT_VERSION = "1.0.0";
|
||||
|
||||
public static final String DEFAULT_APPLICATION_NAME = "DefaultApplication";
|
||||
public static final String ADMIN_USERNAME = "admin";
|
||||
|
||||
public static final String DEFAULT_DOC_FILE_NAME = "document.yaml";
|
||||
|
||||
public static ObjectMapper mapper;
|
||||
|
||||
@ -27,6 +27,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
|
||||
private final AtomicInteger appCounter = new AtomicInteger(1);
|
||||
private SearchedArtifact adminsDefaultApplication;
|
||||
|
||||
/**
|
||||
* Main entry point for the import process.
|
||||
@ -49,7 +50,13 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
|
||||
for (SearchedArtifact app : apps.getArtifacts()) {
|
||||
final int index = appCounter.getAndIncrement();
|
||||
executor.submit(() -> processApp(app, token, index, apps.getCount()));
|
||||
executor.submit(() -> processApp(app, token, index, apps.getCount(), false));
|
||||
}
|
||||
|
||||
if (adminsDefaultApplication != null) {
|
||||
log.info("Found default application for admins: {}", adminsDefaultApplication.getName());
|
||||
executor.submit(() -> processApp(adminsDefaultApplication, token,
|
||||
appCounter.getAndIncrement(), apps.getCount(), true));
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
@ -63,7 +70,7 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
}
|
||||
}
|
||||
|
||||
private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total) {
|
||||
private void processApp(SearchedArtifact app, TokenResponse tokenResponse, int index, int total, boolean createAdminApp) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
@ -82,6 +89,14 @@ public class ExportAppsToWso2FromV32 extends AbstractProcess {
|
||||
if (content != null && content.length > 0) {
|
||||
ApplicationDetail appDetail = mapper
|
||||
.readValue(content, ApplicationDetail.class);
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
ApplicationCreateRequest appCreateRequest = mapAppDetailToCreateRequest(appDetail);
|
||||
byte[] data = mapper.writeValueAsBytes(appCreateRequest);
|
||||
log.info(" - Application {} with owner {} prepared for WSO2 import", appDetail.getName(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user