import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import java.net.URI;
-import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
-import org.opendaylight.yangtools.concepts.Immutable;
/**
* Abstract base class for StartTimeParameter and StopTimeParameter.
*/
@Beta
-@NonNullByDefault
-public abstract class AbstractReplayParameter implements Immutable {
- private static final URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:replay:1.0");
+// FIXME: sealed when we have JDK17+
+public abstract class AbstractReplayParam<T extends AbstractReplayParam<T>> implements RestconfQueryParam<T> {
+ private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:replay:1.0");
- private final DateAndTime value;
+ private final @NonNull DateAndTime value;
- AbstractReplayParameter(final DateAndTime value) {
+ AbstractReplayParam(final DateAndTime value) {
this.value = requireNonNull(value);
}
- public final DateAndTime value() {
+ public final @NonNull DateAndTime value() {
return value;
}
- public final String uriValue() {
+ @Override
+ public final String paramValue() {
return value.getValue();
}
@Override
public final String toString() {
- return MoreObjects.toStringHelper(this).add("value", uriValue()).toString();
+ return MoreObjects.toStringHelper(this).add("value", paramValue()).toString();
}
- public static final URI capabilityUri() {
+ public static final @NonNull URI capabilityUri() {
return CAPABILITY;
}
}
* Enumeration of possible {@code content} values as defined by
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.1">RFC8040, section 4.8.1</a>.
*/
-public enum ContentParameter {
+public enum ContentParam implements RestconfQueryParam<ContentParam> {
/**
* Return all descendant data nodes.
*/
private final @NonNull String uriValue;
- ContentParameter(final String uriValue) {
+ ContentParam(final String uriValue) {
this.uriValue = requireNonNull(uriValue);
}
- public @NonNull String uriValue() {
+ @Override
+ public final Class<@NonNull ContentParam> javaClass() {
+ return ContentParam.class;
+ }
+
+ @Override
+ public final String paramName() {
+ return uriName();
+ }
+
+ @Override
+ public String paramValue() {
return uriValue;
}
}
// Note: returns null of unknowns
- public static @Nullable ContentParameter forUriValue(final String uriValue) {
+ public static @Nullable ContentParam forUriValue(final String uriValue) {
switch (uriValue) {
case "all":
return ALL;
import java.net.URI;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.Immutable;
/**
* This class represents a {@code depth} parameter as defined in
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3">RFC8040 section 4.8.2</a>.
*/
-public final class DepthParameter implements Immutable {
+public final class DepthParam implements RestconfQueryParam<DepthParam> {
private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:depth:1.0");
- private static final @NonNull DepthParameter MIN = of(1);
- private static final @NonNull DepthParameter MAX = of(65535);
+ private static final @NonNull DepthParam MIN = of(1);
+ private static final @NonNull DepthParam MAX = of(65535);
private final int value;
- private DepthParameter(final int value) {
+ private DepthParam(final int value) {
this.value = value;
checkArgument(value >= 1 && value <= 65535);
}
- public static @NonNull DepthParameter of(final int value) {
- return new DepthParameter(value);
+ public static @NonNull DepthParam of(final int value) {
+ return new DepthParam(value);
}
- @Beta
- public static @NonNull DepthParameter min() {
- return MIN;
- }
-
- @Beta
- public static @NonNull DepthParameter max() {
- return MAX;
+ @Override
+ public Class<@NonNull DepthParam> javaClass() {
+ return DepthParam.class;
}
- public static @Nullable DepthParameter forUriValue(final String uriValue) {
- return uriValue.equals(unboundedUriValue()) ? null : of(Integer.parseUnsignedInt(uriValue, 10));
+ @Override
+ public String paramName() {
+ return uriName();
}
- public int value() {
- return value;
+ @Override
+ public String paramValue() {
+ return String.valueOf(value);
}
public static @NonNull String uriName() {
return "depth";
}
- public @NonNull String uriValue() {
- return String.valueOf(value);
+ @Beta
+ public static @NonNull DepthParam min() {
+ return MIN;
+ }
+
+ @Beta
+ public static @NonNull DepthParam max() {
+ return MAX;
+ }
+
+ public static @Nullable DepthParam forUriValue(final String uriValue) {
+ return "unbounded".equals(uriValue) ? null : of(Integer.parseUnsignedInt(uriValue, 10));
}
- public static String unboundedUriValue() {
- return "unbounded";
+ public int value() {
+ return value;
}
public static @NonNull URI capabilityUri() {
import com.google.common.collect.ImmutableList;
import java.net.URI;
import java.text.ParseException;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.restconf.nb.rfc8040.ApiPath.ApiIdentifier;
import org.opendaylight.yangtools.concepts.Immutable;
*/
@Beta
@NonNullByDefault
-public final class FieldsParameter implements Immutable {
+public final class FieldsParam implements RestconfQueryParam<FieldsParam> {
/**
* A selector for a single node as identified by {@link #path()}. Individual child nodes are subject to further
* filtering based on {@link #subSelectors()}.
private static final URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:fields:1.0");
private final ImmutableList<NodeSelector> nodeSelectors;
- private final String uriValue;
+ private final String paramValue;
- private FieldsParameter(final ImmutableList<NodeSelector> nodeSelectors, final String uriValue) {
+ private FieldsParam(final ImmutableList<NodeSelector> nodeSelectors, final String uriValue) {
this.nodeSelectors = requireNonNull(nodeSelectors);
checkArgument(!nodeSelectors.isEmpty(), "At least one selector is required");
- this.uriValue = requireNonNull(uriValue);
+ this.paramValue = requireNonNull(uriValue);
}
/**
* @return The contents of parameter
* @throws ParseException if {@code str} does not represent a valid {@code fields} parameter.
*/
- public static FieldsParameter parse(final String str) throws ParseException {
- return new FieldsParameter(new FieldsParameterParser().parseNodeSelectors(str), str);
+ public static FieldsParam parse(final String str) throws ParseException {
+ return new FieldsParam(new FieldsParameterParser().parseNodeSelectors(str), str);
+ }
+
+ @Override
+ public Class<@NonNull FieldsParam> javaClass() {
+ return FieldsParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
}
public static String uriName() {
return nodeSelectors;
}
- // FIXME: for migration only
- public String uriValue() {
- return uriValue;
+ @Override
+ public String paramValue() {
+ return paramValue;
}
@Override
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.restconf.nb.rfc8040.ApiPath.ApiIdentifier;
-import org.opendaylight.restconf.nb.rfc8040.FieldsParameter.NodeSelector;
+import org.opendaylight.restconf.nb.rfc8040.FieldsParam.NodeSelector;
import org.opendaylight.yangtools.yang.common.YangNames;
/**
- * Stateful parser for {@link FieldsParameter}. This is not as hard as IETF's ABNF would lead you to believe. The
- * original definition is:
+ * Stateful parser for {@link FieldsParam}. This is not as hard as IETF's ABNF would lead you to believe. The original
+ * definition is:
* <pre>
* fields-expr = path "(" fields-expr ")" / path ";" fields-expr / path
* path = api-identifier [ "/" path ]
* </pre>
*
* <p>
- * That ANTLR4 grammar dictates the layout of {@link FieldsParameter}. It also shows the parsing is recursive on
+ * That ANTLR4 grammar dictates the layout of {@link FieldsParam}. It also shows the parsing is recursive on
* {@code node-selectors}, which is what {@link #parse(String)} and
* {@link NodeSelectorParser#parseSubSelectors(String, int)} deal with.
*/
import java.net.URI;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.Immutable;
/**
* This class represents a {@code filter} parameter as defined in
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">RFC8040 section 4.8.4</a>.
*/
-public final class FilterParameter implements Immutable {
+public final class FilterParam implements RestconfQueryParam<FilterParam> {
private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:filter:1.0");
// FIXME: can we have a parsed, but not bound version of an XPath, please?
private final @NonNull String value;
- private FilterParameter(final String value) {
+ private FilterParam(final String value) {
this.value = requireNonNull(value);
}
- public static @NonNull FilterParameter forUriValue(final String uriValue) {
- return new FilterParameter(uriValue);
+ @Override
+ public Class<@NonNull FilterParam> javaClass() {
+ return FilterParam.class;
}
- public static @NonNull String uriName() {
- return "filter";
+ @Override
+ public String paramName() {
+ return uriName();
}
- public @NonNull String uriValue() {
+ @Override
+ public String paramValue() {
return value;
}
+ public static @NonNull FilterParam forUriValue(final String uriValue) {
+ return new FilterParam(uriValue);
+ }
+
+ public static @NonNull String uriName() {
+ return "filter";
+ }
+
public static @NonNull URI capabilityUri() {
return CAPABILITY;
}
* Enumeration of possible {@code insert} values as defined by
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.1">RFC8040, section 4.8.1</a>.
*/
-public enum InsertParameter {
+public enum InsertParam implements RestconfQueryParam<InsertParam> {
/**
* Insert the new data after the insertion point, as specified by the value of the "point" parameter.
*/
private @NonNull String uriValue;
- InsertParameter(final String uriValue) {
+ InsertParam(final String uriValue) {
this.uriValue = requireNonNull(uriValue);
}
- public @NonNull String uriValue() {
+ @Override
+ public Class<@NonNull InsertParam> javaClass() {
+ return InsertParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
+ }
+
+ @Override
+ public String paramValue() {
return uriValue;
}
}
// Note: returns null of unknowns
- public static @Nullable InsertParameter forUriValue(final String uriValue) {
+ public static @Nullable InsertParam forUriValue(final String uriValue) {
switch (uriValue) {
case "after":
return AFTER;
* Parser and holder of query parameters from uriInfo for notifications.
*/
public final class NotificationQueryParams implements Immutable {
- private final StartTimeParameter startTime;
- private final StopTimeParameter stopTime;
- private final FilterParameter filter;
+ private final StartTimeParam startTime;
+ private final StopTimeParam stopTime;
+ private final FilterParam filter;
private final boolean skipNotificationData;
- private NotificationQueryParams(final StartTimeParameter startTime, final StopTimeParameter stopTime,
- final FilterParameter filter, final boolean skipNotificationData) {
+ private NotificationQueryParams(final StartTimeParam startTime, final StopTimeParam stopTime,
+ final FilterParam filter, final boolean skipNotificationData) {
this.startTime = startTime;
this.stopTime = stopTime;
this.filter = filter;
this.skipNotificationData = skipNotificationData;
}
- public static @NonNull NotificationQueryParams of(final StartTimeParameter startTime,
- final StopTimeParameter stopTime, final FilterParameter filter, final boolean skipNotificationData) {
+ public static @NonNull NotificationQueryParams of(final StartTimeParam startTime, final StopTimeParam stopTime,
+ final FilterParam filter, final boolean skipNotificationData) {
checkArgument(stopTime == null || startTime != null,
"Stop-time parameter has to be used with start-time parameter.");
return new NotificationQueryParams(startTime, stopTime, filter, skipNotificationData);
*
* @return start-time
*/
- public @Nullable StartTimeParameter startTime() {
+ public @Nullable StartTimeParam startTime() {
return startTime;
}
*
* @return stop-time
*/
- public @Nullable StopTimeParameter stopTime() {
+ public @Nullable StopTimeParam stopTime() {
return stopTime;
}
*
* @return filter
*/
- public @Nullable FilterParameter filter() {
+ public @Nullable FilterParam filter() {
return filter;
}
public String toString() {
final var helper = MoreObjects.toStringHelper(this);
if (startTime != null) {
- helper.add("startTime", startTime.uriValue());
+ helper.add("startTime", startTime.paramValue());
}
if (stopTime != null) {
- helper.add("stopTime", stopTime.uriValue());
+ helper.add("stopTime", stopTime.paramValue());
}
if (filter != null) {
- helper.add("filter", filter.uriValue());
+ helper.add("filter", filter.paramValue());
}
return helper.add("skipNotificationData", skipNotificationData).toString();
}
import static java.util.Objects.requireNonNull;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.concepts.Immutable;
/**
* This class represents a {@code point} parameter as defined in
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">RFC8040 section 4.8.4</a>.
*/
@NonNullByDefault
-public final class PointParameter implements Immutable {
+public final class PointParam implements RestconfQueryParam<PointParam> {
// FIXME: This should be ApiPath
private final String value;
- private PointParameter(final String value) {
+ private PointParam(final String value) {
this.value = requireNonNull(value);
}
- public static PointParameter forUriValue(final String uriValue) {
- return new PointParameter(uriValue);
+ @Override
+ public Class<@NonNull PointParam> javaClass() {
+ return PointParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
+ }
+
+ @Override
+ public String paramValue() {
+ return value;
+ }
+
+ public static PointParam forUriValue(final String uriValue) {
+ return new PointParam(uriValue);
}
public static String uriName() {
// FIXME: this should be a record once we have JDK17+
public final class ReadDataParams implements Immutable {
private static final @NonNull ReadDataParams EMPTY =
- new ReadDataParams(ContentParameter.ALL, null, null, null, false, false);
+ new ReadDataParams(ContentParam.ALL, null, null, null, false, false);
- private final @NonNull ContentParameter content;
- private final WithDefaultsParameter withDefaults;
- private final FieldsParameter fields;
- private final DepthParameter depth;
+ private final @NonNull ContentParam content;
+ private final WithDefaultsParam withDefaults;
+ private final FieldsParam fields;
+ private final DepthParam depth;
private final boolean prettyPrint;
private final boolean tagged;
- private ReadDataParams(final ContentParameter content, final DepthParameter depth, final FieldsParameter fields,
- final WithDefaultsParameter withDefaults, final boolean tagged, final boolean prettyPrint) {
+ private ReadDataParams(final ContentParam content, final DepthParam depth, final FieldsParam fields,
+ final WithDefaultsParam withDefaults, final boolean tagged, final boolean prettyPrint) {
this.content = requireNonNull(content);
this.depth = depth;
this.fields = fields;
return EMPTY;
}
- public static @NonNull ReadDataParams of(final ContentParameter content, final DepthParameter depth,
- final FieldsParameter fields, final WithDefaultsParameter withDefaults, final boolean tagged,
+ public static @NonNull ReadDataParams of(final ContentParam content, final DepthParam depth,
+ final FieldsParam fields, final WithDefaultsParam withDefaults, final boolean tagged,
final boolean prettyPrint) {
return new ReadDataParams(content, depth, fields, withDefaults, tagged, prettyPrint);
}
- public @NonNull ContentParameter content() {
+ public @NonNull ContentParam content() {
return content;
}
- public @Nullable DepthParameter depth() {
+ public @Nullable DepthParam depth() {
return depth;
}
- public @Nullable FieldsParameter fields() {
+ public @Nullable FieldsParam fields() {
return fields;
}
- public @Nullable WithDefaultsParameter withDefaults() {
+ public @Nullable WithDefaultsParam withDefaults() {
return withDefaults;
}
@Override
public String toString() {
- final var helper = MoreObjects.toStringHelper(this).add("content", content.uriValue());
+ final var helper = MoreObjects.toStringHelper(this).add("content", content.paramValue());
if (depth != null) {
helper.add("depth", depth.value());
}
helper.add("fields", fields.toString());
}
if (withDefaults != null) {
- helper.add("withDefaults", withDefaults.uriValue());
+ helper.add("withDefaults", withDefaults.paramValue());
}
return helper.add("tagged", tagged).add("prettyPrint", prettyPrint).toString();
}
--- /dev/null
+/*
+ * Copyright (c) 2021 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.nb.rfc8040;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.concepts.Immutable;
+
+/**
+ * Interface implemented by all Java classes which represent a
+ * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8">RESTCONF query parameter</a>.
+ */
+// FIXME: sealed when we have JDK17+?
+public interface RestconfQueryParam<T extends RestconfQueryParam<T>> extends Immutable {
+ /**
+ * Return the Java representation class.
+ *
+ * @return the Java representation class
+ */
+ @NonNull Class<@NonNull T> javaClass();
+
+ /**
+ * Return the URI Request parameter name.
+ *
+ * @return the URI Request parameter name.
+ */
+ @NonNull String paramName();
+
+ /**
+ * Return the URI Request parameter value.
+ *
+ * @return the URI Request parameter value.
+ */
+ @NonNull String paramValue();
+}
* This class represents a {@code start-time} parameter as defined in
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">RFC8040 section 4.8.7</a>.
*/
-public final class StartTimeParameter extends AbstractReplayParameter {
- private StartTimeParameter(final DateAndTime value) {
+public final class StartTimeParam extends AbstractReplayParam<StartTimeParam> {
+ private StartTimeParam(final DateAndTime value) {
super(value);
}
- public static @NonNull StartTimeParameter of(final DateAndTime value) {
- return new StartTimeParameter(value);
+ public static @NonNull StartTimeParam of(final DateAndTime value) {
+ return new StartTimeParam(value);
+ }
+
+ @Override
+ public Class<@NonNull StartTimeParam> javaClass() {
+ return StartTimeParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
}
public static @NonNull String uriName() {
return "start-time";
}
- public static @NonNull StartTimeParameter forUriValue(final String uriValue) {
+ public static @NonNull StartTimeParam forUriValue(final String uriValue) {
return of(new DateAndTime(uriValue));
}
}
* This class represents a {@code stop-time} parameter as defined in
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.8">RFC8040 section 4.8.8</a>.
*/
-public final class StopTimeParameter extends AbstractReplayParameter {
- private StopTimeParameter(final DateAndTime value) {
+public final class StopTimeParam extends AbstractReplayParam<StopTimeParam> {
+ private StopTimeParam(final DateAndTime value) {
super(value);
}
- public static @NonNull StopTimeParameter of(final DateAndTime value) {
- return new StopTimeParameter(value);
+ public static @NonNull StopTimeParam of(final DateAndTime value) {
+ return new StopTimeParam(value);
+ }
+
+ @Override
+ public Class<@NonNull StopTimeParam> javaClass() {
+ return StopTimeParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
}
public static @NonNull String uriName() {
return "stop-time";
}
- public static @NonNull StopTimeParameter forUriValue(final String uriValue) {
+ public static @NonNull StopTimeParam forUriValue(final String uriValue) {
return of(new DateAndTime(uriValue));
}
}
* Enumeration of possible {@code with-defaults} parameter values as defined by
* <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.9">RFC8040, section 4.8.9</a>.
*/
-public enum WithDefaultsParameter {
+public enum WithDefaultsParam implements RestconfQueryParam<WithDefaultsParam> {
/**
* Data nodes set to the YANG default by the client are reported.
*/
private final @NonNull String uriValue;
- WithDefaultsParameter(final String uriValue) {
+ WithDefaultsParam(final String uriValue) {
this.uriValue = requireNonNull(uriValue);
}
- public static @NonNull String uriName() {
- return "with-defaults";
+ @Override
+ public Class<@NonNull WithDefaultsParam> javaClass() {
+ return WithDefaultsParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName();
}
- public @NonNull String uriValue() {
+ @Override
+ public String paramValue() {
return uriValue;
}
- public static @Nullable WithDefaultsParameter forUriValue(final String uriValue) {
+ public static @NonNull String uriName() {
+ return "with-defaults";
+ }
+
+ public static @Nullable WithDefaultsParam forUriValue(final String uriValue) {
switch (uriValue) {
case "explicit":
return EXPLICIT;
public final class WriteDataParams implements Immutable {
private static final @NonNull WriteDataParams EMPTY = new WriteDataParams(null, null);
- private final PointParameter point;
- private final InsertParameter insert;
+ private final PointParam point;
+ private final InsertParam insert;
- private WriteDataParams(final InsertParameter insert, final PointParameter point) {
+ private WriteDataParams(final InsertParam insert, final PointParam point) {
this.insert = insert;
this.point = point;
}
return EMPTY;
}
- public static @NonNull WriteDataParams of(final InsertParameter insert, final PointParameter point) {
+ public static @NonNull WriteDataParams of(final InsertParam insert, final PointParam point) {
if (point == null) {
if (insert == null) {
return empty();
// If the values "before" or "after" are used, then a "point" query
// parameter for the "insert" query parameter MUST also be present, or a
// "400 Bad Request" status-line is returned.
- if (insert == InsertParameter.BEFORE || insert == InsertParameter.AFTER) {
+ if (insert == InsertParam.BEFORE || insert == InsertParam.AFTER) {
throw new IllegalArgumentException(
- "Insert parameter " + insert.uriValue() + " cannot be used without a Point parameter.");
+ "Insert parameter " + insert.paramValue() + " cannot be used without a Point parameter.");
}
} else {
// https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.6:
// If the "insert" query parameter is not present or has a value other
// than "before" or "after", then a "400 Bad Request" status-line is
// returned.
- if (insert != InsertParameter.BEFORE && insert != InsertParameter.AFTER) {
+ if (insert != InsertParam.BEFORE && insert != InsertParam.AFTER) {
throw new IllegalArgumentException(
"Point parameter can be used only with 'after' or 'before' values of Insert parameter.");
}
return new WriteDataParams(insert, point);
}
- public @Nullable InsertParameter insert() {
+ public @Nullable InsertParam insert() {
return insert;
}
- public @Nullable PointParameter point() {
+ public @Nullable PointParam point() {
return point;
}
public String toString() {
final var helper = MoreObjects.toStringHelper(this).omitNullValues();
if (insert != null) {
- helper.add("insert", insert.uriValue());
+ helper.add("insert", insert.paramValue());
}
if (point != null) {
helper.add("point", point.value());
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
-import org.opendaylight.restconf.nb.rfc8040.FieldsParameter;
-import org.opendaylight.restconf.nb.rfc8040.FilterParameter;
-import org.opendaylight.restconf.nb.rfc8040.InsertParameter;
+import org.opendaylight.restconf.nb.rfc8040.ContentParam;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
+import org.opendaylight.restconf.nb.rfc8040.FieldsParam;
+import org.opendaylight.restconf.nb.rfc8040.FilterParam;
+import org.opendaylight.restconf.nb.rfc8040.InsertParam;
import org.opendaylight.restconf.nb.rfc8040.NotificationQueryParams;
-import org.opendaylight.restconf.nb.rfc8040.PointParameter;
+import org.opendaylight.restconf.nb.rfc8040.PointParam;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
-import org.opendaylight.restconf.nb.rfc8040.StartTimeParameter;
-import org.opendaylight.restconf.nb.rfc8040.StopTimeParameter;
-import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
+import org.opendaylight.restconf.nb.rfc8040.StartTimeParam;
+import org.opendaylight.restconf.nb.rfc8040.StopTimeParam;
+import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParam;
import org.opendaylight.restconf.nb.rfc8040.WriteDataParams;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
import org.opendaylight.yangtools.yang.common.ErrorTag;
@Beta
public final class QueryParams {
- private static final Set<String> ALLOWED_PARAMETERS = Set.of(ContentParameter.uriName(), DepthParameter.uriName(),
- FieldsParameter.uriName(), WithDefaultsParameter.uriName());
- private static final List<String> POSSIBLE_CONTENT = Arrays.stream(ContentParameter.values())
- .map(ContentParameter::uriValue)
+ private static final Set<String> ALLOWED_PARAMETERS = Set.of(ContentParam.uriName(), DepthParam.uriName(),
+ FieldsParam.uriName(), WithDefaultsParam.uriName());
+ private static final List<String> POSSIBLE_CONTENT = Arrays.stream(ContentParam.values())
+ .map(ContentParam::paramValue)
.collect(Collectors.toUnmodifiableList());
- private static final List<String> POSSIBLE_WITH_DEFAULTS = Arrays.stream(WithDefaultsParameter.values())
- .map(WithDefaultsParameter::uriValue)
+ private static final List<String> POSSIBLE_WITH_DEFAULTS = Arrays.stream(WithDefaultsParam.values())
+ .map(WithDefaultsParam::paramValue)
.collect(Collectors.toUnmodifiableList());
private QueryParams() {
}
public static @NonNull NotificationQueryParams newNotificationQueryParams(final UriInfo uriInfo) {
- StartTimeParameter startTime = null;
- StopTimeParameter stopTime = null;
- FilterParameter filter = null;
+ StartTimeParam startTime = null;
+ StopTimeParam stopTime = null;
+ FilterParam filter = null;
boolean skipNotificationData = false;
for (final Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
final List<String> paramValues = entry.getValue();
try {
- if (paramName.equals(StartTimeParameter.uriName())) {
- startTime = optionalParam(StartTimeParameter::forUriValue, paramName, paramValues);
+ if (paramName.equals(StartTimeParam.uriName())) {
+ startTime = optionalParam(StartTimeParam::forUriValue, paramName, paramValues);
break;
- } else if (paramName.equals(StopTimeParameter.uriName())) {
- stopTime = optionalParam(StopTimeParameter::forUriValue, paramName, paramValues);
+ } else if (paramName.equals(StopTimeParam.uriName())) {
+ stopTime = optionalParam(StopTimeParam::forUriValue, paramName, paramValues);
break;
- } else if (paramName.equals(FilterParameter.uriName())) {
- filter = optionalParam(FilterParameter::forUriValue, paramName, paramValues);
+ } else if (paramName.equals(FilterParam.uriName())) {
+ filter = optionalParam(FilterParam::forUriValue, paramName, paramValues);
} else if (paramName.equals("odl-skip-notification-data")) {
// FIXME: this should be properly encapsulated in SkipNotificatioDataParameter
skipNotificationData = Boolean.parseBoolean(optionalParam(paramName, paramValues));
}
return identifier.getMountPoint() != null
- ? QueryParameters.ofFieldPaths(params, parseFieldsPaths(identifier, fields.uriValue()))
- : QueryParameters.ofFields(params, parseFieldsParameter(identifier, fields.uriValue()));
+ ? QueryParameters.ofFieldPaths(params, parseFieldsPaths(identifier, fields.paramValue()))
+ : QueryParameters.ofFields(params, parseFieldsParameter(identifier, fields.paramValue()));
}
/**
checkParametersTypes(queryParams.keySet(), ALLOWED_PARAMETERS);
// check and set content
- final String contentStr = getSingleParameter(queryParams, ContentParameter.uriName());
- final ContentParameter content = contentStr == null ? ContentParameter.ALL
- : RestconfDocumentedException.throwIfNull(ContentParameter.forUriValue(contentStr),
+ final String contentStr = getSingleParameter(queryParams, ContentParam.uriName());
+ final ContentParam content = contentStr == null ? ContentParam.ALL
+ : RestconfDocumentedException.throwIfNull(ContentParam.forUriValue(contentStr),
ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
"Invalid content parameter: %s, allowed values are %s", contentStr, POSSIBLE_CONTENT);
// check and set depth
- final DepthParameter depth;
- final String depthStr = getSingleParameter(queryParams, DepthParameter.uriName());
+ final DepthParam depth;
+ final String depthStr = getSingleParameter(queryParams, DepthParam.uriName());
if (depthStr != null) {
try {
- depth = DepthParameter.forUriValue(depthStr);
+ depth = DepthParam.forUriValue(depthStr);
} catch (IllegalArgumentException e) {
throw new RestconfDocumentedException(e, new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
"Invalid depth parameter: " + depthStr, null,
}
// check and set fields
- final FieldsParameter fields;
- final String fieldsStr = getSingleParameter(queryParams, FieldsParameter.uriName());
+ final FieldsParam fields;
+ final String fieldsStr = getSingleParameter(queryParams, FieldsParam.uriName());
if (fieldsStr != null) {
try {
- fields = FieldsParameter.parse(fieldsStr);
+ fields = FieldsParam.parse(fieldsStr);
} catch (ParseException e) {
throw new RestconfDocumentedException(e, new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
"Invalid filds parameter: " + fieldsStr));
}
// check and set withDefaults parameter
- final WithDefaultsParameter withDefaults;
+ final WithDefaultsParam withDefaults;
final boolean tagged;
- final String withDefaultsStr = getSingleParameter(queryParams, WithDefaultsParameter.uriName());
+ final String withDefaultsStr = getSingleParameter(queryParams, WithDefaultsParam.uriName());
if (withDefaultsStr != null) {
- final WithDefaultsParameter val = WithDefaultsParameter.forUriValue(withDefaultsStr);
+ final WithDefaultsParam val = WithDefaultsParam.forUriValue(withDefaultsStr);
if (val == null) {
throw new RestconfDocumentedException(new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
"Invalid with-defaults parameter: " + withDefaultsStr, null,
}
public static @NonNull WriteDataParams newWriteDataParams(final UriInfo uriInfo) {
- InsertParameter insert = null;
- PointParameter point = null;
+ InsertParam insert = null;
+ PointParam point = null;
for (final Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
final String uriName = entry.getKey();
final List<String> paramValues = entry.getValue();
- if (uriName.equals(InsertParameter.uriName())) {
+ if (uriName.equals(InsertParam.uriName())) {
final String str = optionalParam(uriName, paramValues);
if (str != null) {
- insert = InsertParameter.forUriValue(str);
+ insert = InsertParam.forUriValue(str);
if (insert == null) {
throw new RestconfDocumentedException("Unrecognized insert parameter value '" + str + "'",
ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
}
}
- } else if (PointParameter.uriName().equals(uriName)) {
+ } else if (PointParam.uriName().equals(uriName)) {
final String str = optionalParam(uriName, paramValues);
if (str != null) {
- point = PointParameter.forUriValue(str);
+ point = PointParam.forUriValue(str);
}
} else {
throw new RestconfDocumentedException("Bad parameter for post: " + uriName,
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.AbstractReplayParameter;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
-import org.opendaylight.restconf.nb.rfc8040.FieldsParameter;
-import org.opendaylight.restconf.nb.rfc8040.FilterParameter;
+import org.opendaylight.restconf.nb.rfc8040.AbstractReplayParam;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
+import org.opendaylight.restconf.nb.rfc8040.FieldsParam;
+import org.opendaylight.restconf.nb.rfc8040.FilterParam;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
+import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParam;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Capabilities;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
.withNodeIdentifier(new NodeIdentifier(Capabilities.QNAME))
.withChild(Builders.<String>orderedLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(CAPABILITY_QNAME))
- .withChildValue(DepthParameter.capabilityUri().toString())
- .withChildValue(FieldsParameter.capabilityUri().toString())
- .withChildValue(FilterParameter.capabilityUri().toString())
- .withChildValue(AbstractReplayParameter.capabilityUri().toString())
- .withChildValue(WithDefaultsParameter.capabilityUri().toString())
+ .withChildValue(DepthParam.capabilityUri().toString())
+ .withChildValue(FieldsParam.capabilityUri().toString())
+ .withChildValue(FilterParam.capabilityUri().toString())
+ .withChildValue(AbstractReplayParam.capabilityUri().toString())
+ .withChildValue(WithDefaultsParam.capabilityUri().toString())
.build())
.build())
.build();
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.Provider;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
private static void writeNormalizedNode(final JsonWriter jsonWriter,
final SchemaPath path, final InstanceIdentifierContext<SchemaNode> context, final NormalizedNode data,
- final DepthParameter depth, final List<Set<QName>> fields) throws IOException {
+ final DepthParam depth, final List<Set<QName>> fields) throws IOException {
final RestconfNormalizedNodeWriter nnWriter;
if (context.getSchemaNode() instanceof RpcDefinition) {
private static RestconfNormalizedNodeWriter createNormalizedNodeWriter(
final InstanceIdentifierContext<SchemaNode> context, final SchemaPath path, final JsonWriter jsonWriter,
- final DepthParameter depth, final List<Set<QName>> fields) {
+ final DepthParam depth, final List<Set<QName>> fields) {
final SchemaNode schema = context.getSchemaNode();
final JSONCodecFactory codecs = getCodecFactory(context);
import java.util.Optional;
import java.util.Set;
import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
protected final List<Set<QName>> fields;
protected int currentDepth = 0;
- private ParameterAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final DepthParameter depth,
+ private ParameterAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final DepthParam depth,
final List<Set<QName>> fields) {
this.writer = requireNonNull(writer);
maxDepth = depth == null ? null : depth.value();
* @return A new instance.
*/
public static ParameterAwareNormalizedNodeWriter forStreamWriter(
- final NormalizedNodeStreamWriter writer, final DepthParameter maxDepth, final List<Set<QName>> fields) {
+ final NormalizedNodeStreamWriter writer, final DepthParam maxDepth, final List<Set<QName>> fields) {
return forStreamWriter(writer, true, maxDepth, fields);
}
/**
* Create a new writer backed by a {@link NormalizedNodeStreamWriter}. Unlike the simple
- * {@link #forStreamWriter(NormalizedNodeStreamWriter, DepthParameter, List)} method, this allows the caller to
+ * {@link #forStreamWriter(NormalizedNodeStreamWriter, DepthParam, List)} method, this allows the caller to
* switch off RFC6020 XML compliance, providing better throughput. The reason is that the XML mapping rules in
* RFC6020 require the encoding to emit leaf nodes which participate in a list's key first and in the order in which
* they are defined in the key. For JSON, this requirement is completely relaxed and leaves can be ordered in any
*/
public static ParameterAwareNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer,
final boolean orderKeyLeaves,
- final DepthParameter depth,
+ final DepthParam depth,
final List<Set<QName>> fields) {
return orderKeyLeaves ? new OrderedParameterAwareNormalizedNodeWriter(writer, depth, fields)
: new ParameterAwareNormalizedNodeWriter(writer, depth, fields);
private static final class OrderedParameterAwareNormalizedNodeWriter extends ParameterAwareNormalizedNodeWriter {
private static final Logger LOG = LoggerFactory.getLogger(OrderedParameterAwareNormalizedNodeWriter.class);
- OrderedParameterAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final DepthParameter depth,
+ OrderedParameterAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final DepthParam depth,
final List<Set<QName>> fields) {
super(writer, depth, fields);
}
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
}
private static void writeNormalizedNode(final XMLStreamWriter xmlWriter, final SchemaPath path,
- final InstanceIdentifierContext<?> pathContext, final NormalizedNode data, final DepthParameter depth,
+ final InstanceIdentifierContext<?> pathContext, final NormalizedNode data, final DepthParam depth,
final List<Set<QName>> fields) throws IOException {
final RestconfNormalizedNodeWriter nnWriter;
final EffectiveModelContext schemaCtx = pathContext.getSchemaContext();
}
private static RestconfNormalizedNodeWriter createNormalizedNodeWriter(final XMLStreamWriter xmlWriter,
- final EffectiveModelContext schemaContext, final SchemaPath schemaPath, final DepthParameter depth,
+ final EffectiveModelContext schemaContext, final SchemaPath schemaPath, final DepthParam depth,
final List<Set<QName>> fields) {
final NormalizedNodeStreamWriter xmlStreamWriter = XMLStreamNormalizedNodeStreamWriter
.create(xmlWriter, schemaContext, schemaPath);
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
return params;
}
- public @Nullable DepthParameter depth() {
+ public @Nullable DepthParam depth() {
return params.depth();
}
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.InsertParameter;
-import org.opendaylight.restconf.nb.rfc8040.PointParameter;
+import org.opendaylight.restconf.nb.rfc8040.InsertParam;
+import org.opendaylight.restconf.nb.rfc8040.PointParam;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfTransaction;
*/
public static Response postData(final UriInfo uriInfo, final NormalizedNodePayload payload,
final RestconfStrategy strategy,
- final EffectiveModelContext schemaContext, final InsertParameter insert,
- final PointParameter point) {
+ final EffectiveModelContext schemaContext, final InsertParam insert,
+ final PointParam point) {
final YangInstanceIdentifier path = payload.getInstanceIdentifierContext().getInstanceIdentifier();
final FluentFuture<? extends CommitInfo> future = submitData(path, payload.getData(),
strategy, schemaContext, insert, point);
final NormalizedNode data,
final RestconfStrategy strategy,
final EffectiveModelContext schemaContext,
- final InsertParameter insert,
- final PointParameter point) {
+ final InsertParam insert,
+ final PointParam point) {
final RestconfTransaction transaction = strategy.prepareWriteExecution();
if (insert == null) {
makePost(path, data, schemaContext, transaction);
}
private static void insertWithPointPost(final YangInstanceIdentifier path, final NormalizedNode data,
- final EffectiveModelContext schemaContext, final PointParameter point,
+ final EffectiveModelContext schemaContext, final PointParam point,
final NormalizedNodeContainer<?> readList, final boolean before,
final RestconfTransaction transaction) {
final YangInstanceIdentifier parent = path.getParent().getParent();
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.InsertParameter;
-import org.opendaylight.restconf.nb.rfc8040.PointParameter;
+import org.opendaylight.restconf.nb.rfc8040.InsertParam;
+import org.opendaylight.restconf.nb.rfc8040.PointParam;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfTransaction;
* @return {@link Response}
*/
public static Response putData(final NormalizedNodePayload payload, final EffectiveModelContext schemaContext,
- final RestconfStrategy strategy, final InsertParameter insert,
- final PointParameter point) {
+ final RestconfStrategy strategy, final InsertParam insert,
+ final PointParam point) {
final YangInstanceIdentifier path = payload.getInstanceIdentifierContext().getInstanceIdentifier();
final FluentFuture<Boolean> existsFuture = strategy.exists(LogicalDatastoreType.CONFIGURATION, path);
final EffectiveModelContext schemaContext,
final RestconfStrategy strategy,
final NormalizedNode data,
- final InsertParameter insert,
- final PointParameter point) {
+ final InsertParam insert,
+ final PointParam point) {
final RestconfTransaction transaction = strategy.prepareWriteExecution();
if (insert == null) {
return makePut(path, schemaContext, transaction, data);
private static void insertWithPointPut(final RestconfTransaction transaction,
final YangInstanceIdentifier path,
final NormalizedNode data,
- final EffectiveModelContext schemaContext, final PointParameter point,
+ final EffectiveModelContext schemaContext, final PointParam point,
final NormalizedNodeContainer<?> readList, final boolean before) {
transaction.remove(path.getParent());
final InstanceIdentifierContext<?> instanceIdentifier =
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
-import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
+import org.opendaylight.restconf.nb.rfc8040.ContentParam;
+import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParam;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
* @param ctx schema context
* @return {@link NormalizedNode}
*/
- public static @Nullable NormalizedNode readData(final @NonNull ContentParameter content,
+ public static @Nullable NormalizedNode readData(final @NonNull ContentParam content,
final @NonNull YangInstanceIdentifier path,
final @NonNull RestconfStrategy strategy,
- final WithDefaultsParameter withDefa,
+ final WithDefaultsParam withDefa,
final EffectiveModelContext ctx) {
// FIXME: use a switch expression when they are available, removing source of RestconfDocumentedException
switch (content) {
default:
throw new RestconfDocumentedException(
new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- "Invalid content parameter: " + content.uriValue(), null,
+ "Invalid content parameter: " + content.paramValue(), null,
"The content parameter value must be either config, nonconfig or all (default)"));
}
}
* @param fields paths to selected subtrees which should be read, relative to to the parent path
* @return {@link NormalizedNode}
*/
- public static @Nullable NormalizedNode readData(final @NonNull ContentParameter content,
+ public static @Nullable NormalizedNode readData(final @NonNull ContentParam content,
final @NonNull YangInstanceIdentifier path, final @NonNull RestconfStrategy strategy,
- final @Nullable WithDefaultsParameter withDefa, @NonNull final EffectiveModelContext ctx,
+ final @Nullable WithDefaultsParam withDefa, @NonNull final EffectiveModelContext ctx,
final @NonNull List<YangInstanceIdentifier> fields) {
// FIXME: use a switch expression when they are available, removing source of RestconfDocumentedException
switch (content) {
return readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path, fields);
default:
throw new RestconfDocumentedException(new RestconfError(ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- "Invalid content parameter: " + content.uriValue(), null,
+ "Invalid content parameter: " + content.paramValue(), null,
"The content parameter value must be either config, nonconfig or all (default)"));
}
}
private static NormalizedNode prepareDataByParamWithDef(final NormalizedNode result,
- final YangInstanceIdentifier path, final WithDefaultsParameter withDefa, final EffectiveModelContext ctx) {
+ final YangInstanceIdentifier path, final WithDefaultsParam withDefa, final EffectiveModelContext ctx) {
boolean trim;
switch (withDefa) {
case TRIM:
trim = false;
break;
default:
- throw new RestconfDocumentedException("Unsupported with-defaults value " + withDefa.uriValue());
+ throw new RestconfDocumentedException("Unsupported with-defaults value " + withDefa.paramValue());
}
final DataSchemaContextTree baseSchemaCtxTree = DataSchemaContextTree.from(ctx);
* @return {@link NormalizedNode}
*/
private static @Nullable NormalizedNode readAllData(final @NonNull RestconfStrategy strategy,
- final YangInstanceIdentifier path, final WithDefaultsParameter withDefa, final EffectiveModelContext ctx) {
+ final YangInstanceIdentifier path, final WithDefaultsParam withDefa, final EffectiveModelContext ctx) {
// PREPARE STATE DATA NODE
final NormalizedNode stateDataNode = readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path);
// PREPARE CONFIG DATA NODE
* @return {@link NormalizedNode}
*/
private static @Nullable NormalizedNode readAllData(final @NonNull RestconfStrategy strategy,
- final @NonNull YangInstanceIdentifier path, final @Nullable WithDefaultsParameter withDefa,
+ final @NonNull YangInstanceIdentifier path, final @Nullable WithDefaultsParam withDefa,
final @NonNull EffectiveModelContext ctx, final @NonNull List<YangInstanceIdentifier> fields) {
// PREPARE STATE DATA NODE
final NormalizedNode stateDataNode = readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path,
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.FilterParameter;
-import org.opendaylight.restconf.nb.rfc8040.StartTimeParameter;
-import org.opendaylight.restconf.nb.rfc8040.StopTimeParameter;
+import org.opendaylight.restconf.nb.rfc8040.FilterParam;
+import org.opendaylight.restconf.nb.rfc8040.StartTimeParam;
+import org.opendaylight.restconf.nb.rfc8040.StopTimeParam;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
/**
* @param leafNodesOnly If TRUE, notifications will contain changes of leaf nodes only.
*/
@SuppressWarnings("checkstyle:hiddenField")
- public final void setQueryParams(final StartTimeParameter startTime, final StopTimeParameter stopTime,
- final FilterParameter filter, final boolean leafNodesOnly, final boolean skipNotificationData) {
+ public final void setQueryParams(final StartTimeParam startTime, final StopTimeParam stopTime,
+ final FilterParam filter, final boolean leafNodesOnly, final boolean skipNotificationData) {
start = startTime == null ? Instant.now() : parseDateAndTime(startTime.value());
stop = stopTime == null ? null : parseDateAndTime(stopTime.value());
this.leafNodesOnly = leafNodesOnly;
if (filter != null) {
try {
- setFilter(filter.uriValue());
+ setFilter(filter.paramValue());
} catch (XPathExpressionException e) {
throw new IllegalArgumentException("Failed to get filter", e);
}
import java.util.List;
import org.junit.Test;
import org.opendaylight.restconf.nb.rfc8040.ApiPath.ApiIdentifier;
-import org.opendaylight.restconf.nb.rfc8040.FieldsParameter.NodeSelector;
+import org.opendaylight.restconf.nb.rfc8040.FieldsParam.NodeSelector;
public class FieldsParameterTest {
// https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3:
}
private static void assertInvalidFields(final String str, final String message, final int errorOffset) {
- final var ex = assertThrows(ParseException.class, () -> FieldsParameter.parse(str));
+ final var ex = assertThrows(ParseException.class, () -> FieldsParam.parse(str));
assertEquals(message, ex.getMessage());
assertEquals(errorOffset, ex.getErrorOffset());
}
private static List<NodeSelector> assertValidFields(final String str) {
try {
- return FieldsParameter.parse(str).nodeSelectors();
+ return FieldsParam.parse(str).nodeSelectors();
} catch (ParseException e) {
throw new AssertionError(e);
}
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.ContentParam;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
-import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
+import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParam;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
@Test
public void getSingleParameterTest() {
final MultivaluedHashMap<String, String> parameters = new MultivaluedHashMap<>();
- parameters.putSingle(ContentParameter.uriName(), "all");
- assertEquals("all", QueryParams.getSingleParameter(parameters, ContentParameter.uriName()));
+ parameters.putSingle(ContentParam.uriName(), "all");
+ assertEquals("all", QueryParams.getSingleParameter(parameters, ContentParam.uriName()));
}
/**
@Test
public void getSingleParameterNegativeTest() {
final MultivaluedHashMap<String, String> parameters = new MultivaluedHashMap<>();
- parameters.put(ContentParameter.uriName(), List.of("config", "nonconfig", "all"));
+ parameters.put(ContentParam.uriName(), List.of("config", "nonconfig", "all"));
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
- () -> QueryParams.getSingleParameter(parameters, ContentParameter.uriName()));
+ () -> QueryParams.getSingleParameter(parameters, ContentParam.uriName()));
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
@Test
public void checkParametersTypesTest() {
QueryParams.checkParametersTypes(Set.of("content"),
- Set.of(ContentParameter.uriName(), DepthParameter.uriName()));
+ Set.of(ContentParam.uriName(), DepthParam.uriName()));
}
/**
public void checkParametersTypesNegativeTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
() -> QueryParams.checkParametersTypes(Set.of("not-allowed-parameter"),
- Set.of(ContentParameter.uriName(), DepthParameter.uriName())));
+ Set.of(ContentParam.uriName(), DepthParam.uriName())));
final List<RestconfError> errors = ex.getErrors();
assertEquals(1, errors.size());
mockQueryParameters(new MultivaluedHashMap<String, String>());
final var parsedParameters = QueryParams.newReadDataParams(uriInfo);
- assertEquals(ContentParameter.ALL, parsedParameters.content());
+ assertEquals(ContentParam.ALL, parsedParameters.content());
assertNull(parsedParameters.depth());
assertNull(parsedParameters.fields());
}
mockQueryParameter("with-defaults", "explicit");
final var parsedParameters = QueryParams.newReadDataParams(uriInfo);
- assertSame(WithDefaultsParameter.EXPLICIT, parsedParameters.withDefaults());
+ assertSame(WithDefaultsParam.EXPLICIT, parsedParameters.withDefaults());
assertFalse(parsedParameters.tagged());
}
final ReadDataParams parsedParameters = QueryParams.newReadDataParams(uriInfo);
// content
- assertEquals(ContentParameter.CONFIG, parsedParameters.content());
+ assertEquals(ContentParam.CONFIG, parsedParameters.content());
// depth
- final DepthParameter depth = parsedParameters.depth();
+ final DepthParam depth = parsedParameters.depth();
assertNotNull(depth);
assertEquals(10, depth.value());
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@Test
public void writeContainerWithoutChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.min(), null);
+ writer, DepthParam.min(), null);
parameterWriter.write(containerNodeData);
@Test
public void writeContainerWithChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.max(), null);
+ writer, DepthParam.max(), null);
parameterWriter.write(containerNodeData);
@Test
public void writeMapNodeWithoutChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.min(), null);
+ writer, DepthParam.min(), null);
parameterWriter.write(mapNodeData);
@Test
public void writeMapNodeWithChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.max(), null);
+ writer, DepthParam.max(), null);
parameterWriter.write(mapNodeData);
@Test
public void writeLeafSetNodeWithoutChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.min(), null);
+ writer, DepthParam.min(), null);
parameterWriter.write(leafSetNodeData);
@Test
public void writeLeafSetNodeWithChildrenDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.max(), null);
+ writer, DepthParam.max(), null);
parameterWriter.write(leafSetNodeData);
@Test
public void writeLeafSetEntryNodeDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.max(), null);
+ writer, DepthParam.max(), null);
parameterWriter.write(leafSetEntryNodeData);
@Test
public void writeMapEntryNodeUnorderedOnlyKeysDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, false, DepthParameter.min(), null);
+ writer, false, DepthParam.min(), null);
parameterWriter.write(mapEntryNodeData);
@Test
public void writeMapEntryNodeUnorderedDepthTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, false, DepthParameter.max(), null);
+ writer, false, DepthParam.max(), null);
parameterWriter.write(mapEntryNodeData);
@Test
public void writeMapEntryNodeOrderedWithoutChildrenTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, true, DepthParameter.min(), null);
+ writer, true, DepthParam.min(), null);
parameterWriter.write(mapEntryNodeData);
@Test
public void writeMapEntryNodeOrderedTest() throws Exception {
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, true, DepthParameter.max(), null);
+ writer, true, DepthParam.max(), null);
parameterWriter.write(mapEntryNodeData);
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
limitedFields.add(Sets.newHashSet(leafSetEntryNodeIdentifier.getNodeType()));
final ParameterAwareNormalizedNodeWriter parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(
- writer, DepthParameter.min(), limitedFields);
+ writer, DepthParam.min(), limitedFields);
parameterWriter.write(containerNodeData);
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.ContentParameter;
+import org.opendaylight.restconf.nb.rfc8040.ContentParam;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy;
import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
doReturn(immediateFluentFuture(Optional.of(DATA.data3))).when(read)
.read(LogicalDatastoreType.CONFIGURATION, DATA.path);
doReturn(immediateFluentFuture(Optional.of(DATA.data3))).when(netconfService).getConfig(DATA.path);
- NormalizedNode normalizedNode = readData(ContentParameter.CONFIG, DATA.path, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.CONFIG, DATA.path, mdsalStrategy);
assertEquals(DATA.data3, normalizedNode);
- normalizedNode = readData(ContentParameter.CONFIG, DATA.path, netconfStrategy);
+ normalizedNode = readData(ContentParam.CONFIG, DATA.path, netconfStrategy);
assertEquals(DATA.data3, normalizedNode);
}
.read(LogicalDatastoreType.OPERATIONAL, DATA.path);
doReturn(immediateFluentFuture(Optional.of(DATA.data3))).when(netconfService).getConfig(DATA.path);
doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).get(DATA.path);
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path, mdsalStrategy);
assertEquals(DATA.data3, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path, netconfStrategy);
assertEquals(DATA.data3, normalizedNode);
}
.read(LogicalDatastoreType.CONFIGURATION, DATA.path2);
doReturn(immediateFluentFuture(Optional.of(DATA.data2))).when(netconfService).get(DATA.path2);
doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(DATA.path2);
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path2, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path2, mdsalStrategy);
assertEquals(DATA.data2, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path2, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path2, netconfStrategy);
assertEquals(DATA.data2, normalizedNode);
}
doReturn(immediateFluentFuture(Optional.of(DATA.data2))).when(read)
.read(LogicalDatastoreType.OPERATIONAL, DATA.path2);
doReturn(immediateFluentFuture(Optional.of(DATA.data2))).when(netconfService).get(DATA.path2);
- NormalizedNode normalizedNode = readData(ContentParameter.NONCONFIG, DATA.path2, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.NONCONFIG, DATA.path2, mdsalStrategy);
assertEquals(DATA.data2, normalizedNode);
- normalizedNode = readData(ContentParameter.NONCONFIG, DATA.path2, netconfStrategy);
+ normalizedNode = readData(ContentParam.NONCONFIG, DATA.path2, netconfStrategy);
assertEquals(DATA.data2, normalizedNode);
}
.withChild(DATA.contentLeaf)
.withChild(DATA.contentLeaf2)
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path, mdsalStrategy);
assertEquals(checkingData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path, netconfStrategy);
assertEquals(checkingData, normalizedNode);
}
.withChild(DATA.contentLeaf)
.withChild(DATA.contentLeaf2)
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path, mdsalStrategy);
assertEquals(checkingData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path, netconfStrategy);
assertEquals(checkingData, normalizedNode);
}
.withNodeIdentifier(new NodeIdentifier(QName.create("ns", "2016-02-28", "list")))
.withChild(DATA.checkData)
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path3, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path3, mdsalStrategy);
assertEquals(checkingData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path3, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path3, netconfStrategy);
assertEquals(checkingData, normalizedNode);
}
.withNodeIdentifier(new NodeIdentifier(DATA.listQname))
.withChild(DATA.checkData)
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path3,
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path3,
mdsalStrategy);
assertEquals(expectedData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path3, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path3, netconfStrategy);
assertEquals(expectedData, normalizedNode);
}
.withNodeIdentifier(new NodeIdentifier(DATA.listQname))
.withChild(DATA.unkeyedListEntryNode1.body().iterator().next())
.withChild(DATA.unkeyedListEntryNode2.body().iterator().next()).build()).build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.path3, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.path3, mdsalStrategy);
assertEquals(expectedData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.path3, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.path3, netconfStrategy);
assertEquals(expectedData, normalizedNode);
}
.addAll(DATA.leafSetNode2.body())
.build())
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.leafSetNodePath,
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.leafSetNodePath,
mdsalStrategy);
assertEquals(expectedData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.leafSetNodePath, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.leafSetNodePath, netconfStrategy);
assertEquals(expectedData, normalizedNode);
}
.addAll(DATA.orderedLeafSetNode2.body())
.build())
.build();
- NormalizedNode normalizedNode = readData(ContentParameter.ALL, DATA.leafSetNodePath,
+ NormalizedNode normalizedNode = readData(ContentParam.ALL, DATA.leafSetNodePath,
mdsalStrategy);
assertEquals(expectedData, normalizedNode);
- normalizedNode = readData(ContentParameter.ALL, DATA.leafSetNodePath, netconfStrategy);
+ normalizedNode = readData(ContentParam.ALL, DATA.leafSetNodePath, netconfStrategy);
assertEquals(expectedData, normalizedNode);
}
doReturn(immediateFluentFuture(Optional.empty())).when(read)
.read(LogicalDatastoreType.CONFIGURATION, DATA.path2);
doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(DATA.path2);
- NormalizedNode normalizedNode = readData(ContentParameter.CONFIG, DATA.path2, mdsalStrategy);
+ NormalizedNode normalizedNode = readData(ContentParam.CONFIG, DATA.path2, mdsalStrategy);
assertNull(normalizedNode);
- normalizedNode = readData(ContentParameter.CONFIG, DATA.path2, netconfStrategy);
+ normalizedNode = readData(ContentParam.CONFIG, DATA.path2, netconfStrategy);
assertNull(normalizedNode);
}
* @param strategy {@link RestconfStrategy} - wrapper for variables
* @return {@link NormalizedNode}
*/
- private @Nullable NormalizedNode readData(final @NonNull ContentParameter content,
+ private @Nullable NormalizedNode readData(final @NonNull ContentParam content,
final YangInstanceIdentifier path, final @NonNull RestconfStrategy strategy) {
return ReadDataTransactionUtil.readData(content, path, strategy, null, schemaContext);
}
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.restconf.nb.rfc8040.StartTimeParameter;
+import org.opendaylight.restconf.nb.rfc8040.StartTimeParam;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.yang.gen.v1.instance.identifier.patch.module.rev151121.PatchCont;
import org.opendaylight.yang.gen.v1.instance.identifier.patch.module.rev151121.patch.cont.MyList1;
final NotificationOutputTypeGrouping.NotificationOutputType outputType,
final boolean leafNodesOnly, final boolean skipNotificationData) {
super(path, streamName, outputType);
- setQueryParams(StartTimeParameter.forUriValue("1970-01-01T00:00:00Z"), null, null, leafNodesOnly,
+ setQueryParams(StartTimeParam.forUriValue("1970-01-01T00:00:00Z"), null, null, leafNodesOnly,
skipNotificationData);
}