Merge "Bug 8989 - Create just one DS for each test-tool's simulated netconf device"
authorJakub Morvay <jmorvay@cisco.com>
Mon, 4 Sep 2017 17:02:01 +0000 (17:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 4 Sep 2017 17:02:01 +0000 (17:02 +0000)
45 files changed:
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfConnectDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfCommandsImpl.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/utils/NetconfConsoleUtils.java
netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/exi/NetconfStartExiMessage.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/netconf/notifications/impl/ops/CreateSubscription.java
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/netconf/notifications/impl/ops/Get.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java
netconf/netconf-util/pom.xml
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfUtil.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/SubtreeFilter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NotificationHandler.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/listener/UncancellableFuture.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfMessageTransformUtil.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/MessageCounter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/RemoteDeviceId.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/Cli.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/NetconfDeviceConnectionManager.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/CommandDispatcher.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/output/Output.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/AbstractReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/ConfigReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/custom/DataWriter.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/Main.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/http/perf/Parameters.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/Parameters.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/IdentityValuesDTO.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Config.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Delete.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Get.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Operational.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Post.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Put.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Rpcs.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractCommonSubscriber.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractNotificationsData.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java

index 19e72dfe08bf9aec4d1397b085a3271e8e1de2df..3d86ee1751adfd5037c8c369a42124e4a3f0f442 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.aaa.odl;
 
-import java.util.Map;
 import org.opendaylight.aaa.api.AuthenticationException;
 import org.opendaylight.aaa.api.Claim;
 import org.opendaylight.aaa.api.CredentialAuth;
@@ -27,11 +26,6 @@ import org.slf4j.LoggerFactory;
 public final class CredentialServiceAuthProvider implements AuthProvider, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(CredentialServiceAuthProvider.class);
 
-    /**
-     * Singleton instance with delayed instantiation.
-     */
-    public static volatile Map.Entry<BundleContext, CredentialServiceAuthProvider> INSTANCE;
-
     // FIXME CredentialAuth is generic and it causes warnings during compilation
     // Maybe there should be a PasswordCredentialAuth implements CredentialAuth<PasswordCredentials>
     private volatile CredentialAuth<PasswordCredentials> nullableCredService;
index 2e5d0c3c020bef6e38e626a7c571b34a3320a1bf..6ecaec63b2e6718e6bd8dd68351401388d922f01 100644 (file)
@@ -93,8 +93,8 @@ public class NetconfConnectDeviceCommand extends AbstractAction {
             return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
         }
 
-        final boolean isTcpOnly = (connectionType.equals("true")) ? true : false;
-        final boolean isSchemaless = (schemaless.equals("true")) ? true : false;
+        final boolean isTcpOnly = connectionType.equals("true");
+        final boolean isSchemaless = schemaless.equals("true");
         final Credentials credentials = new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
 
         final NetconfNode netconfNode = new NetconfNodeBuilder()
index 810a4389d6a1f72a2e980e2a120dc9e2491200c7..47417bc7372597cb9825bd5d6f723d72b13bbcfb 100644 (file)
@@ -202,9 +202,9 @@ public class NetconfCommandsImpl implements NetconfCommands {
                     : updated.get(NetconfConsoleConstants.NETCONF_IP);
             final String devicePort = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.NETCONF_PORT))
                     ? netconfNode.getPort().getValue().toString() : updated.get(NetconfConsoleConstants.NETCONF_PORT);
-            final Boolean tcpOnly = (updated.get(NetconfConsoleConstants.TCP_ONLY).equals("true")) ? true : false;
+            final Boolean tcpOnly = updated.get(NetconfConsoleConstants.TCP_ONLY).equals("true");
             final Boolean isSchemaless =
-                    (updated.get(NetconfConsoleConstants.SCHEMALESS).equals("true")) ? true : false;
+                    updated.get(NetconfConsoleConstants.SCHEMALESS).equals("true");
             final String newUsername = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.USERNAME))
                     ? updated.get(NetconfConsoleConstants.USERNAME) : username;
             final String newPassword = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.PASSWORD))
