- XmlElement configElement = xml.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.CONFIG_KEY);
-
- ObjectName taON = transactionProvider.getOrCreateTransaction();
- ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(taON);
-
- return new EditConfigXmlParser.EditConfigExecution(cfgMapping, configElement, testOption,
- ta, editStrategyType);
- }
-
- @VisibleForTesting
- static enum TestOption {
- testOnly, set, testThenSet;
-
- static TestOption getFromXmlName(String testOptionXmlName) {
- switch (testOptionXmlName) {
- case "test-only":
- return testOnly;
- case "test-then-set":
- return testThenSet;
- case "set":
- return set;
- default:
- throw new IllegalArgumentException("Unsupported test option " + testOptionXmlName + " supported: "
- + Arrays.toString(TestOption.values()));
- }
- }
-
- public static TestOption getDefault() {
- return testThenSet;
- }
-
- }
-
- @VisibleForTesting
- static class EditConfigExecution {
-
- private final Map<String, Multimap<String, ModuleElementResolved>> resolvedXmlElements;
- private final TestOption testOption;
- private final EditStrategyType defaultEditStrategyType;
- private final Services services;
-
- EditConfigExecution(Config configResolver, XmlElement configElement, TestOption testOption, ServiceReferenceReadableRegistry ta, EditStrategyType defaultStrategy) {
- Config.ConfigElementResolved configElementResolved = configResolver.fromXml(configElement, defaultStrategy, ta);
- this.resolvedXmlElements = configElementResolved.getResolvedModules();
- this.services = configElementResolved.getServices();
- this.testOption = testOption;
- this.defaultEditStrategyType = defaultStrategy;
- }
-
- boolean shouldTest() {
- return testOption == TestOption.testOnly || testOption == TestOption.testThenSet;
- }