Remove ActionServiceHandler 66/96166/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 13 May 2021 13:10:45 +0000 (15:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 13 May 2021 14:32:39 +0000 (16:32 +0200)
This is a useless indirection class, just remove it and deal with
DOMActionService instead.

JIRA: NETCONF-773
Change-Id: I4e9fc4aec72427f9d39852cf1518666dd18ab0c4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/Rfc8040RestConfWiring.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/ActionServiceHandler.java [deleted file]
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapper.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java

index f0b2b56767b5fdca2c85c5419117ebce1a579a89..cb329e384ca328d7c177867fc6e09cfbd1c579bc 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.restconf.nb.rfc8040;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.apache.aries.blueprint.annotation.service.Reference;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
@@ -44,13 +44,13 @@ public class Rfc8040RestConfWiring {
             final DOMMountPointServiceHandler domMountPointServiceHandler,
             final TransactionChainHandler transactionChainHandler,
             final DOMDataBrokerHandler domDataBrokerHandler, final RpcServiceHandler rpcServiceHandler,
-            final ActionServiceHandler actionServiceHandler,
+            @Reference final DOMActionService actionService,
             final NotificationServiceHandler notificationServiceHandler,
             final SSEInitializer sseInit,
             final Configuration configuration,
             @Reference final DOMSchemaService domSchemaService) {
         servicesWrapper = ServicesWrapper.newInstance(schemaCtxHandler, domMountPointServiceHandler,
-            transactionChainHandler, domDataBrokerHandler, rpcServiceHandler, actionServiceHandler,
+            transactionChainHandler, domDataBrokerHandler, rpcServiceHandler, actionService,
             notificationServiceHandler, domSchemaService, configuration);
         servicesNotifWrapper = ServicesNotifWrapper.newInstance(sseInit);
     }
diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/ActionServiceHandler.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/ActionServiceHandler.java
deleted file mode 100644 (file)
index 6e83d91..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2019 Ericsson Software Technology AB. 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.handlers;
-
-import static java.util.Objects.requireNonNull;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.dom.api.DOMActionService;
-
-/**
- * Implementation of {@link ActionServiceHandler}.
- */
-// FIXME: remove this class
-@Singleton
-public class ActionServiceHandler {
-    private final @NonNull DOMActionService actionService;
-
-    /**
-     * Set DOMActionService.
-     *
-     * @param actionService
-     *             DOMActionService
-     */
-    @Inject
-    public ActionServiceHandler(final @Reference DOMActionService actionService) {
-        this.actionService = requireNonNull(actionService);
-    }
-
-    public @NonNull DOMActionService get() {
-        return this.actionService;
-    }
-}
index ccfcdc80aa6b70370ad554a80910940d9ed323ca..4771643c5e85e36c387c82b8cebf6af349020f4b 100644 (file)
@@ -33,6 +33,7 @@ import javax.ws.rs.core.UriInfo;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMActionResult;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
@@ -45,7 +46,6 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
-import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
@@ -109,15 +109,15 @@ public class RestconfDataServiceImpl implements RestconfDataService {
     private final SchemaContextHandler schemaContextHandler;
     private final TransactionChainHandler transactionChainHandler;
     private final DOMMountPointServiceHandler mountPointServiceHandler;
-    private final ActionServiceHandler actionServiceHandler;
+    private final DOMActionService actionService;
 
     public RestconfDataServiceImpl(final SchemaContextHandler schemaContextHandler,
             final TransactionChainHandler transactionChainHandler,
             final DOMMountPointServiceHandler mountPointServiceHandler,
             final RestconfStreamsSubscriptionService delegRestconfSubscrService,
-            final ActionServiceHandler actionServiceHandler,
+            final DOMActionService actionService,
             final Configuration configuration) {
-        this.actionServiceHandler = requireNonNull(actionServiceHandler);
+        this.actionService = requireNonNull(actionService);
         this.schemaContextHandler = requireNonNull(schemaContextHandler);
         this.transactionChainHandler = requireNonNull(transactionChainHandler);
         this.mountPointServiceHandler = requireNonNull(mountPointServiceHandler);
@@ -410,7 +410,7 @@ public class RestconfDataServiceImpl implements RestconfDataService {
             schemaContextRef = modelContext(mountPoint);
         } else {
             response = RestconfInvokeOperationsUtil.invokeAction((ContainerNode) data, schemaPath,
-                this.actionServiceHandler, yangIIdContext);
+                this.actionService, yangIIdContext);
             schemaContextRef = this.schemaContextHandler.get();
         }
         final DOMActionResult result = RestconfInvokeOperationsUtil.checkActionResponse(response);
index 9eee1b462ee821bf104db9c94bd7ccaa82b75729..c6c2d62b4f80bae1d8dd13eb33999b0d68b0f978 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
-import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
@@ -149,14 +148,14 @@ public final class RestconfInvokeOperationsUtil {
      *             input data
      * @param schemaPath
      *             schema path of data
-     * @param actionServiceHandler
-     *             action service handler to invoke action
+     * @param actionService
+     *             action service to invoke action
      * @return {@link DOMActionResult}
      */
+    // FIXME: eliminate this method
     public static DOMActionResult invokeAction(final ContainerNode data, final Absolute schemaPath,
-            final ActionServiceHandler actionServiceHandler, final YangInstanceIdentifier yangIId) {
-        return prepareActionResult(
-            actionServiceHandler.get().invokeAction(schemaPath, prepareDataTreeId(yangIId), data));
+            final DOMActionService actionService, final YangInstanceIdentifier yangIId) {
+        return prepareActionResult(actionService.invokeAction(schemaPath, prepareDataTreeId(yangIId), data));
     }
 
     /**
index 64f3565d4598a91cbc20b93e43e117d14c80311e..1b3e05a2162d2ebacc473eec71057a647aaaa2e1 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.restconf.nb.rfc8040.services.wrapper;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.common.schema.SchemaExportContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
@@ -72,7 +72,7 @@ public final class ServicesWrapper implements BaseServicesWrapper, TransactionSe
     public static ServicesWrapper newInstance(final SchemaContextHandler schemaCtxHandler,
             final DOMMountPointServiceHandler domMountPointServiceHandler,
             final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
-            final RpcServiceHandler rpcServiceHandler, final ActionServiceHandler actionServiceHandler,
+            final RpcServiceHandler rpcServiceHandler, final DOMActionService actionService,
             final NotificationServiceHandler notificationServiceHandler, final DOMSchemaService domSchemaService,
             final Configuration configuration) {
         RestconfOperationsService restconfOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler,
@@ -85,7 +85,7 @@ public final class ServicesWrapper implements BaseServicesWrapper, TransactionSe
             domDataBrokerHandler, notificationServiceHandler, schemaCtxHandler, transactionChainHandler,
             configuration);
         RestconfDataService restconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
-            domMountPointServiceHandler, restconfSubscrService, actionServiceHandler, configuration);
+            domMountPointServiceHandler, restconfSubscrService, actionService, configuration);
         RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(
             rpcServiceHandler, schemaCtxHandler);
         RestconfService restconfService = new RestconfImpl(schemaCtxHandler);
index d68b9905330c4ec4d63837ba1b2c556dbe53d0f0..63bcf5d08e64c2f4f94d190334eeedcfbc1d9cd2 100644 (file)
@@ -42,6 +42,7 @@ import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
@@ -60,7 +61,6 @@ import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchEntity;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
@@ -128,7 +128,7 @@ public class RestconfDataServiceImplTest {
     @Mock
     private NetconfDataTreeService netconfService;
     @Mock
-    private ActionServiceHandler actionServiceHandler;
+    private DOMActionService actionService;
     @Mock
     private DOMTransactionChain mountTransactionChain;
     @Mock
@@ -213,7 +213,7 @@ public class RestconfDataServiceImplTest {
         schemaContextHandler.onModelContextUpdated(this.contextRef);
         this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
                 new DOMMountPointServiceHandler(mountPointService), this.delegRestconfSubscrService,
-                this.actionServiceHandler, configuration);
+                this.actionService, configuration);
         doReturn(Optional.of(this.mountPoint)).when(this.mountPointService)
                 .getMountPoint(any(YangInstanceIdentifier.class));
         doReturn(Optional.of(FixedDOMSchemaService.of(this.contextRef))).when(this.mountPoint)