index 0845764f21ce81cf4ee7a3e9ba7b518c5fa9b0a9..385f0f9e82f348a7c2e9c1f98baffd5e682d98e1 100644 (file)
@@ -95,10 +95,7 @@ public class NetconfConsoleUtils {
      * @return :<code>true</code> if not empty, else, <code>false</code>
      */
     private static boolean isNetconfNodesPresent(final Topology topology) {
-        if (topology == null || topology.getNode() == null || topology.getNode().isEmpty()) {
-            return false;
-        }
-        return true;
+        return topology != null && topology.getNode() != null && !topology.getNode().isEmpty();
     }
 
     /**
index 078e9aae9ed71eef43c70dbb30b9c195f6744013..c308aa8e7b68cfac756ecb6612184d396fe3efd8 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.netconf.mapping.api;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.util.Objects;
 
 public final class HandlingPriority implements Comparable<HandlingPriority> {
 
@@ -88,11 +89,7 @@ public final class HandlingPriority implements Comparable<HandlingPriority> {
 
         HandlingPriority that = (HandlingPriority) obj;
 
-        if (priority != null ? !priority.equals(that.priority) : that.priority != null) {
-            return false;
-        }
-
-        return true;
+        return Objects.equals(priority, that.priority);
     }
 
     @Override
index 2f30023f541f94914fac34bac68d8852f383cb68..1a548f41da16a221dd130458246803389127af8d 100644 (file)
@@ -125,7 +125,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
 
                         // Do not fail negotiation if promise is done or canceled
                         // It would result in setting result of the promise second time and that throws exception
-                        if (isPromiseFinished() == false) {
+                        if (!isPromiseFinished()) {
                             LOG.warn("Netconf session was not established after {}", connectionTimeoutMillis);
                             changeState(State.FAILED);
 
index 5d69d401118e3bf9da1716dbc6e8725461508955..5ca4e491d86cec65a88344429b9bc099e1d64079 100644 (file)
@@ -93,7 +93,7 @@ public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder
 
             final NetconfMessage message = getNetconfMessage(additionalHeader, doc);
             if (message instanceof NetconfHelloMessage) {
-                Preconditions.checkState(helloReceived == false,
+                Preconditions.checkState(!helloReceived,
                         "Multiple hello messages received, unexpected hello: %s", message);
                 out.add(message);
                 helloReceived = true;
index 3f81a5175e4689ab993c3920b3095cfcefeb9008..7e7dad3163f58041c7f00ac647ece7b1e30511e3 100644 (file)
@@ -66,7 +66,7 @@ public final class NetconfStartExiMessage extends NetconfMessage {
         createFidelityElement(doc, fidelityElements, exiOptions.getPreservePIs(), PIS_KEY);
         createFidelityElement(doc, fidelityElements, exiOptions.getPreserveNS(), PREFIXES_KEY);
 
-        if (fidelityElements.isEmpty() == false) {
+        if (!fidelityElements.isEmpty()) {
             final Element fidelityElement = doc.createElementNS(
                     XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0, FIDELITY_KEY);
             for (final Element element : fidelityElements) {
index 8f6e2baa6304583b456901717bf48e4ec3988e7e..44444683c4812d14456491451b067b273f7a3e41 100644 (file)
@@ -281,7 +281,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
             session.close(false).addListener(new SshFutureListener<CloseFuture>() {
                 @Override
                 public void operationComplete(final CloseFuture future) {
-                    if (future.isClosed() == false) {
+                    if (!future.isClosed()) {
                         session.close(true);
                     }
                     session = null;
index d116b99f828ac7e0bab6aba2e0f6521dafb22c84..35f5d972c053ea07a861cf71640c9866f45f0177 100644 (file)
@@ -67,7 +67,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
                 promise.setFailure(new IllegalStateException("Channel closed"));
             } else {
                 final ByteBuf byteBufMsg = (ByteBuf) msg;
-                if (pending.isEmpty() == false) {
+                if (!pending.isEmpty()) {
                     queueRequest(ctx, byteBufMsg, promise);
                     return;
                 }
@@ -129,7 +129,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
 
         } catch (final WritePendingException e) {
 
-            if (wasPending == false) {
+            if (!wasPending) {
                 queueRequest(ctx, byteBufMsg, promise);
             }
         }
index 812080618cdc51a46dac9d3a2e84751a57eb7be0..9f79caf3f05eaea1e5e67f67cc3d1b78ecadd091 100644 (file)
@@ -69,18 +69,18 @@ public class CreateSubscription extends AbstractSingletonNetconfOperation
         // Replay not supported
         final Optional<XmlElement> startTime =
                 operationElement.getOnlyChildElementWithSameNamespaceOptionally("startTime");
-        Preconditions.checkArgument(startTime.isPresent() == false, "StartTime element not yet supported");
+        Preconditions.checkArgument(!startTime.isPresent(), "StartTime element not yet supported");
 
         // Stop time not supported
         final Optional<XmlElement> stopTime =
                 operationElement.getOnlyChildElementWithSameNamespaceOptionally("stopTime");
-        Preconditions.checkArgument(stopTime.isPresent() == false, "StopTime element not yet supported");
+        Preconditions.checkArgument(!stopTime.isPresent(), "StopTime element not yet supported");
 
         final StreamNameType streamNameType = parseStreamIfPresent(operationElement);
 
         Preconditions.checkNotNull(netconfSession);
         // Premature streams are allowed (meaning listener can register even if no provider is available yet)
-        if (notifications.isStreamAvailable(streamNameType) == false) {
+        if (!notifications.isStreamAvailable(streamNameType)) {
             LOG.warn("Registering premature stream {}. No publisher available yet for session {}", streamNameType,
                     getNetconfSessionIdForReporting());
         }
index 3655ae209cf3ffab1e3518eae999757771b34d48..0ff934b39d57063961f398b2b22d3c000fa3c94f 100644 (file)
@@ -65,7 +65,7 @@ public class Get extends AbstractNetconfOperation implements AutoCloseable {
             throws DocumentedException {
         final Document partialResponse = subsequentOperation.execute(requestMessage);
         final Streams availableStreams = notificationRegistry.getNotificationPublishers();
-        if (availableStreams.getStream().isEmpty() == false) {
+        if (!availableStreams.getStream().isEmpty()) {
             serializeStreamsSubtree(partialResponse, availableStreams);
         }
         return partialResponse;
index b5a6355d2990c6c26926b6a3fae1280af89dce85..d8d4148a9e3425847fa4ca45a8eb26b7258f6f23 100644 (file)
@@ -142,7 +142,7 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware {
 
                 @Override
                 public void operationComplete(final ChannelFuture future) throws Exception {
-                    if (future.isSuccess() == false) {
+                    if (!future.isSuccess()) {
                         LOG.warn("Unable to release internal connection to netconf server on channel: {}",
                                 clientChannel);
                     }
index 6cb0fca5df74b5af3c45fe535c57eee14386e1cb..c5c94ada2976d18b40fa7ff7ac74ff282c4997e6 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-impl</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-data-codec-xml</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.compendium</artifactId>
index d81e5c9be72c37df19bcb7c69b3c240c41308991..134aefecc23e4ef19b6ccb85117d249c2870cda4 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
@@ -40,7 +40,7 @@ public final class NetconfUtil {
 
     private NetconfUtil() {}
 
-    public static Document checkIsMessageOk(Document response) throws DocumentedException {
+    public static Document checkIsMessageOk(final Document response) throws DocumentedException {
         XmlElement element = XmlElement.fromDomDocument(response);
         Preconditions.checkState(element.getName().equals(XmlMappingConstants.RPC_REPLY_KEY));
         element = element.getOnlyChildElement();
index 96e19b9378b73d4693157f3b71e3e52378953af2..4f6d852e69ff5ede136e6de883331d3bba11e762 100644 (file)
@@ -135,10 +135,10 @@ public class SubtreeFilter {
         MatchingResult matches = matches(src, filter);
         if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
             // copy srcChild to dst
-            boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
+            boolean filterHasChildren = !filter.getChildElements().isEmpty();
             // copy to depth if this is leaf of filter tree
-            Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
-            boolean shouldAppend = filterHasChildren == false;
+            Element copied = (Element) document.importNode(src.getDomElement(), !filterHasChildren);
+            boolean shouldAppend = !filterHasChildren;
             if (filterHasChildren) { // this implies TAG_MATCH
                 // do the same recursively
                 int numberOfTextMatchingChildren = 0;
@@ -191,7 +191,7 @@ public class SubtreeFilter {
             if (result == null) {
                 for (Attr attr : filter.getAttributes().values()) {
                     // ignore namespace declarations
-                    if (XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI()) == false) {
+                    if (!XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI())) {
                         // find attr with matching localName(),  namespaceURI(),  == value() in src
                         String found = src.getAttribute(attr.getLocalName(), attr.getNamespaceURI());
                         if (attr.getValue().equals(found) && result != MatchingResult.NO_MATCH) {
index 6f42761afecacd0af3751bfa539243a2fcfcadfa..f5ae6935b5023f8d7661c5f857b86fe4dfe51643 100644 (file)
@@ -89,7 +89,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
      */
     static NetconfStateSchemas create(final DOMRpcService deviceRpc,
                                   final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id) {
-        if (remoteSessionCapabilities.isMonitoringSupported() == false) {
+        if (!remoteSessionCapabilities.isMonitoringSupported()) {
             // TODO - need to search for get-schema support, not just ietf-netconf-monitoring support
             // issue might be a deviation to ietf-netconf-monitoring where get-schema is unsupported...
             LOG.warn("{}: Netconf monitoring not supported on device, cannot detect provided schemas", id);
@@ -108,7 +108,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
             return EMPTY;
         }
 
-        if (schemasNodeResult.getErrors().isEmpty() == false) {
+        if (!schemasNodeResult.getErrors().isEmpty()) {
             LOG.warn("{}: Unable to detect available schemas, get to {} failed, {}",
                     id, STATE_SCHEMAS_IDENTIFIER, schemasNodeResult.getErrors());
             return EMPTY;
@@ -158,13 +158,13 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
         }
         final Optional<DataContainerChild<?, ?>> dataNode =
                 ((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME));
-        if (dataNode.isPresent() == false) {
+        if (!dataNode.isPresent()) {
             return Optional.absent();
         }
 
         final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> nStateNode =
                 ((DataContainerNode<?>) dataNode.get()).getChild(toId(NetconfState.QNAME));
-        if (nStateNode.isPresent() == false) {
+        if (!nStateNode.isPresent()) {
             return Optional.absent();
         }
 
@@ -191,14 +191,14 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
             final String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
 
-            if (formatAsString.equals(Yang.QNAME.toString()) == false) {
+            if (!formatAsString.equals(Yang.QNAME.toString())) {
                 LOG.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString);
                 return Optional.absent();
             }
 
             childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_LOCATION;
             final Set<String> locationsAsString = getAllChildNodeValues(schemaNode, childNode);
-            if (locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString()) == false) {
+            if (!locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString())) {
                 LOG.debug("{}: Ignoring schema due to unsupported location: {}", id, locationsAsString);
                 return Optional.absent();
             }
@@ -272,11 +272,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
             final RemoteYangSchema that = (RemoteYangSchema) obj;
 
-            if (!qname.equals(that.qname)) {
-                return false;
-            }
-
-            return true;
+            return qname.equals(that.qname);
         }
 
         @Override
index 5b28366c07703d2b5337866f355438b5691bd4f2..7db88e0d048baa09be115d015f3e0eaba8153509 100644 (file)
@@ -72,7 +72,7 @@ final class NotificationHandler {
     }
 
     private void queueNotification(final NetconfMessage notification) {
-        Preconditions.checkState(passNotifications == false);
+        Preconditions.checkState(!passNotifications);
 
         LOG.debug("{}: Caching notification {}, remote schema not yet fully built", id, notification);
         if (LOG.isTraceEnabled()) {
index 85b45e9f945bee13556afb1a3e38a999d6ad25b0..8f010e778057e7dbd77eed8b0e23e3ad8abfe8fc 100644 (file)
@@ -35,7 +35,7 @@ final class UncancellableFuture<V> extends AbstractFuture<V> {
 
     @Override
     public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
-        return uncancellable ? false : super.cancel(mayInterruptIfRunning);
+        return !uncancellable && super.cancel(mayInterruptIfRunning);
     }
 
     @Override
index 80566edcf3013418db90864b59ba9a1666e9612b..4726b7aaa7f5a23a877682f2ccefa8b00d1f633f 100644 (file)
@@ -206,7 +206,7 @@ public class NetconfMessageTransformUtil {
         final String inputMsgId = input.getDocument().getDocumentElement().getAttribute(MESSAGE_ID_ATTR);
         final String outputMsgId = output.getDocument().getDocumentElement().getAttribute(MESSAGE_ID_ATTR);
 
-        if (inputMsgId.equals(outputMsgId) == false) {
+        if (!inputMsgId.equals(outputMsgId)) {
             final Map<String, String> errorInfo = ImmutableMap.<String, String>builder()
                     .put("actual-message-id", outputMsgId)
                     .put("expected-message-id", inputMsgId)
index 555c6a3f10394cb5965af8a22f0df7379acf96b2..5ce347494b35259603183ea8de5ea4ed602dc697 100644 (file)
@@ -18,7 +18,7 @@ public class MessageCounter {
     private static final String MESSAGE_ID_BLUEPRINT = "%s-%s";
 
     public String getNewMessageId(final String prefix) {
-        Preconditions.checkArgument(Strings.isNullOrEmpty(prefix) == false, "Null or empty prefix");
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(prefix), "Null or empty prefix");
         return String.format(MESSAGE_ID_BLUEPRINT, prefix, getNewMessageId());
     }
 
index c52e55e7f5070e6b83987cc402e7ce301ccbd650..bfb39330aec756ff4336a9c85a1a0474581494d4 100644 (file)
@@ -160,11 +160,7 @@ public final class RemoteDeviceId {
         if (!name.equals(that.name)) {
             return false;
         }
-        if (!bindingPath.equals(that.bindingPath)) {
-            return false;
-        }
-
-        return true;
+        return bindingPath.equals(that.bindingPath);
     }
 
     @Override
index 8df78fa542770ccb1d6d77ba401622fbc9ebf752..f29c8062b1c0b8ff075ce2bf7ea233aa6681ed94 100644 (file)
@@ -67,7 +67,7 @@ public class Cli implements Runnable {
                 final String commandName = consoleIO.read();
                 final Optional<Command> commandOpt = commandRegistry.getCommand(commandName);
 
-                if (commandOpt.isPresent() == false) {
+                if (!commandOpt.isPresent()) {
                     continue;
                 }
 
index aeebcbf669c772205dbf05d9c6169d777d90c315..99e25bb0c3877aea2b452e6a75233cf196c41ddd 100644 (file)
@@ -110,7 +110,7 @@ public class NetconfDeviceConnectionManager implements Closeable {
                                                     final NetconfClientConfigurationBuilder configBuilder) {
         this.connect(name, address, configBuilder);
         synchronized (handler) {
-            while (handler.isUp() == false) {
+            while (!handler.isUp()) {
                 try {
                     // TODO implement Timeout for unsuccessful connection
                     handler.wait();
index da448515a5790d01b0ebf437ab3807df6b4d3221..53583985a2dbb18c6997b4554ca9a69f30132fb3 100644 (file)
@@ -80,7 +80,7 @@ public class CommandDispatcher {
     public synchronized Optional<Command> getCommand(final String nameWithModule) {
         final QName commandQName = mergeCommandIds().get(nameWithModule);
         final Map<QName, Command> qNameCommandMap = mergeCommands();
-        if (commandQName == null || qNameCommandMap.containsKey(commandQName) == false) {
+        if (commandQName == null || !qNameCommandMap.containsKey(commandQName)) {
             return Optional.absent();
         }
 
index 45a7b4ad2268eeb802f91376bfc132942552b6fa..dd06fda5af7783982e9a6ec897144a8c3e0d6414 100644 (file)
@@ -33,7 +33,7 @@ public class Output {
     }
 
     public Map<DataSchemaNode, List<NormalizedNode<?, ?>>> unwrap(final OutputDefinition outputDefinition) {
-        Preconditions.checkArgument(outputDefinition.isEmpty() == false);
+        Preconditions.checkArgument(!outputDefinition.isEmpty());
 
         final Map<QName, DataSchemaNode> mappedSchemaNodes = mapOutput(outputDefinition);
         final Map<DataSchemaNode, List<NormalizedNode<?, ?>>> mappedNodesToSchema = Maps.newHashMap();
index 1b1d222231a0faf1e7b0b8c8ab8acb05a54509ce..de7f41b3b9584b792865f4aaaac4d476b391e5cf 100644 (file)
@@ -72,10 +72,7 @@ public abstract class AbstractReader<T extends DataSchemaNode> implements Reader
     }
 
     private boolean isReadingWanted(final DataSchemaNode node) {
-        if (readConfigNode && !node.isConfiguration()) {
-            return false;
-        }
-        return true;
+        return !readConfigNode || node.isConfiguration();
     }
 
     // TODO javadoc
index 995e232d8747cd4952cb77661e47018ac6680a8c..74daadb706dae00a04fbc32ac4aef36c2a87c493 100644 (file)
@@ -194,7 +194,7 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
 
     private Optional<DataSchemaNode> getCurrentNode(DataSchemaNode parent, final String buffer) {
         for (final String part : buffer.split(SEPARATOR)) {
-            if (IOUtil.isQName(part) == false) {
+            if (!IOUtil.isQName(part)) {
                 return Optional.of(parent);
             }
 
index 05cca30c3d3aedc35bab4ee97c4672df1dd083c9..cd999405f6ad7f243716cb3434bec5ea05f6dec6 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.netconf.cli.writer.impl.NormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
+import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -50,7 +50,7 @@ public class DataWriter extends AbstractWriter<DataSchemaNode> {
 
         for (final Object childNodeObject : ((DataContainerNode) dataNode).getValue()) {
             final NormalizedNode<?, ?> childNode = (NormalizedNode<?, ?>) childNodeObject;
-            final Optional<DataSchemaNode> schemaNode = XmlDocumentUtils.findFirstSchema(childNode.getNodeType(),
+            final Optional<DataSchemaNode> schemaNode = SchemaUtils.findFirstSchema(childNode.getNodeType(),
                 remoteSchemaContext.getDataDefinitions());
             Preconditions.checkState(schemaNode.isPresent(), "Unknown data node %s, not defined in schema",
                 childNode.getNodeType());
index 6217e6590c9f2cfef84ef662bef0054d7d267c60..3a0b69a47ee4fa835b8f7599cb37d758581cd9f0 100644 (file)
@@ -140,7 +140,7 @@ public final class Main {
         public List<File> generate(final boolean useSsh, final int batchSize,
                                    final int generateConfigsTimeout, final String address,
                                    final int devicesPerPort) {
-            if (configDir.exists() == false) {
+            if (!configDir.exists()) {
                 Preconditions.checkState(configDir.mkdirs(), "Unable to create directory " + configDir);
             }
 
index 2f4bf0334f6b7a27f74ac019c87fa0438637ab22..4814940f33c427ccc4b7ec40292da9ab652a8a02 100644 (file)
@@ -141,7 +141,7 @@ public class Parameters {
         Preconditions.checkArgument(timeout > 0, "Timeout =< 0");
 
         Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
-        Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
+        Preconditions.checkArgument(!editContent.isDirectory(), "Edit content file is a dir");
         Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
 
         Preconditions.checkArgument(destination.startsWith("/"), "Destination should start with a '/'");
index fdd2202678dac0c0e6d2122e00f5a2fad46ea2c4..03e7ed988bc15e815fb139cdc3ea79353f95ab8d 100644 (file)
@@ -185,7 +185,7 @@ public class Parameters {
         }
 
         Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
-        Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
+        Preconditions.checkArgument(!editContent.isDirectory(), "Edit content file is a dir");
         Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
         Preconditions.checkArgument(threadAmount > 0, "Parameter thread-amount must be greater than 0");
         Preconditions.checkArgument(msgTimeout >= 0, "Parameter msg-timeout must be greater than 0");
index 8d2de78788446067a7fa3b7ba3d80eb2259e0874..1b73749a82719bcb2953093b4d83322308fe5a41 100644 (file)
@@ -135,7 +135,7 @@ public final class IdentityValuesDTO {
         }
 
         public boolean isLeafList() {
-            return name == null ? true : false;
+            return name == null;
         }
 
     }
index 4abc492dff87e6bdadcd89e000507358faab2115..19a130fafe6f921aecda5c6f30ea8e7480dd00aa 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.netconf.sal.restconf.impl;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -37,6 +38,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
@@ -830,7 +832,7 @@ public class RestconfImpl implements RestconfService {
             try {
                 result.getFutureOfPutData().checkedGet();
                 return Response.status(result.getStatus()).build();
-            } catch (TransactionCommitFailedException e) {
+            } catch (final TransactionCommitFailedException e) {
                 if (e instanceof OptimisticLockFailedException) {
                     if (--tries <= 0) {
                         LOG.debug("Got OptimisticLockFailedException on last try - failing " + identifier);
@@ -893,7 +895,8 @@ public class RestconfImpl implements RestconfService {
         }
     }
 
-    private static void isEqualUriAndPayloadKeyValues(final Map<QName, Object> uriKeyValues, final MapEntryNode payload,
+    @VisibleForTesting
+    public static void isEqualUriAndPayloadKeyValues(final Map<QName, Object> uriKeyValues, final MapEntryNode payload,
             final List<QName> keyDefinitions) {
 
         final Map<QName, Object> mutableCopyUriKeyValues = Maps.newHashMap(uriKeyValues);
@@ -905,7 +908,7 @@ public class RestconfImpl implements RestconfService {
 
             final Object dataKeyValue = payload.getIdentifier().getKeyValues().get(keyDefinition);
 
-            if (!uriKeyValue.equals(dataKeyValue)) {
+            if (!Objects.deepEquals(uriKeyValue, dataKeyValue)) {
                 final String errMsg = "The value '" + uriKeyValue + "' for key '" + keyDefinition.getLocalName()
                         + "' specified in the URI doesn't match the value '" + dataKeyValue
                         + "' specified in the message body. ";
@@ -978,7 +981,7 @@ public class RestconfImpl implements RestconfService {
             future.checkedGet();
         } catch (final RestconfDocumentedException e) {
             throw e;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.info("Error creating data " + (uriInfo != null ? uriInfo.getPath() : ""), e);
             throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
         }
@@ -1059,7 +1062,7 @@ public class RestconfImpl implements RestconfService {
 
         try {
             future.checkedGet();
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             final Optional<Throwable> searchedException = Iterables.tryFind(Throwables.getCausalChain(e),
                     Predicates.instanceOf(ModifiedNodeDoesNotExistException.class));
             if (searchedException.isPresent()) {
@@ -1173,7 +1176,7 @@ public class RestconfImpl implements RestconfService {
         final TemporalAccessor p;
         try {
             p = FORMATTER.parse(value);
-        } catch (DateTimeParseException e) {
+        } catch (final DateTimeParseException e) {
             throw new RestconfDocumentedException("Cannot parse of value in date: " + value, e);
         }
         return Instant.from(p);
index a48d962b8b88ed732646621dfa354b449ecf5633..a11525408bf5eb58e9bf5462c7dd8ec7551885a4 100644 (file)
@@ -75,11 +75,7 @@ public class Config {
             return false;
         }
 
-        if (!java.util.Objects.equals(put, that.put)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(put, that.put);
 
     }
 }
index dd3c4fcd114c23f80de5c14656fe8a40af2c22f4..16a815bd102435bf5580791706b4db0d32810a23 100644 (file)
@@ -63,11 +63,7 @@ public class Delete {
             return false;
         }
 
-        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(failedResponses, that.failedResponses);
 
     }
 }
index d2b4b6295d9fcfe7bc19c1cb43a2bee1b52441a6..45603a8e5ea07ef461cb9f330722c91b1b04474a 100644 (file)
@@ -62,11 +62,7 @@ public class Get {
             return false;
         }
 
-        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(failedResponses, that.failedResponses);
 
     }
 }
index a8318544e9d42e05fbd71fa018f9908e07da777d..5d9989b535d641940acbcf39824bfc6e88f613ab 100644 (file)
@@ -32,11 +32,7 @@ public class Operational {
             return false;
         }
         final Operational that = (Operational) obj;
-        if (!java.util.Objects.equals(get, that.get)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(get, that.get);
 
     }
 }
index 8a460083a5efffca21c4bcc047aa84e3e9bbae3b..a466c0130944eb4d0c834e8f0fc9c140ca10d03e 100644 (file)
@@ -62,11 +62,7 @@ public class Post {
             return false;
         }
 
-        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(failedResponses, that.failedResponses);
 
     }
 }
index 2eb6bae9aa0a815aceef61a81a7b6b3e2ddd0935..589f02cdba39a49fc86849784e47d1676791b0e5 100644 (file)
@@ -62,10 +62,6 @@ public class Put {
             return false;
         }
 
-        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(failedResponses, that.failedResponses);
     }
 }
index 6a4596eac3ddcb1891e6912f1604ee22ac6ee79b..d849a4dba8ff808540c408b8bef8f6b1ae161b05 100644 (file)
@@ -62,10 +62,6 @@ public class Rpcs {
             return false;
         }
 
-        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
-            return false;
-        }
-
-        return true;
+        return java.util.Objects.equals(failedResponses, that.failedResponses);
     }
 }
index 371cf7607b12c168cffb2a7a2b87610a087cba1b..67cffe212aae075ed6be6d77fa7297e1693c2785 100644 (file)
@@ -104,7 +104,7 @@ abstract class AbstractCommonSubscriber extends AbstractQueryParams implements B
      * @return True if exist, false otherwise.
      */
     public boolean isListening() {
-        return this.registration == null ? false : true;
+        return this.registration != null;
     }
 
     /**
index f531a62a8d08e3bad3f4089842c22bc1c1b27461..8b548ade594341a9bdde0e05a9a3bd87d2962c70 100644 (file)
@@ -36,7 +36,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
@@ -51,6 +50,7 @@ import org.w3c.dom.Element;
 abstract class AbstractNotificationsData {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNotificationsData.class);
     private static final TransformerFactory TF = TransformerFactory.newInstance();
+    private static final XMLOutputFactory OF = XMLOutputFactory.newFactory();
 
     private TransactionChainHandler transactionChainHandler;
     private SchemaContextHandler schemaHandler;
@@ -124,15 +124,14 @@ abstract class AbstractNotificationsData {
      */
     protected DOMResult writeNormalizedNode(final NormalizedNode<?, ?> normalized, final SchemaContext context,
             final SchemaPath schemaPath) throws IOException, XMLStreamException {
-        final XMLOutputFactory xmlFactory = XMLOutputFactory.newFactory();
-        final Document doc = XmlDocumentUtils.getDocument();
+        final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
         final DOMResult result = new DOMResult(doc);
         NormalizedNodeWriter normalizedNodeWriter = null;
         NormalizedNodeStreamWriter normalizedNodeStreamWriter = null;
         XMLStreamWriter writer = null;
 
         try {
-            writer = xmlFactory.createXMLStreamWriter(result);
+            writer = OF.createXMLStreamWriter(result);
             normalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(writer, context, schemaPath);
             normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(normalizedNodeStreamWriter);
 
index 37b0e595ce1ce798298e2f274dfbae1147a14295..c08b3349989469d993b880f86fc458d0e98ebef6 100644 (file)
@@ -24,8 +24,11 @@ import com.google.common.util.concurrent.Futures;
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import javax.ws.rs.core.MultivaluedHashMap;
@@ -43,14 +46,20 @@ import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.netconf.sal.streams.listeners.Notificator;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
@@ -84,6 +93,44 @@ public class RestconfImplTest {
         this.restconfImpl.setControllerContext(controllerContext);
     }
 
+    @Test
+    public void binaryKeyTest() {
+        final List<Byte> al = new ArrayList<>();
+        al.add(new Byte((byte) 1));
+        binaryKeyTest(al, al);
+    }
+
+    private void binaryKeyTest(final List<Byte> al, final List<Byte> al2) {
+
+        final QName keyDef = QName.create("test:key:binary", "2017-14-08", "b1");
+
+        final Map<QName, Object> uriKeyValues = new HashMap<>();
+        uriKeyValues.put(keyDef, al.toArray());
+
+        final MapEntryNode payload = mock(MapEntryNode.class);
+        final NodeIdentifierWithPredicates nodeIdWithPred =
+                new NodeIdentifierWithPredicates(keyDef, keyDef, al2.toArray());
+        when(payload.getIdentifier()).thenReturn(nodeIdWithPred);
+
+        final List<QName> keyDefinitions = new ArrayList<>();
+        keyDefinitions.add(keyDef);
+        RestconfImpl.isEqualUriAndPayloadKeyValues(uriKeyValues, payload, keyDefinitions);
+    }
+
+    @Test
+    public void binaryKeyFailTest() {
+        final List<Byte> al = new ArrayList<>();
+        al.add(new Byte((byte) 1));
+        final List<Byte> al2 = new ArrayList<>();
+        try {
+            binaryKeyTest(al, al2);
+        } catch (final RestconfDocumentedException e) {
+            final RestconfError err = e.getErrors().iterator().next();
+            assertEquals(ErrorType.PROTOCOL, err.getErrorType());
+            assertEquals(ErrorTag.INVALID_VALUE, err.getErrorTag());
+        }
+    }
+
     @SuppressWarnings("unchecked")
     @Test
     public void testExample() throws FileNotFoundException, ParseException {
index f709d036524b6183d06eb6134a6dec89675ce73d..6c21c267af9889dcbfaeba4f3c54800652fba48e 100644 (file)
@@ -82,10 +82,7 @@ public class RestDocgenUtil {
 
     private static boolean isEqualNamespaceAndRevision(final QName parentQName, final QName nodeQName) {
         if (parentQName == null) {
-            if (nodeQName == null) {
-                return true;
-            }
-            return false;
+            return nodeQName == null;
         }
         return parentQName.getNamespace().equals(nodeQName.getNamespace())
                 && parentQName.getRevision().equals(nodeQName.getRevision());