X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-rfc8040%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Frests%2Futils%2FReadDataTransactionUtil.java;h=76f0d6f1a27f72bdc0767b512a68045977cd0667;hb=01566dd41c162b950cfbbd4eca5a09482ed833c2;hp=843f65c024bb0a5ee081c4461bf32a8df81240ca;hpb=e8700e853a9058e14761945a711bfed183985e47;p=netconf.git diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java index 843f65c024..76f0d6f1a2 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java @@ -20,8 +20,8 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType; 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; @@ -88,10 +88,10 @@ public final class ReadDataTransactionUtil { * @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) { @@ -105,7 +105,7 @@ public final class ReadDataTransactionUtil { 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)")); } } @@ -122,9 +122,9 @@ public final class ReadDataTransactionUtil { * @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 fields) { // FIXME: use a switch expression when they are available, removing source of RestconfDocumentedException switch (content) { @@ -138,13 +138,13 @@ public final class ReadDataTransactionUtil { 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: @@ -154,7 +154,7 @@ public final class ReadDataTransactionUtil { 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); @@ -199,18 +199,14 @@ public final class ReadDataTransactionUtil { if (keys.contains(child.getIdentifier().getNodeType())) { leafBuilder.withValue(((LeafNode) child).body()); builder.withChild(leafBuilder.build()); - } else { - if (trim) { - if (defaultVal == null || !defaultVal.equals(nodeVal)) { - leafBuilder.withValue(((LeafNode) child).body()); - builder.withChild(leafBuilder.build()); - } - } else { - if (defaultVal != null && defaultVal.equals(nodeVal)) { - leafBuilder.withValue(((LeafNode) child).body()); - builder.withChild(leafBuilder.build()); - } + } else if (trim) { + if (defaultVal == null || !defaultVal.equals(nodeVal)) { + leafBuilder.withValue(((LeafNode) child).body()); + builder.withChild(leafBuilder.build()); } + } else if (defaultVal != null && defaultVal.equals(nodeVal)) { + leafBuilder.withValue(((LeafNode) child).body()); + builder.withChild(leafBuilder.build()); } } } @@ -257,11 +253,9 @@ public final class ReadDataTransactionUtil { leafBuilder.withValue(((LeafNode) child).body()); builder.withChild(leafBuilder.build()); } - } else { - if (defaultVal != null && defaultVal.equals(nodeVal)) { - leafBuilder.withValue(((LeafNode) child).body()); - builder.withChild(leafBuilder.build()); - } + } else if (defaultVal != null && defaultVal.equals(nodeVal)) { + leafBuilder.withValue(((LeafNode) child).body()); + builder.withChild(leafBuilder.build()); } } } @@ -316,7 +310,7 @@ public final class ReadDataTransactionUtil { * @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 @@ -339,7 +333,7 @@ public final class ReadDataTransactionUtil { * @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 fields) { // PREPARE STATE DATA NODE final NormalizedNode stateDataNode = readDataViaTransaction(strategy, LogicalDatastoreType.OPERATIONAL, path,