Rename OperationsContent 16/109016/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 17 Nov 2023 23:08:07 +0000 (00:08 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 18 Nov 2023 08:00:58 +0000 (09:00 +0100)
A better name for this interface is OperationsGetResult, mirroring
DataPutResult.

JIRA: NETCONF-773
Change-Id: Ic00d867373fd635ac2d7de78d6d87100a8a433c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/MdsalRestconfServer.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfImpl.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsGetResult.java [moved from restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsContent.java with 91% similarity]
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsGetResultHelper.java [moved from restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsContentHelper.java with 94% similarity]
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/RestconfServer.java

index 960901b3d5769201bea57e2d526373f46a08b6aa..51bc0b1fb191405a31a78d09171a12c78b96b985 100644 (file)
@@ -61,7 +61,7 @@ import org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStra
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.restconf.server.api.DataPutResult;
-import org.opendaylight.restconf.server.api.OperationsContent;
+import org.opendaylight.restconf.server.api.OperationsGetResult;
 import org.opendaylight.restconf.server.api.RestconfServer;
 import org.opendaylight.restconf.server.spi.OperationInput;
 import org.opendaylight.restconf.server.spi.OperationOutput;
@@ -327,12 +327,12 @@ public final class MdsalRestconfServer implements RestconfServer {
     }
 
     @Override
-    public OperationsContent operationsGET() {
+    public OperationsGetResult operationsGET() {
         return operationsGET(databindProvider.currentContext().modelContext());
     }
 
     @Override
-    public OperationsContent operationsGET(final String operation) {
+    public OperationsGetResult operationsGET(final String operation) {
         // get current module RPCs/actions by RPC/action name
         final var inference = bindRequestPath(operation).inference();
         if (inference.isEmpty()) {
@@ -341,17 +341,17 @@ public final class MdsalRestconfServer implements RestconfServer {
 
         final var stmt = inference.toSchemaInferenceStack().currentStatement();
         if (stmt instanceof RpcEffectiveStatement rpc) {
-            return new OperationsContent.Leaf(inference.getEffectiveModelContext(), rpc.argument());
+            return new OperationsGetResult.Leaf(inference.getEffectiveModelContext(), rpc.argument());
         }
         LOG.debug("Operation '{}' resulted in non-RPC {}", operation, stmt);
         return null;
     }
 
-    private static @NonNull OperationsContent operationsGET(final EffectiveModelContext modelContext) {
+    private static @NonNull OperationsGetResult operationsGET(final EffectiveModelContext modelContext) {
         final var modules = modelContext.getModuleStatements();
         if (modules.isEmpty()) {
             // No modules, or defensive return empty content
-            return new OperationsContent.Container(modelContext, ImmutableSetMultimap.of());
+            return new OperationsGetResult.Container(modelContext, ImmutableSetMultimap.of());
         }
 
         // RPCs by their XMLNamespace/Revision
@@ -375,7 +375,7 @@ public final class MdsalRestconfServer implements RestconfServer {
                 .findFirst()
                 .ifPresent(row -> rpcs.putAll(QNameModule.create(entry.getKey(), row.getKey()), row.getValue()));
         }
-        return new OperationsContent.Container(modelContext, rpcs.build());
+        return new OperationsGetResult.Container(modelContext, rpcs.build());
     }
 
     @Override
index 709b66d0115c0b6b92db481fcd33da8dd5078fe5..82ab6d1819e266d9c5ce6def66bda4928af548f7 100644 (file)
@@ -49,7 +49,7 @@ import org.opendaylight.restconf.nb.rfc8040.databind.jaxrs.QueryParams;
 import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.restconf.server.api.DataPutResult;
-import org.opendaylight.restconf.server.api.OperationsContent;
+import org.opendaylight.restconf.server.api.OperationsGetResult;
 import org.opendaylight.restconf.server.api.RestconfServer;
 import org.opendaylight.restconf.server.spi.OperationOutput;
 import org.opendaylight.yangtools.yang.common.Empty;
@@ -503,7 +503,7 @@ public final class RestconfImpl {
         return operationsGET(operation).toXML();
     }
 
-    private @NonNull OperationsContent operationsGET(final String operation) {
+    private @NonNull OperationsGetResult operationsGET(final String operation) {
         final var content = server.operationsGET(operation);
         if (content == null) {
             throw new NotFoundException();
similarity index 91%
rename from restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsContent.java
rename to restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsGetResult.java
index e33a0a4746a4e1a813d8862a215dd5e62a11919e..5015d4c3b552f7aec5e0ff3bdcd1954ad0f74019 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.restconf.server.api;
 
 import static java.util.Objects.requireNonNull;
-import static org.opendaylight.restconf.server.api.OperationsContentHelper.appendJSON;
-import static org.opendaylight.restconf.server.api.OperationsContentHelper.appendXML;
-import static org.opendaylight.restconf.server.api.OperationsContentHelper.jsonPrefix;
+import static org.opendaylight.restconf.server.api.OperationsGetResultHelper.appendJSON;
+import static org.opendaylight.restconf.server.api.OperationsGetResultHelper.appendXML;
+import static org.opendaylight.restconf.server.api.OperationsGetResultHelper.jsonPrefix;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableSetMultimap;
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
  * RESTCONF {@code /operations} content for a {@code GET} operation as per
  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.2">RFC8040</a>.
  */
-public sealed interface OperationsContent {
-    record Leaf(EffectiveModelContext modelContext, QName rpc) implements OperationsContent {
+public sealed interface OperationsGetResult {
+    record Leaf(EffectiveModelContext modelContext, QName rpc) implements OperationsGetResult {
         public Leaf {
             requireNonNull(modelContext);
             requireNonNull(rpc);
@@ -62,7 +62,7 @@ public sealed interface OperationsContent {
     }
 
     record Container(EffectiveModelContext modelContext, ImmutableSetMultimap<QNameModule, QName> rpcs)
-            implements OperationsContent {
+            implements OperationsGetResult {
         public Container {
             requireNonNull(modelContext);
             requireNonNull(rpcs);
similarity index 94%
rename from restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsContentHelper.java
rename to restconf/restconf-nb/src/main/java/org/opendaylight/restconf/server/api/OperationsGetResultHelper.java
index 6374a8f3b888959b8d8f7915565299da3d4e9091..7ec5558a29484c614dca54fa8b6617f87d5c58db 100644 (file)
@@ -18,8 +18,8 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
  *   <li>SpotBugs ends up reporting UPM_UNCALLED_PRIVATE_METHOD</li>
  * </ul>
  */
-final class OperationsContentHelper {
-    private OperationsContentHelper() {
+final class OperationsGetResultHelper {
+    private OperationsGetResultHelper() {
         // Hidden on purpose
     }
 
index 400044fc68bf8847a87c1be7741152a7c35532d0..bb2a8b0af4cb3473a102cfdad59b55a39cace51e 100644 (file)
@@ -114,9 +114,9 @@ public interface RestconfServer {
     /**
      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
      *
-     * @return An {@link OperationsContent}
+     * @return An {@link OperationsGetResult}
      */
-    OperationsContent operationsGET();
+    OperationsGetResult operationsGET();
 
     /*
      * Return the details about a particular operation supported by
@@ -129,7 +129,7 @@ public interface RestconfServer {
     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
     //        and hence it is a path right now
     // FIXME: use ApiPath instead of String
-    @Nullable OperationsContent operationsGET(String operation);
+    @Nullable OperationsGetResult operationsGET(String operation);
 
     /**
      * Invoke an RPC operation, as defined in