switch srm/shell from binding to quality parent 07/73307/2
authorMichael Vorburger <vorburger@redhat.com>
Thu, 21 Jun 2018 12:09:31 +0000 (14:09 +0200)
committerFaseela K <faseela.k@ericsson.com>
Fri, 22 Jun 2018 12:55:03 +0000 (12:55 +0000)
because the YANG models are in srm/api, the shell doesn't need binding.
The (infrautils) quality parent enforces checkstyle, findbugs and
error-prone.

This change also deals with the impacts of these enforced additional
quality controls in the existing code.

Change-Id: I3e9b0692c138f79a6f1d6f5184c34475c6920e25
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
srm/shell/pom.xml
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/RecoverCommand.java
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/ReinstallCommand.java
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/SrmCliUtils.java
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/SrmDebugCommand.java

index 67ea566c497c432682c6186039504a2e0c752e33..9a2690e90cfb5cffda445538ebb0e5e8973724ad 100644 (file)
@@ -7,15 +7,15 @@ terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.opendaylight.serviceutils</groupId>
-    <artifactId>binding-parent</artifactId>
+    <artifactId>quality-parent</artifactId>
     <version>0.2.0-SNAPSHOT</version>
-    <relativePath>../../commons/binding-parent</relativePath>
+    <relativePath>../../commons/quality-parent</relativePath>
   </parent>
 
-  <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.serviceutils</groupId>
   <artifactId>srm-shell</artifactId>
   <version>0.2.0-SNAPSHOT</version>
@@ -43,6 +43,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
           <artifactId>*</artifactId>
         </exclusion>
       </exclusions>
-   </dependency>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
   </dependencies>
 </project>
index 33c417300a7b98148f2b9c38ba4605f903ea7b9d..faf4c76584570f4761207fed6b42d6ea1a6053bd 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.serviceutils.srm.shell;
 
 import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
@@ -43,7 +44,7 @@ public class RecoverCommand extends OsgiCommandSupport {
     String id;
 
     @Override
-    protected Object doExecute() throws Exception {
+    protected @Nullable Object doExecute() throws Exception {
         RecoverInput input = getInput();
         if (input == null) {
             // We've already shown the relevant error msg
@@ -69,7 +70,7 @@ public class RecoverCommand extends OsgiCommandSupport {
         session.getConsole().println(strResult.toString());
     }
 
-    private RecoverInput getInput() {
+    private @Nullable RecoverInput getInput() {
         if (type == null || name == null) {
             return null;
         }
index 02a70baacff32c761c3928d194d0f6df692f19fc..4f8320bae5bf20bcfec62b8cac5aa1bc4695d84a 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.serviceutils.srm.shell;
 
 import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
@@ -28,7 +29,7 @@ public class ReinstallCommand extends OsgiCommandSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(ReinstallCommand.class);
 
-    private SrmRpcsService srmRpcService;
+    private final SrmRpcsService srmRpcService;
     private final Class<? extends EntityTypeBase> entityType = EntityTypeService.class;
 
     public ReinstallCommand(SrmRpcsService srmRpcService) {
@@ -40,7 +41,7 @@ public class ReinstallCommand extends OsgiCommandSupport {
     String name;
 
     @Override
-    protected Object doExecute() throws Exception {
+    protected @Nullable Object doExecute() throws Exception {
         ReinstallInput input = getInput();
         if (input == null) {
             // We've already shown the relevant error msg
@@ -65,7 +66,7 @@ public class ReinstallCommand extends OsgiCommandSupport {
         session.getConsole().println(strResult.toString());
     }
 
-    private ReinstallInput getInput() {
+    private @Nullable ReinstallInput getInput() {
         Class<? extends EntityNameBase> entityName = SrmCliUtils.getEntityName(entityType, name);
         if (entityName == null) {
             session.getConsole().println(SrmCliUtils.getNameHelp(entityType));
index 0b51a25f099fd2ccc5df821f47422cb37fc88095..a1e8aa33bafe2a36f3ff85388bee09eb6483298e 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.serviceutils.srm.shell;
 
 import com.google.common.collect.ImmutableMap;
 import java.util.Locale;
+import javax.annotation.Nullable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev170711.EntityNameBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev170711.EntityTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev170711.EntityTypeInstance;
@@ -96,7 +97,8 @@ public final class SrmCliUtils {
      * @param strName Entity Name as a string
      * @return EntityName for use
      */
-    public static Class<? extends EntityNameBase> getEntityName(Class<? extends EntityTypeBase> type, String strName) {
+    public static @Nullable Class<? extends EntityNameBase> getEntityName(Class<? extends EntityTypeBase> type,
+            String strName) {
         LOG.debug("Getting entityName for type {} and name: {}", type, strName);
         if (EntityTypeService.class.equals(type)) {
             return SERVICE_NAME_MAP.get(strName.toUpperCase(Locale.ROOT));
index 2946fe7359c7cab1a35e21fc892e94c75a75d27c..b16805ad82f7897169b748ada252ac1db18a3aa2 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.serviceutils.srm.shell;
 
+import javax.annotation.Nullable;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
@@ -35,7 +36,7 @@ public class SrmDebugCommand extends OsgiCommandSupport {
     boolean clearOps;
 
     @Override
-    protected Object doExecute() throws Exception {
+    protected @Nullable Object doExecute() throws Exception {
         if (clearOps) {
             clearOpsDs();
         }
@@ -46,7 +47,7 @@ public class SrmDebugCommand extends OsgiCommandSupport {
         InstanceIdentifier<ServiceOps> path = getInstanceIdentifier();
         WriteTransaction tx = txDataBroker.newWriteOnlyTransaction();
         tx.delete(LogicalDatastoreType.OPERATIONAL, path);
-        tx.submit();
+        tx.commit().get();
     }
 
     private static InstanceIdentifier<ServiceOps> getInstanceIdentifier() {