- // FIXME create RestconfIdetifierHelper and move this method there
- private static YangInstanceIdentifier checkConsistencyOfNormalizedNodeContext(final NormalizedNodeContext payload) {
- Preconditions.checkArgument(payload != null);
- Preconditions.checkArgument(payload.getData() != null);
- Preconditions.checkArgument(payload.getData().getNodeType() != null);
- Preconditions.checkArgument(payload.getInstanceIdentifierContext() != null);
- Preconditions.checkArgument(payload.getInstanceIdentifierContext().getInstanceIdentifier() != null);
-
- final QName payloadNodeQname = payload.getData().getNodeType();
- final YangInstanceIdentifier yangIdent = payload.getInstanceIdentifierContext().getInstanceIdentifier();
- if (payloadNodeQname.compareTo(yangIdent.getLastPathArgument().getNodeType()) > 0) {
- return yangIdent;
- }
- final InstanceIdentifierContext<?> parentContext = payload.getInstanceIdentifierContext();
- final SchemaNode parentSchemaNode = parentContext.getSchemaNode();
- if (parentSchemaNode instanceof DataNodeContainer) {
- final DataNodeContainer cast = (DataNodeContainer) parentSchemaNode;
- for (final DataSchemaNode child : cast.getChildNodes()) {
- if (payloadNodeQname.compareTo(child.getQName()) == 0) {
- return YangInstanceIdentifier.builder(yangIdent).node(child.getQName()).build();
- }
- }
- }
- if (parentSchemaNode instanceof RpcDefinition) {
- return yangIdent;
- }
- final String errMsg = "Error parsing input: DataSchemaNode has not children ";
- LOG.info(errMsg + yangIdent);
- throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
- }
-