Fix findbugs violations in restconf-nb-bierman02
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / BrokerFacade.java
index 85263d056b86feb3418e3626dde47dbf0bb832ff..2aa300f00eeec7c4781f0a1ca6cda166f3b9658f 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -96,14 +97,16 @@ public class BrokerFacade {
     private DOMDataBroker domDataBroker;
     private DOMNotificationService domNotification;
 
-    private BrokerFacade() {}
+    BrokerFacade() {
+
+    }
 
     public void setRpcService(final DOMRpcService router) {
         this.rpcService = router;
     }
 
-    public void setDomNotificationService(final DOMNotificationService domNotification) {
-        this.domNotification = domNotification;
+    public void setDomNotificationService(final DOMNotificationService service) {
+        this.domNotification = service;
     }
 
     public static BrokerFacade getInstance() {
@@ -374,23 +377,6 @@ public class BrokerFacade {
                     }
                     break;
                 case DELETE:
-                    if (withoutError) {
-                        try {
-                            deleteDataWithinTransaction(patchTransaction, CONFIGURATION, patchEntity
-                                    .getTargetNode());
-                            editCollection.add(new PatchStatusEntity(patchEntity.getEditId(), true, null));
-                        } catch (final RestconfDocumentedException e) {
-                            LOG.error("Error call http Patch operation {} on target {}",
-                                    operation,
-                                    patchEntity.getTargetNode().toString());
-
-                            editErrors = new ArrayList<>();
-                            editErrors.addAll(e.getErrors());
-                            editCollection.add(new PatchStatusEntity(patchEntity.getEditId(), false, editErrors));
-                            withoutError = false;
-                        }
-                    }
-                    break;
                 case REMOVE:
                     if (withoutError) {
                         try {
@@ -463,7 +449,7 @@ public class BrokerFacade {
                         new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, throwable.getMessage()))));
                 waiter.countDown();
             }
-        });
+        }, MoreExecutors.directExecutor());
 
         waiter.await();
         return status.getStatus();
@@ -562,7 +548,7 @@ public class BrokerFacade {
                     throw new RestconfDocumentedException(
                             error.getMessage(),
                             ErrorType.TRANSPORT,
-                            ErrorTag.RESOURCE_DENIED_TRANSPORT);
+                            ErrorTag.RESOURCE_DENIED_TRANSPORT, e);
                 }
             }
             throw new RestconfDocumentedException("Error reading data.", e, e.getErrorList());
@@ -619,8 +605,8 @@ public class BrokerFacade {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (keys.contains(child.getNodeType())) {
@@ -674,8 +660,8 @@ public class BrokerFacade {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (trim) {