import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-
+import java.util.Map;
+import javax.management.ObjectName;
+import javax.management.openmbean.OpenType;
import org.opendaylight.controller.config.util.ConfigRegistryClient;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.ModuleRpcs;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.Rpcs;
import org.opendaylight.controller.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.EnumResolver;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreContext;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.management.ObjectName;
-import javax.management.openmbean.OpenType;
-
-import java.util.Map;
-
public class RuntimeRpc extends AbstractConfigNetconfOperation {
- private static final Logger logger = LoggerFactory.getLogger(Commit.class);
+ private static final Logger LOG = LoggerFactory.getLogger(RuntimeRpc.class);
public static final String CONTEXT_INSTANCE = "context-instance";
- private final YangStoreSnapshot yangStoreSnapshot;
+ private final YangStoreContext yangStoreSnapshot;
- public RuntimeRpc(final YangStoreSnapshot yangStoreSnapshot, ConfigRegistryClient configRegistryClient,
+ public RuntimeRpc(final YangStoreContext yangStoreSnapshot, ConfigRegistryClient configRegistryClient,
String netconfSessionIdForReporting) {
super(configRegistryClient, netconfSessionIdForReporting);
this.yangStoreSnapshot = yangStoreSnapshot;
try {
namespace = xml.getNamespace();
} catch (MissingNameSpaceException e) {
- logger.trace("Can't get namespace from xml element due to {}",e);
+ LOG.trace("Can't get namespace from xml element due to ",e);
throw NetconfDocumentedException.wrap(e);
}
final XmlElement contextInstanceElement = xml.getOnlyChildElement(CONTEXT_INSTANCE);
final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(
contextInstanceElement.getTextContent(), operationName, namespace);
- final Rpcs rpcs = mapRpcs(yangStoreSnapshot.getModuleMXBeanEntryMap());
+ final Rpcs rpcs = mapRpcs(yangStoreSnapshot.getModuleMXBeanEntryMap(), yangStoreSnapshot.getEnumResolver());
final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(), operationName);
try {
netconfOperationNamespace = operationElement.getNamespace();
} catch (MissingNameSpaceException e) {
- logger.debug("Cannot retrieve netconf operation namespace from message due to {}", e);
+ LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
return HandlingPriority.CANNOT_HANDLE;
}
.getTextContent(), netconfOperationName, netconfOperationNamespace);
// TODO reuse rpcs instance in fromXml method
- final Rpcs rpcs = mapRpcs(yangStoreSnapshot.getModuleMXBeanEntryMap());
+ final Rpcs rpcs = mapRpcs(yangStoreSnapshot.getModuleMXBeanEntryMap(), yangStoreSnapshot.getEnumResolver());
try {
netconfOperationName);
} catch (IllegalStateException e) {
- logger.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e);
+ LOG.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e);
return HandlingPriority.CANNOT_HANDLE;
}
// TODO check for namespaces and unknown elements
final NetconfOperationExecution execution = fromXml(xml);
- logger.debug("Invoking operation {} on {} with arguments {}", execution.operationName, execution.on,
+ LOG.debug("Invoking operation {} on {} with arguments {}", execution.operationName, execution.on,
execution.attributes);
final Object result = executeOperation(getConfigRegistryClient(), execution.on, execution.operationName,
execution.attributes);
- logger.trace("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName,
+ LOG.trace("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName,
execution.on, execution.attributes, result);
if (execution.isVoid()) {
return sorted;
}
- private static Rpcs mapRpcs(final Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries) {
+ private static Rpcs mapRpcs(final Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries, final EnumResolver enumResolver) {
final Map<String, Map<String, ModuleRpcs>> map = Maps.newHashMap();
ModuleRpcs rpcMapping = namespaceToModules.get(moduleEntry.getKey());
if (rpcMapping == null) {
- rpcMapping = new ModuleRpcs();
+ rpcMapping = new ModuleRpcs(enumResolver);
namespaceToModules.put(moduleEntry.getKey(), rpcMapping);
}