- private Object executeOperation(final ConfigRegistryClient configRegistryClient, final ObjectName on,
- final String name, final Map<String, AttributeConfigElement> attributes) {
- final Object[] params = new Object[attributes.size()];
- final String[] signature = new String[attributes.size()];
-
- int i = 0;
- for (final AttributeConfigElement attribute : attributes.values()) {
- final Optional<?> resolvedValueOpt = attribute.getResolvedValue();
-
- params[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get() : attribute.getResolvedDefaultValue();
- signature[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get().getClass().getName() : attribute
- .getResolvedDefaultValue().getClass().getName();
- i++;
- }
-
- return configRegistryClient.invokeMethod(on, name, params, signature);
- }
-
- public NetconfOperationExecution fromXml(final XmlElement xml) throws NetconfDocumentedException {
- final String namespace;
- try {
- namespace = xml.getNamespace();
- } catch (MissingNameSpaceException 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 String operationName = xml.getName();
-
- final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(
- contextInstanceElement.getTextContent(), operationName, namespace);
-
- final Rpcs rpcs = mapRpcs(yangStoreSnapshot.getModuleMXBeanEntryMap(), yangStoreSnapshot.getEnumResolver());
-
- final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
- final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(), operationName);
-
- // TODO move to Rpcs after xpath attribute is redesigned
-
- final ObjectName on = id.getObjectName(rpcMapping);
- Map<String, AttributeConfigElement> attributes = instanceRuntimeRpc.fromXml(xml);
- attributes = sortAttributes(attributes, xml);
-
- return new NetconfOperationExecution(on, instanceRuntimeRpc.getName(), attributes,
- instanceRuntimeRpc.getReturnType(), namespace);
- }