Example #1
0
  private Element getResponseInternal(
      final Document document,
      final ConfigRegistryClient configRegistryClient,
      final Datastore source) {

    final ConfigTransactionClient registryClient;
    // Read current state from a transaction, if running is source, then start new transaction just
    // for reading
    // in case of candidate, get current transaction representing candidate
    if (source == Datastore.running) {
      final ObjectName readTx = transactionProvider.getOrCreateReadTransaction();
      registryClient = getConfigRegistryClient().getConfigTransactionClient(readTx);
    } else {
      registryClient =
          getConfigRegistryClient()
              .getConfigTransactionClient(transactionProvider.getOrCreateTransaction());
    }

    try {
      Element dataElement =
          XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
      final Set<ObjectName> instances =
          Datastore.getInstanceQueryStrategy(source, this.transactionProvider)
              .queryInstances(configRegistryClient);

      final Config configMapping =
          new Config(
              EditConfig.transformMbeToModuleConfigs(
                  registryClient, yangStoreSnapshot.getModuleMXBeanEntryMap()),
              yangStoreSnapshot.getEnumResolver());

      ServiceRegistryWrapper serviceTracker = new ServiceRegistryWrapper(registryClient);
      dataElement =
          configMapping.toXml(
              instances, this.maybeNamespace, document, dataElement, serviceTracker);

      LOG.trace("{} operation successful", GET_CONFIG);

      return dataElement;
    } finally {
      if (source == Datastore.running) {
        transactionProvider.closeReadTransaction();
      }
    }
  }
 EditConfigExecution(
     XmlElement xml,
     Config configResolver,
     XmlElement configElement,
     TestOption testOption,
     Set<ObjectName> instancesForFillingServiceRefMapping,
     EditStrategyType defaultStrategy) {
   this.editConfigXml = xml;
   this.resolvedXmlElements =
       configResolver.fromXml(
           configElement, instancesForFillingServiceRefMapping, defaultStrategy);
   this.testOption = testOption;
   this.defaultEditStrategyType = defaultStrategy;
 }