2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.server.api;
10 import java.io.InputStream;
11 import org.opendaylight.restconf.api.ConsumableBody;
12 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
13 import org.opendaylight.restconf.common.errors.RestconfError;
14 import org.opendaylight.yangtools.yang.data.api.YangNetconfError;
15 import org.opendaylight.yangtools.yang.data.api.YangNetconfErrorAware;
18 * An abstract request body backed by an {@link InputStream}. In controls the access to input stream, so that it can
21 abstract sealed class RequestBody extends ConsumableBody
22 permits ChildBody, DataPostBody, OperationInputBody, PatchBody, ResourceBody {
23 RequestBody(final InputStream inputStream) {
28 * Throw a {@link RestconfDocumentedException} if the specified exception has a {@link YangNetconfError} attachment.
30 * @param cause Proposed cause of a RestconfDocumentedException
32 static void throwIfYangError(final Exception cause) {
33 if (cause instanceof YangNetconfErrorAware infoAware) {
34 throw new RestconfDocumentedException(cause, infoAware.getNetconfErrors().stream()
35 .map(error -> new RestconfError(error.type(), error.tag(), error.message(), error.appTag(),
36 // FIXME: pass down error info