overwrite application in Apicurio
This commit is contained in:
parent
a36ee218c2
commit
8b14aa04b3
@ -22,18 +22,22 @@ public class ApiSync {
|
|||||||
StartParameters sp = StartParameters.parse(commandLine);
|
StartParameters sp = StartParameters.parse(commandLine);
|
||||||
log.info("Parsed parameters: " + sp);
|
log.info("Parsed parameters: " + sp);
|
||||||
|
|
||||||
if (sp.getCommand().equalsIgnoreCase("wso2ToApicurio")) {
|
if (sp.getCommand().equalsIgnoreCase("wso2ApisToApicurio")) {
|
||||||
log.info("Import command selected.");
|
log.info("wso2ApisToApicurio command selected.");
|
||||||
Wso2v32ToApicurio imp = new Wso2v32ToApicurio();
|
Wso2v32ToApicurio imp = new Wso2v32ToApicurio();
|
||||||
imp.process();
|
imp.process();
|
||||||
} else if (sp.getCommand().equalsIgnoreCase("apicurioToWso2")) {
|
} else if (sp.getCommand().equalsIgnoreCase("apicurioApisToWso2")) {
|
||||||
log.info("Export command selected.");
|
log.info("apicurioApisToWso2 command selected.");
|
||||||
ExportToWso2FromV32 exp = new ExportToWso2FromV32();
|
ExportToWso2FromV32 exp = new ExportToWso2FromV32();
|
||||||
exp.process();
|
exp.process();
|
||||||
} else if (sp.getCommand().equalsIgnoreCase("wso2AppsToApicurio")) {
|
} else if (sp.getCommand().equalsIgnoreCase("wso2AppsToApicurio")) {
|
||||||
log.info("Export command selected.");
|
log.info("wso2AppsToApicurio command selected.");
|
||||||
Wso2AppsToApicurio apps = new Wso2AppsToApicurio();
|
Wso2AppsToApicurio apps = new Wso2AppsToApicurio();
|
||||||
apps.process();
|
apps.process();
|
||||||
|
} else if (sp.getCommand().equalsIgnoreCase("apicurioAppsToWso2")) {
|
||||||
|
log.info("apicurioAppsToWso2 command selected.");
|
||||||
|
ExportToWso2FromV32 exp = new ExportToWso2FromV32();
|
||||||
|
exp.process();
|
||||||
} else {
|
} else {
|
||||||
log.error("Unknown command: " + sp.getCommand());
|
log.error("Unknown command: " + sp.getCommand());
|
||||||
printHelp();
|
printHelp();
|
||||||
|
|||||||
@ -105,20 +105,19 @@ public class Wso2AppsToApicurio extends AbstractProcess {
|
|||||||
existingArtifacts = null;
|
existingArtifacts = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingArtifacts == null) {
|
if (existingArtifacts == null || existingArtifacts.getCount() == 0) {
|
||||||
log.info("Creating new Application to Apicurio '{}' ({}).", appDetail.getName(),
|
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||||
appDetail.getOwner());
|
} else if (existingArtifacts != null && existingArtifacts.getCount() > 0
|
||||||
// Create new artifact
|
&& config.getApicurio().isOverwriteExistingApplication()) {
|
||||||
ArtifactMetaData meta = client.createArtifact(group, mainArtifactId,
|
try {
|
||||||
ARTIFACT_APPLICATION_DEFAULT_VERSION, null, null,
|
log.info("Deleting existing Application in Apicurio '{}' ({}).", appDetail.getName(),
|
||||||
null,
|
appDetail.getOwner());
|
||||||
appDetail.getName(), appDetail.getName(), null, null, null,
|
client.deleteArtifact(group, mainArtifactId);
|
||||||
new ByteArrayInputStream(entry.getContent()), null);
|
createApplicationInApicurio(appDetail, group, mainArtifactId, entry.getContent());
|
||||||
|
} catch (Exception e) {
|
||||||
// Create the three required rules
|
log.error("Error deleting existing Application '{}' ({}): {}", appDetail.getName(),
|
||||||
createRule(meta, "NONE", RuleType.COMPATIBILITY);
|
appDetail.getOwner(), e.getMessage());
|
||||||
createRule(meta, "NONE", RuleType.VALIDITY);
|
}
|
||||||
createRule(meta, "NONE", RuleType.INTEGRITY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +128,24 @@ public class Wso2AppsToApicurio extends AbstractProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
private ApplicationList getApplicationList(String adminApiUrl, TokenResponse tokenResponse) throws Exception {
|
private ApplicationList getApplicationList(String adminApiUrl, TokenResponse tokenResponse) throws Exception {
|
||||||
|
|
||||||
ApplicationList listOfApps = null;
|
ApplicationList listOfApps = null;
|
||||||
|
|||||||
@ -59,6 +59,8 @@ public class ApplicationConfig {
|
|||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
@JsonProperty("default_api_group")
|
@JsonProperty("default_api_group")
|
||||||
private String defaultApiGroup;
|
private String defaultApiGroup;
|
||||||
|
@JsonProperty("overwrite_existing_application")
|
||||||
|
private boolean overwriteExistingApplication = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@ -24,5 +24,6 @@ patterns:
|
|||||||
apicurio:
|
apicurio:
|
||||||
api_url: http://apicurio:8095/apis/registry/v2
|
api_url: http://apicurio:8095/apis/registry/v2
|
||||||
default_api_group: api
|
default_api_group: api
|
||||||
|
overwrite_existing_application: true
|
||||||
|
|
||||||
max_threads: 1
|
max_threads: 1
|
||||||
Loading…
x
Reference in New Issue
Block a user