import org.opendaylight.restconf.server.api.DataPostResult;
import org.opendaylight.restconf.server.api.DataPostResult.CreateResource;
import org.opendaylight.restconf.server.api.DataPostResult.InvokeOperation;
-import org.opendaylight.restconf.server.api.DataPutPath;
import org.opendaylight.restconf.server.api.DataPutResult;
import org.opendaylight.restconf.server.api.DataYangPatchResult;
import org.opendaylight.restconf.server.api.DatabindContext;
}
final NormalizedNode data;
try {
- data = body.toNormalizedNode(new DataPutPath(databind, path.inference(), path.instance()));
+ data = body.toNormalizedNode(path);
} catch (RestconfDocumentedException e) {
return RestconfFuture.failed(e);
}
final NormalizedNode data;
try {
- data = body.toNormalizedNode(new DataPutPath(databind, path.inference(), path.instance()));
+ data = body.toNormalizedNode(path);
} catch (RestconfDocumentedException e) {
return RestconfFuture.failed(e);
}
+++ /dev/null
-/*
- * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.server.api;
-
-import static java.util.Objects.requireNonNull;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.restconf.api.ApiPath;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
-
-/**
- * An {@link ApiPath} subpath of {@code /data} {@code PUT} HTTP operation, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
- *
- * @param databind Associated {@link DatabindContext}
- * @param inference Associated {@link Inference} pointing to the {@link EffectiveStatement} of the last ApiPath element.
- * This can be one of:
- * <ul>
- * <li>a datatore, inference being {@link Inference#isEmpty() empty}</li>
- * <li>a data resource, inference pointing to the the {@code data schema node} identified by
- * {@code instance}</li>
- * </ul>
- * @param instance Associated {@link YangInstanceIdentifier}
- * @see DataPostBody
- */
-@NonNullByDefault
-public record DataPutPath(DatabindContext databind, Inference inference, YangInstanceIdentifier instance)
- implements DatabindAware {
- public DataPutPath {
- requireNonNull(databind);
- requireNonNull(inference);
- requireNonNull(instance);
- }
-
- public DataPutPath(final DatabindContext databind) {
- this(databind, Inference.ofDataTreePath(databind.modelContext()), YangInstanceIdentifier.of());
- }
-}
}
@Override
- void streamTo(final DataPutPath path, final PathArgument name, final InputStream inputStream,
+ void streamTo(final DatabindPath.Data path, final PathArgument name, final InputStream inputStream,
final NormalizedNodeStreamWriter writer) throws IOException {
try (var jsonParser = newParser(path, writer)) {
try (var reader = new JsonReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
ErrorTag.MALFORMED_MESSAGE, cause);
}
- private static JsonParserStream newParser(final DataPutPath path, final NormalizedNodeStreamWriter writer) {
+ private static JsonParserStream newParser(final DatabindPath.Data path, final NormalizedNodeStreamWriter writer) {
final var codecs = path.databind().jsonCodecs();
final var inference = path.inference();
if (inference.isEmpty()) {
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.restconf.restconf.Data;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
/**
* Acquire the {@link NormalizedNode} representation of this body.
*
- * @param path A {@link YangInstanceIdentifier} corresponding to the body
+ * @param path A {@link DatabindPath.Data} corresponding to the body
* @throws RestconfDocumentedException if the body cannot be decoded or it does not match {@code path}
*/
@SuppressWarnings("checkstyle:illegalCatch")
- public @NonNull NormalizedNode toNormalizedNode(final @NonNull DataPutPath path) {
+ public @NonNull NormalizedNode toNormalizedNode(final DatabindPath.@NonNull Data path) {
final var instance = path.instance();
final var expectedName = instance.isEmpty() ? DATA_NID : instance.getLastPathArgument();
final var holder = new NormalizationResultHolder();
return data;
}
- abstract void streamTo(@NonNull DataPutPath path, @NonNull PathArgument name, @NonNull InputStream inputStream,
- @NonNull NormalizedNodeStreamWriter writer) throws IOException;
+ abstract void streamTo(DatabindPath.@NonNull Data path, @NonNull PathArgument name,
+ @NonNull InputStream inputStream, @NonNull NormalizedNodeStreamWriter writer) throws IOException;
}
\ No newline at end of file
Map<String, String> queryParameters);
/**
- * Replace the data store.
+ * Replace the data store, as described in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
*
* @param body data node for put to config DS
* @param queryParameters Query parameters
RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
/**
- * Create or replace a data store resource.
+ * Create or replace a data store resource, as described in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
*
* @param identifier resource identifier
* @param body data node for put to config DS
}
@Override
- void streamTo(final DataPutPath path, final PathArgument name, final InputStream inputStream,
+ void streamTo(final DatabindPath.Data path, final PathArgument name, final InputStream inputStream,
final NormalizedNodeStreamWriter writer) throws IOException {
try (var xmlParser = XmlParserStream.create(writer, path.databind().xmlCodecs(), path.inference())) {
final var doc = UntrustedXML.newDocumentBuilder().parse(inputStream);
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy;
-import org.opendaylight.restconf.server.api.DataPutPath;
import org.opendaylight.restconf.server.api.DatabindContext;
import org.opendaylight.restconf.server.api.ResourceBody;
import org.opendaylight.yangtools.yang.common.ErrorTag;
final var stratAndPath = strategy.resolveStrategyPath(apiPath);
try (var body = bodyConstructor.apply(stringInputStream(patchBody))) {
- return body.toNormalizedNode(new DataPutPath(stratAndPath.strategy().databind(),
- stratAndPath.path().inference(), stratAndPath.path().instance()));
+ return body.toNormalizedNode(stratAndPath.path());
}
}