release version 1.10.0
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
|
||||
<artifactId>object-producing</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.10.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.core.object-producing</groupId>
|
||||
<artifactId>object-producing-shell</artifactId>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* object-producing-shell
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* object-producing-shell
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* object-producing-shell
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
@ -26,6 +26,8 @@
|
||||
package ru.entaxy.platform.core.producer.shell;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -55,106 +57,115 @@ import ru.entaxy.platform.core.producer.api.ProducerResult.CommandResult;
|
||||
@Command(scope = EntaxyProducerServiceSupport.SCOPE, name = "produce")
|
||||
public class Produce extends EntaxyProducerServiceSupport implements Action {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Produce.class);
|
||||
|
||||
@Argument(index = 0, name = "configuration", multiValued = false, required = false)
|
||||
String configuration;
|
||||
|
||||
@Option(name = "-u", aliases = {"--config-url"}, multiValued = false, required = false)
|
||||
String configurationUrl;
|
||||
private static final Logger log = LoggerFactory.getLogger(Produce.class);
|
||||
|
||||
@Option(name = "-o", aliases = {"--for-object"}, multiValued = false, required = false)
|
||||
@Completion(value = ObjectCompleter.class)
|
||||
String objectId;
|
||||
@Argument(index = 0, name = "configuration", multiValued = false, required = false)
|
||||
String configuration;
|
||||
|
||||
@Option(name = "-t", aliases = {"--output-type"}, multiValued = false, required = false)
|
||||
String outputType;
|
||||
|
||||
|
||||
@Option(name = "-i", aliases = {"--build-instructions"}, multiValued = false, required = false)
|
||||
String instructions;
|
||||
@Option(name = "-u", aliases = {"--config-url"}, multiValued = false, required = false)
|
||||
String configurationUrl;
|
||||
|
||||
@Option(name = "-p", aliases = {"--print-plan"}, multiValued = false, required = false)
|
||||
boolean printPlan;
|
||||
|
||||
@Reference
|
||||
EntaxyObjectService objectService;
|
||||
|
||||
@Override
|
||||
public Object execute() throws Exception {
|
||||
JsonObject configurationObject = null;
|
||||
if (CommonUtils.isValid(configuration)) {
|
||||
try {
|
||||
configurationObject = JSONUtils.getJsonRootObject(configuration);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Configuration loading failed:");
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (CommonUtils.isValid(configurationUrl)) {
|
||||
try {
|
||||
URL url = new URL(configurationUrl);
|
||||
configurationObject = JSONUtils.getJsonRootObject(url);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Configuration loading failed:");
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (CommonUtils.isValid(objectId)) {
|
||||
List<EntaxyObject> candidates = objectService.getObjects().stream().
|
||||
filter(obj->obj.getObjectFullId().equals(objectId)).collect(Collectors.toList());
|
||||
if (candidates.size()==0) {
|
||||
System.out.println("Object not found: " + objectId);
|
||||
return null;
|
||||
}
|
||||
configurationObject = JSONUtils.getJsonRootObject(candidates.get(0).getConfiguration());
|
||||
if (CommonUtils.isValid(outputType))
|
||||
configurationObject.addProperty("outputType", outputType);
|
||||
} else {
|
||||
System.out.println("Configuration not found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!CommonUtils.isValid(instructions))
|
||||
this.instructions = "{}";
|
||||
|
||||
ProducerResult result = producerService.produce(configurationObject, instructions);
|
||||
|
||||
if (printPlan) {
|
||||
ExecutionPlan plan = result.findResultObject(ExecutionPlan.class);
|
||||
if (plan == null) {
|
||||
System.out.println("\n\tPlan not found");
|
||||
} else {
|
||||
System.out.println("\n\tPlan: "
|
||||
+ plan.tasks.stream().map(t -> t.commandId).collect(Collectors.joining(" -> "))
|
||||
);
|
||||
}
|
||||
System.out.println("-----------");
|
||||
}
|
||||
|
||||
System.out.println("\tExecution result:");
|
||||
|
||||
ShellTable table = new ShellTable();
|
||||
table.column("Command");
|
||||
table.column("Result");
|
||||
table.column("Result object class");
|
||||
table.column("Exceptions");
|
||||
|
||||
for (CommandResult cr: result.getCommandResults())
|
||||
table.addRow().addContent(
|
||||
cr.commandId,
|
||||
cr.skipped?"SKIPPED":cr.result,
|
||||
cr.resultObject==null?"null":cr.resultObject.getClass().getName(),
|
||||
cr.exceptions.stream().map(e -> e.getClass().getName()).collect(Collectors.joining(","))
|
||||
);
|
||||
|
||||
table.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
@Option(name = "-o", aliases = {"--for-object"}, multiValued = false, required = false)
|
||||
@Completion(value = ObjectCompleter.class)
|
||||
String objectId;
|
||||
|
||||
@Option(name = "-t", aliases = {"--output-type"}, multiValued = false, required = false)
|
||||
String outputType;
|
||||
|
||||
|
||||
@Option(name = "-i", aliases = {"--build-instructions"}, multiValued = false, required = false)
|
||||
String instructions;
|
||||
|
||||
@Option(name = "-p", aliases = {"--print-plan"}, multiValued = false, required = false)
|
||||
boolean printPlan;
|
||||
|
||||
@Reference
|
||||
EntaxyObjectService objectService;
|
||||
|
||||
@Override
|
||||
public Object execute() throws Exception {
|
||||
JsonObject configurationObject = null;
|
||||
if (CommonUtils.isValid(configuration)) {
|
||||
try {
|
||||
configurationObject = JSONUtils.getJsonRootObject(configuration);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Configuration loading failed:");
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (CommonUtils.isValid(configurationUrl)) {
|
||||
String urlToOpen = configurationUrl;
|
||||
|
||||
if (!urlToOpen.contains(";//")) {
|
||||
// suppose it's relative file path
|
||||
Path karafHome = Paths.get(System.getProperty("karaf.home"));
|
||||
Path targetPath = karafHome.toAbsolutePath().resolve(Paths.get(urlToOpen));
|
||||
|
||||
urlToOpen = targetPath.toUri().toURL().toString();
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
URL url = new URL(urlToOpen);
|
||||
configurationObject = JSONUtils.getJsonRootObject(url);
|
||||
} catch (Exception e) {
|
||||
System.out.println(String.format("Configuration loading failed: %s", e.getClass().getName()));
|
||||
System.out.println(String.format(" -> %s", e.getMessage()));
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (CommonUtils.isValid(objectId)) {
|
||||
List<EntaxyObject> candidates = objectService.getObjects().stream()
|
||||
.filter(obj -> obj.getObjectFullId().equals(objectId)).collect(Collectors.toList());
|
||||
if (candidates.size() == 0) {
|
||||
System.out.println("Object not found: " + objectId);
|
||||
return null;
|
||||
}
|
||||
configurationObject = JSONUtils.getJsonRootObject(candidates.get(0).getConfiguration());
|
||||
if (CommonUtils.isValid(outputType))
|
||||
configurationObject.addProperty("outputType", outputType);
|
||||
} else {
|
||||
System.out.println("Configuration not found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!CommonUtils.isValid(instructions))
|
||||
this.instructions = "{}";
|
||||
|
||||
ProducerResult result = producerService.produce(configurationObject, instructions);
|
||||
|
||||
if (printPlan) {
|
||||
ExecutionPlan plan = result.findResultObject(ExecutionPlan.class);
|
||||
if (plan == null) {
|
||||
System.out.println("\n\tPlan not found");
|
||||
} else {
|
||||
System.out.println("\n\tPlan: "
|
||||
+ plan.tasks.stream().map(t -> t.commandId).collect(Collectors.joining(" -> ")));
|
||||
}
|
||||
System.out.println("-----------");
|
||||
}
|
||||
|
||||
System.out.println("\tExecution result:");
|
||||
|
||||
ShellTable table = new ShellTable();
|
||||
table.column("Command");
|
||||
table.column("Result");
|
||||
table.column("Result object class");
|
||||
table.column("Exceptions");
|
||||
|
||||
for (CommandResult cr : result.getCommandResults())
|
||||
table.addRow().addContent(
|
||||
cr.commandId,
|
||||
cr.skipped ? "SKIPPED" : cr.result,
|
||||
cr.resultObject == null ? "null" : cr.resultObject.getClass().getName(),
|
||||
cr.exceptions.stream().map(e -> e.getClass().getName()).collect(Collectors.joining(",")));
|
||||
|
||||
table.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
Reference in New Issue
Block a user