- private Module findModule(final DOMMountPoint mountPoint, final Node<?> data) {
- if (data instanceof NodeWrapper) {
- return findModule(mountPoint, (NodeWrapper<?>) data);
- } else if (data != null) {
- URI namespace = data.getNodeType().getNamespace();
- if (mountPoint != null) {
- return this.controllerContext.findModuleByNamespace(mountPoint, namespace);
- } else {
- return this.controllerContext.findModuleByNamespace(namespace);
- }
- } else {
- throw new IllegalArgumentException("Unhandled parameter types: "
- + Arrays.<Object> asList(mountPoint, data).toString());
- }
- }
-
- private Module findModule(final DOMMountPoint mountPoint, final NodeWrapper<?> data) {
- URI namespace = data.getNamespace();
- Preconditions.<URI> checkNotNull(namespace);
-
- Module module = null;
- if (mountPoint != null) {
- module = this.controllerContext.findModuleByNamespace(mountPoint, namespace);
- if (module == null) {
- module = this.controllerContext.findModuleByName(mountPoint, namespace.toString());
- }
- } else {
- module = this.controllerContext.findModuleByNamespace(namespace);
- if (module == null) {
- module = this.controllerContext.findModuleByName(namespace.toString());
- }
- }
-
- return module;
- }
-
- private InstanceIdWithSchemaNode addLastIdentifierFromData(final InstanceIdWithSchemaNode identifierWithSchemaNode,
- final CompositeNode data, final DataSchemaNode schemaOfData) {
- YangInstanceIdentifier instanceIdentifier = null;
- if (identifierWithSchemaNode != null) {
- instanceIdentifier = identifierWithSchemaNode.getInstanceIdentifier();
- }
-
- final YangInstanceIdentifier iiOriginal = instanceIdentifier;
- InstanceIdentifierBuilder iiBuilder = null;
- if (iiOriginal == null) {
- iiBuilder = YangInstanceIdentifier.builder();
- } else {
- iiBuilder = YangInstanceIdentifier.builder(iiOriginal);
- }
-
- iiBuilder.node(schemaOfData.getQName());
-
- YangInstanceIdentifier instance = iiBuilder.toInstance();
- DOMMountPoint mountPoint = null;
- if (identifierWithSchemaNode != null) {
- mountPoint = identifierWithSchemaNode.getMountPoint();
- }
-
- return new InstanceIdWithSchemaNode(instance, schemaOfData, mountPoint);
- }
-
- private HashMap<QName, Object> resolveKeysFromData(final ListSchemaNode listNode, final CompositeNode dataNode) {
- final HashMap<QName, Object> keyValues = new HashMap<QName, Object>();
- List<QName> _keyDefinition = listNode.getKeyDefinition();
- for (final QName key : _keyDefinition) {
- SimpleNode<? extends Object> head = null;
- String localName = key.getLocalName();
- List<SimpleNode<? extends Object>> simpleNodesByName = dataNode.getSimpleNodesByName(localName);
- if (simpleNodesByName != null) {
- head = Iterables.getFirst(simpleNodesByName, null);
- }
-
- Object dataNodeKeyValueObject = null;
- if (head != null) {
- dataNodeKeyValueObject = head.getValue();
- }
-
- if (dataNodeKeyValueObject == null) {
- throw new RestconfDocumentedException("Data contains list \"" + dataNode.getNodeType().getLocalName()
- + "\" which does not contain key: \"" + key.getLocalName() + "\"", ErrorType.PROTOCOL,
- ErrorTag.INVALID_VALUE);
- }
-
- keyValues.put(key, dataNodeKeyValueObject);
- }
-
- return keyValues;
- }
-