Merge "fix failure during connecting device when channelActive happens later than...
authorJakub Morvay <jakub.morvay@gmail.com>
Thu, 12 Apr 2018 14:20:59 +0000 (14:20 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 12 Apr 2018 14:20:59 +0000 (14:20 +0000)
298 files changed:
features/netconf/features-netconf/pom.xml
features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml
features/netconf/odl-aaa-netconf-plugin/pom.xml
features/netconf/odl-config-netconf-connector/pom.xml [deleted file]
features/netconf/odl-netconf-all/pom.xml
features/netconf/odl-netconf-api/pom.xml
features/netconf/odl-netconf-client/pom.xml
features/netconf/odl-netconf-impl/pom.xml
features/netconf/odl-netconf-mdsal/pom.xml
features/netconf/odl-netconf-notifications-api/pom.xml
features/netconf/odl-netconf-tcp/pom.xml
features/netconf/pom.xml
features/restconf/odl-restconf-common/pom.xml
netconf/aaa-authn-odl-plugin/pom.xml
netconf/callhome-protocol/pom.xml
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/AuthorizedKeysDecoder.java
netconf/callhome-provider/pom.xml
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/BaseCallHomeTopology.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java
netconf/config-netconf-connector/pom.xml [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/AbstractConfigNetconfOperation.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Commit.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/DiscardChanges.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Lock.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/UnLock.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Validate.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfig.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigXmlParser.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/get/Get.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/getconfig/GetConfig.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/Activator.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java [deleted file]
netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/NetconfMappingTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/ServiceTrackerTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/ValidateTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/MergeEditConfigStrategyTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/ReplaceEditConfigStrategyTest.java [deleted file]
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java [deleted file]
netconf/mdsal-netconf-connector/pom.xml
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/TransactionProvider.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractEdit.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/Commit.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfig.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/DiscardChanges.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/EditConfig.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/Lock.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/Unlock.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/AbstractGet.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/FilterContentValidator.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/Get.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/GetConfig.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/AbstractNetconfOperationTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/CopyConfigTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/get/Bug8084.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/get/FilterContentValidatorTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/get/Netconf506Test.java
netconf/mdsal-netconf-connector/src/test/resources/filter/expected.txt
netconf/mdsal-netconf-monitoring/pom.xml
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MdsalMonitoringMapperFactory.java
netconf/mdsal-netconf-notification/pom.xml
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/NetconfNotificationOperationServiceFactory.java
netconf/mdsal-netconf-yang-library/pom.xml
netconf/messagebus-netconf/pom.xml
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSource.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManager.java
netconf/netconf-api/pom.xml
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/DocumentedException.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/NetconfDocumentedException.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/BasicCapability.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/Capability.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/messages/NetconfHelloMessage.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/monitoring/CapabilityListener.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/util/NetconfConstants.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/MissingNameSpaceException.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedElementException.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedNamespaceException.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlElement.java [new file with mode: 0644]
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlNetconfConstants.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlUtil.java [new file with mode: 0644]
netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/NetconfDocumentedExceptionTest.java
netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlElementTest.java [new file with mode: 0644]
netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlUtilTest.java [new file with mode: 0644]
netconf/netconf-artifacts/pom.xml
netconf/netconf-auth/pom.xml
netconf/netconf-client/pom.xml
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientDispatcherImpl.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/SimpleNetconfClientSessionListener.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfiguration.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/SimpleNetconfClientSessionListenerTest.java
netconf/netconf-console/pom.xml
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfConnectDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfListDevicesCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfShowDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfCommandsImpl.java
netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/commands/NetconfCommandsImplCallsTest.java
netconf/netconf-impl/pom.xml
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionListener.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiator.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultCloseSession.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStartExi.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStopExi.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/AggregatedNetconfOperationServiceFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringService.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouter.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/util/DeserializerExceptionHandler.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/ConcurrentClientsTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionListenerTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/mapping/operations/DefaultCloseSessionTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStopExiTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/AggregatedNetconfOperationServiceFactoryTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringServiceTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImplTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfSessionMonitoringServiceTest.java
netconf/netconf-it/pom.xml
netconf/netconf-mapping-api/pom.xml
netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperation.java
netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationChainedExecution.java
netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationServiceFactory.java
netconf/netconf-monitoring/pom.xml
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/Get.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/GetSchema.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/osgi/NetconfMonitoringActivator.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/MonitoringSchema.java
netconf/netconf-monitoring/src/test/java/org/opendaylight/netconf/monitoring/GetSchemaTest.java
netconf/netconf-monitoring/src/test/java/org/opendaylight/netconf/monitoring/GetTest.java
netconf/netconf-monitoring/src/test/java/org/opendaylight/netconf/monitoring/xml/JaxBSerializerTest.java
netconf/netconf-netty-util/pom.xml
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ChunkedFramingMechanismEncoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/EOMFramingMechanismEncoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/MessageParts.java [new file with mode: 0644]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEOMAggregator.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/NetconfXMLToMessageDecoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/exi/EXIParameters.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/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/EOMFramingMechanismEncoderTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfEXIHandlersTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfHelloMessageToXMLEncoderTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoderTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/exi/EXIParametersTest.java
netconf/netconf-notifications-api/pom.xml
netconf/netconf-notifications-api/src/main/java/org/opendaylight/netconf/notifications/NetconfNotification.java
netconf/netconf-notifications-impl/pom.xml
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-notifications-impl/src/main/java/org/opendaylight/netconf/notifications/impl/ops/NotificationsTransformUtil.java
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/netconf/notifications/impl/osgi/Activator.java
netconf/netconf-notifications-impl/src/test/java/org/opendaylight/netconf/notifications/impl/ops/CreateSubscriptionTest.java
netconf/netconf-notifications-impl/src/test/java/org/opendaylight/netconf/notifications/impl/ops/GetTest.java
netconf/netconf-notifications-impl/src/test/java/org/opendaylight/netconf/notifications/impl/ops/NotificationsTransformUtilTest.java
netconf/netconf-notifications-impl/src/test/java/org/opendaylight/netconf/notifications/impl/osgi/ActivatorTest.java
netconf/netconf-parent/pom.xml
netconf/netconf-ssh/pom.xml
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyClientHandler.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyServer.java
netconf/netconf-tcp/pom.xml
netconf/netconf-topology-singleton/pom.xml
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyContext.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/NetconfNodeActor.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/ReadAdapter.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/CreateInitialMasterActorData.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/RefreshSetupMasterActorData.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/RefreshSlaveActor.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/SchemaPathMessage.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessage.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessageReply.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/transactions/NewReadTransactionReply.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/transactions/NewReadTransactionRequest.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/transactions/NewReadWriteTransactionReply.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/transactions/NewWriteTransactionReply.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/transactions/NewWriteTransactionRequest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadTransactionTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java
netconf/netconf-topology/pom.xml
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.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/mapping/AbstractLastNetconfOperation.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/mapping/AbstractNetconfOperation.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/mapping/AbstractSingletonNetconfOperation.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/NetconfMessageConstants.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/NetconfMessageUtil.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/SendErrorExceptionUtil.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/SubtreeFilter.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/mapping/AbstractLastNetconfOperationTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/mapping/AbstractNetconfOperationTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/mapping/AbstractSingletonNetconfOperationTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/messages/SendErrorExceptionUtilTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/messages/SubtreeFilterNotificationTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/messages/SubtreeFilterRpcTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/test/XmlFileLoader.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/test/XmlUnitUtil.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/xml/XMLNetconfUtilTest.java
netconf/pom.xml
netconf/sal-netconf-connector/pom.xml
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemas.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.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/NetconfDeviceCommunicator.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/sal/KeepaliveSalFacade.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/AbstractWriteTx.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/YangLibrarySchemaYangSourceProvider.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.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/netconf/util/NetconfRpcFutureCallback.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/SchemalessRpcStructureTransformer.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDeviceTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToNotificationTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToRpcRequestTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/listener/NetconfDeviceCommunicatorTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpcTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfKeystoreAdapterTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpcTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformerTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOpsTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfSalKeystoreServiceTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/SchemalessRpcStructureTransformerTest.java
netconf/tools/netconf-testtool/pom.xml
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/DummyMonitoringService.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/Execution.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/FakeCapability.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/MdsalOperationProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/ScaleUtil.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/SimulatedOperationProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/http/perf/AsyncExecutionStrategy.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/http/perf/RestPerfClient.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/AsyncExecutionStrategy.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/StressClient.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/SyncExecutionStrategy.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/customrpc/RpcMapping.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/customrpc/SettableOperationProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/customrpc/SettableRpc.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/operations/DefaultOperationsCreator.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/operations/OperationsCreator.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/operations/OperationsProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/DataList.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedCommit.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedCreateSubscription.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedDiscardChanges.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedEditConfig.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedGet.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedGetConfig.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedLock.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpc/SimulatedUnLock.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/RpcHandler.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/RpcHandlerDefault.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableOperationRpcProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableRpc.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/scale/util/ScaleUtilParameters.java
netconf/yanglib/pom.xml
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibRestApp.java
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibServiceImpl.java
netconf/yanglib/src/main/resources/WEB-INF/web.xml
netconf/yanglib/src/main/resources/org/opendaylight/blueprint/yanglib.xml
netconf/yanglib/src/test/java/org/opendaylight/yanglib/impl/YangLibProviderTest.java
netconf/yanglib/src/test/java/org/opendaylight/yanglib/impl/YangLibRestAppTest.java
protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java
protocol-framework/src/main/java/org/opendaylight/protocol/framework/ReconnectPromise.java

index d958d8207e18b1ae6f6b2a2e1eb6a15124983321..d4ebbc5b9fef1cc31a5ecc3852698c81cd825f32 100644 (file)
       <type>xml</type>
       <classifier>features</classifier>
     </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>odl-config-netconf-connector</artifactId>
-      <type>xml</type>
-      <classifier>features</classifier>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>odl-netconf-all</artifactId>
index 18c00e8773a8f5798e85b05a25b95b3a6010b42b..ebfaf49b839fa67b691e845e08dfa8b18758a8eb 100644 (file)
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-api</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>netconf-auth</artifactId>
@@ -61,4 +54,4 @@
             <artifactId>aaa-authn-odl-plugin</artifactId>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 8edfb1fd343101e05033fd808fb768040dce2e52..aef73969a5821afd741882d4e1bb32bd0c9b56cb 100644 (file)
     <name>OpenDaylight :: AAA :: ODL NETCONF Plugin</name>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-api</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-auth</artifactId>
@@ -51,4 +44,4 @@
             <version>${project.version}</version>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/features/netconf/odl-config-netconf-connector/pom.xml b/features/netconf/odl-config-netconf-connector/pom.xml
deleted file mode 100644 (file)
index a40c887..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright Â© 2017 Red Hat, Inc. and others.
-
- 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
- -->
-<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.odlparent</groupId>
-        <artifactId>single-feature-parent</artifactId>
-        <version>3.0.2</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>odl-config-netconf-connector</artifactId>
-    <version>1.5.0-SNAPSHOT</version>
-    <packaging>feature</packaging>
-
-    <name>OpenDaylight :: Netconf :: Connector</name>
-
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.opendaylight.controller</groupId>
-                <artifactId>config-artifacts</artifactId>
-                <version>0.9.0-SNAPSHOT</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.netconf</groupId>
-                <artifactId>netconf-artifacts</artifactId>
-                <version>${project.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-manager</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-netty</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>odl-netconf-netty-util</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>netconf-impl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>odl-netconf-notifications-impl</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>config-netconf-connector</artifactId>
-        </dependency>
-    </dependencies>
-</project>
index b7ad7c0f630a7b06b6b7cda3a782d0de4f3ba84c..d3af3f15d4a08d604a4623eeab4b66c684bf2057 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>odl-config-netconf-connector</artifactId>
-            <version>${project.version}</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-netty-util</artifactId>
@@ -83,4 +76,4 @@
             <classifier>features</classifier>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 41430b4d22f88a1cca76ebf59e554170acd77cb0..71d8bca083f7b3a2c8f19de0de2d2bcd03756d9b 100644 (file)
 
     <dependencyManagement>
         <dependencies>
-            <dependency>
-                <groupId>org.opendaylight.controller</groupId>
-                <artifactId>config-artifacts</artifactId>
-                <version>0.9.0-SNAPSHOT</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
             <dependency>
                 <groupId>org.opendaylight.mdsal.model</groupId>
                 <artifactId>mdsal-model-artifacts</artifactId>
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-util</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.model</groupId>
             <artifactId>odl-mdsal-models</artifactId>
index e74e6aac25fbe9ad159602759a9f0c35a7dea48b..f8a98ae61a99ea7030f24d435d6f2cd1d5ddb59f 100644 (file)
     <packaging>feature</packaging>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-all</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-netty</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-netty-util</artifactId>
@@ -56,4 +42,4 @@
             <version>${project.version}</version>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 31f2de9620155ec3a8be2ffb8ee952276c8ebe50..fa77c751e884834d8ea7bbe33ca4f28b037ce85c 100644 (file)
     <name>OpenDaylight :: Netconf :: Impl</name>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>yang-jmx-generator</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-api</artifactId>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-netty</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <!-- Netconf server without config connector is just an empty shell -->
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>odl-config-netconf-connector</artifactId>
-            <version>${project.version}</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <!-- Netconf will not provide schemas without monitoring -->
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-manager-facade-xml</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-monitoring</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 29c39ec38c47a70243d0eda0ceabad9969a06319..9a861214c8e78ba2c68970cde1a2a40a3e1345ff 100644 (file)
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-all</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-netty</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-all</artifactId>
             <artifactId>mdsal-netconf-impl</artifactId>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index a3e0cdf6cc2f40ccdf85f7a24018829a28389c07..9f919fdaa975dec8c912281bdab453c52bf91272 100644 (file)
     <name>OpenDaylight :: Netconf :: Notification :: Api</name>
 
     <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-manager-facade-xml</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-netconf-api</artifactId>
@@ -46,4 +39,4 @@
             <version>${project.version}</version>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index db3e5eb29750d47046f1da22820aec4ec9855966..551b11725e1e8ad0ff2fa4f0f2082eff03519b1b 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>odl-config-netty</artifactId>
-            <version>0.9.0-SNAPSHOT</version>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-tcp</artifactId>
index 0d1772a9f9f856b25c915a03ae8b773cf413a3df..6d2872b9d3139ef50f6c34459ef399d785a8a450 100644 (file)
@@ -24,7 +24,6 @@
     <module>features-netconf</module>
     <module>odl-aaa-netconf-plugin</module>
     <module>odl-aaa-netconf-plugin-no-cluster</module>
-    <module>odl-config-netconf-connector</module>
     <module>odl-netconf-all</module>
     <module>odl-netconf-api</module>
     <module>odl-netconf-client</module>
index 91cde29b44fabf23b242e965446b7af983a565e8..98bbfd07bfd8fd199fb765233cbbf27d06fc39fd 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-servlet</artifactId>
+        </dependency>
+
     </dependencies>
 </project>
index a185140497689f5a8e821ed4b8b8cd9651ad8ed2..55027f77757f4f145089560e42b75dbba22389b8 100644 (file)
         </dependency>
     </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
 </project>
index e0cb38e94422c3039abd232291d368898d988d61..10cd6ceb94bf0b8e3ba1e4ba3f64397bc3b6ac37 100644 (file)
       <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
index e544195fd8045c32bcc8ffb6d008e45b9fbc6584..7e07568a632e39042c3983686cf48d08ee59defb 100644 (file)
@@ -11,6 +11,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
 import java.security.KeyFactory;
 import java.security.PublicKey;
@@ -63,7 +64,7 @@ public class AuthorizedKeysDecoder {
 
         // look for the Base64 encoded part of the line to decode
         // both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes
-        bytes = Base64.getDecoder().decode(keyLine.getBytes());
+        bytes = Base64.getDecoder().decode(keyLine.getBytes(StandardCharsets.UTF_8));
         if (bytes.length == 0) {
             throw new IllegalArgumentException("No Base64 part to decode in " + keyLine);
         }
@@ -121,7 +122,7 @@ public class AuthorizedKeysDecoder {
 
     private String decodeType() {
         int len = decodeInt();
-        String type = new String(bytes, pos, len);
+        String type = new String(bytes, pos, len, StandardCharsets.UTF_8);
         pos += len;
         return type;
     }
@@ -140,23 +141,22 @@ public class AuthorizedKeysDecoder {
     }
 
     public static String encodePublicKey(final PublicKey publicKey) throws IOException {
-        String publicKeyEncoded;
         ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
-        if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_RSA)) {
+        if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_RSA) && publicKey instanceof RSAPublicKey) {
             RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
             DataOutputStream dout = new DataOutputStream(byteOs);
-            dout.writeInt(KEY_TYPE_RSA.getBytes().length);
-            dout.write(KEY_TYPE_RSA.getBytes());
+            dout.writeInt(KEY_TYPE_RSA.getBytes(StandardCharsets.UTF_8).length);
+            dout.write(KEY_TYPE_RSA.getBytes(StandardCharsets.UTF_8));
             dout.writeInt(rsaPublicKey.getPublicExponent().toByteArray().length);
             dout.write(rsaPublicKey.getPublicExponent().toByteArray());
             dout.writeInt(rsaPublicKey.getModulus().toByteArray().length);
             dout.write(rsaPublicKey.getModulus().toByteArray());
-        } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_DSA)) {
+        } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_DSA) && publicKey instanceof DSAPublicKey) {
             DSAPublicKey dsaPublicKey = (DSAPublicKey) publicKey;
             DSAParams dsaParams = dsaPublicKey.getParams();
             DataOutputStream dout = new DataOutputStream(byteOs);
-            dout.writeInt(KEY_TYPE_DSA.getBytes().length);
-            dout.write(KEY_TYPE_DSA.getBytes());
+            dout.writeInt(KEY_TYPE_DSA.getBytes(StandardCharsets.UTF_8).length);
+            dout.write(KEY_TYPE_DSA.getBytes(StandardCharsets.UTF_8));
             dout.writeInt(dsaParams.getP().toByteArray().length);
             dout.write(dsaParams.getP().toByteArray());
             dout.writeInt(dsaParams.getQ().toByteArray().length);
@@ -165,13 +165,13 @@ public class AuthorizedKeysDecoder {
             dout.write(dsaParams.getG().toByteArray());
             dout.writeInt(dsaPublicKey.getY().toByteArray().length);
             dout.write(dsaPublicKey.getY().toByteArray());
-        } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_ECDSA)) {
+        } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_ECDSA) && publicKey instanceof BCECPublicKey) {
             BCECPublicKey ecPublicKey = (BCECPublicKey) publicKey;
             DataOutputStream dout = new DataOutputStream(byteOs);
-            dout.writeInt(KEY_TYPE_ECDSA.getBytes().length);
-            dout.write(KEY_TYPE_ECDSA.getBytes());
-            dout.writeInt(ECDSA_SUPPORTED_CURVE_NAME.getBytes().length);
-            dout.write(ECDSA_SUPPORTED_CURVE_NAME.getBytes());
+            dout.writeInt(KEY_TYPE_ECDSA.getBytes(StandardCharsets.UTF_8).length);
+            dout.write(KEY_TYPE_ECDSA.getBytes(StandardCharsets.UTF_8));
+            dout.writeInt(ECDSA_SUPPORTED_CURVE_NAME.getBytes(StandardCharsets.UTF_8).length);
+            dout.write(ECDSA_SUPPORTED_CURVE_NAME.getBytes(StandardCharsets.UTF_8));
 
             byte[] coordX = ecPublicKey.getQ().getAffineXCoord().getEncoded();
             byte[] coordY = ecPublicKey.getQ().getAffineYCoord().getEncoded();
@@ -182,7 +182,6 @@ public class AuthorizedKeysDecoder {
         } else {
             throw new IllegalArgumentException("Unknown public key encoding: " + publicKey.getAlgorithm());
         }
-        publicKeyEncoded = new String(Base64.getEncoder().encodeToString(byteOs.toByteArray()));
-        return publicKeyEncoded;
+        return Base64.getEncoder().encodeToString(byteOs.toByteArray());
     }
 }
index 389b91fe89c86a007e99bec61f1bd3cb6153c4c4..1a2934f66846c8530b915ee32f0692b0d5d4b7d7 100644 (file)
             <artifactId>mockito-core</artifactId>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 0fcfb82fc79e8268e37228fc2ff3a6fb6bab17d2..d4f9e132b8ed0429de94999b077db6dde98fab7c 100644 (file)
@@ -19,9 +19,6 @@ import org.opendaylight.netconf.topology.AbstractNetconfTopology;
 import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider;
 
 abstract class BaseCallHomeTopology extends AbstractNetconfTopology {
-
-    protected DOMMountPointService mountPointService = null;
-
     BaseCallHomeTopology(final String topologyId, final NetconfClientDispatcher clientDispatcher,
                          final EventExecutor eventExecutor,
                          final ScheduledThreadPool keepaliveExecutor,
@@ -33,6 +30,5 @@ abstract class BaseCallHomeTopology extends AbstractNetconfTopology {
         super(topologyId, clientDispatcher, eventExecutor, keepaliveExecutor,
               processingExecutor, schemaRepositoryProvider, dataBroker, mountPointService,
               encryptionService);
-        this.mountPointService = mountPointService;
     }
 }
index 29632c247f1f4caf420b94009db530aab6b7d864..15445eb7460a39943163d5c5c1cae1b776acf607 100644 (file)
@@ -126,7 +126,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         return remoteAddress.toString();
     }
 
-    private class DeviceConfig implements DataTreeChangeListener<Device> {
+    private static class DeviceConfig implements DataTreeChangeListener<Device> {
 
         private final AuthorizedKeysDecoder keyDecoder = new AuthorizedKeysDecoder();
 
@@ -189,7 +189,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         }
     }
 
-    private class DeviceOp implements DataTreeChangeListener<Device> {
+    private static class DeviceOp implements DataTreeChangeListener<Device> {
 
         private final ConcurrentMap<String, Device> byPublicKey = new ConcurrentHashMap<>();
 
@@ -242,7 +242,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         }
     }
 
-    private class GlobalConfig implements DataTreeChangeListener<Global> {
+    private static class GlobalConfig implements DataTreeChangeListener<Global> {
 
         private volatile Global current = null;
 
index 713b7ec4a5837c7dcf1f038f3cf78bc0a41eb90e..14ab22a7f66af1978e4a0cf5a209de0fb9b843ae 100644 (file)
@@ -69,16 +69,13 @@ public class Configuration {
         }
     }
 
-    private final String path;
     private Properties properties;
 
     public Configuration() {
-        path = "<no-path>";
         properties = new Properties();
     }
 
     public Configuration(final String path) throws ConfigurationException {
-        this.path = path;
         try {
             this.properties = readFromPath(path);
         } catch (IOException ioe) {
diff --git a/netconf/config-netconf-connector/pom.xml b/netconf/config-netconf-connector/pom.xml
deleted file mode 100644 (file)
index a0f2ea6..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2016 Cisco Systems, Inc. and others.  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
--->
-<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.netconf</groupId>
-    <artifactId>netconf-parent</artifactId>
-    <version>1.5.0-SNAPSHOT</version>
-    <relativePath>../netconf-parent</relativePath>
-  </parent>
-
-  <groupId>org.opendaylight.netconf</groupId>
-  <artifactId>config-netconf-connector</artifactId>
-  <version>1.5.0-SNAPSHOT</version>
-  <name>${project.artifactId}</name>
-  <packaging>bundle</packaging>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-artifacts</artifactId>
-        <version>0.9.0-SNAPSHOT</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
-  <dependencies>
-    <!-- compile dependencies -->
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager-facade-xml</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-impl</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-mapping-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-notifications-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>mockito-configuration</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.mdsal</groupId>
-      <artifactId>mdsal-binding-generator-impl</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-simple</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-test-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-util</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>yang-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <configuration>
-          <instructions>
-            <Bundle-Activator>org.opendaylight.netconf.confignetconfconnector.osgi.Activator</Bundle-Activator>
-          </instructions>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/AbstractConfigNetconfOperation.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/AbstractConfigNetconfOperation.java
deleted file mode 100644 (file)
index 0db795b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-
-public abstract class AbstractConfigNetconfOperation extends AbstractLastNetconfOperation {
-
-    private final ConfigSubsystemFacade configSubsystemFacade;
-
-    protected AbstractConfigNetconfOperation(ConfigSubsystemFacade configSubsystemFacade,
-            String netconfSessionIdForReporting) {
-        super(netconfSessionIdForReporting);
-        this.configSubsystemFacade = configSubsystemFacade;
-    }
-
-    public ConfigSubsystemFacade getConfigSubsystemFacade() {
-        return configSubsystemFacade;
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Commit.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Commit.java
deleted file mode 100644 (file)
index 176d3e2..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Commit extends AbstractConfigNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Commit.class);
-
-    public  Commit(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    private static void checkXml(XmlElement xml) throws DocumentedException {
-        xml.checkName(XmlNetconfConstants.COMMIT);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-    }
-
-    @Override
-    protected String getOperationName() {
-        return XmlNetconfConstants.COMMIT;
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
-
-        checkXml(xml);
-        CommitStatus status;
-        try {
-            status = getConfigSubsystemFacade().commitTransaction();
-            LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
-        } catch (ConflictingVersionException | ValidationException e) {
-            throw DocumentedException.wrap(e);
-        }
-        LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
-
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/DiscardChanges.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/DiscardChanges.java
deleted file mode 100644 (file)
index f3cc244..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-public class DiscardChanges extends AbstractConfigNetconfOperation {
-
-    public static final String DISCARD = "discard-changes";
-
-    private static final Logger LOG = LoggerFactory.getLogger(DiscardChanges.class);
-
-    public DiscardChanges(final ConfigSubsystemFacade configSubsystemFacade,
-                          final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    private static void fromXml(final XmlElement xml) throws DocumentedException {
-        xml.checkName(DISCARD);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-    }
-
-    @Override
-    protected String getOperationName() {
-        return DISCARD;
-    }
-
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    @Override
-    protected Element handleWithNoSubsequentOperations(final Document document,
-                                                       final XmlElement xml) throws DocumentedException {
-        fromXml(xml);
-        try {
-            getConfigSubsystemFacade().abortConfiguration();
-        } catch (final RuntimeException e) {
-            LOG.warn("Abort failed: ", e);
-            final Map<String, String> errorInfo = new HashMap<>();
-            errorInfo
-                    .put(ErrorTag.OPERATION_FAILED.name(),
-                            "Abort failed.");
-            throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
-                    ErrorSeverity.ERROR, errorInfo);
-        }
-        LOG.trace("Changes discarded successfully from datastore {}", Datastore.candidate);
-
-
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Lock.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Lock.java
deleted file mode 100644 (file)
index 9cca810..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Simple Lock implementation that pretends to lock candidate datastore.
- * Candidate datastore is allocated per session and is private so no real locking is needed
- * (JMX is the only possible interference)
- */
-public class Lock extends AbstractLastNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Lock.class);
-
-    private static final String LOCK = "lock";
-    private static final String TARGET_KEY = "target";
-
-    public Lock(final String netconfSessionIdForReporting) {
-        super(netconfSessionIdForReporting);
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(final Document document,
-                                                       final XmlElement operationElement) throws DocumentedException {
-        final Datastore targetDatastore = extractTargetParameter(operationElement);
-        if (targetDatastore == Datastore.candidate) {
-            // Since candidate datastore instances are allocated per session and not accessible anywhere else,
-            // no need to lock
-            LOG.debug("Locking {} datastore on session: {}", targetDatastore, getNetconfSessionIdForReporting());
-            // TODO should this fail if we are already locked ?
-            return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-        }
-
-        // Not supported running lock
-        throw new DocumentedException("Unable to lock " + Datastore.running + " datastore",
-                DocumentedException.ErrorType.APPLICATION,
-                DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED, DocumentedException.ErrorSeverity.ERROR);
-    }
-
-    static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
-        final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
-        final XmlElement targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
-
-        return Datastore.valueOf(targetChildNode.getName());
-    }
-
-    @Override
-    protected String getOperationName() {
-        return LOCK;
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/UnLock.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/UnLock.java
deleted file mode 100644 (file)
index 17fff3d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Simple unlock implementation that pretends to unlock candidate datastore.
- * Candidate datastore is allocated per session and is private so no real locking is needed
- * (JMX is the only possible interference)
- */
-public class UnLock extends AbstractLastNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(UnLock.class);
-
-    private static final String UNLOCK = "unlock";
-
-    public UnLock(final String netconfSessionIdForReporting) {
-        super(netconfSessionIdForReporting);
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(final Document document,
-                                                       final XmlElement operationElement) throws DocumentedException {
-        final Datastore targetDatastore = Lock.extractTargetParameter(operationElement);
-        if (targetDatastore == Datastore.candidate) {
-            // Since candidate datastore instances are allocated per session and not accessible anywhere else,
-            // no need to lock
-            LOG.debug("Unlocking {} datastore on session: {}", targetDatastore, getNetconfSessionIdForReporting());
-            // TODO this should fail if we are not locked
-            return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-        }
-
-        // Not supported running lock
-        throw new DocumentedException("Unable to unlock " + Datastore.running + " datastore",
-                DocumentedException.ErrorType.APPLICATION,
-                DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED, DocumentedException.ErrorSeverity.ERROR);
-    }
-
-    @Override
-    protected String getOperationName() {
-        return UNLOCK;
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Validate.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/Validate.java
deleted file mode 100644 (file)
index 7c4e823..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Validate extends AbstractConfigNetconfOperation {
-
-    public static final String VALIDATE = "validate";
-
-    private static final Logger LOG = LoggerFactory.getLogger(Validate.class);
-
-    public Validate(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    private void checkXml(final XmlElement xml) throws DocumentedException {
-        xml.checkName(VALIDATE);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
-        final XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
-                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-        final XmlElement sourceChildNode = sourceElement.getOnlyChildElement();
-
-        sourceChildNode.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-        final String datastoreValue = sourceChildNode.getName();
-        final Datastore sourceDatastore = Datastore.valueOf(datastoreValue);
-
-        if (sourceDatastore != Datastore.candidate) {
-            throw new DocumentedException("Only " + Datastore.candidate
-                    + " is supported as source for " + VALIDATE + " but was " + datastoreValue, ErrorType.APPLICATION,
-                    ErrorTag.DATA_MISSING, ErrorSeverity.ERROR);
-        }
-    }
-
-    @Override
-    protected String getOperationName() {
-        return VALIDATE;
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(final Document document,
-                                                       final XmlElement xml) throws DocumentedException {
-        checkXml(xml);
-        try {
-            getConfigSubsystemFacade().validateConfiguration();
-        } catch (final ValidationException e) {
-            LOG.warn("Validation failed", e);
-            throw DocumentedException.wrap(e);
-        } catch (final IllegalStateException e) {
-            LOG.warn("Validation failed", e);
-            final Map<String, String> errorInfo = new HashMap<>();
-            errorInfo
-                    .put(ErrorTag.OPERATION_FAILED.name(),
-                            "Datastore is not present. "
-                                    + "Use 'get-config' or 'edit-config' before triggering 'operations' operation");
-            throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
-                    ErrorSeverity.ERROR, errorInfo);
-
-        }
-
-        LOG.trace("Datastore {} validated successfully", Datastore.candidate);
-
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfig.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
deleted file mode 100644 (file)
index e247928..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.editconfig;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class EditConfig extends AbstractConfigNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EditConfig.class);
-
-    private final EditConfigXmlParser editConfigXmlParser;
-
-    public EditConfig(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-        this.editConfigXmlParser = new EditConfigXmlParser();
-    }
-
-    @VisibleForTesting
-    Element getResponseInternal(final Document document,
-            final ConfigExecution configExecution) throws DocumentedException {
-
-        try {
-            getConfigSubsystemFacade().executeConfigExecution(configExecution);
-        } catch (final ValidationException e) {
-            LOG.warn("Test phase for {} failed", EditConfigXmlParser.EDIT_CONFIG, e);
-            final Map<String, String> errorInfo = new HashMap<>();
-            errorInfo.put(ErrorTag.OPERATION_FAILED.name(), e.getMessage());
-            throw new DocumentedException("Test phase: " + e.getMessage(), e, ErrorType.APPLICATION,
-                    ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR, errorInfo);
-        }
-
-        LOG.trace("Operation {} successful", EditConfigXmlParser.EDIT_CONFIG);
-
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
-    }
-
-    @Override
-    protected String getOperationName() {
-        return EditConfigXmlParser.EDIT_CONFIG;
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(final Document document,
-                                                       final XmlElement xml) throws DocumentedException {
-        // FIXME config mapping getter works on dynamic yang store service
-        // and so does later executeConfigExecution method
-        // They might have different view of current yangs in ODL and might cause race conditions
-        final Config cfg = getConfigSubsystemFacade().getConfigMapping();
-        final ConfigExecution configExecution = editConfigXmlParser.fromXml(xml, cfg);
-
-        return getResponseInternal(document, configExecution);
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigXmlParser.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigXmlParser.java
deleted file mode 100644 (file)
index ddba4ae..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.editconfig;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.facade.xml.TestOption;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
-import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EditConfigXmlParser {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EditConfigXmlParser.class);
-
-    public static final String EDIT_CONFIG = "edit-config";
-    public static final String DEFAULT_OPERATION_KEY = "default-operation";
-    static final String ERROR_OPTION_KEY = "error-option";
-    static final String DEFAULT_ERROR_OPTION = "stop-on-error";
-    static final String TARGET_KEY = "target";
-    static final String TEST_OPTION_KEY = "test-option";
-
-    public EditConfigXmlParser() {
-    }
-
-    ConfigExecution fromXml(final XmlElement xml, final Config cfgMapping)
-            throws DocumentedException {
-
-        //TODO remove transactionProvider and CfgRegistry from parameters, accept only service ref store
-
-        EditStrategyType editStrategyType = EditStrategyType.getDefaultStrategy();
-
-        xml.checkName(EditConfigXmlParser.EDIT_CONFIG);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
-
-        XmlElement targetElement;
-        XmlElement targetChildNode;
-        targetElement  = xml.getOnlyChildElementWithSameNamespace(EditConfigXmlParser.TARGET_KEY);
-        targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
-
-        final String datastoreValue = targetChildNode.getName();
-        final Datastore targetDatastore = Datastore.valueOf(datastoreValue);
-        LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TARGET_KEY, targetDatastore);
-
-        // check target
-        if (targetDatastore != Datastore.candidate) {
-            throw new DocumentedException(String.format(
-                    "Only %s datastore supported for edit config but was: %s",
-                    Datastore.candidate,
-                    targetDatastore),
-                    DocumentedException.ErrorType.APPLICATION,
-                    DocumentedException.ErrorTag.INVALID_VALUE,
-                    DocumentedException.ErrorSeverity.ERROR);
-        }
-
-        // Test option
-        final TestOption testOption;
-        final Optional<XmlElement> testOptionElementOpt = xml
-                .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
-        if (testOptionElementOpt.isPresent()) {
-            final String testOptionValue = testOptionElementOpt.get().getTextContent();
-            testOption = TestOption.getFromXmlName(testOptionValue);
-        } else {
-            testOption = TestOption.getDefault();
-        }
-        LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TEST_OPTION_KEY, testOption);
-
-        // Error option
-        final Optional<XmlElement> errorOptionElement = xml
-                .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
-        if (errorOptionElement.isPresent()) {
-            final String errorOptionParsed = errorOptionElement.get().getTextContent();
-            if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)) {
-                throw new UnsupportedOperationException("Only " + EditConfigXmlParser.DEFAULT_ERROR_OPTION
-                        + " supported for " + EditConfigXmlParser.ERROR_OPTION_KEY + ", was " + errorOptionParsed);
-            }
-        }
-
-        // Default op
-        final Optional<XmlElement> defaultContent = xml
-                .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
-        if (defaultContent.isPresent()) {
-            final String mergeStrategyString = defaultContent.get().getTextContent();
-            LOG.trace("Setting merge strategy to {}", mergeStrategyString);
-            editStrategyType = EditStrategyType.valueOf(mergeStrategyString);
-        }
-
-        XmlElement configElement;
-        configElement = xml.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.CONFIG_KEY);
-
-        return new ConfigExecution(cfgMapping, configElement, testOption, editStrategyType);
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/get/Get.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/get/Get.java
deleted file mode 100644 (file)
index 761497e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.get;
-
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Get extends AbstractConfigNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Get.class);
-
-    public Get(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    private static void checkXml(XmlElement xml) throws DocumentedException {
-        xml.checkName(XmlNetconfConstants.GET);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
-        // Filter option: ignore for now, TODO only load modules specified by the filter
-    }
-
-    @Override
-    protected String getOperationName() {
-        return XmlNetconfConstants.GET;
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
-        checkXml(xml);
-        final Element element = getConfigSubsystemFacade().get(document);
-        LOG.trace("{} operation successful", XmlNetconfConstants.GET);
-        return element;
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/getconfig/GetConfig.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
deleted file mode 100644 (file)
index dc1c31d..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.getconfig;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class GetConfig extends AbstractConfigNetconfOperation {
-
-    public static final String GET_CONFIG = "get-config";
-
-    private final Optional<String> maybeNamespace;
-
-    private static final Logger LOG = LoggerFactory.getLogger(GetConfig.class);
-
-    public GetConfig(final ConfigSubsystemFacade configSubsystemFacade, final Optional<String> maybeNamespace,
-                     final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-        this.maybeNamespace = maybeNamespace;
-    }
-
-    public static Datastore fromXml(XmlElement xml) throws DocumentedException {
-
-        xml.checkName(GET_CONFIG);
-        xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
-        XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
-                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-        XmlElement sourceNode = sourceElement.getOnlyChildElement();
-        String sourceParsed = sourceNode.getName();
-        LOG.debug("Setting source datastore to '{}'", sourceParsed);
-
-        // Filter option: ignore for now, TODO only load modules specified by the filter
-
-        return Datastore.valueOf(sourceParsed);
-
-    }
-
-    @Override
-    protected String getOperationName() {
-        return GET_CONFIG;
-    }
-
-    @Override
-    public Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
-        return getConfigSubsystemFacade().getConfiguration(document, fromXml(xml), maybeNamespace);
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java
deleted file mode 100644 (file)
index bbcdf28..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.runtimerpc;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.RpcFacade;
-import org.opendaylight.controller.config.facade.xml.rpc.InstanceRuntimeRpc;
-import org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs;
-import org.opendaylight.controller.config.facade.xml.rpc.Rpcs;
-import org.opendaylight.controller.config.facade.xml.rpc.RuntimeRpcElementResolved;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class RuntimeRpc extends AbstractConfigNetconfOperation {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RuntimeRpc.class);
-
-    public RuntimeRpc(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
-        super(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-
-    @Override
-    public HandlingPriority canHandle(Document message) throws DocumentedException {
-        XmlElement requestElement = getRequestElementWithCheck(message);
-
-        XmlElement operationElement = requestElement.getOnlyChildElement();
-        final String netconfOperationName = operationElement.getName();
-        final String netconfOperationNamespace;
-        try {
-            netconfOperationNamespace = operationElement.getNamespace();
-        } catch (DocumentedException e) {
-            LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
-            return HandlingPriority.CANNOT_HANDLE;
-        }
-
-        final Optional<XmlElement> contextInstanceElement = operationElement
-                .getOnlyChildElementOptionally(RpcFacade.CONTEXT_INSTANCE);
-
-        if (!contextInstanceElement.isPresent()) {
-            return HandlingPriority.CANNOT_HANDLE;
-        }
-
-        final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(contextInstanceElement.get()
-                .getTextContent(), netconfOperationName, netconfOperationNamespace);
-
-        // TODO reuse rpcs instance in fromXml method
-        final Rpcs rpcs = getConfigSubsystemFacade().getRpcFacade().mapRpcs();
-
-        try {
-            final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
-            final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(),
-                    netconfOperationName);
-            Preconditions.checkState(instanceRuntimeRpc != null, "No rpc found for %s:%s", netconfOperationNamespace,
-                    netconfOperationName);
-        } catch (IllegalStateException e) {
-            LOG.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e);
-            return HandlingPriority.CANNOT_HANDLE;
-        }
-
-        return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
-    }
-
-    @Override
-    protected HandlingPriority canHandle(String netconfOperationName, String namespace) {
-        throw new UnsupportedOperationException(
-                "This should not be used since it is not possible to provide check with these attributes");
-    }
-
-    @Override
-    protected String getOperationName() {
-        throw new UnsupportedOperationException("Runtime rpc does not have a stable name");
-    }
-
-    @Override
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
-        // TODO check for namespaces and unknown elements
-        final RpcFacade.OperationExecution execution = getConfigSubsystemFacade().getRpcFacade().fromXml(xml);
-
-        LOG.debug("Invoking operation {} on {} with arguments {}", execution.getOperationName(), execution.getOn(),
-                execution.getAttributes());
-        final Object result = getConfigSubsystemFacade().getRpcFacade().executeOperation(execution);
-
-        LOG.trace("Operation {} called successfully on {} with arguments {} with result {}",
-                execution.getOperationName(), execution.getOn(), execution.getAttributes(), result);
-
-        if (execution.isVoid()) {
-            return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
-        } else {
-            return getConfigSubsystemFacade().getRpcFacade().toXml(document, result, execution);
-        }
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/Activator.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/Activator.java
deleted file mode 100644 (file)
index 40edbec..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.osgi;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
-import org.opendaylight.netconf.api.util.NetconfConstants;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Activator implements BundleActivator {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
-
-    private ServiceRegistration<?> osgiRegistration;
-
-    @Override
-    public void start(final BundleContext context) throws Exception {
-        ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory,
-                ConfigSubsystemFacadeFactory> schemaServiceTrackerCustomizer =
-                new ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory>() {
-
-            @Override
-            public ConfigSubsystemFacadeFactory addingService(
-                    ServiceReference<ConfigSubsystemFacadeFactory> reference) {
-                LOG.debug("Got addingService(SchemaContextProvider) event");
-                // Yang store service should not be registered multiple times
-                ConfigSubsystemFacadeFactory configSubsystemFacade =
-                        reference.getBundle().getBundleContext().getService(reference);
-                osgiRegistration = startNetconfServiceFactory(configSubsystemFacade, context);
-                return configSubsystemFacade;
-            }
-
-            @Override
-            public void modifiedService(ServiceReference<ConfigSubsystemFacadeFactory> reference,
-                                        ConfigSubsystemFacadeFactory service) {
-                LOG.warn("Config manager facade was modified unexpectedly");
-            }
-
-            @Override
-            public void removedService(ServiceReference<ConfigSubsystemFacadeFactory> reference,
-                                       ConfigSubsystemFacadeFactory service) {
-                LOG.warn("Config manager facade was removed unexpectedly");
-            }
-        };
-
-        ServiceTracker<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory> schemaContextProviderServiceTracker =
-                new ServiceTracker<>(context, ConfigSubsystemFacadeFactory.class, schemaServiceTrackerCustomizer);
-        schemaContextProviderServiceTracker.open();
-    }
-
-    @Override
-    public void stop(final BundleContext bundleContext) throws Exception {
-        if (osgiRegistration != null) {
-            osgiRegistration.unregister();
-        }
-    }
-
-    private ServiceRegistration<NetconfOperationServiceFactory> startNetconfServiceFactory(
-            final ConfigSubsystemFacadeFactory configSubsystemFacade, final BundleContext context) {
-        final NetconfOperationServiceFactoryImpl netconfOperationServiceFactory =
-                new NetconfOperationServiceFactoryImpl(configSubsystemFacade);
-        // Add properties to autowire with netconf-impl instance for cfg subsystem
-        final Dictionary<String, String> properties = new Hashtable<>();
-        properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.CONFIG_NETCONF_CONNECTOR);
-        return context.registerService(NetconfOperationServiceFactory.class,
-                netconfOperationServiceFactory, properties);
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java
deleted file mode 100644 (file)
index 3006468..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.osgi;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.Sets;
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.Validate;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-
-final class NetconfOperationProvider {
-    private final Set<NetconfOperation> operations;
-
-    NetconfOperationProvider(final ConfigSubsystemFacade configSubsystemFacade,
-                             final String netconfSessionIdForReporting) {
-
-        operations = setUpOperations(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    Set<NetconfOperation> getOperations() {
-        return operations;
-    }
-
-    private static Set<NetconfOperation> setUpOperations(final ConfigSubsystemFacade configSubsystemFacade,
-            String netconfSessionIdForReporting) {
-        Set<NetconfOperation> ops = Sets.newHashSet();
-
-        GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.absent(), netconfSessionIdForReporting);
-
-        ops.add(getConfigOp);
-        ops.add(new EditConfig(configSubsystemFacade, netconfSessionIdForReporting));
-        ops.add(new Commit(configSubsystemFacade, netconfSessionIdForReporting));
-        ops.add(new Lock(netconfSessionIdForReporting));
-        ops.add(new UnLock(netconfSessionIdForReporting));
-        ops.add(new Get(configSubsystemFacade, netconfSessionIdForReporting));
-        ops.add(new DiscardChanges(configSubsystemFacade, netconfSessionIdForReporting));
-        ops.add(new Validate(configSubsystemFacade, netconfSessionIdForReporting));
-        ops.add(new RuntimeRpc(configSubsystemFacade, netconfSessionIdForReporting));
-
-        return ops;
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java
deleted file mode 100644 (file)
index 370e59e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.osgi;
-
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-
-public class NetconfOperationServiceFactoryImpl implements NetconfOperationServiceFactory {
-
-    private final ConfigSubsystemFacadeFactory configFacadeFactory;
-
-    public NetconfOperationServiceFactoryImpl(ConfigSubsystemFacadeFactory configFacadeFactory) {
-        this.configFacadeFactory = configFacadeFactory;
-    }
-
-    @Override
-    public NetconfOperationServiceImpl createService(String netconfSessionIdForReporting) {
-        return new NetconfOperationServiceImpl(configFacadeFactory.createFacade(netconfSessionIdForReporting),
-                netconfSessionIdForReporting);
-    }
-
-    @Override
-    public Set<Capability> getCapabilities() {
-        return configFacadeFactory.getCurrentCapabilities();
-    }
-
-    @Override
-    public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-        return configFacadeFactory.getYangStoreService().registerModuleListener(listener::onCapabilitiesChanged);
-    }
-}
diff --git a/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java b/netconf/config-netconf-connector/src/main/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java
deleted file mode 100644 (file)
index 37a744b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.osgi;
-
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-
-public class NetconfOperationServiceImpl implements NetconfOperationService {
-
-    private final NetconfOperationProvider operationProvider;
-    private final ConfigSubsystemFacade configSubsystemFacade;
-
-    public NetconfOperationServiceImpl(final ConfigSubsystemFacade configSubsystemFacade,
-            final String netconfSessionIdForReporting) {
-        this.configSubsystemFacade = configSubsystemFacade;
-        this.operationProvider = new NetconfOperationProvider(configSubsystemFacade, netconfSessionIdForReporting);
-    }
-
-    @Override
-    public Set<NetconfOperation> getNetconfOperations() {
-        return operationProvider.getOperations();
-    }
-
-    @Override
-    public void close() {
-        configSubsystemFacade.close();
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/NetconfMappingTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/NetconfMappingTest.java
deleted file mode 100644 (file)
index 923141f..0000000
+++ /dev/null
@@ -1,931 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector;
-
-import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.opendaylight.controller.config.util.xml.XmlUtil.readXmlToElement;
-import static org.opendaylight.netconf.util.test.XmlUnitUtil.assertContainsElement;
-import static org.opendaylight.netconf.util.test.XmlUnitUtil.assertContainsElementWithText;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import io.netty.channel.Channel;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import javax.xml.parsers.ParserConfigurationException;
-import org.custommonkey.xmlunit.AbstractNodeTester;
-import org.custommonkey.xmlunit.NodeTest;
-import org.custommonkey.xmlunit.NodeTestException;
-import org.custommonkey.xmlunit.NodeTester;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.osgi.EnumResolver;
-import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
-import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.config.yang.test.impl.ComplexDtoBInner;
-import org.opendaylight.controller.config.yang.test.impl.ComplexList;
-import org.opendaylight.controller.config.yang.test.impl.Deep;
-import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.DtoAInner;
-import org.opendaylight.controller.config.yang.test.impl.DtoAInnerInner;
-import org.opendaylight.controller.config.yang.test.impl.DtoC;
-import org.opendaylight.controller.config.yang.test.impl.DtoD;
-import org.opendaylight.controller.config.yang.test.impl.IdentityTestModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.config.yang.test.impl.Peers;
-import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
-import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
-import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.impl.NetconfServerSession;
-import org.opendaylight.netconf.impl.NetconfServerSessionListener;
-import org.opendaylight.netconf.impl.mapping.operations.DefaultCloseSession;
-import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
-import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.xml.sax.SAXException;
-
-
-public class NetconfMappingTest extends AbstractConfigTest {
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfMappingTest.class);
-
-    private static final String INSTANCE_NAME = "instance-from-code";
-    private static final String NETCONF_SESSION_ID = "foo";
-    private static final String TEST_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:test:impl";
-    private NetconfTestImplModuleFactory factory;
-    private DepTestImplModuleFactory factory2;
-    private IdentityTestModuleFactory factory3;
-    private TestImplModuleFactory factory4;
-
-    @Mock
-    YangStoreService yangStoreSnapshot;
-    @Mock
-    NetconfOperationRouter netconfOperationRouter;
-    @Mock
-    AggregatedNetconfOperationServiceFactory netconfOperationServiceSnapshot;
-    @Mock
-    private AutoCloseable sessionCloseable;
-
-    private TransactionProvider transactionProvider;
-
-    private ConfigSubsystemFacade configSubsystemFacade;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-
-        final Filter filter = mock(Filter.class);
-        doReturn(filter).when(mockedContext).createFilter(anyString());
-        doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
-        doReturn(new ServiceReference<?>[]{}).when(mockedContext).getServiceReferences(anyString(), anyString());
-
-        doReturn(yangStoreSnapshot).when(yangStoreSnapshot).getCurrentSnapshot();
-        doReturn(getMbes()).when(this.yangStoreSnapshot).getModuleMXBeanEntryMap();
-        doReturn(getModules()).when(this.yangStoreSnapshot).getModules();
-        doReturn(new EnumResolver() {
-            @Override
-            public String fromYang(final String enumType, final String enumYangValue) {
-                return Preconditions.checkNotNull(getEnumMapping().get(enumYangValue),
-                        "Unable to resolve enum value %s, for enum %s with mappings %s",
-                        enumYangValue, enumType, getEnumMapping());
-            }
-
-            @Override
-            public String toYang(final String enumType, final String enumYangValue) {
-                return Preconditions.checkNotNull(getEnumMapping().inverse().get(enumYangValue),
-                        "Unable to resolve enum value %s, for enum %s with mappings %s",
-                        enumYangValue, enumType, getEnumMapping().inverse());
-            }
-        }).when(this.yangStoreSnapshot).getEnumResolver();
-
-        this.factory = new NetconfTestImplModuleFactory();
-        this.factory2 = new DepTestImplModuleFactory();
-        this.factory3 = new IdentityTestModuleFactory();
-        factory4 = new TestImplModuleFactory();
-        doNothing().when(sessionCloseable).close();
-
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, this.factory,
-                this.factory2, this.factory3, factory4));
-
-        transactionProvider = new TransactionProvider(this.configRegistryClient, NETCONF_SESSION_ID);
-
-        configSubsystemFacade = new ConfigSubsystemFacade(configRegistryClient, configRegistryClient, yangStoreSnapshot,
-                "mapping-test");
-    }
-
-    private ObjectName createModule(final String instanceName) throws InstanceAlreadyExistsException,
-            InstanceNotFoundException, URISyntaxException, ValidationException, ConflictingVersionException {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-
-        final ObjectName on = transaction.createModule(this.factory.getImplementationName(), instanceName);
-        final NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
-        setModule(mxBean, transaction, instanceName + "_dep");
-
-        int index = 1;
-        for (final Class<? extends AbstractServiceInterface> serviceInterface :
-                factory.getImplementedServiceIntefaces()) {
-            final ServiceInterfaceAnnotation annotation =
-                    serviceInterface.getAnnotation(ServiceInterfaceAnnotation.class);
-            transaction.saveServiceReference(
-                    transaction.getServiceInterfaceName(annotation.namespace(), annotation.localName()),
-                    "ref_from_code_to_" + instanceName + "_" + index++, on);
-
-        }
-        transaction.commit();
-        return on;
-    }
-
-    @Test
-    public void testIdentityRefs() throws Exception {
-        edit("netconfMessages/editConfig_identities.xml");
-
-        commit();
-        Document configRunning = getConfigRunning();
-        String asString = XmlUtil.toString(configRunning);
-        assertThat(asString, containsString("test-identity2"));
-        assertThat(asString, containsString("test-identity1"));
-        assertEquals(2, countSubstringOccurence(asString, "</identities>"));
-
-        edit("netconfMessages/editConfig_identities_inner_replace.xml");
-        commit();
-        configRunning = getConfigRunning();
-        asString = XmlUtil.toString(configRunning);
-        // test-identity1 was removed by replace
-        assertThat(asString, not(containsString("test-identity2")));
-        // now only 1 identities entry is present
-        assertEquals(1, countSubstringOccurence(asString, "</identities>"));
-    }
-
-    private static int countSubstringOccurence(final String string, final String substring) {
-        final Matcher matches = Pattern.compile(substring).matcher(string);
-        int count = 0;
-        while (matches.find()) {
-            count++;
-        }
-        return count;
-    }
-
-    @Override
-    protected BindingRuntimeContext getBindingRuntimeContext() {
-        final BindingRuntimeContext ret = super.getBindingRuntimeContext();
-        doReturn(TestIdentity1.class).when(ret).getIdentityClass(TestIdentity1.QNAME);
-        doReturn(TestIdentity2.class).when(ret).getIdentityClass(TestIdentity2.QNAME);
-        doReturn(getSchemaContext()).when(ret).getSchemaContext();
-        return ret;
-    }
-
-    @Test
-    public void testServicePersistance() throws Exception {
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        Document config = getConfigCandidate();
-        assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
-                "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
-                "ref_from_code_to_instance-from-code_1"));
-
-
-        edit("netconfMessages/editConfig_addServiceName.xml");
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
-                "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
-                "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
-        edit("netconfMessages/editConfig_addServiceNameOnTest.xml");
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
-                "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
-                "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
-        commit();
-        config = getConfigRunning();
-        assertCorrectRefNamesForDependencies(config);
-        assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
-                "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
-                "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
-        edit("netconfMessages/editConfig_removeServiceNameOnTest.xml");
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
-                "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
-                "ref_from_code_to_instance-from-code_1"));
-
-        try {
-            edit("netconfMessages/editConfig_removeServiceNameOnTest.xml");
-            fail("Should've failed, non-existing service instance");
-        } catch (final DocumentedException e) {
-            assertEquals(e.getErrorSeverity(), DocumentedException.ErrorSeverity.ERROR);
-            assertEquals(e.getErrorTag(), DocumentedException.ErrorTag.OPERATION_FAILED);
-            assertEquals(e.getErrorType(), DocumentedException.ErrorType.APPLICATION);
-        }
-
-        edit("netconfMessages/editConfig_replace_default.xml");
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Collections.<String>emptySet());
-
-        edit("netconfMessages/editConfig_remove.xml");
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Collections.<String>emptySet());
-
-        commit();
-        config = getConfigCandidate();
-        assertCorrectServiceNames(config, Collections.<String>emptySet());
-
-    }
-
-    @Test
-    public void testUnLock() throws Exception {
-        assertTrue(NetconfMessageUtil.isOKMessage(lockCandidate()));
-        assertTrue(NetconfMessageUtil.isOKMessage(unlockCandidate()));
-    }
-
-    private static void assertCorrectRefNamesForDependencies(final Document config) throws NodeTestException {
-        final NodeList modulesList = config.getElementsByTagName("modules");
-        assertEquals(1, modulesList.getLength());
-
-        final NodeTest nt = new NodeTest((DocumentTraversal) config, modulesList.item(0));
-        final NodeTester tester = new AbstractNodeTester() {
-            private int defaultRefNameCount = 0;
-            private int userRefNameCount = 0;
-
-            @Override
-            public void testText(final Text text) throws NodeTestException {
-                if (text.getData().equals("ref_dep2")) {
-                    defaultRefNameCount++;
-                } else if (text.getData().equals("ref_dep_user_two")) {
-                    userRefNameCount++;
-                }
-            }
-
-            @Override
-            public void noMoreNodes(final NodeTest forTest) throws NodeTestException {
-                assertEquals(0, defaultRefNameCount);
-                assertEquals(2, userRefNameCount);
-            }
-        };
-        nt.performTest(tester, Node.TEXT_NODE);
-    }
-
-    private static void assertCorrectServiceNames(final Document configCandidate,
-                                                  final Set<String> refNames) throws NodeTestException {
-        final Set<String> refNames2 = new HashSet<>(refNames);
-        final NodeList servicesNodes = configCandidate.getElementsByTagName("services");
-        assertEquals(1, servicesNodes.getLength());
-
-        final NodeTest nt = new NodeTest((DocumentTraversal) configCandidate, servicesNodes.item(0));
-        final NodeTester tester = new AbstractNodeTester() {
-
-            @Override
-            public void testElement(final Element element) throws NodeTestException {
-                if (element.getNodeName() != null) {
-                    if (element.getNodeName().equals("name")) {
-                        final String elmText = element.getTextContent();
-                        if (refNames2.contains(elmText)) {
-                            refNames2.remove(elmText);
-                        } else {
-                            throw new NodeTestException("Unexpected services defined: " + elmText);
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void noMoreNodes(final NodeTest forTest) throws NodeTestException {
-                assertEquals(Collections.<String>emptySet(), refNames2);
-                assertTrue(refNames2.toString(), refNames2.isEmpty());
-            }
-        };
-        nt.performTest(tester, Node.ELEMENT_NODE);
-    }
-
-    @Test
-    public void testConfigNetconfUnionTypes() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        commit();
-        Document response = getConfigRunning();
-        final Element ipElement = readXmlToElement(
-                "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">0:0:0:0:0:0:0:1</ip>");
-        assertContainsElement(response, readXmlToElement(
-                "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">0:0:0:0:0:0:0:1</ip>"));
-
-        assertContainsElement(response, readXmlToElement("<union-test-attr xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">456</union-test-attr>"));
-
-
-        edit("netconfMessages/editConfig_setUnions.xml");
-        commit();
-        response = getConfigRunning();
-        assertContainsElement(response, readXmlToElement(
-                "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">127.1.2.3</ip>"));
-        assertContainsElement(response, readXmlToElement("<union-test-attr xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">"
-                + "randomStringForUnion</union-test-attr>"));
-
-    }
-
-    @Test
-    public void testConfigNetconf() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        final Document configCandidate = getConfigCandidate();
-        checkBinaryLeafEdited(configCandidate);
-
-
-        // default-operation:none, should not affect binary leaf
-        edit("netconfMessages/editConfig_none.xml");
-        checkBinaryLeafEdited(getConfigCandidate());
-
-        // check after edit
-        commit();
-        final Document response = getConfigRunning();
-
-        checkBinaryLeafEdited(response);
-        checkTypeConfigAttribute(response);
-        checkTypedefs(response);
-        checkTestingDeps(response);
-        checkEnum(response);
-        checkBigDecimal(response);
-
-        edit("netconfMessages/editConfig_remove.xml");
-
-        commit();
-        assertXMLEqual(getConfigCandidate(), getConfigRunning());
-
-        final Document expectedResult =
-                XmlFileLoader.xmlFileToDocument("netconfMessages/editConfig_expectedResult.xml");
-        XMLUnit.setIgnoreWhitespace(true);
-        assertXMLEqual(expectedResult, getConfigRunning());
-        assertXMLEqual(expectedResult, getConfigCandidate());
-
-        edit("netconfMessages/editConfig_none.xml");
-        closeSession();
-        verify(sessionCloseable).close();
-        verifyNoMoreInteractions(netconfOperationRouter);
-        verifyNoMoreInteractions(netconfOperationServiceSnapshot);
-    }
-
-    private static void checkBigDecimal(final Document response) throws NodeTestException, SAXException, IOException {
-        assertContainsElement(response, readXmlToElement("<sleep-factor xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.58</sleep-factor>"));
-        // Default
-        assertContainsElement(response, readXmlToElement("<sleep-factor xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.00</sleep-factor>"));
-    }
-
-    private void closeSession() throws ParserConfigurationException, SAXException,
-            IOException, DocumentedException {
-        final Channel channel = mock(Channel.class);
-        doReturn("channel").when(channel).toString();
-        final NetconfServerSessionListener listener = mock(NetconfServerSessionListener.class);
-        final NetconfServerSession session =
-                new NetconfServerSession(listener, channel, 1L,
-                        NetconfHelloMessageAdditionalHeader.fromString("[netconf;10.12.0.102:48528;ssh;;;;;;]"));
-        final DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID, sessionCloseable);
-        closeOp.setNetconfSession(session);
-        executeOp(closeOp, "netconfMessages/closeSession.xml");
-    }
-
-    private void edit(final String resource) throws ParserConfigurationException, SAXException, IOException,
-            DocumentedException {
-        final EditConfig editOp = new EditConfig(configSubsystemFacade, NETCONF_SESSION_ID);
-        executeOp(editOp, resource);
-    }
-
-    private void commit() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
-        final Commit commitOp = new Commit(configSubsystemFacade, NETCONF_SESSION_ID);
-        executeOp(commitOp, "netconfMessages/commit.xml");
-    }
-
-    private static Document lockCandidate() throws ParserConfigurationException, SAXException, IOException,
-            DocumentedException {
-        final Lock commitOp = new Lock(NETCONF_SESSION_ID);
-        return executeOp(commitOp, "netconfMessages/lock.xml");
-    }
-
-    private static Document unlockCandidate() throws ParserConfigurationException, SAXException, IOException,
-            DocumentedException {
-        final UnLock commitOp = new UnLock(NETCONF_SESSION_ID);
-        return executeOp(commitOp, "netconfMessages/unlock.xml");
-    }
-
-    private Document getConfigCandidate() throws ParserConfigurationException, SAXException, IOException,
-            DocumentedException {
-        final GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.<String>absent(),
-                NETCONF_SESSION_ID);
-        return executeOp(getConfigOp, "netconfMessages/getConfig_candidate.xml");
-    }
-
-    private Document getConfigRunning() throws ParserConfigurationException, SAXException, IOException,
-            DocumentedException {
-        final GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.<String>absent(),
-                NETCONF_SESSION_ID);
-        return executeOp(getConfigOp, "netconfMessages/getConfig.xml");
-    }
-
-    @Ignore("second edit message corrupted")
-    @Test(expected = DocumentedException.class)
-    public void testConfigNetconfReplaceDefaultEx() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        edit("netconfMessages/editConfig_replace_default_ex.xml");
-    }
-
-    @Test
-    public void testConfigNetconfReplaceDefault() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        commit();
-        Document response = getConfigRunning();
-        final int allInstances = response.getElementsByTagName("module").getLength();
-
-        edit("netconfMessages/editConfig_replace_default.xml");
-
-        commit();
-        response = getConfigRunning();
-
-        final int afterReplace = response.getElementsByTagName("module").getLength();
-        assertEquals(4, allInstances);
-        assertEquals(2, afterReplace);
-    }
-
-    @Test
-    public void testSameAttrDifferentNamespaces() throws Exception {
-        try {
-            edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespaces.xml");
-            fail();
-        } catch (final DocumentedException e) {
-            final String message = e.getMessage();
-            assertContainsString(message, "Element simpleInt present multiple times with different namespaces");
-            assertContainsString(message, TEST_NAMESPACE);
-            assertContainsString(message, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
-        }
-    }
-
-    @Test
-    public void testDifferentNamespaceInTO() throws Exception {
-        try {
-            edit("netconfMessages/namespaces/editConfig_differentNamespaceTO.xml");
-            fail();
-        } catch (final DocumentedException e) {
-            final String message = e.getMessage();
-            assertContainsString(message, "Unrecognised elements");
-            assertContainsString(message, "simple-int2");
-            assertContainsString(message, "dto_d");
-        }
-    }
-
-    @Test
-    public void testSameAttrDifferentNamespacesList() throws Exception {
-        try {
-            edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespacesList.xml");
-            fail();
-        } catch (final DocumentedException e) {
-            final String message = e.getMessage();
-            assertContainsString(message, "Element allow-user present multiple times with different namespaces");
-            assertContainsString(message, TEST_NAMESPACE);
-            assertContainsString(message, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
-        }
-    }
-
-    @Test
-    public void testTypeNameConfigAttributeMatching() throws Exception {
-        edit("netconfMessages/editConfig.xml");
-        commit();
-        edit("netconfMessages/namespaces/editConfig_typeNameConfigAttributeMatching.xml");
-        commit();
-
-        final Document response = getConfigRunning();
-        checkTypeConfigAttribute(response);
-    }
-
-    // TODO add <modules operation="replace"> functionality
-    @Test(expected = DocumentedException.class)
-    public void testConfigNetconfReplaceModuleEx() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        edit("netconfMessages/editConfig_replace_module_ex.xml");
-    }
-
-    @Test
-    public void testUnrecognisedConfigElements() throws Exception {
-
-        final String format = "netconfMessages/unrecognised/editConfig_unrecognised%d.xml";
-        final int testsCount = 8;
-
-        for (int i = 0; i < testsCount; i++) {
-            final String file = String.format(format, i + 1);
-            LOG.info("Reading {}", file);
-            try {
-                edit(file);
-            } catch (final DocumentedException e) {
-                assertContainsString(e.getMessage(), "Unrecognised elements");
-                assertContainsString(e.getMessage(), "unknownAttribute");
-                continue;
-            }
-            fail("Unrecognised test should throw exception " + file);
-        }
-    }
-
-    @Test
-    @Ignore
-    // FIXME
-    public void testConfigNetconfReplaceModule() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        commit();
-        Document response = getConfigRunning();
-        final int allInstances = response.getElementsByTagName("instance").getLength();
-
-        edit("netconfMessages/editConfig_replace_module.xml");
-
-        commit();
-        response = getConfigRunning();
-        final int afterReplace = response.getElementsByTagName("instance").getLength();
-
-        assertEquals(4 + 4 /* Instances from services */, allInstances);
-        assertEquals(3 + 3, afterReplace);
-    }
-
-    @Test
-    public void testEx2() throws Exception {
-        //check abort before tx creation
-        assertContainsElement(discard(), readXmlToElement("<ok xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
-
-        //check abort after tx creation
-        edit("netconfMessages/editConfig.xml");
-        assertContainsElement(discard(), readXmlToElement("<ok xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
-    }
-
-    @Test
-    public void testFailedDiscardChangesAbort() throws Exception {
-        final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
-        doThrow(new RuntimeException("Mocked runtime exception, Abort has to fail")).when(facade).abortConfiguration();
-
-        final DiscardChanges discardOp = new DiscardChanges(facade, NETCONF_SESSION_ID);
-
-        try {
-            executeOp(discardOp, "netconfMessages/discardChanges.xml");
-            fail("Should've failed, abort on mocked is supposed to throw RuntimeException");
-        } catch (final DocumentedException e) {
-            assertTrue(e.getErrorTag() == DocumentedException.ErrorTag.OPERATION_FAILED);
-            assertTrue(e.getErrorSeverity() == DocumentedException.ErrorSeverity.ERROR);
-            assertTrue(e.getErrorType() == DocumentedException.ErrorType.APPLICATION);
-        }
-    }
-
-    private Document discard() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
-        final DiscardChanges discardOp = new DiscardChanges(configSubsystemFacade, NETCONF_SESSION_ID);
-        return executeOp(discardOp, "netconfMessages/discardChanges.xml");
-    }
-
-    private static void checkBinaryLeafEdited(final Document response)
-            throws NodeTestException, SAXException, IOException {
-        assertContainsElement(response, readXmlToElement("<binaryLeaf xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">YmluYXJ5</binaryLeaf>"));
-        assertContainsElement(response, readXmlToElement("<binaryLeaf xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">ZGVmYXVsdEJpbg==</binaryLeaf>"));
-    }
-
-    private static void checkTypedefs(final Document response) throws NodeTestException, SAXException, IOException {
-
-        assertContainsElement(response, readXmlToElement(
-                "<extended xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">10</extended>"));
-        // Default
-        assertContainsElement(response, readXmlToElement(
-                "<extended xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">1</extended>"));
-
-        assertContainsElement(response, readXmlToElement("<extended-twice xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">20</extended-twice>"));
-        // Default
-        assertContainsElement(response, readXmlToElement("<extended-twice xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2</extended-twice>"));
-
-        assertContainsElement(response, readXmlToElement("<extended-enum xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">two</extended-enum>"));
-        // Default
-        assertContainsElement(response, readXmlToElement("<extended-enum xmlns="
-                + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">one</extended-enum>"));
-    }
-
-    private static void assertContainsString(final String string, final String substring) {
-        assertThat(string, containsString(substring));
-    }
-
-    private static void checkEnum(final Document response) throws Exception {
-
-        final String expectedEnumContent = "two";
-
-        XMLAssert.assertXpathEvaluatesTo(expectedEnumContent,
-                getXpathForNetconfImplSubnode(INSTANCE_NAME, "extended-enum"),
-                response);
-    }
-
-    private static void checkTestingDeps(final Document response) {
-        final int testingDepsSize = response.getElementsByTagName("testing-deps").getLength();
-        assertEquals(2, testingDepsSize);
-    }
-
-    private static String getXpathForNetconfImplSubnode(final String instanceName, final String subnode) {
-        return "/urn:ietf:params:xml:ns:netconf:base:1.0:rpc-reply"
-                + "/urn:ietf:params:xml:ns:netconf:base:1.0:data"
-                + "/urn:opendaylight:params:xml:ns:yang:controller:config:modules"
-                + "/urn:opendaylight:params:xml:ns:yang:controller:config:module"
-                + "[urn:opendaylight:params:xml:ns:yang:controller:config:name='" + instanceName + "']"
-                + "/urn:opendaylight:params:xml:ns:yang:controller:test:impl:impl-netconf"
-                + "/urn:opendaylight:params:xml:ns:yang:controller:test:impl:" + subnode;
-    }
-
-    private static void checkTypeConfigAttribute(final Document response) throws Exception {
-
-        final Map<String, String> namesToTypeValues = ImmutableMap.of("instance-from-code", "configAttributeType",
-                "test2", "default-string");
-        for (final Entry<String, String> nameToExpectedValue : namesToTypeValues.entrySet()) {
-            XMLAssert.assertXpathEvaluatesTo(nameToExpectedValue.getValue(),
-                    getXpathForNetconfImplSubnode(nameToExpectedValue.getKey(), "type"),
-                    response);
-        }
-    }
-
-    private static Map<String, Map<String, ModuleMXBeanEntry>> getMbes() {
-
-        final SchemaContext schemaContext = getSchemaContext();
-        final YangStoreService yangStoreService = new YangStoreService(() -> schemaContext,
-            mock(SchemaSourceProvider.class));
-        final BindingRuntimeContext bindingRuntimeContext = mock(BindingRuntimeContext.class);
-        doReturn(schemaContext).when(bindingRuntimeContext).getSchemaContext();
-        doReturn(getEnumMapping()).when(bindingRuntimeContext).getEnumMapping(any(Class.class));
-        yangStoreService.refresh(bindingRuntimeContext);
-        final Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries = new HashMap<>();
-        mBeanEntries.putAll(yangStoreService.getModuleMXBeanEntryMap());
-
-        return mBeanEntries;
-    }
-
-    private static BiMap<String, String> getEnumMapping() {
-        final HashBiMap<String, String> enumBiMap = HashBiMap.create();
-        // Enum constants mapping from yang -> Java and back
-        enumBiMap.put("one", "One");
-        enumBiMap.put("two", "Two");
-        enumBiMap.put("version1", "Version1");
-        enumBiMap.put("version2", "Version2");
-        return enumBiMap;
-    }
-
-    private static Set<org.opendaylight.yangtools.yang.model.api.Module> getModules() {
-        return getSchemaContext().getModules();
-    }
-
-    @Test
-    public void testConfigNetconfRuntime() throws Exception {
-
-        createModule(INSTANCE_NAME);
-
-        edit("netconfMessages/editConfig.xml");
-        checkBinaryLeafEdited(getConfigCandidate());
-
-        // check after edit
-        commit();
-        Document response = get();
-
-        assertEquals(2/*With runtime beans*/ + 2 /*Without runtime beans*/, getElementsSize(response, "module"));
-        // data from state
-        assertEquals(2, getElementsSize(response, "asdf"));
-        // data from running config
-        assertEquals(2, getElementsSize(response, "simple-short"));
-
-        assertEquals(8, getElementsSize(response, "inner-running-data"));
-        assertEquals(8, getElementsSize(response, "deep2"));
-        assertEquals(8 * 4, getElementsSize(response, "inner-inner-running-data"));
-        assertEquals(8 * 4, getElementsSize(response, "deep3"));
-        assertEquals(8 * 4 * 2, getElementsSize(response, "list-of-strings"));
-        assertEquals(8, getElementsSize(response, "inner-running-data-additional",
-                "urn:opendaylight:params:xml:ns:yang:controller:test:impl"));
-        assertEquals(8, getElementsSize(response, "deep4"));
-        // TODO assert keys
-
-        final RuntimeRpc netconf = new RuntimeRpc(configSubsystemFacade, NETCONF_SESSION_ID);
-
-        response = executeOp(netconf, "netconfMessages/rpc.xml");
-        assertContainsElementWithText(response, "testarg1");
-
-        response = executeOp(netconf, "netconfMessages/rpcInner.xml");
-        final Document expectedReplyOk = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
-        XMLUnit.setIgnoreWhitespace(true);
-        XMLAssert.assertXMLEqual(expectedReplyOk, response);
-
-        response = executeOp(netconf, "netconfMessages/rpcInnerInner.xml");
-        assertContainsElementWithText(response, "true");
-
-        response = executeOp(netconf, "netconfMessages/rpcInnerInner_complex_output.xml");
-        assertContainsElementWithText(response, "1");
-        assertContainsElementWithText(response, "2");
-    }
-
-    private Document get() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
-        final Get getOp = new Get(configSubsystemFacade, NETCONF_SESSION_ID);
-        return executeOp(getOp, "netconfMessages/get.xml");
-    }
-
-    private static int getElementsSize(final Document response, final String elementName) {
-        return response.getElementsByTagName(elementName).getLength();
-    }
-
-    private static int getElementsSize(final Document response, final String elementName, final String namespace) {
-        return response.getElementsByTagNameNS(namespace, elementName).getLength();
-    }
-
-    private static Document executeOp(final NetconfOperation op,
-                                      final String filename) throws ParserConfigurationException,
-            SAXException, IOException, DocumentedException {
-
-        final Document request = XmlFileLoader.xmlFileToDocument(filename);
-
-        LOG.debug("Executing netconf operation\n{}", XmlUtil.toString(request));
-        final HandlingPriority priority = op.canHandle(request);
-
-        Preconditions.checkState(priority != HandlingPriority.CANNOT_HANDLE);
-
-        final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
-        LOG.debug("Got response\n{}", XmlUtil.toString(response));
-        return response;
-    }
-
-    private static SchemaContext getSchemaContext() {
-        return YangParserTestUtils.parseYangResources(NetconfMappingTest.class,
-            "/META-INF/yang/config@2013-04-05.yang", "/META-INF/yang/rpc-context@2013-06-17.yang",
-            "/META-INF/yang/config-test@2013-06-13.yang", "/META-INF/yang/config-test-impl@2013-04-03.yang",
-            "/META-INF/yang/test-types@2013-11-27.yang", "/META-INF/yang/test-groups@2014-12-08.yang",
-            "/META-INF/yang/ietf-inet-types@2013-07-15.yang");
-    }
-
-    private void setModule(final NetconfTestImplModuleMXBean mxBean, final ConfigTransactionJMXClient transaction,
-                           final String depName)
-            throws InstanceAlreadyExistsException, InstanceNotFoundException {
-        mxBean.setSimpleInt((long) 44);
-        mxBean.setBinaryLeaf(new byte[]{8, 7, 9});
-        final DtoD dtob = getDtoD();
-        mxBean.setDtoD(dtob);
-        //
-        final DtoC dtoa = getDtoC();
-        mxBean.setDtoC(dtoa);
-        mxBean.setSimpleBoolean(false);
-        //
-        final Peers p1 = new Peers();
-        p1.setCoreSize(44L);
-        p1.setPort("port1");
-        p1.setSimpleInt3(456);
-        final Peers p2 = new Peers();
-        p2.setCoreSize(44L);
-        p2.setPort("port23");
-        p2.setSimpleInt3(456);
-        mxBean.setPeers(Lists.<Peers>newArrayList(p1, p2));
-        // //
-        mxBean.setSimpleLong(454545L);
-        mxBean.setSimpleLong2(44L);
-        mxBean.setSimpleBigInteger(BigInteger.valueOf(999L));
-        mxBean.setSimpleByte(new Byte((byte) 4));
-        mxBean.setSimpleShort(new Short((short) 4));
-        mxBean.setSimpleTest(545);
-
-        mxBean.setComplexList(Lists.<ComplexList>newArrayList());
-        mxBean.setSimpleList(Lists.<Integer>newArrayList());
-
-        final ObjectName testingDepOn = transaction.createModule(this.factory2.getImplementationName(), depName);
-        int index = 1;
-        for (final Class<? extends AbstractServiceInterface> serviceInterface :
-                factory2.getImplementedServiceIntefaces()) {
-            final ServiceInterfaceAnnotation annotation =
-                    serviceInterface.getAnnotation(ServiceInterfaceAnnotation.class);
-            transaction.saveServiceReference(
-                    transaction.getServiceInterfaceName(annotation.namespace(), annotation.localName()),
-                    "ref_from_code_to_" + depName + "_" + index++, testingDepOn);
-
-        }
-        mxBean.setTestingDep(testingDepOn);
-    }
-
-    private static DtoD getDtoD() {
-        final DtoD dtob = new DtoD();
-        dtob.setSimpleInt1((long) 444);
-        dtob.setSimpleInt2((long) 4444);
-        dtob.setSimpleInt3(454);
-        final ComplexDtoBInner dtobInner = new ComplexDtoBInner();
-        final Deep deep = new Deep();
-        deep.setSimpleInt3(4);
-        dtobInner.setDeep(deep);
-        dtobInner.setSimpleInt3(44);
-        dtobInner.setSimpleList(Lists.newArrayList(4));
-        dtob.setComplexDtoBInner(Lists.newArrayList(dtobInner));
-        dtob.setSimpleList(Lists.newArrayList(4));
-        return dtob;
-    }
-
-    private static DtoC getDtoC() {
-        final DtoC dtoa = new DtoC();
-        // dtoa.setSimpleArg((long) 55);
-        final DtoAInner dtoAInner = new DtoAInner();
-        final DtoAInnerInner dtoAInnerInner = new DtoAInnerInner();
-        dtoAInnerInner.setSimpleArg(456L);
-        dtoAInner.setDtoAInnerInner(dtoAInnerInner);
-        dtoAInner.setSimpleArg(44L);
-        dtoa.setDtoAInner(dtoAInner);
-        return dtoa;
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/ServiceTrackerTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/ServiceTrackerTest.java
deleted file mode 100644 (file)
index dfa5d22..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services.ServiceInstance;
-
-public class ServiceTrackerTest {
-
-    @Test
-    public void test() {
-        Services.ServiceInstance serviceInstance = new ServiceInstance("module", "serviceInstance");
-
-        String string = serviceInstance.toString();
-
-        Services.ServiceInstance serviceInstance2 = Services.ServiceInstance.fromString(string);
-
-        assertEquals(serviceInstance, serviceInstance2);
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/ValidateTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/ValidateTest.java
deleted file mode 100644 (file)
index 26886d6..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.w3c.dom.Element;
-
-public class ValidateTest {
-
-    public static final String NETCONF_SESSION_ID_FOR_REPORTING = "foo";
-
-    @Test(expected = DocumentedException.class)
-    public void test() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<abc></abc>");
-        final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test(expected = DocumentedException.class)
-    public void testNoSource() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
-                + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 + "\"/>");
-        final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test(expected = DocumentedException.class)
-    public void testNoNamespace() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<validate/>");
-        final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test(expected = DocumentedException.class)
-    public void testRunningSource() throws Exception {
-
-        final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
-                + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
-                + "\"><source><running></running></source></validate>");
-        final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test(expected = DocumentedException.class)
-    public void testNoTransaction() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
-                + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
-                + "\"><source><candidate/></source></validate>");
-        final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
-        doThrow(IllegalStateException.class).when(facade).validateConfiguration();
-        final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test(expected = DocumentedException.class)
-    public void testValidationException() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
-                + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
-                + "\">><source><candidate/></source></validate>");
-        final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
-        doThrow(ValidationException.class).when(facade).validateConfiguration();
-        final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
-        validate.handleWithNoSubsequentOperations(null, xml);
-    }
-
-    @Test
-    public void testValidation() throws Exception {
-        final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
-                + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
-                + "\"><source><candidate/></source></validate>");
-        final Element okElement = XmlUtil.readXmlToElement("<ok/>");
-        final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
-        doNothing().when(facade).validateConfiguration();
-        final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
-        Element ok = validate.handleWithNoSubsequentOperations(XmlUtil.newDocument(), xml);
-        assertEquals(XmlUtil.toString(okElement), XmlUtil.toString(ok));
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java
deleted file mode 100644 (file)
index 39a3ee1..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.editconfig;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMapOf;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import java.util.Collections;
-import java.util.Map;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfigElementResolved;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementDefinition;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementResolved;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
-import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
-import org.opendaylight.controller.config.facade.xml.strategy.EditConfigStrategy;
-import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
-import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
-import org.opendaylight.controller.config.util.ConfigRegistryClient;
-import org.opendaylight.controller.config.util.ConfigTransactionClient;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.confignetconfconnector.operations.ValidateTest;
-
-public class EditConfigTest {
-
-    @Mock
-    private YangStoreService yangStoreSnapshot;
-    @Mock
-    private TransactionProvider provider;
-    @Mock
-    private ConfigRegistryClient configRegistry;
-    @Mock
-    private ConfigTransactionClient configTransactionClient;
-    @Mock
-    private ObjectName mockOn;
-
-    private ConfigSubsystemFacade cfgFacade;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-        doReturn("mockON").when(mockOn).toString();
-        doReturn(mockOn).when(provider).getTestTransaction();
-        doNothing().when(provider).validateTestTransaction(any(ObjectName.class));
-
-        doReturn(mockOn).when(provider).getTestTransaction();
-        doNothing().when(provider).abortTestTransaction(any(ObjectName.class));
-        doReturn(mockOn).when(provider).getOrCreateTransaction();
-
-        doNothing().when(provider).wipeTestTransaction(any(ObjectName.class));
-
-        doReturn(configTransactionClient).when(configRegistry).getConfigTransactionClient(any(ObjectName.class));
-        doReturn("mockConfigTransactionClient").when(configTransactionClient).toString();
-
-        doReturn(mockOn).when(configTransactionClient).lookupConfigBean(anyString(), anyString());
-
-        cfgFacade = new ConfigSubsystemFacade(configRegistry, configRegistry, yangStoreSnapshot, provider);
-    }
-
-    @Test
-    public void test() throws Exception {
-        EditConfig edit = new EditConfig(cfgFacade, ValidateTest.NETCONF_SESSION_ID_FOR_REPORTING);
-        EditConfigStrategy editStrat = mock(EditConfigStrategy.class);
-
-        doNothing().when(editStrat).executeConfiguration(anyString(), anyString(), anyMapOf(String.class,
-                AttributeConfigElement.class),
-                any(ConfigTransactionClient.class), any(ServiceRegistryWrapper.class));
-
-        ConfigExecution editConfigExecution = mockExecution(editStrat);
-
-        edit.getResponseInternal(XmlUtil.newDocument(), editConfigExecution);
-
-        verify(provider).getTestTransaction();
-        verify(provider).validateTestTransaction(mockOn);
-        verify(provider).abortTestTransaction(mockOn);
-
-        verify(provider).getOrCreateTransaction();
-
-        // For every instance execute strat
-        verify(editStrat, times(2/* Test */ + 2/* Set */ + 2/*Handle missing instance Test*/
-                + 2 /*Handle missing instance Set*/)).executeConfiguration(anyString(),
-                anyString(), anyMapOf(String.class, AttributeConfigElement.class),
-                any(ConfigTransactionClient.class), any(ServiceRegistryWrapper.class));
-    }
-
-    private ConfigExecution mockExecution(EditConfigStrategy editStrat) throws Exception {
-        ConfigExecution mock = mock(ConfigExecution.class);
-        doReturn(getMapping(editStrat)).when(mock).getResolvedXmlElements(any(ConfigTransactionClient.class));
-        doReturn(getMappingDefinition(editStrat)).when(mock).getModulesDefinition(any(ConfigTransactionClient.class));
-        doReturn(EditStrategyType.merge).when(mock).getDefaultStrategy();
-        doReturn(true).when(mock).shouldSet();
-        doReturn(true).when(mock).shouldTest();
-        doReturn(mockServices()).when(mock).getServiceRegistryWrapper(any(ConfigTransactionClient.class));
-        doReturn(new Services()).when(mock).getServices();
-        doReturn(XmlElement.fromDomElement(XmlUtil.readXmlToElement("<abc/>"))).when(mock).getConfigElement();
-        return mock;
-    }
-
-    private Object getMappingDefinition(EditConfigStrategy editStrat) {
-        final Map<String, Multimap<String, ModuleElementDefinition>> result = Maps.newHashMap();
-
-        Multimap<String, ModuleElementDefinition> innerMultimap = HashMultimap.create();
-        Map<String, AttributeConfigElement> attributes = getSimpleAttributes();
-
-        ModuleElementDefinition mockedDefinition = mock(ModuleElementDefinition.class);
-        doReturn(editStrat).when(mockedDefinition).getEditStrategy();
-        doReturn("i1").when(mockedDefinition).getInstanceName();
-        innerMultimap.put("m1", mockedDefinition);
-
-        ModuleElementDefinition mockedDefinition2 = mock(ModuleElementDefinition.class);
-        doReturn(editStrat).when(mockedDefinition2).getEditStrategy();
-        doReturn("i2").when(mockedDefinition2).getInstanceName();
-        innerMultimap.put("m1", mockedDefinition2);
-
-        result.put("n1", innerMultimap);
-
-        return result;
-    }
-
-    private static ServiceReferenceReadableRegistry mockServiceRegistry() {
-        ServiceReferenceReadableRegistry mock = mock(ServiceReferenceReadableRegistry.class);
-        doReturn(
-                Collections.emptyMap())
-                .when(mock).getServiceMapping();
-        doReturn("mockedServiceReg").when(mock).toString();
-
-        return mock;
-    }
-
-    static ServiceRegistryWrapper mockServices() {
-        return new ServiceRegistryWrapper(mockServiceRegistry());
-    }
-
-    private Map<String, Multimap<String, ModuleElementResolved>> getMapping(EditConfigStrategy editStrat) {
-        final Map<String, Multimap<String, ModuleElementResolved>> result = Maps.newHashMap();
-
-        Multimap<String, ModuleElementResolved> innerMultimap = HashMultimap.create();
-        Map<String, AttributeConfigElement> attributes = getSimpleAttributes();
-
-        InstanceConfigElementResolved ice1 = mock(InstanceConfigElementResolved.class);
-        doReturn(attributes).when(ice1).getConfiguration();
-        doReturn(editStrat).when(ice1).getEditStrategy();
-        innerMultimap.put("m1", new ModuleElementResolved("i1", ice1));
-
-        InstanceConfigElementResolved ice2 = mock(InstanceConfigElementResolved.class);
-        doReturn(attributes).when(ice2).getConfiguration();
-        doReturn(editStrat).when(ice2).getEditStrategy();
-        innerMultimap.put("m1", new ModuleElementResolved("i2", ice2));
-
-        result.put("n1", innerMultimap);
-
-        return result;
-    }
-
-    static Map<String, AttributeConfigElement> getSimpleAttributes() {
-        final Map<String, AttributeConfigElement> attributes = Maps.newHashMap();
-        AttributeConfigElement ace1 = mock(AttributeConfigElement.class);
-        doReturn("abcd").when(ace1).getResolvedDefaultValue();
-        doReturn(Optional.<String>of("abc")).when(ace1).getResolvedValue();
-        doReturn("mockedAce1").when(ace1).toString();
-        doReturn("jmxNameAce1").when(ace1).getJmxName();
-        attributes.put("a1", ace1);
-        return attributes;
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/MergeEditConfigStrategyTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/MergeEditConfigStrategyTest.java
deleted file mode 100644 (file)
index 12b6bf4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.editconfig;
-
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.createReadOnlyModuleON;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import java.util.List;
-import java.util.Map;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
-import org.opendaylight.controller.config.facade.xml.strategy.MergeEditConfigStrategy;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModule;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleMXBean;
-
-public class MergeEditConfigStrategyTest extends AbstractConfigTest {
-    private static final MultipleDependenciesModuleFactory FACTORY = new MultipleDependenciesModuleFactory();
-    private static final String FACTORY_NAME = FACTORY.getImplementationName();
-    public static final String PARENT = "parent";
-    public static final String D1 = "d1";
-    public static final String D2 = "d2";
-    public static final String D3 = "d3";
-
-    @Before
-    public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, FACTORY));
-
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        ObjectName d1 = transaction.createModule(FACTORY_NAME, D1);
-        ObjectName d2 = transaction.createModule(FACTORY_NAME, D2);
-        ObjectName parent = transaction.createModule(FACTORY_NAME, PARENT);
-        MultipleDependenciesModuleMXBean multipleDependenciesModuleMXBean = transaction.newMXBeanProxy(parent,
-                MultipleDependenciesModuleMXBean.class);
-        multipleDependenciesModuleMXBean.setTestingDeps(asList(d1, d2));
-        transaction.createModule(FACTORY_NAME, D3);
-        transaction.commit();
-    }
-
-    @Test
-    public void testMergingOfObjectNames() throws Exception {
-        final MergeEditConfigStrategy strategy = new MergeEditConfigStrategy();
-        final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-
-        // add D3
-
-        AttributeConfigElement attributeConfigElement = mock(AttributeConfigElement.class);
-        doReturn(Optional.of(new ObjectName[] {createReadOnlyModuleON(FACTORY_NAME, D3)}))
-                .when(attributeConfigElement).getResolvedValue();
-        doReturn("mocked").when(attributeConfigElement).toString();
-        String attributeName = MultipleDependenciesModule.testingDepsJmxAttribute.getAttributeName();
-        doReturn(attributeName).when(attributeConfigElement).getJmxName();
-        Map<String, AttributeConfigElement> configuration = ImmutableMap.of(
-                attributeName,
-                attributeConfigElement);
-
-        strategy.executeConfiguration(FACTORY_NAME, PARENT, configuration, transaction,
-                mock(ServiceRegistryWrapper.class));
-        transaction.commit();
-
-        // parent's attribute should contain d1,d2,d3
-        MultipleDependenciesModuleMXBean proxy = configRegistryClient.newMXBeanProxy(
-                createReadOnlyModuleON(FACTORY_NAME, PARENT),
-                MultipleDependenciesModuleMXBean.class);
-        List<ObjectName> testingDeps = proxy.getTestingDeps();
-        List<ObjectName> expected = asList(createReadOnlyModuleON(FACTORY_NAME, D1),
-                createReadOnlyModuleON(FACTORY_NAME, D2),
-                createReadOnlyModuleON(FACTORY_NAME, D3));
-        assertEquals(expected, testingDeps);
-    }
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/ReplaceEditConfigStrategyTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/operations/editconfig/ReplaceEditConfigStrategyTest.java
deleted file mode 100644 (file)
index 397feec..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.operations.editconfig;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.collect.Sets;
-import java.util.Map;
-import javax.management.Attribute;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.strategy.ReplaceEditConfigStrategy;
-import org.opendaylight.controller.config.util.ConfigTransactionClient;
-
-public class ReplaceEditConfigStrategyTest {
-
-    @Mock
-    private ConfigTransactionClient ta;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        doNothing().when(ta).destroyModule(anyString(), anyString());
-        doReturn(mockON()).when(ta).lookupConfigBean(anyString(), anyString());
-        doNothing().when(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
-    }
-
-    @Test
-    public void test() throws Exception {
-        ReplaceEditConfigStrategy strat = new ReplaceEditConfigStrategy();
-
-        Map<String, AttributeConfigElement> map = EditConfigTest.getSimpleAttributes();
-
-        doReturn(Sets.newHashSet(mockON(), mockON())).when(ta).lookupConfigBeans();
-
-        strat.executeConfiguration("m1", "i1", map, ta, EditConfigTest.mockServices());
-
-        verify(ta).lookupConfigBean(anyString(), anyString());
-        verify(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
-    }
-
-    ObjectName mockON() {
-        ObjectName mock = mock(ObjectName.class);
-        doReturn("mockON").when(mock).toString();
-        return mock;
-    }
-
-}
diff --git a/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java b/netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java
deleted file mode 100644 (file)
index f286bd3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  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.netconf.confignetconfconnector.osgi;
-
-import static junit.framework.TestCase.assertTrue;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.Validate;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-
-public class NetconfOperationServiceImplTest {
-
-    @Test
-    public void testOperationService() {
-        final ConfigSubsystemFacade configSubsystemFacade = mock(ConfigSubsystemFacade.class);
-        final NetconfOperationService netconfOperationService =
-                new NetconfOperationServiceImpl(configSubsystemFacade, "reportingID");
-
-        // testing operations in Set from NetconfOperationProvider
-
-        Set<NetconfOperation> operations = netconfOperationService.getNetconfOperations();
-
-        assertTrue(containInstance(operations, GetConfig.class));
-        assertTrue(containInstance(operations, EditConfig.class));
-        assertTrue(containInstance(operations, Commit.class));
-        assertTrue(containInstance(operations, Lock.class));
-        assertTrue(containInstance(operations, UnLock.class));
-        assertTrue(containInstance(operations, Get.class));
-        assertTrue(containInstance(operations, DiscardChanges.class));
-        assertTrue(containInstance(operations, Validate.class));
-        assertTrue(containInstance(operations, RuntimeRpc.class));
-
-        // verify closing service
-
-        doNothing().when(configSubsystemFacade).close();
-        netconfOperationService.close();
-
-        verify(configSubsystemFacade, times(1)).close();
-    }
-
-    private boolean containInstance(final Set<NetconfOperation> operations, final Class<?> cls) {
-        return operations.stream().filter(cls::isInstance).findFirst().isPresent();
-    }
-}
index 97ec648e1245603507e5b0cef5425574f63df333..34c07edc771f48bf6697f383cd4b1d4d6444e1d7 100644 (file)
       <artifactId>yang-data-codec-xml</artifactId>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
index d83cfb56f40d07bf0965a4ebd56c7303686efa2b..61a3b950a794d7b08535c7cfffe3a150677ef7ee 100644 (file)
@@ -13,8 +13,8 @@ import com.google.common.collect.Sets;
 import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
-import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -63,4 +63,4 @@ public class CurrentSchemaContext implements SchemaContextListener, AutoCloseabl
         listeners1.add(listener);
         return () -> listeners1.remove(listener);
     }
-}
\ No newline at end of file
+}
index d957097ae8fe68b45d4430c39ad0905600701a76..d88e64ef15aba94bd1286493b04523ca4418425a 100644 (file)
@@ -18,11 +18,11 @@ import java.util.HashSet;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.controller.config.util.capability.YangModuleCapability;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.netconf.api.capability.Capability;
+import org.opendaylight.netconf.api.capability.YangModuleCapability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
index 78680e00ba24ef08f5a69a26127c64203b9dfd53..b906b741e14c4d81dbd1c8f32702ab806e49d973 100644 (file)
@@ -13,13 +13,13 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,7 +81,7 @@ public class TransactionProvider implements AutoCloseable {
             future.checkedGet();
         } catch (final TransactionCommitFailedException e) {
             LOG.debug("Transaction {} failed on", candidateTransaction, e);
-            final String cause = e.getCause() != null ? (" Cause: " + e.getCause().getMessage()) : "";
+            final String cause = e.getCause() != null ? " Cause: " + e.getCause().getMessage() : "";
             throw new DocumentedException(
                     "Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting + cause, e,
                     ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
index 125f6b91cee00fcf88bad85b5d432cec64bba0d0..0efeab08ad45a1c63f2b70ae76c19b1c45e3b1b3 100644 (file)
@@ -16,12 +16,12 @@ import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Map;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.opendaylight.yangtools.yang.common.QName;
index 8489faefce24e3ddbaaa7b7c92d12c13ea309be7..38a24ae79ec37d545492405af63daeaf24c2bba2 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
index 9f0f9d9910d02457215651fe2274488498f6680a..df29fb30e152447a7d985d8f7583bb8663425887 100644 (file)
@@ -9,15 +9,15 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 9944f4e9ffe32b936a0a35c4ee3ef9f887125b4e..3e90745d334643bf9145380c621d39ef8245aac2 100644 (file)
@@ -11,13 +11,13 @@ package org.opendaylight.netconf.mdsal.connector.ops;
 import com.google.common.base.Optional;
 import java.util.HashMap;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
index 2da085290e7c434588f6226569d51cf906d3a57f..6776b6be261ba9432db0d4445a1df6e2ad83982f 100644 (file)
@@ -14,15 +14,15 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.mdsal.connector.ops.DataTreeChangeTracker.DataTreeChange;
index 3c0089d227a1d8c39f0261f7a35b338f85c51cac..c39c61891eb26b7265678861f73423403019b571 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 6d4ba4305ae99a1799d5e8ed90f768e76f44172a..a2f8c1b6ef3d6f86bee692b606c9689ef2aa1cd9 100644 (file)
@@ -21,18 +21,17 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
@@ -182,7 +181,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
         final Map<String, Attr> attributes = requestElement.getAttributes();
 
         final Element response = handle(document, operationElement, subsequentOperation);
-        final Element rpcReply = XmlUtil.createElement(document, XmlMappingConstants.RPC_REPLY_KEY,
+        final Element rpcReply = XmlUtil.createElement(document, XmlNetconfConstants.RPC_REPLY_KEY,
                 Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
 
         if (XmlElement.fromDomElement(response).hasNamespace()) {
@@ -207,7 +206,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
 
     private Node transformNormalizedNode(final Document document, final NormalizedNode<?, ?> data,
                                          final SchemaPath rpcOutputPath) {
-        final DOMResult result = new DOMResult(document.createElement(XmlMappingConstants.RPC_REPLY_KEY));
+        final DOMResult result = new DOMResult(document.createElement(XmlNetconfConstants.RPC_REPLY_KEY));
 
         final XMLStreamWriter xmlWriter = getXmlStreamWriter(result);
 
@@ -259,7 +258,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
     @Nullable
     private NormalizedNode<?, ?> rpcToNNode(final XmlElement element, @Nullable final ContainerSchemaNode input)
             throws DocumentedException {
-        if (input.getChildNodes().isEmpty()) {
+        if (input == null || input.getChildNodes().isEmpty()) {
             return null;
         }
 
index d0b32c10fbf7b603521fef257ebe78eab0ed853d..3b5eb3c7d55fad7122ac6edd73ae5ed59c6f4809 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 4fa0baa805aa25d8915c17cb67524422ecb99c96..eb6c095020380df7015a95503eb8c09d28fe107c 100644 (file)
@@ -17,11 +17,11 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.ops.Datastore;
index c4cd6b7726b85236a1e29410c3d27b871d256d5c..1c88362cee70cddf9ebc63e64a86e628841be54d 100644 (file)
@@ -22,9 +22,9 @@ import java.util.List;
 import java.util.Map;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLStreamWriter;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.MissingNameSpaceException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.MissingNameSpaceException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 376d358c283418a61030c5c21588e3f51ca4424a..603e6d4d031f3dd50857373cf40a39efc8759816 100644 (file)
@@ -9,16 +9,16 @@
 package org.opendaylight.netconf.mdsal.connector.ops.get;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.mdsal.connector.ops.Datastore;
index d383cee471118a4ea492083b78310a5595b9901e..30b5079925e9eb768775a2ebd1045805e120a68d 100644 (file)
@@ -10,16 +10,16 @@ package org.opendaylight.netconf.mdsal.connector.ops.get;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.mdsal.connector.ops.Datastore;
index 555f201e8db371a9e0af889b3e499230d725a6c5..5a9a6a60a60258388b5724e664f18d13ec00ac07 100644 (file)
@@ -29,12 +29,12 @@ import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
@@ -233,4 +233,4 @@ abstract class AbstractNetconfOperationTest {
             new StreamResult(writer));
         LOG.warn(writer.getBuffer().toString());
     }
-}
\ No newline at end of file
+}
index e634dc4cc596e97a53c1bdfa5527c89b9c2a55d9..14c177b80616848cf8946c6703249f67eecf8b36 100644 (file)
@@ -13,10 +13,10 @@ import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
 
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.w3c.dom.Document;
@@ -206,4 +206,4 @@ public class CopyConfigTest extends AbstractNetconfOperationTest {
             getTransactionProvider());
         return executeOperation(copyConfig, resource);
     }
-}
\ No newline at end of file
+}
index a7709ecd0ebb6b9db70c610d6a620d5a0ef9f3ab..3361ec5ea4dd387cfe110b91c27ef4b56ca625df 100644 (file)
@@ -21,12 +21,12 @@ import javax.xml.transform.stream.StreamResult;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
index 60ac65ab688f0c6a51264b99f79784cc66db5299..28508dbad5d3536fc54dea7c5dcd52f1d2e21bf4 100644 (file)
@@ -32,17 +32,17 @@ import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
index d90e31b071a524588099e184ae205c613797b8a9..779d49348228741bcd0f8a6ec55fa895e5b74fd3 100644 (file)
@@ -16,8 +16,8 @@ import java.math.BigInteger;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index cec6855c4609f2312488f4876aea1be3ce09d82f..04a3a1414cbab3527945cee77f056c29cc9b32fc 100644 (file)
@@ -28,8 +28,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.model.InitializationError;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index de4f801ab419f083d237ecf22e161020724fe14c..7aa7df12cf4ad31b7b98cbb619a7e076cf8ca0be 100644 (file)
@@ -14,8 +14,8 @@ import static org.mockito.Mockito.mock;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 95e7a12cb6bc13fbe04eada6a0b1aad7cd50a108..873fa7bf99ed2b7244f9d0f7e510fd7b533dbefa 100644 (file)
@@ -1,13 +1,13 @@
-error=org.opendaylight.controller.config.util.xml.DocumentedException
+error=org.opendaylight.netconf.api.DocumentedException
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/choiceList
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/maincontent
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/choiceList
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/(urn:dummy:aug?revision=1999-08-17)augmented-leaf
-error=org.opendaylight.controller.config.util.xml.DocumentedException
+error=org.opendaylight.netconf.api.DocumentedException
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/choiceList/choiceList[{(urn:dummy:mod-0?revision=2016-03-01)name=aaa}]
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/multi-key-list
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/multi-key-list/multi-key-list[{(urn:dummy:mod-0?revision=2016-03-01)id1=aaa, (urn:dummy:mod-0?revision=2016-03-01)id2=bbb}]
 success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/multi-key-list
-success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/inner/inner-multi-key-list/inner-multi-key-list[{(urn:dummy:mod-0?revision=2016-03-01)id1=aaa, (urn:dummy:mod-0?revision=2016-03-01)id2=bbb}]
\ No newline at end of file
+success=/(urn:dummy:mod-0?revision=2016-03-01)mainroot/inner/inner-multi-key-list/inner-multi-key-list[{(urn:dummy:mod-0?revision=2016-03-01)id1=aaa, (urn:dummy:mod-0?revision=2016-03-01)id2=bbb}]
index deeb5e7366f6c1b0e63314961afe674d08973a11..d9cc172bb8205ee6cd3b215e5559655110c18a45 100644 (file)
       <artifactId>slf4j-api</artifactId>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
index a163dd7540abf65659985e541ee594da24b3f83e..cb98d40892207887c2801d54d2fa6fca91e510e8 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
 
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
@@ -77,4 +77,4 @@ public class MdsalMonitoringMapperFactory implements NetconfOperationServiceFact
         netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
     }
 
-}
\ No newline at end of file
+}
index f0fb994617cd65c7154825e94a4a621d3b9d64a2..3feea7de55646ee05e01d9633286453b34c2d44d 100644 (file)
                     </instructions>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 </project>
index b6c92d0a852f2dec5f569d2d32985e66f35f423f..1846494aa833df67c954b46f7e84528f210b0884 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.netconf.mdsal.notification;
 
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
index 980315c306c06e354c621753b12c44225a8d91e0..d028269befdf55b665884d635fa4ea841a9356dd 100644 (file)
             <artifactId>yang-test-util</artifactId>
         </dependency>
     </dependencies>
-    
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index ab91bd694b03a975786857165d1a2b212b1db78e..3fdcb7cd81d0c6c8783525e00f735616f507cec4 100644 (file)
@@ -77,16 +77,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <artifactId>hamcrest-core</artifactId>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 26609d21e31196c1291d72e516b6847727ecc28e..cdaa00bc131ff1bc12b06c9c3aee4438221a82d7 100644 (file)
@@ -23,13 +23,13 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.regex.Pattern;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
@@ -38,6 +38,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
 import org.opendaylight.controller.messagebus.app.util.TopicDOMNotification;
 import org.opendaylight.controller.messagebus.app.util.Util;
 import org.opendaylight.controller.messagebus.spi.EventSource;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.NetconfUtil;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
@@ -122,8 +123,9 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
                 .put(cntr.getNotificationUrnPrefix(), cntr);
         Map<String, Stream> availableStreams = getAvailableStreams();
         LOG.debug("Stream configuration compare...");
-        for (String urnPrefix : this.urnPrefixToStreamMap.keySet()) {
-            final String streamName = this.urnPrefixToStreamMap.get(urnPrefix);
+        for (Entry<String, String> entry : this.urnPrefixToStreamMap.entrySet()) {
+            String urnPrefix = entry.getKey();
+            final String streamName = entry.getValue();
             LOG.debug("urnPrefix: {} streamName: {}", urnPrefix, streamName);
             if (availableStreams.containsKey(streamName)) {
                 LOG.debug("Stream containig on device");
index 91df5f781218707acccf96c1f1319d06627af033..6360136b9fd3f401cf1b6c2e2f0b558ebb8f705a 100644 (file)
@@ -114,22 +114,6 @@ public final class NetconfEventSourceManager implements DataTreeChangeListener<N
         }
     }
 
-    private void nodeUpdated(final InstanceIdentifier<?> key, final Node node) {
-        Preconditions.checkNotNull(key);
-        if (!validateNode(node)) {
-            LOG.warn("NodeUpdated event : Node [{}] is null or not valid.", key.toString());
-            return;
-        }
-
-        LOG.info("Netconf event source [{}] is updating...", key.toString());
-        NetconfEventSourceRegistration nesr = registrationMap.get(key);
-        if (nesr != null) {
-            nesr.updateStatus();
-        } else {
-            nodeCreated(key, node);
-        }
-    }
-
     private void nodeRemoved(final InstanceIdentifier<?> key) {
         Preconditions.checkNotNull(key);
         LOG.info("Netconf event source [{}] is removing...", key.toString());
index a20589007420fd6ca32d57a83dc2851e031bca3d..84fcfd01124e878ed79d5c362b771f79a9a3327d 100644 (file)
   <name>${project.artifactId}</name>
   <packaging>bundle</packaging>
 
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-artifacts</artifactId>
-        <version>0.9.0-SNAPSHOT</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <groupId>${project.groupId}</groupId>
       <artifactId>protocol-framework</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-util</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.mdsal.model</groupId>
       <artifactId>ietf-inet-types-2013-07-15</artifactId>
       <groupId>org.opendaylight.mdsal.model</groupId>
       <artifactId>ietf-yang-types-20130715</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-model-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>mockito-configuration</artifactId>
     </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/DocumentedException.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/DocumentedException.java
new file mode 100644 (file)
index 0000000..ec6b060
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api;
+
+import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.RPC_REPLY_KEY;
+import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
+
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Checked exception to communicate an error that needs to be sent to the
+ * netconf client.
+ */
+public class DocumentedException extends Exception {
+
+    public static final String RPC_ERROR = "rpc-error";
+    public static final String ERROR_TYPE = "error-type";
+    public static final String ERROR_TAG = "error-tag";
+    public static final String ERROR_SEVERITY = "error-severity";
+    public static final String ERROR_APP_TAG = "error-app-tag";
+    public static final String ERROR_PATH = "error-path";
+    public static final String ERROR_MESSAGE = "error-message";
+    public static final String ERROR_INFO = "error-info";
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(DocumentedException.class);
+
+    private static final DocumentBuilderFactory BUILDER_FACTORY;
+
+    static {
+        BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+        try {
+            BUILDER_FACTORY.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+            BUILDER_FACTORY.setFeature("http://xml.org/sax/features/external-general-entities", false);
+            BUILDER_FACTORY.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+            BUILDER_FACTORY.setXIncludeAware(false);
+            BUILDER_FACTORY.setExpandEntityReferences(false);
+        } catch (final ParserConfigurationException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+        BUILDER_FACTORY.setNamespaceAware(true);
+        BUILDER_FACTORY.setCoalescing(true);
+        BUILDER_FACTORY.setIgnoringElementContentWhitespace(true);
+        BUILDER_FACTORY.setIgnoringComments(true);
+    }
+
+    public enum ErrorType {
+        TRANSPORT("transport"), RPC("rpc"), PROTOCOL("protocol"), APPLICATION("application");
+
+        private final String typeValue;
+
+        ErrorType(final String typeValue) {
+            this.typeValue = Preconditions.checkNotNull(typeValue);
+        }
+
+        public String getTypeValue() {
+            return this.typeValue;
+        }
+
+        public static ErrorType from(final String text) {
+            for (ErrorType e : values()) {
+                if (e.getTypeValue().equalsIgnoreCase(text)) {
+                    return e;
+                }
+            }
+
+            return APPLICATION;
+        }
+    }
+
+    public enum ErrorTag {
+        ACCESS_DENIED("access-denied"),
+        BAD_ATTRIBUTE("bad-attribute"),
+        BAD_ELEMENT("bad-element"),
+        DATA_EXISTS("data-exists"),
+        DATA_MISSING("data-missing"),
+        IN_USE("in-use"),
+        INVALID_VALUE("invalid-value"),
+        LOCK_DENIED("lock-denied"),
+        MALFORMED_MESSAGE("malformed-message"),
+        MISSING_ATTRIBUTE("missing-attribute"),
+        MISSING_ELEMENT("missing-element"),
+        OPERATION_FAILED("operation-failed"),
+        OPERATION_NOT_SUPPORTED("operation-not-supported"),
+        RESOURCE_DENIED("resource-denied"),
+        ROLLBCK_FAILED("rollback-failed"),
+        TOO_BIG("too-big"),
+        UNKNOWN_ATTRIBUTE("unknown-attribute"),
+        UNKNOWN_ELEMENT("unknown-element"),
+        UNKNOWN_NAMESPACE("unknown-namespace");
+
+        private final String tagValue;
+
+        ErrorTag(final String tagValue) {
+            this.tagValue = tagValue;
+        }
+
+        public String getTagValue() {
+            return this.tagValue;
+        }
+
+        public static ErrorTag from(final String text) {
+            for (ErrorTag e : values()) {
+                if (e.getTagValue().equals(text)) {
+                    return e;
+                }
+            }
+
+            return OPERATION_FAILED;
+        }
+    }
+
+    public enum ErrorSeverity {
+        ERROR("error"), WARNING("warning");
+
+        private final String severityValue;
+
+        ErrorSeverity(final String severityValue) {
+            this.severityValue = Preconditions.checkNotNull(severityValue);
+        }
+
+        public String getSeverityValue() {
+            return this.severityValue;
+        }
+
+        public static ErrorSeverity from(final String text) {
+            for (ErrorSeverity e : values()) {
+                if (e.getSeverityValue().equalsIgnoreCase(text)) {
+                    return e;
+                }
+            }
+
+            return ERROR;
+        }
+    }
+
+    private final ErrorType errorType;
+    private final ErrorTag errorTag;
+    private final ErrorSeverity errorSeverity;
+    private final Map<String, String> errorInfo;
+
+    public DocumentedException(final String message) {
+        this(message, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE,
+                DocumentedException.ErrorSeverity.ERROR);
+    }
+
+    public DocumentedException(final String message, final Exception cause) {
+        this(message, cause, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE,
+                DocumentedException.ErrorSeverity.ERROR);
+    }
+
+    public DocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
+            final ErrorSeverity errorSeverity) {
+        this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+    }
+
+    public DocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
+            final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
+        super(message);
+        this.errorType = errorType;
+        this.errorTag = errorTag;
+        this.errorSeverity = errorSeverity;
+        this.errorInfo = errorInfo;
+    }
+
+    public DocumentedException(final String message, final Exception cause, final ErrorType errorType,
+            final ErrorTag errorTag, final ErrorSeverity errorSeverity) {
+        this(message, cause, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+    }
+
+    public DocumentedException(final String message, final Exception cause, final ErrorType errorType,
+            final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
+        super(message, cause);
+        this.errorType = errorType;
+        this.errorTag = errorTag;
+        this.errorSeverity = errorSeverity;
+        this.errorInfo = errorInfo;
+    }
+
+    public static <E extends Exception> DocumentedException wrap(final E exception) throws DocumentedException {
+        final Map<String, String> errorInfo = new HashMap<>();
+        errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Exception thrown");
+        throw new DocumentedException(exception.getMessage(), exception, ErrorType.APPLICATION,
+                ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR, errorInfo);
+    }
+
+    public static DocumentedException fromXMLDocument(final Document fromDoc) {
+
+        ErrorType errorType = ErrorType.APPLICATION;
+        ErrorTag errorTag = ErrorTag.OPERATION_FAILED;
+        ErrorSeverity errorSeverity = ErrorSeverity.ERROR;
+        Map<String, String> errorInfo = null;
+        String errorMessage = "";
+
+        Node rpcReply = fromDoc.getDocumentElement();
+
+        // FIXME: BUG? - we only handle one rpc-error.
+
+        NodeList replyChildren = rpcReply.getChildNodes();
+        for (int i = 0; i < replyChildren.getLength(); i++) {
+            Node replyChild = replyChildren.item(i);
+            if (RPC_ERROR.equals(replyChild.getNodeName())) {
+                NodeList rpcErrorChildren = replyChild.getChildNodes();
+                for (int j = 0; j < rpcErrorChildren.getLength(); j++) {
+                    Node rpcErrorChild = rpcErrorChildren.item(j);
+                    if (ERROR_TYPE.equals(rpcErrorChild.getNodeName())) {
+                        errorType = ErrorType.from(rpcErrorChild.getTextContent());
+                    } else if (ERROR_TAG.equals(rpcErrorChild.getNodeName())) {
+                        errorTag = ErrorTag.from(rpcErrorChild.getTextContent());
+                    } else if (ERROR_SEVERITY.equals(rpcErrorChild.getNodeName())) {
+                        errorSeverity = ErrorSeverity.from(rpcErrorChild.getTextContent());
+                    } else if (ERROR_MESSAGE.equals(rpcErrorChild.getNodeName())) {
+                        errorMessage = rpcErrorChild.getTextContent();
+                    } else if (ERROR_INFO.equals(rpcErrorChild.getNodeName())) {
+                        errorInfo = parseErrorInfo(rpcErrorChild);
+                    }
+                }
+
+                break;
+            }
+        }
+
+        return new DocumentedException(errorMessage, errorType, errorTag, errorSeverity, errorInfo);
+    }
+
+    private static Map<String, String> parseErrorInfo(final Node node) {
+        Map<String, String> infoMap = new HashMap<>();
+        NodeList children = node.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            Node child = children.item(i);
+            if (child.getNodeType() == Node.ELEMENT_NODE) {
+                infoMap.put(child.getNodeName(), child.getTextContent());
+            }
+        }
+
+        return infoMap;
+    }
+
+    public ErrorType getErrorType() {
+        return this.errorType;
+    }
+
+    public ErrorTag getErrorTag() {
+        return this.errorTag;
+    }
+
+    public ErrorSeverity getErrorSeverity() {
+        return this.errorSeverity;
+    }
+
+    public Map<String, String> getErrorInfo() {
+        return this.errorInfo;
+    }
+
+    public Document toXMLDocument() {
+        Document doc = null;
+        try {
+            doc = BUILDER_FACTORY.newDocumentBuilder().newDocument();
+
+            Node rpcReply = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, RPC_REPLY_KEY);
+            doc.appendChild(rpcReply);
+
+            Node rpcError = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, RPC_ERROR);
+            rpcReply.appendChild(rpcError);
+
+            rpcError.appendChild(createTextNode(doc, ERROR_TYPE, getErrorType().getTypeValue()));
+            rpcError.appendChild(createTextNode(doc, ERROR_TAG, getErrorTag().getTagValue()));
+            rpcError.appendChild(createTextNode(doc, ERROR_SEVERITY, getErrorSeverity().getSeverityValue()));
+            rpcError.appendChild(createTextNode(doc, ERROR_MESSAGE, getLocalizedMessage()));
+
+            Map<String, String> errorInfoMap = getErrorInfo();
+            if (errorInfoMap != null && !errorInfoMap.isEmpty()) {
+                /*
+                 * <error-info> <bad-attribute>message-id</bad-attribute>
+                 * <bad-element>rpc</bad-element> </error-info>
+                 */
+
+                Node errorInfoNode = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, ERROR_INFO);
+                errorInfoNode.setPrefix(rpcReply.getPrefix());
+                rpcError.appendChild(errorInfoNode);
+
+                for (Entry<String, String> entry : errorInfoMap.entrySet()) {
+                    errorInfoNode.appendChild(createTextNode(doc, entry.getKey(), entry.getValue()));
+                }
+            }
+        } catch (final ParserConfigurationException e) {
+            // this shouldn't happen
+            LOG.error("Error outputting to XML document", e);
+        }
+
+        return doc;
+    }
+
+    private Node createTextNode(final Document doc, final String tag, final String textContent) {
+        Node node = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, tag);
+        node.setTextContent(textContent);
+        return node;
+    }
+
+    @Override
+    public String toString() {
+        return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + this.errorType
+                + ", errorTag=" + this.errorTag + ", errorSeverity=" + this.errorSeverity + ", errorInfo="
+                + this.errorInfo + '}';
+    }
+}
index 8e289fa9e82dc243df9346da319b756ebbff9b83..87b2ac729883ed9fa0527c4ac1d8893bcacdf393 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.netconf.api;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.w3c.dom.Document;
 
 /**
@@ -43,6 +43,7 @@ public class NetconfDocumentedException extends DocumentedException {
         super(message, cause, errorType, errorTag, errorSeverity, errorInfo);
     }
 
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
     public NetconfDocumentedException(final DocumentedException exception) {
         super(exception.getMessage(), (Exception) exception.getCause(), exception.getErrorType(),
                 exception.getErrorTag(), exception.getErrorSeverity(), exception.getErrorInfo());
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/BasicCapability.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/BasicCapability.java
new file mode 100644 (file)
index 0000000..ea025d8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api.capability;
+
+import com.google.common.base.Optional;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Capability representing a basic, one-line, string based capability.
+ */
+public class BasicCapability implements Capability {
+
+    private final String capability;
+
+    public BasicCapability(final String capability) {
+        this.capability = capability;
+    }
+
+    @Override
+    public String getCapabilityUri() {
+        return capability;
+    }
+
+    @Override
+    public Optional<String> getModuleNamespace() {
+        return Optional.absent();
+    }
+
+    @Override
+    public Optional<String> getModuleName() {
+        return Optional.absent();
+    }
+
+    @Override
+    public Optional<String> getRevision() {
+        return Optional.absent();
+    }
+
+    @Override
+    public Optional<String> getCapabilitySchema() {
+        return Optional.absent();
+    }
+
+    @Override
+    public Collection<String> getLocation() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public String toString() {
+        return capability;
+    }
+}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/Capability.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/Capability.java
new file mode 100644 (file)
index 0000000..f17ce50
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api.capability;
+
+import com.google.common.base.Optional;
+import java.util.Collection;
+
+/**
+ * Contains capability URI announced by server hello message and optionally its
+ * corresponding yang schema that can be retrieved by get-schema rpc.
+ */
+public interface Capability {
+
+    String getCapabilityUri();
+
+    Optional<String> getModuleNamespace();
+
+    Optional<String> getModuleName();
+
+    Optional<String> getRevision();
+
+    Optional<String> getCapabilitySchema();
+
+    Collection<String> getLocation();
+}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java
new file mode 100644 (file)
index 0000000..6546f66
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api.capability;
+
+import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+/**
+ * Yang model representing capability.
+ */
+public final class YangModuleCapability extends BasicCapability {
+
+    private final String content;
+    private final String revision;
+    private final String moduleName;
+    private final String moduleNamespace;
+
+    public YangModuleCapability(final Module module, final String moduleContent) {
+        super(toCapabilityURI(module));
+        this.content = moduleContent;
+        this.moduleName = module.getName();
+        this.moduleNamespace = module.getNamespace().toString();
+        this.revision = module.getRevision().map(Revision::toString).orElse(null);
+    }
+
+    @Override
+    public Optional<String> getCapabilitySchema() {
+        return Optional.of(content);
+    }
+
+    private static String toCapabilityURI(final Module module) {
+        final StringBuilder sb = new StringBuilder();
+        sb.append(module.getNamespace()).append("?module=").append(module.getName());
+
+        final java.util.Optional<Revision> rev = module.getRevision();
+        if (rev.isPresent()) {
+            sb.append("&revision=").append(rev.get());
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public Optional<String> getModuleName() {
+        return Optional.of(moduleName);
+    }
+
+    @Override
+    public Optional<String> getModuleNamespace() {
+        return Optional.of(moduleNamespace);
+    }
+
+    @Override
+    public Optional<String> getRevision() {
+        return Optional.of(revision);
+    }
+}
index f3266968f0a27f10f02a8921ec35daa0a2cf68c2..d450672638c2aaa55d4d6ba23e3ada9907519fcd 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.netconf.api.messages;
 import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.util.Set;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
index 77f73cc913f5c3e7f293c9b0fd892d47676f6260..360a58882640a5a458801bb28b7cddde7c9b2069 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.netconf.api.monitoring;
 
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 
 public interface CapabilityListener {
 
index 3abeeea40c4e0a68f00ebd29e8f8d6ccf3533353..0c7856f84c8a8c3e6e8fc03568876335e80b187b 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.netconf.api.util;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
 import java.util.Set;
 
 /**
@@ -25,7 +25,7 @@ public final class NetconfConstants {
     public static final String NETCONF_MONITORING = "ietf-netconf-monitoring";
     public static final String NETCONF_NOTIFICATION = "ietf-netconf-notifications";
 
-    public static final Set<String> CONFIG_SERVICE_MARKERS = Sets.newHashSet(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR,
+    public static final Set<String> CONFIG_SERVICE_MARKERS = ImmutableSet.of(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR,
             NETCONF_MONITORING, NETCONF_NOTIFICATION);
 
     private NetconfConstants() {
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/MissingNameSpaceException.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/MissingNameSpaceException.java
new file mode 100644 (file)
index 0000000..d5ab5d0
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.netconf.api.DocumentedException;
+
+public class MissingNameSpaceException extends DocumentedException {
+    private static final long serialVersionUID = 1L;
+
+    public MissingNameSpaceException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
+        this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+    }
+
+    public MissingNameSpaceException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity,
+            final Map<String, String> errorInfo) {
+        super(message, errorType, errorTag, errorSeverity, errorInfo);
+    }
+}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedElementException.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedElementException.java
new file mode 100644 (file)
index 0000000..ec31b9e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.netconf.api.DocumentedException;
+
+public class UnexpectedElementException extends DocumentedException {
+    private static final long serialVersionUID = 1L;
+
+    public UnexpectedElementException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
+        this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+    }
+
+    public UnexpectedElementException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity,
+            final Map<String, String> errorInfo) {
+        super(message, errorType, errorTag, errorSeverity, errorInfo);
+    }
+}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedNamespaceException.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/UnexpectedNamespaceException.java
new file mode 100644 (file)
index 0000000..4152e26
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.netconf.api.DocumentedException;
+
+public class UnexpectedNamespaceException extends DocumentedException {
+    private static final long serialVersionUID = 1L;
+
+    public UnexpectedNamespaceException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
+        this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+    }
+
+    public UnexpectedNamespaceException(final String message, final DocumentedException.ErrorType errorType,
+            final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity,
+            final Map<String, String> errorInfo) {
+        super(message, errorType, errorTag, errorSeverity, errorInfo);
+    }
+}
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlElement.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlElement.java
new file mode 100644 (file)
index 0000000..ad90fb3
--- /dev/null
@@ -0,0 +1,503 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+
+public final class XmlElement {
+
+    public static final String DEFAULT_NAMESPACE_PREFIX = "";
+
+    private final Element element;
+    private static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
+
+    private XmlElement(final Element element) {
+        this.element = element;
+    }
+
+    public static XmlElement fromDomElement(final Element element) {
+        return new XmlElement(element);
+    }
+
+    public static XmlElement fromDomDocument(final Document xml) {
+        return new XmlElement(xml.getDocumentElement());
+    }
+
+    public static XmlElement fromString(final String str) throws DocumentedException {
+        try {
+            return new XmlElement(XmlUtil.readXmlToElement(str));
+        } catch (IOException | SAXException e) {
+            throw DocumentedException.wrap(e);
+        }
+    }
+
+    public static XmlElement fromDomElementWithExpected(final Element element, final String expectedName)
+            throws DocumentedException {
+        XmlElement xmlElement = XmlElement.fromDomElement(element);
+        xmlElement.checkName(expectedName);
+        return xmlElement;
+    }
+
+    public static XmlElement fromDomElementWithExpected(final Element element, final String expectedName,
+            final String expectedNamespace) throws DocumentedException {
+        XmlElement xmlElement = XmlElement.fromDomElementWithExpected(element, expectedName);
+        xmlElement.checkNamespace(expectedNamespace);
+        return xmlElement;
+    }
+
+    private Map<String, String> extractNamespaces() throws DocumentedException {
+        Map<String, String> namespaces = new HashMap<>();
+        NamedNodeMap attributes = element.getAttributes();
+        for (int i = 0; i < attributes.getLength(); i++) {
+            Node attribute = attributes.item(i);
+            String attribKey = attribute.getNodeName();
+            if (attribKey.startsWith(XmlUtil.XMLNS_ATTRIBUTE_KEY)) {
+                String prefix;
+                if (attribKey.equals(XmlUtil.XMLNS_ATTRIBUTE_KEY)) {
+                    prefix = DEFAULT_NAMESPACE_PREFIX;
+                } else {
+                    if (!attribKey.startsWith(XmlUtil.XMLNS_ATTRIBUTE_KEY + ":")) {
+                        throw new DocumentedException("Attribute doesn't start with :",
+                                DocumentedException.ErrorType.APPLICATION,
+                                DocumentedException.ErrorTag.INVALID_VALUE,
+                                DocumentedException.ErrorSeverity.ERROR);
+                    }
+                    prefix = attribKey.substring(XmlUtil.XMLNS_ATTRIBUTE_KEY.length() + 1);
+                }
+                namespaces.put(prefix, attribute.getNodeValue());
+            }
+        }
+
+        // namespace does not have to be defined on this element but inherited
+        if (!namespaces.containsKey(DEFAULT_NAMESPACE_PREFIX)) {
+            Optional<String> namespaceOptionally = getNamespaceOptionally();
+            if (namespaceOptionally.isPresent()) {
+                namespaces.put(DEFAULT_NAMESPACE_PREFIX, namespaceOptionally.get());
+            }
+        }
+
+        return namespaces;
+    }
+
+    public void checkName(final String expectedName) throws UnexpectedElementException {
+        if (!getName().equals(expectedName)) {
+            throw new UnexpectedElementException(String.format("Expected %s xml element but was %s", expectedName,
+                    getName()),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+    }
+
+    public void checkNamespaceAttribute(final String expectedNamespace)
+            throws UnexpectedNamespaceException, MissingNameSpaceException {
+        if (!getNamespaceAttribute().equals(expectedNamespace)) {
+            throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
+                    getNamespaceAttribute(),
+                    expectedNamespace),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+    }
+
+    public void checkNamespace(final String expectedNamespace)
+            throws UnexpectedNamespaceException, MissingNameSpaceException {
+        if (!getNamespace().equals(expectedNamespace)) {
+            throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
+                    getNamespace(),
+                    expectedNamespace),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+    }
+
+    public String getName() {
+        final String localName = element.getLocalName();
+        if (!Strings.isNullOrEmpty(localName)) {
+            return localName;
+        }
+        return element.getTagName();
+    }
+
+    public String getAttribute(final String attributeName) {
+        return element.getAttribute(attributeName);
+    }
+
+    public String getAttribute(final String attributeName, final String namespace) {
+        return element.getAttributeNS(namespace, attributeName);
+    }
+
+    public NodeList getElementsByTagName(final String name) {
+        return element.getElementsByTagName(name);
+    }
+
+    public void appendChild(final Element toAppend) {
+        this.element.appendChild(toAppend);
+    }
+
+    public Element getDomElement() {
+        return element;
+    }
+
+    public Map<String, Attr> getAttributes() {
+
+        Map<String, Attr> mappedAttributes = Maps.newHashMap();
+
+        NamedNodeMap attributes = element.getAttributes();
+        for (int i = 0; i < attributes.getLength(); i++) {
+            Attr attr = (Attr) attributes.item(i);
+            mappedAttributes.put(attr.getNodeName(), attr);
+        }
+
+        return mappedAttributes;
+    }
+
+    /**
+     * Non recursive.
+     */
+    private List<XmlElement> getChildElementsInternal(final ElementFilteringStrategy strat) {
+        NodeList childNodes = element.getChildNodes();
+        final List<XmlElement> result = new ArrayList<>();
+        for (int i = 0; i < childNodes.getLength(); i++) {
+            Node item = childNodes.item(i);
+            if (!(item instanceof Element)) {
+                continue;
+            }
+            if (strat.accept((Element) item)) {
+                result.add(new XmlElement((Element) item));
+            }
+        }
+
+        return result;
+    }
+
+    public List<XmlElement> getChildElements() {
+        return getChildElementsInternal(e -> true);
+    }
+
+    /**
+     * Returns the child elements for the given tag.
+     *
+     * @param tagName tag name without prefix
+     * @return List of child elements
+     */
+    public List<XmlElement> getChildElements(final String tagName) {
+        return getChildElementsInternal(e -> {
+            // localName returns pure localName without prefix
+            return e.getLocalName().equals(tagName);
+        });
+    }
+
+    public List<XmlElement> getChildElementsWithinNamespace(final String childName, final String namespace) {
+        return Lists.newArrayList(Collections2.filter(getChildElementsWithinNamespace(namespace),
+            xmlElement -> xmlElement.getName().equals(childName)));
+    }
+
+    public List<XmlElement> getChildElementsWithinNamespace(final String namespace) {
+        return getChildElementsInternal(e -> {
+            try {
+                return XmlElement.fromDomElement(e).getNamespace().equals(namespace);
+            } catch (final MissingNameSpaceException e1) {
+                return false;
+            }
+        });
+    }
+
+    public Optional<XmlElement> getOnlyChildElementOptionally(final String childName) {
+        List<XmlElement> nameElements = getChildElements(childName);
+        if (nameElements.size() != 1) {
+            return Optional.absent();
+        }
+        return Optional.of(nameElements.get(0));
+    }
+
+    public Optional<XmlElement> getOnlyChildElementOptionally(final String childName, final String namespace) {
+        List<XmlElement> children = getChildElementsWithinNamespace(namespace);
+        children = Lists.newArrayList(Collections2.filter(children,
+            xmlElement -> xmlElement.getName().equals(childName)));
+        if (children.size() != 1) {
+            return Optional.absent();
+        }
+        return Optional.of(children.get(0));
+    }
+
+    public Optional<XmlElement> getOnlyChildElementOptionally() {
+        List<XmlElement> children = getChildElements();
+        if (children.size() != 1) {
+            return Optional.absent();
+        }
+        return Optional.of(children.get(0));
+    }
+
+    public XmlElement getOnlyChildElementWithSameNamespace(final String childName) throws  DocumentedException {
+        return getOnlyChildElement(childName, getNamespace());
+    }
+
+    public XmlElement getOnlyChildElementWithSameNamespace() throws DocumentedException {
+        XmlElement childElement = getOnlyChildElement();
+        childElement.checkNamespace(getNamespace());
+        return childElement;
+    }
+
+    public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally(final String childName) {
+        Optional<String> namespace = getNamespaceOptionally();
+        if (namespace.isPresent()) {
+            List<XmlElement> children = getChildElementsWithinNamespace(namespace.get());
+            children = Lists.newArrayList(Collections2.filter(children,
+                xmlElement -> xmlElement.getName().equals(childName)));
+            if (children.size() != 1) {
+                return Optional.absent();
+            }
+            return Optional.of(children.get(0));
+        }
+        return Optional.absent();
+    }
+
+    public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally() {
+        Optional<XmlElement> child = getOnlyChildElementOptionally();
+        if (child.isPresent()
+                && child.get().getNamespaceOptionally().isPresent()
+                && getNamespaceOptionally().isPresent()
+                && getNamespaceOptionally().get().equals(child.get().getNamespaceOptionally().get())) {
+            return child;
+        }
+        return Optional.absent();
+    }
+
+    public XmlElement getOnlyChildElement(final String childName, final String namespace) throws DocumentedException {
+        List<XmlElement> children = getChildElementsWithinNamespace(namespace);
+        children = Lists.newArrayList(Collections2.filter(children,
+            xmlElement -> xmlElement.getName().equals(childName)));
+        if (children.size() != 1) {
+            throw new DocumentedException(String.format("One element %s:%s expected in %s but was %s", namespace,
+                    childName, toString(), children.size()),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+
+        return children.get(0);
+    }
+
+    public XmlElement getOnlyChildElement(final String childName) throws DocumentedException {
+        List<XmlElement> nameElements = getChildElements(childName);
+        if (nameElements.size() != 1) {
+            throw new DocumentedException("One element " + childName + " expected in " + toString(),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+        return nameElements.get(0);
+    }
+
+    public XmlElement getOnlyChildElement() throws DocumentedException {
+        List<XmlElement> children = getChildElements();
+        if (children.size() != 1) {
+            throw new DocumentedException(String.format("One element expected in %s but was %s", toString(),
+                    children.size()),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+        return children.get(0);
+    }
+
+    public String getTextContent() throws DocumentedException {
+        NodeList childNodes = element.getChildNodes();
+        if (childNodes.getLength() == 0) {
+            return DEFAULT_NAMESPACE_PREFIX;
+        }
+        for (int i = 0; i < childNodes.getLength(); i++) {
+            Node textChild = childNodes.item(i);
+            if (textChild instanceof Text) {
+                String content = textChild.getTextContent();
+                return content.trim();
+            }
+        }
+        throw new DocumentedException(getName() + " should contain text.",
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.INVALID_VALUE,
+                DocumentedException.ErrorSeverity.ERROR
+        );
+    }
+
+    public Optional<String> getOnlyTextContentOptionally() {
+        // only return text content if this node has exactly one Text child node
+        if (element.getChildNodes().getLength() == 1) {
+            Node item = element.getChildNodes().item(0);
+            if (item instanceof Text) {
+                return Optional.of(((Text) item).getWholeText());
+            }
+        }
+        return Optional.absent();
+    }
+
+    public String getNamespaceAttribute() throws MissingNameSpaceException {
+        String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY);
+        if (attribute.isEmpty() || attribute.equals(DEFAULT_NAMESPACE_PREFIX)) {
+            throw new MissingNameSpaceException(String.format("Element %s must specify namespace",
+                    toString()),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+        return attribute;
+    }
+
+    public Optional<String> getNamespaceAttributeOptionally() {
+        String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY);
+        if (attribute.isEmpty() || attribute.equals(DEFAULT_NAMESPACE_PREFIX)) {
+            return Optional.absent();
+        }
+        return Optional.of(attribute);
+    }
+
+    public Optional<String> getNamespaceOptionally() {
+        String namespaceURI = element.getNamespaceURI();
+        if (Strings.isNullOrEmpty(namespaceURI)) {
+            return Optional.absent();
+        } else {
+            return Optional.of(namespaceURI);
+        }
+    }
+
+    public String getNamespace() throws MissingNameSpaceException {
+        Optional<String> namespaceURI = getNamespaceOptionally();
+        if (!namespaceURI.isPresent()) {
+            throw new MissingNameSpaceException(String.format("No namespace defined for %s", this),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+        return namespaceURI.get();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("XmlElement{");
+        sb.append("name='").append(getName()).append('\'');
+        if (element.getNamespaceURI() != null) {
+            try {
+                sb.append(", namespace='").append(getNamespace()).append('\'');
+            } catch (final MissingNameSpaceException e) {
+                LOG.trace("Missing namespace for element.");
+            }
+        }
+        sb.append('}');
+        return sb.toString();
+    }
+
+    /**
+     * Search for element's attributes defining namespaces. Look for the one
+     * namespace that matches prefix of element's text content. E.g.
+     *
+     * <pre>
+     * &lt;type
+     * xmlns:th-java="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl"&gt;
+     *     th-java:threadfactory-naming&lt;/type&gt;
+     * </pre>
+     *
+     * <p>
+     * returns {"th-java","urn:.."}. If no prefix is matched, then default
+     * namespace is returned with empty string as key. If no default namespace
+     * is found value will be null.
+     */
+    public Map.Entry<String/* prefix */, String/* namespace */> findNamespaceOfTextContent()
+            throws DocumentedException {
+        Map<String, String> namespaces = extractNamespaces();
+        String textContent = getTextContent();
+        int indexOfColon = textContent.indexOf(':');
+        String prefix;
+        if (indexOfColon > -1) {
+            prefix = textContent.substring(0, indexOfColon);
+        } else {
+            prefix = DEFAULT_NAMESPACE_PREFIX;
+        }
+        if (!namespaces.containsKey(prefix)) {
+            throw new IllegalArgumentException("Cannot find namespace for " + XmlUtil.toString(element)
+                + ". Prefix from content is " + prefix + ". Found namespaces " + namespaces);
+        }
+        return Maps.immutableEntry(prefix, namespaces.get(prefix));
+    }
+
+    public List<XmlElement> getChildElementsWithSameNamespace(final String childName) throws MissingNameSpaceException {
+        List<XmlElement> children = getChildElementsWithinNamespace(getNamespace());
+        return Lists.newArrayList(Collections2.filter(children, xmlElement -> xmlElement.getName().equals(childName)));
+    }
+
+    public void checkUnrecognisedElements(final List<XmlElement> recognisedElements,
+                                          final XmlElement... additionalRecognisedElements) throws DocumentedException {
+        List<XmlElement> childElements = getChildElements();
+        childElements.removeAll(recognisedElements);
+        for (XmlElement additionalRecognisedElement : additionalRecognisedElements) {
+            childElements.remove(additionalRecognisedElement);
+        }
+        if (!childElements.isEmpty()) {
+            throw new DocumentedException(String.format("Unrecognised elements %s in %s", childElements, this),
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
+        }
+    }
+
+    public void checkUnrecognisedElements(final XmlElement... additionalRecognisedElements) throws DocumentedException {
+        checkUnrecognisedElements(Collections.<XmlElement>emptyList(), additionalRecognisedElements);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        XmlElement that = (XmlElement) obj;
+
+        return element.isEqualNode(that.element);
+
+    }
+
+    @Override
+    public int hashCode() {
+        return element.hashCode();
+    }
+
+    public boolean hasNamespace() {
+        return getNamespaceAttributeOptionally().isPresent() || getNamespaceOptionally().isPresent();
+    }
+
+    private interface ElementFilteringStrategy {
+        boolean accept(Element element);
+    }
+}
index 955127c938352095ecabf838ef55d74b3937d6ec..d34838559b68bf0be2655dcee1259a94f2e6eecb 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.netconf.api.xml;
 
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-
 public final class XmlNetconfConstants {
 
     private XmlNetconfConstants() {}
@@ -25,6 +23,7 @@ public final class XmlNetconfConstants {
     public static final String RPC_KEY = "rpc";
     public static final String NOTIFICATION_ELEMENT_NAME = "notification";
     public static final String EVENT_TIME = "eventTime";
+    public static final String PREFIX = "prefix";
 
     public static final String MESSAGE_ID = "message-id";
     public static final String SESSION_ID = "session-id";
@@ -32,8 +31,9 @@ public final class XmlNetconfConstants {
     public static final String GET = "get";
     public static final String GET_CONFIG = "get-config";
 
-    public static final String URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 =
-            XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
+    public static final String RPC_REPLY_KEY = "rpc-reply";
+
+    public static final String URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0";
     public static final String URN_IETF_PARAMS_NETCONF_BASE_1_0 = "urn:ietf:params:netconf:base:1.0";
     public static final String URN_IETF_PARAMS_NETCONF_BASE_1_1 = "urn:ietf:params:netconf:base:1.1";
     public static final String URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0 = "urn:ietf:params:xml:ns:netconf:exi:1.0";
diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlUtil.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlUtil.java
new file mode 100644 (file)
index 0000000..a080889
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import com.google.common.base.Optional;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public final class XmlUtil {
+
+    public static final String XMLNS_ATTRIBUTE_KEY = "xmlns";
+    public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+    private static final DocumentBuilderFactory BUILDER_FACTORY;
+    private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+    private static final SchemaFactory SCHEMA_FACTORY = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+    static {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        try {
+            factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+            factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+            factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+            factory.setXIncludeAware(false);
+            factory.setExpandEntityReferences(false);
+            // Performance improvement for messages with size <10k according to
+            // https://xerces.apache.org/xerces2-j/faq-performance.html
+            factory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
+        } catch (final ParserConfigurationException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+        factory.setNamespaceAware(true);
+        factory.setCoalescing(true);
+        factory.setIgnoringElementContentWhitespace(true);
+        factory.setIgnoringComments(true);
+        BUILDER_FACTORY = factory;
+    }
+
+    private static final ThreadLocal<DocumentBuilder> DEFAULT_DOM_BUILDER = new ThreadLocal<DocumentBuilder>() {
+        @Override
+        protected DocumentBuilder initialValue() {
+            try {
+                return BUILDER_FACTORY.newDocumentBuilder();
+            } catch (final ParserConfigurationException e) {
+                throw new IllegalStateException("Failed to create threadLocal dom builder", e);
+            }
+        }
+
+        @Override
+        public void set(final DocumentBuilder value) {
+            throw new UnsupportedOperationException();
+        }
+    };
+
+    private XmlUtil() {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    public static Element readXmlToElement(final File xmlFile) throws SAXException, IOException {
+        return readXmlToDocument(new FileInputStream(xmlFile)).getDocumentElement();
+    }
+
+    public static Element readXmlToElement(final String xmlContent) throws SAXException, IOException {
+        Document doc = readXmlToDocument(xmlContent);
+        return doc.getDocumentElement();
+    }
+
+    public static Element readXmlToElement(final InputStream xmlContent) throws SAXException, IOException {
+        Document doc = readXmlToDocument(xmlContent);
+        return doc.getDocumentElement();
+    }
+
+    public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
+        return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8)));
+    }
+
+    // TODO improve exceptions throwing
+    // along with XmlElement
+
+    public static Document readXmlToDocument(final InputStream xmlContent) throws SAXException, IOException {
+        Document doc = DEFAULT_DOM_BUILDER.get().parse(xmlContent);
+
+        doc.getDocumentElement().normalize();
+        return doc;
+    }
+
+    public static Document newDocument() {
+        return DEFAULT_DOM_BUILDER.get().newDocument();
+    }
+
+    public static Element createElement(final Document document, final String qmame,
+            final Optional<String> namespaceURI) {
+        if (namespaceURI.isPresent()) {
+            final Element element = document.createElementNS(namespaceURI.get(), qmame);
+            String name = XMLNS_ATTRIBUTE_KEY;
+            if (element.getPrefix() != null) {
+                name += ":" + element.getPrefix();
+            }
+            element.setAttributeNS(XMLNS_URI, name, namespaceURI.get());
+            return element;
+        }
+        return document.createElement(qmame);
+    }
+
+    public static Element createTextElement(final Document document, final String qname, final String content,
+            final Optional<String> namespaceURI) {
+        Element typeElement = createElement(document, qname, namespaceURI);
+        typeElement.appendChild(document.createTextNode(content));
+        return typeElement;
+    }
+
+    public static Element createTextElementWithNamespacedContent(final Document document, final String qname,
+            final String prefix, final String namespace, final String contentWithoutPrefix) {
+
+        return createTextElementWithNamespacedContent(document, qname, prefix, namespace, contentWithoutPrefix,
+                Optional.<String>absent());
+    }
+
+    public static Element createTextElementWithNamespacedContent(final Document document, final String qname,
+            final String prefix, final String namespace, final String contentWithoutPrefix,
+            final Optional<String> namespaceURI) {
+
+        String content = createPrefixedValue(XmlNetconfConstants.PREFIX, contentWithoutPrefix);
+        Element element = createTextElement(document, qname, content, namespaceURI);
+        String prefixedNamespaceAttr = createPrefixedValue(XMLNS_ATTRIBUTE_KEY, prefix);
+        element.setAttributeNS(XMLNS_URI, prefixedNamespaceAttr, namespace);
+        return element;
+    }
+
+    public static String createPrefixedValue(final String prefix, final String value) {
+        return prefix + ":" + value;
+    }
+
+    public static String toString(final Document document) {
+        return toString(document.getDocumentElement());
+    }
+
+    public static String toString(final Element xml) {
+        return toString(xml, false);
+    }
+
+    public static String toString(final XmlElement xmlElement) {
+        return toString(xmlElement.getDomElement(), false);
+    }
+
+    public static String toString(final Element xml, final boolean addXmlDeclaration) {
+        try {
+            Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, addXmlDeclaration ? "no" : "yes");
+
+            StreamResult result = new StreamResult(new StringWriter());
+            DOMSource source = new DOMSource(xml);
+            transformer.transform(source, result);
+
+            return result.getWriter().toString();
+        } catch (TransformerFactoryConfigurationError | TransformerException e) {
+            throw new IllegalStateException("Unable to serialize xml element " + xml, e);
+        }
+    }
+
+    public static String toString(final Document doc, final boolean addXmlDeclaration) {
+        return toString(doc.getDocumentElement(), addXmlDeclaration);
+    }
+
+    public static Schema loadSchema(final InputStream... fromStreams) {
+        Source[] sources = new Source[fromStreams.length];
+        int index = 0;
+        for (InputStream stream : fromStreams) {
+            sources[index++] = new StreamSource(stream);
+        }
+
+        try {
+            return SCHEMA_FACTORY.newSchema(sources);
+        } catch (final SAXException e) {
+            throw new IllegalStateException("Failed to instantiate XML schema", e);
+        }
+    }
+
+    public static Object evaluateXPath(final XPathExpression expr, final Object rootNode, final QName returnType) {
+        try {
+            return expr.evaluate(rootNode, returnType);
+        } catch (final XPathExpressionException e) {
+            throw new IllegalStateException("Error while evaluating xpath expression " + expr, e);
+        }
+    }
+
+    public static Document createDocumentCopy(final Document original) {
+        final Document copiedDocument = newDocument();
+        final Node copiedRoot = copiedDocument.importNode(original.getDocumentElement(), true);
+        copiedDocument.appendChild(copiedRoot);
+        return copiedDocument;
+    }
+}
index 7876a5cadb67324f05df84255d5f0b1fcd5a639c..d1e85067370b440ad7e1180fa94fe4aa174c6133 100644 (file)
@@ -21,7 +21,6 @@ import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
diff --git a/netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlElementTest.java b/netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlElementTest.java
new file mode 100644 (file)
index 0000000..fac88d6
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import static org.hamcrest.CoreMatchers.both;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.common.base.Optional;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class XmlElementTest {
+
+    private final String elementAsString =
+            "<top xmlns=\"namespace\" xmlns:a=\"attrNamespace\" a:attr1=\"value1\" attr2=\"value2\">"
+            + "<inner>" + "<deepInner>deepValue</deepInner>" + "</inner>"
+            + "<innerNamespace xmlns=\"innerNamespace\">innerNamespaceValue</innerNamespace>"
+            + "<innerPrefixed xmlns:b=\"prefixedValueNamespace\">b:valueWithPrefix</innerPrefixed>" + "</top>";
+    private Document document;
+    private Element element;
+    private XmlElement xmlElement;
+
+    @Before
+    public void setUp() throws Exception {
+        document = XmlUtil.readXmlToDocument(elementAsString);
+        element = document.getDocumentElement();
+        xmlElement = XmlElement.fromDomElement(element);
+    }
+
+    @Test
+    public void testConstruct() throws Exception {
+        final XmlElement fromString = XmlElement.fromString(elementAsString);
+        assertEquals(fromString, xmlElement);
+        XmlElement.fromDomDocument(document);
+        XmlElement.fromDomElement(element);
+        XmlElement.fromDomElementWithExpected(element, "top");
+        XmlElement.fromDomElementWithExpected(element, "top", "namespace");
+
+        try {
+            XmlElement.fromString("notXml");
+            fail();
+        } catch (final DocumentedException e) {
+            // expected
+        }
+
+        try {
+            XmlElement.fromDomElementWithExpected(element, "notTop");
+            fail();
+        } catch (final DocumentedException e) {
+            // expected
+        }
+
+        try {
+            XmlElement.fromDomElementWithExpected(element, "top", "notNamespace");
+            fail();
+        } catch (final DocumentedException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testGetters() throws Exception {
+        assertEquals(element, xmlElement.getDomElement());
+        assertEquals(element.getElementsByTagName("inner").getLength(),
+                xmlElement.getElementsByTagName("inner").getLength());
+
+        assertEquals("top", xmlElement.getName());
+        assertTrue(xmlElement.hasNamespace());
+        assertEquals("namespace", xmlElement.getNamespace());
+        assertEquals("namespace", xmlElement.getNamespaceAttribute());
+        assertEquals(Optional.of("namespace"), xmlElement.getNamespaceOptionally());
+
+        assertEquals("value1", xmlElement.getAttribute("attr1", "attrNamespace"));
+        assertEquals("value2", xmlElement.getAttribute("attr2"));
+        assertEquals(2 + 2/*Namespace definition*/, xmlElement.getAttributes().size());
+
+        assertEquals(3, xmlElement.getChildElements().size());
+        assertEquals(1, xmlElement.getChildElements("inner").size());
+        assertTrue(xmlElement.getOnlyChildElementOptionally("inner").isPresent());
+        assertTrue(xmlElement.getOnlyChildElementWithSameNamespaceOptionally("inner").isPresent());
+        assertEquals(0, xmlElement.getChildElements("unknown").size());
+        assertFalse(xmlElement.getOnlyChildElementOptionally("unknown").isPresent());
+        assertEquals(1, xmlElement.getChildElementsWithSameNamespace("inner").size());
+        assertEquals(0, xmlElement.getChildElementsWithSameNamespace("innerNamespace").size());
+        assertEquals(1, xmlElement.getChildElementsWithinNamespace("innerNamespace", "innerNamespace").size());
+        assertTrue(xmlElement.getOnlyChildElementOptionally("innerNamespace", "innerNamespace").isPresent());
+        assertFalse(xmlElement.getOnlyChildElementOptionally("innerNamespace", "unknownNamespace").isPresent());
+
+        final XmlElement noNamespaceElement = XmlElement.fromString("<noNamespace/>");
+        assertFalse(noNamespaceElement.hasNamespace());
+        try {
+            noNamespaceElement.getNamespace();
+            fail();
+        } catch (final MissingNameSpaceException e) {
+            // expected
+        }
+
+        final XmlElement inner = xmlElement.getOnlyChildElement("inner");
+        final XmlElement deepInner = inner.getOnlyChildElementWithSameNamespaceOptionally().get();
+        assertEquals(deepInner, inner.getOnlyChildElementWithSameNamespace());
+        assertEquals(Optional.<XmlElement>absent(), xmlElement.getOnlyChildElementOptionally("unknown"));
+        assertEquals("deepValue", deepInner.getTextContent());
+        assertEquals("deepValue", deepInner.getOnlyTextContentOptionally().get());
+        assertEquals("deepValue", deepInner.getOnlyTextContentOptionally().get());
+    }
+
+    @Test
+    public void testExtractNamespaces() throws Exception {
+        final XmlElement innerPrefixed = xmlElement.getOnlyChildElement("innerPrefixed");
+        Map.Entry<String, String> namespaceOfTextContent = innerPrefixed.findNamespaceOfTextContent();
+
+        assertNotNull(namespaceOfTextContent);
+        assertEquals("b", namespaceOfTextContent.getKey());
+        assertEquals("prefixedValueNamespace", namespaceOfTextContent.getValue());
+        final XmlElement innerNamespace = xmlElement.getOnlyChildElement("innerNamespace");
+        namespaceOfTextContent = innerNamespace.findNamespaceOfTextContent();
+
+        assertEquals("", namespaceOfTextContent.getKey());
+        assertEquals("innerNamespace", namespaceOfTextContent.getValue());
+    }
+
+    @Test
+    public void testUnrecognisedElements() throws Exception {
+        xmlElement.checkUnrecognisedElements(xmlElement.getOnlyChildElement("inner"),
+                xmlElement.getOnlyChildElement("innerPrefixed"), xmlElement.getOnlyChildElement("innerNamespace"));
+
+        try {
+            xmlElement.checkUnrecognisedElements(xmlElement.getOnlyChildElement("inner"));
+            fail();
+        } catch (final DocumentedException e) {
+            assertThat(e.getMessage(), both(containsString("innerNamespace")).and(containsString("innerNamespace")));
+        }
+    }
+}
diff --git a/netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlUtilTest.java b/netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlUtilTest.java
new file mode 100644 (file)
index 0000000..c45d7f4
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  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.netconf.api.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.common.base.Optional;
+import java.io.ByteArrayInputStream;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXParseException;
+
+public class XmlUtilTest {
+
+    private final String xml = "<top xmlns=\"namespace\">\n" + "<innerText>value</innerText>\n"
+        + "<innerPrefixedText xmlns:pref=\"prefixNamespace\">prefix:value</innerPrefixedText>\n"
+        + "<innerPrefixedText xmlns=\"randomNamespace\" xmlns:pref=\"prefixNamespace\">prefix:value"
+            + "</innerPrefixedText>\n"
+        + "</top>";
+
+    @Test
+    public void testCreateElement() throws Exception {
+        final Document document = XmlUtil.newDocument();
+        final Element top = XmlUtil.createElement(document, "top", Optional.of("namespace"));
+
+        top.appendChild(XmlUtil.createTextElement(document, "innerText", "value", Optional.of("namespace")));
+        top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref",
+                "prefixNamespace", "value", Optional.of("namespace")));
+        top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref",
+                "prefixNamespace", "value", Optional.of("randomNamespace")));
+
+        document.appendChild(top);
+        assertEquals("top", XmlUtil.createDocumentCopy(document).getDocumentElement().getTagName());
+
+        XMLUnit.setIgnoreAttributeOrder(true);
+        XMLUnit.setIgnoreWhitespace(true);
+
+        final Diff diff = XMLUnit.compareXML(XMLUnit.buildControlDocument(xml), document);
+        assertTrue(diff.toString(), diff.similar());
+    }
+
+    @Test
+    public void testLoadSchema() throws Exception {
+        XmlUtil.loadSchema();
+        try {
+            XmlUtil.loadSchema(new ByteArrayInputStream(xml.getBytes()));
+            fail("Input stream does not contain xsd");
+        } catch (final IllegalStateException e) {
+            assertTrue(e.getCause() instanceof SAXParseException);
+        }
+
+    }
+
+    @Test(expected = SAXParseException.class)
+    public void testXXEFlaw() throws Exception {
+        XmlUtil.readXmlToDocument(
+                "<!DOCTYPE foo [  \n" + "<!ELEMENT foo ANY >\n" + "<!ENTITY xxe SYSTEM \"file:///etc/passwd\" >]>\n"
+                        + "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + "  <capabilities>\n"
+                        + "    <capability>urn:ietf:params:netconf:base:1.0 &xxe;</capability>\n"
+                        + "  </capabilities>\n" + "  </hello>]]>]]>");
+    }
+
+}
index 2254734174c2307c586260186f7d93a41817eb79..b9e1d8f88758e5601e8a65a88bcfe724c2a1daa4 100644 (file)
                 <artifactId>aaa-authn-odl-plugin</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>config-netconf-connector</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>config-persister-impl</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-api</artifactId>
                 <type>xml</type>
                 <classifier>features</classifier>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>odl-config-netconf-connector</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>features</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>odl-netconf-all</artifactId>
index 9433264aa585610e5d5b0197aef976f272d35f5d..b2c0ae02c7aa9474856caa3f2389316a5bf93489 100644 (file)
     <version>1.5.0-SNAPSHOT</version>
     <name>${project.artifactId}</name>
     <packaging>bundle</packaging>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 083f0422c1d41e2b693c2804a0e2bf5a1b95db57..2e4a8aaa912f6c2ee06b9f2406df383448a42c25 100644 (file)
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
index d0dc480299b97192a7a5495daf2e3fed344525c6..780ce7ff59f4103810ba99462b89dbd1ff9f1e30 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.netconf.client;
 import io.netty.channel.EventLoopGroup;
 import io.netty.util.Timer;
 import io.netty.util.concurrent.Future;
-import java.io.Closeable;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.protocol.framework.AbstractDispatcher;
@@ -19,7 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClientSession, NetconfClientSessionListener>
-        implements NetconfClientDispatcher, Closeable {
+        implements NetconfClientDispatcher {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
 
index 0b456f447f8ce33be11239ec8901dcffe0a041aa..69dc1059b5535f8914c95c966b69e9ccaa451b68 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Interner;
 import com.google.common.collect.Interners;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
@@ -22,12 +23,12 @@ import io.netty.util.concurrent.Promise;
 import java.util.Set;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
 import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator;
 import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
@@ -65,6 +66,7 @@ public class NetconfClientSessionNegotiator extends
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
     protected void handleMessage(final NetconfHelloMessage netconfMessage) throws NetconfDocumentedException {
         if (!ifNegotiatedAlready()) {
             LOG.debug("Server hello message received, starting negotiation on channel {}", channel);
@@ -81,10 +83,10 @@ public class NetconfClientSessionNegotiator extends
 
         // If exi should be used, try to initiate exi communication
         // Call negotiationSuccessFul after exi negotiation is finished successfully or not
-        if (shouldUseExi(netconfMessage)) {
+        final NetconfMessage startExiMessage = sessionPreferences.getStartExiMessage();
+        if (shouldUseExi(netconfMessage) && startExiMessage instanceof NetconfStartExiMessage) {
             LOG.debug("Netconf session {} should use exi.", session);
-            NetconfStartExiMessage startExiMessage = (NetconfStartExiMessage) sessionPreferences.getStartExiMessage();
-            tryToInitiateExi(session, startExiMessage);
+            tryToInitiateExi(session, (NetconfStartExiMessage) startExiMessage);
         } else {
             // Exi is not supported, release session immediately
             LOG.debug("Netconf session {} isn't capable of using exi.", session);
@@ -116,6 +118,7 @@ public class NetconfClientSessionNegotiator extends
         });
     }
 
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
     private boolean shouldUseExi(final NetconfHelloMessage helloMsg) {
         return containsExi10Capability(helloMsg.getDocument())
                 && containsExi10Capability(sessionPreferences.getHelloMessage().getDocument());
@@ -141,7 +144,7 @@ public class NetconfClientSessionNegotiator extends
             }
         }
 
-        return Long.valueOf(textContent);
+        return Long.parseLong(textContent);
     }
 
     private static String getSessionIdWithXPath(final Document doc, final XPathExpression sessionIdXPath) {
index 82e72045d44d258f770100980056d5e6e34e4eb8..26f33152dac04473d3c065f1dcab9694ffae8ca2 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netconf.client;
 
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GlobalEventExecutor;
 import io.netty.util.concurrent.Promise;
@@ -40,6 +41,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
     private NetconfClientSession clientSession;
 
     @GuardedBy("this")
+    @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
     private void dispatchRequest() {
         while (!requests.isEmpty()) {
             final RequestEntry e = requests.peek();
index 2cf0e1a5cd32e04aaabf297a695e786946f8723b..5f25800b4b0c595137485c78fc0bc095c1114e82 100644 (file)
@@ -49,7 +49,7 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
 
                 negotiationFutureListener = future -> {
                     if (future.isSuccess()) {
-                        connectPromise.setSuccess();
+                        channelPromise.setSuccess();
                     }
                 };
 
@@ -58,7 +58,7 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
                         //complete connection promise with netconf negotiation future
                         negotiationFuture.addListener(negotiationFutureListener);
                     } else {
-                        connectPromise.setFailure(future.cause());
+                        channelPromise.setFailure(future.cause());
                     }
                 });
                 ctx.connect(remoteAddress, localAddress, tcpConnectFuture);
@@ -66,6 +66,10 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
 
             @Override
             public void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
+                if (connectPromise == null) {
+                    return;
+                }
+
                 // If we have already succeeded and the session was dropped after, we need to fire inactive to notify
                 // reconnect logic
                 if (connectPromise.isSuccess()) {
index b25071156234e1a02b3a174413cfb6766a1893e7..ee41da8a8d165387d4da477d161c2830ac4e4445 100644 (file)
@@ -85,18 +85,17 @@ public class NetconfClientConfiguration {
         return sslHandlerFactory;
     }
 
-    @SuppressWarnings("checkstyle:FallThrough")
     private void validateConfiguration() {
         Preconditions.checkNotNull(clientProtocol, " ");
         switch (clientProtocol) {
             case TLS:
+                validateTlsConfiguration();
+                validateTcpConfiguration();
+                break;
             case SSH:
-                if (clientProtocol == NetconfClientProtocol.SSH) {
-                    validateSshConfiguration();
-                } else {
-                    validateTlsConfiguration();
-                }
-                // Fall through intentional (ssh or tls validation is a superset of tcp validation)
+                validateSshConfiguration();
+                validateTcpConfiguration();
+                break;
             case TCP:
                 validateTcpConfiguration();
                 break;
@@ -141,4 +140,4 @@ public class NetconfClientConfiguration {
     public enum NetconfClientProtocol {
         TCP, SSH, TLS
     }
-}
\ No newline at end of file
+}
index 12d4322ea081ba6625bb6fb3fde55a57f5495856..7b84cb0be481ae9ff77e7706a40923774718e704 100644 (file)
@@ -23,12 +23,12 @@ import static org.mockito.Mockito.verify;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.channel.ChannelPipeline;
 import io.netty.channel.ChannelProgressivePromise;
+import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.HashedWheelTimer;
@@ -40,13 +40,11 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
+import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
@@ -60,14 +58,13 @@ public class NetconfClientSessionNegotiatorTest {
 
     private NetconfHelloMessage helloMessage;
     private ChannelPipeline pipeline;
-    private ChannelFuture future;
+    private ChannelPromise future;
     private Channel channel;
     private ChannelInboundHandlerAdapter channelInboundHandlerAdapter;
 
     @Before
     public void setUp() throws Exception {
-        helloMessage = NetconfHelloMessage.createClientHello(Sets.newSet("exi:1.0"), Optional
-                .<NetconfHelloMessageAdditionalHeader>absent());
+        helloMessage = NetconfHelloMessage.createClientHello(Sets.newSet("exi:1.0"), Optional.absent());
         pipeline = mockChannelPipeline();
         future = mockChannelFuture();
         channel = mockChannel();
@@ -83,8 +80,10 @@ public class NetconfClientSessionNegotiatorTest {
         Channel ret = mock(Channel.class);
         ChannelHandler channelHandler = mockChannelHandler();
         doReturn("").when(ret).toString();
+        doReturn(future).when(ret).newPromise();
         doReturn(future).when(ret).close();
         doReturn(future).when(ret).writeAndFlush(anyObject());
+        doReturn(future).when(ret).writeAndFlush(anyObject(), anyObject());
         doReturn(true).when(ret).isOpen();
         doReturn(pipeline).when(ret).pipeline();
         doReturn("").when(pipeline).toString();
@@ -93,8 +92,8 @@ public class NetconfClientSessionNegotiatorTest {
         return ret;
     }
 
-    private static ChannelFuture mockChannelFuture() {
-        ChannelFuture future = mock(ChannelFuture.class);
+    private static ChannelPromise mockChannelFuture() {
+        ChannelPromise future = mock(ChannelPromise.class);
         doReturn(future).when(future).addListener(any(GenericFutureListener.class));
         return future;
     }
@@ -118,14 +117,9 @@ public class NetconfClientSessionNegotiatorTest {
     private void mockEventLoop() {
         final EventLoop eventLoop = mock(EventLoop.class);
         doReturn(eventLoop).when(channel).eventLoop();
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final Runnable runnable = (Runnable) args[0];
-                runnable.run();
-                return null;
-            }
+        doAnswer(invocation -> {
+            invocation.getArgumentAt(0, Runnable.class).run();
+            return null;
         }).when(eventLoop).execute(any(Runnable.class));
     }
 
@@ -142,21 +136,21 @@ public class NetconfClientSessionNegotiatorTest {
         return new NetconfClientSessionNegotiator(preferences, promise, channel, timer, sessionListener, timeout);
     }
 
-    private NetconfHelloMessage createHelloMsg(final String name) throws Exception {
+    private static NetconfHelloMessage createHelloMsg(final String name) throws Exception {
         final InputStream stream = NetconfClientSessionNegotiatorTest.class.getResourceAsStream(name);
         final Document doc = XmlUtil.readXmlToDocument(stream);
 
         return new NetconfHelloMessage(doc);
     }
 
-    private Set<String> createCapabilities(String name) throws Exception {
+    private static Set<String> createCapabilities(final String name) throws Exception {
         NetconfHelloMessage hello = createHelloMsg(name);
 
         return ImmutableSet.copyOf(NetconfMessageUtil.extractCapabilitiesFromHello(hello.getDocument()));
     }
 
     @Test
-    public void testNetconfClientSessionNegotiator() throws Exception {
+    public void testNetconfClientSessionNegotiator() throws NetconfDocumentedException {
         Promise<NetconfClientSession> promise = mock(Promise.class);
         doReturn(promise).when(promise).setSuccess(anyObject());
         NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
@@ -195,12 +189,9 @@ public class NetconfClientSessionNegotiatorTest {
         Set<String> caps = Sets.newSet("exi:1.0");
         NetconfHelloMessage message = NetconfHelloMessage.createServerHello(caps, 10);
 
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                channelInboundHandlerAdapter = ((ChannelInboundHandlerAdapter) invocationOnMock.getArguments()[2]);
-                return null;
-            }
+        doAnswer(invocationOnMock -> {
+            channelInboundHandlerAdapter = (ChannelInboundHandlerAdapter) invocationOnMock.getArguments()[2];
+            return null;
         }).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
 
         ChannelHandlerContext handlerContext = mock(ChannelHandlerContext.class);
index 1dde3d4dfa64f6f7b4151d807ec722557dd52c28..68c1a762f079d47bb062f64cfe4e58f877200f28 100644 (file)
@@ -19,7 +19,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GenericFutureListener;
@@ -27,15 +27,14 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.internal.util.collections.Sets;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 
 public class SimpleNetconfClientSessionListenerTest {
 
     private Channel channel;
-    private ChannelFuture channelFuture;
+    private ChannelPromise channelFuture;
     Set<String> caps;
     private NetconfHelloMessage helloMessage;
     private NetconfMessage message;
@@ -43,11 +42,13 @@ public class SimpleNetconfClientSessionListenerTest {
     private NetconfClientSession clientSession;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() throws NetconfDocumentedException {
         channel = mock(Channel.class);
-        channelFuture = mock(ChannelFuture.class);
+        channelFuture = mock(ChannelPromise.class);
         mockEventLoop();
+        doReturn(channelFuture).when(channel).newPromise();
         doReturn(channelFuture).when(channel).writeAndFlush(anyObject());
+        doReturn(channelFuture).when(channel).writeAndFlush(anyObject(), any(ChannelPromise.class));
         doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
         caps = Sets.newSet("a", "b");
         helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
@@ -59,14 +60,9 @@ public class SimpleNetconfClientSessionListenerTest {
     private void mockEventLoop() {
         final EventLoop eventLoop = mock(EventLoop.class);
         doReturn(eventLoop).when(channel).eventLoop();
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final Runnable runnable = (Runnable) args[0];
-                runnable.run();
-                return null;
-            }
+        doAnswer(invocation -> {
+            invocation.getArgumentAt(0, Runnable.class).run();
+            return null;
         }).when(eventLoop).execute(any(Runnable.class));
     }
 
@@ -75,29 +71,29 @@ public class SimpleNetconfClientSessionListenerTest {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject());
+        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
 
         simpleListener.onSessionDown(clientSession, new Exception());
         assertFalse(promise.isSuccess());
     }
 
     @Test
-    public void testSendRequest() throws Exception {
+    public void testSendRequest() {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject());
+        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
 
         simpleListener.sendRequest(message);
         assertFalse(promise.isSuccess());
     }
 
     @Test
-    public void testOnMessage() throws Exception {
+    public void testOnMessage() {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject());
+        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
 
         simpleListener.onMessage(clientSession, message);
         assertTrue(promise.isSuccess());
index f1fbfa6284fb044a775e0963b9e96468beeddf24..1a6b9c29ae501d4f3e542438fa4455712c05db84 100644 (file)
@@ -70,16 +70,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
           <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-        <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-checkstyle-plugin</artifactId>
-            <configuration>
-                <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-            </configuration>
-        </plugin>
-    </plugins>
-  </build>
 </project>
index b5c4c657065a41d590217093dd57f58ce743cf7d..be70b8155e473d28e95567129dcdd87ea97d9c08 100644 (file)
@@ -9,6 +9,10 @@
 package org.opendaylight.netconf.console.commands;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Strings;
+
+import java.util.Arrays;
+
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.AbstractAction;
@@ -17,8 +21,12 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol.Name;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.protocol.specification.TlsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.protocol.specification.TlsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.protocol.specification.tls._case.TlsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
 
@@ -55,14 +63,14 @@ public class NetconfConnectDeviceCommand extends AbstractAction {
     @Option(name = "-U",
             aliases = { "--username" },
             description = "Username for netconf connection",
-            required = true,
+            required = false,
             multiValued = false)
     private String username;
 
     @Option(name = "-P",
             aliases = { "--password" },
             description = "Password for netconf connection",
-            required = true,
+            required = false,
             multiValued = false)
     private String password;
 
@@ -73,6 +81,20 @@ public class NetconfConnectDeviceCommand extends AbstractAction {
             multiValued = false)
     private String connectionType = "false";
 
+    @Option(name = "-pr",
+            aliases = { "--protocol" },
+            description = "Which protocol to be used, ssh or tls",
+            required = false,
+            multiValued = false)
+    private String protocol = "ssh";
+
+    @Option(name = "-ev",
+            aliases = { "--excluded-versions" },
+            description = "TLS versions not supported by target device",
+            required = false,
+            multiValued = false)
+    private String excludedTlsVersions;
+
     @Option(name = "-sl",
             aliases = { "--schemaless" },
             description = "Schemaless surpport, true for schemaless",
@@ -95,18 +117,41 @@ public class NetconfConnectDeviceCommand extends AbstractAction {
 
         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()
-                                        .setHost(new Host(new IpAddress(new Ipv4Address(deviceIp))))
-                                        .setPort(new PortNumber(Integer.decode(devicePort)))
-                                        .setTcpOnly(isTcpOnly)
-                                        .setSchemaless(isSchemaless)
-                                        .setCredentials(credentials)
-                                        .build();
-
-        service.connectDevice(netconfNode, deviceId);
+
+        final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+        netconfNodeBuilder.setHost(new Host(new IpAddress(new Ipv4Address(deviceIp))))
+                          .setPort(new PortNumber(Integer.decode(devicePort)))
+                          .setTcpOnly(isTcpOnly)
+                          .setSchemaless(isSchemaless);
+
+        if (isTcpOnly || protocol.equalsIgnoreCase("ssh")) {
+            if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password)) {
+                return "Empty Username:" + username + " or Password:" + password
+                        + ". In TCP or SSH mode, you must provide valid username and password.";
+            }
+            final Credentials credentials =
+                    new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
+            netconfNodeBuilder.setCredentials(credentials);
+            if (!isTcpOnly) {
+                netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build());
+            }
+        } else if (protocol.equalsIgnoreCase("tls")) {
+            TlsCase tlsCase = null;
+            if (!Strings.isNullOrEmpty(excludedTlsVersions)) {
+                tlsCase = new TlsCaseBuilder()
+                            .setTls(new TlsBuilder()
+                                    .setExcludedVersions(Arrays.asList(excludedTlsVersions.split(","))).build())
+                            .build();
+            }
+            netconfNodeBuilder.setProtocol(new ProtocolBuilder()
+                                            .setName(Name.TLS)
+                                            .setSpecification(tlsCase)
+                                            .build());
+        } else {
+            return "Invalid protocol: " + protocol + ". Only SSH and TLS are supported.";
+        }
+
+        service.connectDevice(netconfNodeBuilder.build(), deviceId);
         final String message = "Netconf connector added succesfully";
         return message;
     }
index 874dbc3c1b0db4ffcf8c6e59c295408cc3d769da..f34cbed0014489d34572178e41d8c612440bc635 100644 (file)
@@ -40,8 +40,7 @@ public class NetconfListDevicesCommand extends AbstractAction {
         table.column(NetconfConsoleConstants.NETCONF_PORT).alignLeft();
         table.column(NetconfConsoleConstants.STATUS).alignLeft();
 
-        for (final String nodeIds : allDevices.keySet()) {
-            final Map<String, String> attributes = allDevices.get(nodeIds);
+        for (final Map<String, String> attributes : allDevices.values()) {
             table.addRow().addContent(attributes.get(NetconfConsoleConstants.NETCONF_ID),
                     attributes.get(NetconfConsoleConstants.NETCONF_IP),
                     attributes.get(NetconfConsoleConstants.NETCONF_PORT),
index a6e76350a02299f8fbca45789d3ae81e5ead71ad..8ab84d7257168c3bd6818f5a1307b8064d20015b 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import javax.annotation.Nonnull;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
@@ -75,7 +76,7 @@ public class NetconfShowDeviceCommand extends AbstractAction {
         }
 
         if (!NetconfCommandUtils.isIpValid(deviceIp)
-                || (devicePort != null && !NetconfCommandUtils.isPortValid(devicePort))) {
+                || devicePort != null && !NetconfCommandUtils.isPortValid(devicePort)) {
             return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
         }
 
@@ -93,8 +94,9 @@ public class NetconfShowDeviceCommand extends AbstractAction {
         table.column(NetconfConsoleConstants.STATUS).alignLeft();
         table.column(NetconfConsoleConstants.AVAILABLE_CAPABILITIES).alignLeft();
 
-        for (final String nodeId : devices.keySet()) {
-            final Map<String, List<String>> device = devices.get(nodeId);
+        for (final Entry<String, Map<String, List<String>>> entry : devices.entrySet()) {
+            final String nodeId = entry.getKey();
+            final Map<String, List<String>> device = entry.getValue();
             table.addRow().addContent(nodeId,
                     device.get(NetconfConsoleConstants.NETCONF_IP).get(NetconfConsoleConstants.DEFAULT_INDEX),
                     device.get(NetconfConsoleConstants.NETCONF_PORT).get(NetconfConsoleConstants.DEFAULT_INDEX),
index 9a9fa6e1ee09c7bf665027827c2f1144cc2c428a..8954e4a2947cc3c20a10108447e8d617b315fa83 100644 (file)
@@ -17,6 +17,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.UUID;
 import java.util.stream.Collectors;
@@ -73,7 +74,8 @@ public class NetconfCommandsImpl implements NetconfCommands {
             attributes.put(NetconfConsoleConstants.NETCONF_IP,
                     netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
             attributes.put(NetconfConsoleConstants.NETCONF_PORT, netconfNode.getPort().getValue().toString());
-            attributes.put(NetconfConsoleConstants.STATUS, netconfNode.getConnectionStatus().name().toLowerCase());
+            attributes.put(NetconfConsoleConstants.STATUS, netconfNode.getConnectionStatus().name()
+                    .toLowerCase(Locale.ROOT));
             netconfNodes.put(node.getNodeId().getValue(), attributes);
         }
         return netconfNodes;
index afedf3d5fc5142028b2b6ea68371e618263e022b..45cbb85fa1ba2e90bbeed96352914bf15e80ece8 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netconf.console.commands;
 
 import static junit.framework.TestCase.assertEquals;
 import static junit.framework.TestCase.assertTrue;
+import static org.mockito.BDDMockito.given;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.doNothing;
@@ -18,17 +19,24 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.MockitoAnnotations.initMocks;
 
+import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
 
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(Strings.class)
 public class NetconfCommandsImplCallsTest {
 
     @Mock
@@ -48,6 +56,8 @@ public class NetconfCommandsImplCallsTest {
 
         netconfConnectDeviceCommand = new NetconfConnectDeviceCommand(netconfCommands, "192.168.1.1", "7777");
 
+        PowerMockito.mockStatic(Strings.class);
+        given(Strings.isNullOrEmpty(any())).willReturn(false);
         netconfConnectDeviceCommand.doExecute();
         doNothing().when(netconfCommands).connectDevice(any(), any());
         verify(netconfCommands, times(1)).connectDevice(any(), any());
index 68dbc385726fa4036969dfdb32886d7903ad8235..b449c573b657e9736ef2177b6709ae8a13c0a49b 100644 (file)
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
index 943edd7365a0b8b0a739d37c74b9d0a64fc8e801..026a481ae0985107aff6d9a3ff90c3bc863daf5f 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.netconf.impl;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
@@ -19,6 +18,7 @@ import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.monitoring.SessionEvent;
 import org.opendaylight.netconf.api.monitoring.SessionListener;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.util.messages.SendErrorExceptionUtil;
index b3e263a92beadc5f17597abc0eb46340556f3ff2..e32d5c7e451be7f4492b95ad499c11e5dc988627 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netconf.impl;
 
 import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.channel.Channel;
 import io.netty.channel.local.LocalAddress;
 import io.netty.util.Timer;
@@ -52,6 +53,7 @@ public class NetconfServerSessionNegotiator
     }
 
     @Override
+    @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
     protected NetconfServerSession getSession(
             NetconfServerSessionListener sessionListener, Channel channel,
             NetconfHelloMessage message) {
index 1cf2d41c08555a8ffd358fceb871db53f659b50d..1a018363e513e8889a6facda9ed7dc6ce7bf2b63 100644 (file)
@@ -11,10 +11,10 @@ package org.opendaylight.netconf.impl.mapping.operations;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collections;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
index db75e6e0f53e18b21fc19024026d5e78ec337e2f..f1f57c204a43274a0485e7f6df68453f84864a04 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.netconf.impl.mapping.operations;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
+import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
+import org.opendaylight.netconf.api.DocumentedException.ErrorType;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
index 600f63743d07cd41413d7af727da53bd2ebe9abe..a60ffb756aa7595ef012b583263bba9f0eadc6da 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.netconf.impl.mapping.operations;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
index 5c292b1f6e5b9f70a7cca773554166c845db1339..cd3aa6104e24ca777e83517b8e6f58075b4ec2e7 100644 (file)
@@ -20,7 +20,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
@@ -95,15 +95,12 @@ public class AggregatedNetconfOperationServiceFactory
         }
         listeners.add(listener);
 
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                synchronized (AggregatedNetconfOperationServiceFactory.this) {
-                    listeners.remove(listener);
-                    CloseableUtil.closeAll(regs.values());
-                    for (final Map.Entry<NetconfOperationServiceFactory, AutoCloseable> reg : regs.entrySet()) {
-                        registrations.remove(reg.getKey(), reg.getValue());
-                    }
+        return () -> {
+            synchronized (AggregatedNetconfOperationServiceFactory.this) {
+                listeners.remove(listener);
+                CloseableUtil.closeAll(regs.values());
+                for (final Map.Entry<NetconfOperationServiceFactory, AutoCloseable> reg : regs.entrySet()) {
+                    registrations.remove(reg.getKey(), reg.getValue());
                 }
             }
         };
index 78041d00ba4bb84c436f144aea357499d337232f..6259ba28a3af10d84eaf787c28ac09dc6b10b3c0 100644 (file)
@@ -23,8 +23,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
index e66df69c05a23555d9d4582151263e6d2baed9fa..1e07ed2d61bef206eea5961572a11d4d1450ce33 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.netconf.impl.osgi;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.w3c.dom.Document;
 
index bc1618b0d44a986d3295a551b955334c6d0b09e3..ee712b78c3a8d1bf421f2f2dab784105713f74a2 100644 (file)
@@ -16,9 +16,9 @@ import java.util.HashSet;
 import java.util.NavigableMap;
 import java.util.Set;
 import java.util.TreeMap;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.impl.mapping.operations.DefaultCloseSession;
 import org.opendaylight.netconf.impl.mapping.operations.DefaultNetconfOperation;
index ad996748566d1bb7e06478dc2e40a0e734e34006..18b490ab13b258bb7038483be3abe2b33ada35e0 100644 (file)
@@ -12,7 +12,7 @@ import com.google.common.collect.Maps;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.util.messages.SendErrorExceptionUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index c49b3ad9783a92af545b16843500360b12c290a5..cfa1915e3e8303b6b69f34d6cb48663a852f6e08 100644 (file)
@@ -47,16 +47,16 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.monitoring.SessionEvent;
 import org.opendaylight.netconf.api.monitoring.SessionListener;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.netconf.client.SimpleNetconfClientSessionListener;
@@ -88,9 +88,9 @@ public class ConcurrentClientsTest {
     private static final int CONCURRENCY = 32;
     private static final InetSocketAddress NETCONF_ADDRESS = new InetSocketAddress("127.0.0.1", 8303);
 
-    private int nettyThreads;
-    private Class<? extends Runnable> clientRunnable;
-    private Set<String> serverCaps;
+    private final int nettyThreads;
+    private final Class<? extends Runnable> clientRunnable;
+    private final Set<String> serverCaps;
 
     public ConcurrentClientsTest(int nettyThreads, Class<? extends Runnable> clientRunnable, Set<String> serverCaps) {
         this.nettyThreads = nettyThreads;
@@ -124,11 +124,8 @@ public class ConcurrentClientsTest {
         doNothing().when(sessionListener).onSessionUp(any(NetconfServerSession.class));
         doNothing().when(sessionListener).onSessionDown(any(NetconfServerSession.class));
         doNothing().when(sessionListener).onSessionEvent(any(SessionEvent.class));
-        doReturn(new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
+        doReturn((AutoCloseable) () -> {
 
-            }
         }).when(monitoring).registerCapabilitiesListener(any(NetconfMonitoringService.CapabilitiesListener.class));
         doReturn(sessionListener).when(monitoring).getSessionListener();
         doReturn(new CapabilitiesBuilder().setCapability(Collections.<Uri>emptyList()).build()).when(monitoring)
@@ -289,10 +286,7 @@ public class ConcurrentClientsTest {
 
         @Override
         public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-            return new AutoCloseable() {
-                @Override
-                public void close() throws Exception {
-                }
+            return () -> {
             };
         }
 
index 10ef3cd59752704e51aeda6f331acdf4e1637ebf..0b07c774f250ef1db726c2a15b20ad016956f28b 100644 (file)
@@ -62,18 +62,19 @@ public class MessageParserTest {
         int msgLength = out.readableBytes();
 
         int chunkCount = msgLength / ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE;
-        if ((msgLength % ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE) != 0) {
+        if (msgLength % ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE != 0) {
             chunkCount++;
         }
+
+        byte[] endOfChunkBytes = NetconfMessageConstants.END_OF_CHUNK.getBytes(StandardCharsets.UTF_8);
         for (int i = 1; i <= chunkCount; i++) {
             ByteBuf recievedOutbound = (ByteBuf) messages.poll();
             int exptHeaderLength = ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE;
             if (i == chunkCount) {
-                exptHeaderLength = msgLength - (ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE * (i - 1));
-                byte[] eom = new byte[NetconfMessageConstants.END_OF_CHUNK.length];
-                recievedOutbound
-                        .getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_CHUNK.length, eom);
-                assertArrayEquals(NetconfMessageConstants.END_OF_CHUNK, eom);
+                exptHeaderLength = msgLength - ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE * (i - 1);
+                byte[] eom = new byte[endOfChunkBytes.length];
+                recievedOutbound.getBytes(recievedOutbound.readableBytes() - endOfChunkBytes.length, eom);
+                assertArrayEquals(endOfChunkBytes, eom);
             }
 
             byte[] header = new byte[String.valueOf(exptHeaderLength).length()
@@ -99,10 +100,10 @@ public class MessageParserTest {
         testChunkChannel.writeOutbound(this.msg);
         ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound();
 
-        byte[] eom = new byte[NetconfMessageConstants.END_OF_MESSAGE.length];
-        recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_MESSAGE.length,
-                eom);
-        assertArrayEquals(NetconfMessageConstants.END_OF_MESSAGE, eom);
+        byte[] endOfMsgBytes = NetconfMessageConstants.END_OF_MESSAGE.getBytes(StandardCharsets.UTF_8);
+        byte[] eom = new byte[endOfMsgBytes.length];
+        recievedOutbound.getBytes(recievedOutbound.readableBytes() - endOfMsgBytes.length, eom);
+        assertArrayEquals(endOfMsgBytes, eom);
 
         testChunkChannel.writeInbound(recievedOutbound);
         NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound();
index 37e17659fc39b3115f6213866184dedaeb4952a6..493326281f08c9a91cf8c2f53192436c0dee5325 100644 (file)
@@ -25,12 +25,12 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.monitoring.SessionEvent;
 import org.opendaylight.netconf.api.monitoring.SessionListener;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.w3c.dom.Document;
@@ -167,4 +167,4 @@ public class NetconfServerSessionListenerTest {
         };
     }
 
-}
\ No newline at end of file
+}
index 3d44cdb23e988ea999854f116399be4f91d1eddf..6e4408643680c39c21ef1a3c224aaa19ae8ba856 100644 (file)
@@ -22,9 +22,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXICodec;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
index 2566e070224e0fdffe987e1462cee71412e02227..12933294560cc45eef84a371cf960b5a98ac5e88 100644 (file)
@@ -19,16 +19,17 @@ import static org.mockito.Mockito.verify;
 
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
 import io.netty.util.concurrent.GenericFutureListener;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.impl.NetconfServerSessionListener;
 import org.w3c.dom.Document;
@@ -39,9 +40,7 @@ public class DefaultCloseSessionTest {
         final EventLoop eventLoop = mock(EventLoop.class);
         doReturn(eventLoop).when(channel).eventLoop();
         doAnswer(invocation -> {
-            final Object[] args = invocation.getArguments();
-            final Runnable runnable = (Runnable) args[0];
-            runnable.run();
+            invocation.getArgumentAt(0, Runnable.class).run();
             return null;
         }).when(eventLoop).execute(any(Runnable.class));
         doReturn(true).when(eventLoop).inEventLoop();
@@ -61,12 +60,13 @@ public class DefaultCloseSessionTest {
         doReturn(channelFuture).when(channel).close();
         doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
 
-        final ChannelFuture sendFuture = mock(ChannelFuture.class);
+        final ChannelPromise sendFuture = mock(ChannelPromise.class);
         doAnswer(invocation -> {
-            ((GenericFutureListener) invocation.getArguments()[0]).operationComplete(sendFuture);
+            invocation.getArgumentAt(0, GenericFutureListener.class).operationComplete(sendFuture);
             return null;
         }).when(sendFuture).addListener(any(GenericFutureListener.class));
-        doReturn(sendFuture).when(channel).writeAndFlush(anyObject());
+        doReturn(sendFuture).when(channel).newPromise();
+        doReturn(sendFuture).when(channel).writeAndFlush(anyObject(), anyObject());
         doReturn(true).when(sendFuture).isSuccess();
         final NetconfServerSessionListener listener = mock(NetconfServerSessionListener.class);
         doNothing().when(listener).onSessionTerminated(any(NetconfServerSession.class),
@@ -90,8 +90,7 @@ public class DefaultCloseSessionTest {
         AutoCloseable res = mock(AutoCloseable.class);
         doThrow(NetconfDocumentedException.class).when(res).close();
         DefaultCloseSession session = new DefaultCloseSession("", res);
-        Document doc = XmlUtil.newDocument();
         XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
-        session.handleWithNoSubsequentOperations(doc, elem);
+        session.handleWithNoSubsequentOperations(XmlUtil.newDocument(), elem);
     }
 }
index e181cc6227f5334ff264543be6d094fdf67b6e3e..8459874f8eb118e40a21bbfb52c36f96a14c5d12 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.netconf.impl.mapping.operations;
 
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
@@ -20,8 +20,8 @@ import io.netty.channel.Channel;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.w3c.dom.Document;
 
index bf078e2200574f8d435fbd7072adab0002fd3265..d3b0fcd76aaaafd69dbf2d5a36e1251a437dbda1 100644 (file)
@@ -20,16 +20,16 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
 
 
 public class AggregatedNetconfOperationServiceFactoryTest {
 
-    private Set<Capability> factory1Caps = new HashSet<>();
-    private Set<Capability> factory2Caps = new HashSet<>();
+    private final Set<Capability> factory1Caps = new HashSet<>();
+    private final Set<Capability> factory2Caps = new HashSet<>();
 
     @Mock
     private CapabilityListener listener1;
@@ -124,4 +124,4 @@ public class AggregatedNetconfOperationServiceFactoryTest {
         verify(autoCloseable2, times(2)).close();
     }
 
-}
\ No newline at end of file
+}
index c322737993202eb9d6709c170a6bae7032638cbe..54d3cb3b7c7246f75dae6baef7194779d78d457b 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.controller.config.util.capability.YangModuleCapability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
+import org.opendaylight.netconf.api.capability.YangModuleCapability;
 import org.opendaylight.netconf.api.monitoring.NetconfManagementSession;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
index 1736c72f9371e16a6db516afc7b8ceb9dd69c13a..8b1afec0a866936ad3905944f99e1b14d82c4e6d 100644 (file)
@@ -23,8 +23,8 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
@@ -122,4 +122,4 @@ public class NetconfOperationRouterImplTest {
         verify(operationService).close();
     }
 
-}
\ No newline at end of file
+}
index 305c20ab5aad94811fcedd9398fde7129f9c9d82..860aa36e8b85a4bb06ea16bf17742bacbb70dd53 100644 (file)
@@ -26,8 +26,8 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.NetconfManagementSession;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.monitoring.SessionEvent;
index b6503f3ee663d4c1e3d7a5d9b69b581609af4e1a..beeede463ce6b4de85c057696331cccab1f9b779 100644 (file)
       <artifactId>xmlunit</artifactId>
     </dependency>
     <!-- compile dependencies -->
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-api</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>config-netconf-connector</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-persister-impl</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-util</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>sal-netconf-connector</artifactId>
index af13ed981b42a3b59f11c0a7e25b83debbb29af5..70dc1265b460b10a0b9091b9c6784376826898a7 100644 (file)
       <artifactId>guava</artifactId>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
index 445eb6d3d62923fb176c3adc7ba6172c5090fcaa..7a9523cae21e88b2a5e6cf040f3dedb42dc6e9a6 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.netconf.mapping.api;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.w3c.dom.Document;
 
 /**
index 1e57fc702154a394874ae8458cbc209e79e7ab66..b7fae22c00b7d15d60f7201d2f951d23d4533881 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.netconf.mapping.api;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.w3c.dom.Document;
 
 /**
index 57d896e6ea083697ffcc4816f71027c4102c7fbe..9458476e83943142be07e67d83dc27255921e73f 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.netconf.mapping.api;
 
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 
 /**
index 0321886c6f5cb47dc45cd42e76fec2d398d9884c..80a56f6c63246c790f6d8a153b8990172f39ebaa 100644 (file)
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
           </instructions>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
index 9e122e36c35e39b37972ba96f4592fe1d73a763d..7aa2c2a4d7c99e72639953698e501447d1c8ca6e 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.netconf.monitoring;
 
 import java.util.Collections;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
@@ -36,7 +35,7 @@ public class Get extends AbstractNetconfOperation {
     private Element getPlaceholder(final Document innerResult)
             throws DocumentedException {
         final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
-                innerResult.getDocumentElement(), XmlMappingConstants.RPC_REPLY_KEY,
+                innerResult.getDocumentElement(), XmlNetconfConstants.RPC_REPLY_KEY,
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
         return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
     }
index c3527a29be17ad499e8c574615eee0b1e2823d96..bc42da5b0870b5e9493f40c36b4a3c8578e796a1 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.netconf.monitoring;
 import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 24d9066ba231781f8c37a686a6513c86a576ea13..3db158af2e5ba4dee6d9ecad46f900756a2490e7 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.monitoring.osgi;
 
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
@@ -48,11 +48,8 @@ public class NetconfMonitoringActivator implements BundleActivator {
 
         private final NetconfMonitoringOperationService operationService;
 
-        private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                // NOOP
-            }
+        private static final AutoCloseable AUTO_CLOSEABLE = () -> {
+            // NOOP
         };
 
         public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
index 57ce954dcea21a17abb18d3e11bc3c4df0801e71..37788249450e980f660f9d2b5df80b1f55f648cf 100644 (file)
@@ -30,7 +30,7 @@ final class MonitoringSchema {
 
     @XmlElement(name = "namespace")
     public String getNamespace() {
-        return schema.getNamespace().getValue().toString();
+        return schema.getNamespace().getValue();
     }
 
     @XmlElement(name = "location")
index d452fd5a85c080c4bf2c7f5c475c14365c722999..5ced56c5e6a15ad7c3542dd57aec2c7cd7d28b71 100644 (file)
@@ -18,10 +18,10 @@ import static org.mockito.Mockito.mock;
 import com.google.common.base.Optional;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Document;
 
 public class GetSchemaTest {
@@ -59,4 +59,4 @@ public class GetSchemaTest {
                 XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema))));
     }
 
-}
\ No newline at end of file
+}
index 397e1d21e1c053987ded2a97ac4749542c57359d..012d7291982a699e1835b325ea162a7758acb3ed 100644 (file)
@@ -21,9 +21,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
index bfc0f8504f7c53efa27ab75de74325ab5f3fb2c3..0a3bdabbf284322f43adee12794ae82c6d6ef829 100644 (file)
@@ -18,8 +18,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.monitoring.xml.model.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
index 6e0da46b0afaabc06c8c6f113a67f22a157320dd..d3dca9abdff528fa70cd93a9e8386e9dc1b08625 100644 (file)
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
index fdcd7e6479a91f8ef2b69b7ec3ec771730f4e701..707312abdd709bec92a8791a19283fdd19c26205 100644 (file)
@@ -12,18 +12,16 @@ import com.siemens.ct.exi.exceptions.UnsupportedOption;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
-import io.netty.channel.DefaultChannelPromise;
+import io.netty.channel.ChannelPromise;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToByteEncoder;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.FutureListener;
 import java.io.IOException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.netconf.api.NetconfExiSession;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSession;
 import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXICodec;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToEXIEncoder;
@@ -75,29 +73,17 @@ public abstract class AbstractNetconfSession<S extends NetconfSession,L extends
         // Restconf writes to a netconf mountpoint execute multiple messages
         // and one of these was executed from a restconf thread thus breaking ordering so
         // we need to execute all messages from an EventLoop thread.
-        final DefaultChannelPromise proxyFuture = new DefaultChannelPromise(channel);
-        channel.eventLoop().execute(new Runnable() {
-            @Override
-            public void run() {
-                final ChannelFuture future = channel.writeAndFlush(netconfMessage);
-                future.addListener(new FutureListener<Void>() {
-                    @Override
-                    public void operationComplete(final Future<Void> future) throws Exception {
-                        if (future.isSuccess()) {
-                            proxyFuture.setSuccess();
-                        } else {
-                            proxyFuture.setFailure(future.cause());
-                        }
-                    }
-                });
-                if (delayedEncoder != null) {
-                    replaceMessageEncoder(delayedEncoder);
-                    delayedEncoder = null;
-                }
+
+        final ChannelPromise promise = channel.newPromise();
+        channel.eventLoop().execute(() -> {
+            channel.writeAndFlush(netconfMessage, promise);
+            if (delayedEncoder != null) {
+                replaceMessageEncoder(delayedEncoder);
+                delayedEncoder = null;
             }
         });
 
-        return proxyFuture;
+        return promise;
     }
 
     @Override
index 1d7a3cd5adad2b8b0218e91b1970fb999558b69d..f2592e42304fa62bc1fc9bcf6b149a6c7a7d6364 100644 (file)
@@ -13,7 +13,6 @@ import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
 import java.nio.charset.StandardCharsets;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
 
 public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
     public static final int DEFAULT_CHUNK_SIZE = 8192;
@@ -41,13 +40,13 @@ public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf
         do {
             final int xfer = Math.min(chunkSize, msg.readableBytes());
 
-            out.writeBytes(NetconfMessageConstants.START_OF_CHUNK);
+            out.writeBytes(MessageParts.START_OF_CHUNK);
             out.writeBytes(String.valueOf(xfer).getBytes(StandardCharsets.US_ASCII));
             out.writeByte('\n');
 
             out.writeBytes(msg, xfer);
         } while (msg.isReadable());
 
-        out.writeBytes(NetconfMessageConstants.END_OF_CHUNK);
+        out.writeBytes(MessageParts.END_OF_CHUNK);
     }
 }
index fdb0aae950e225d5622f4433cd5a59dd39df89ef..74009a7301b87b9546ba26793ce89c99bb9b854d 100644 (file)
@@ -11,12 +11,11 @@ package org.opendaylight.netconf.nettyutil.handler;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
 
 public class EOMFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
     @Override
     protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
         out.writeBytes(msg);
-        out.writeBytes(NetconfMessageConstants.END_OF_MESSAGE);
+        out.writeBytes(MessageParts.END_OF_MESSAGE);
     }
 }
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/MessageParts.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/MessageParts.java
new file mode 100644 (file)
index 0000000..3db8ca6
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2018 Inocybe Technologies and others.  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.netconf.nettyutil.handler;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
+
+/**
+ * netconf message part constants as bytes.
+ *
+ * @author Thomas Pantelis
+ */
+interface MessageParts {
+    byte[] END_OF_MESSAGE = NetconfMessageConstants.END_OF_MESSAGE.getBytes(UTF_8);
+    byte[] START_OF_CHUNK = NetconfMessageConstants.START_OF_CHUNK.getBytes(UTF_8);
+    byte[] END_OF_CHUNK = NetconfMessageConstants.END_OF_CHUNK.getBytes(UTF_8);
+}
index 6c0f5a1f6e658043e3fb5c7965def379694fdeca..9c441404d82373d69b41ee302a6ea38cb36d2025 100644 (file)
@@ -11,11 +11,10 @@ package org.opendaylight.netconf.nettyutil.handler;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.handler.codec.DelimiterBasedFrameDecoder;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
 
 public class NetconfEOMAggregator extends DelimiterBasedFrameDecoder {
 
-    public static final ByteBuf DELIMITER = Unpooled.wrappedBuffer(NetconfMessageConstants.END_OF_MESSAGE);
+    public static final ByteBuf DELIMITER = Unpooled.wrappedBuffer(MessageParts.END_OF_MESSAGE);
 
     public NetconfEOMAggregator() {
         super(Integer.MAX_VALUE, DELIMITER);
index 5ca4e491d86cec65a88344429b9bc099e1d64079..82f707572ce2a160ef45ae10609f810c45333c8d 100644 (file)
@@ -21,11 +21,11 @@ import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
index 60a8dd1fb0265312c26a53924eee515943564aa2..ee8f1ad5b762cb33003d7044f6882585277571b2 100644 (file)
@@ -15,9 +15,9 @@ import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import java.io.IOException;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.FailedNetconfMessage;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
index 088f638aa6b21b2f8d87b14f7094f81986f39f6a..8d8ccd9fb732f2f6ceeb1d3b404cacf55a6384ec 100644 (file)
@@ -16,7 +16,7 @@ import com.siemens.ct.exi.FidelityOptions;
 import com.siemens.ct.exi.exceptions.UnsupportedOption;
 import com.siemens.ct.exi.helpers.DefaultEXIFactory;
 import java.util.Objects;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
index f7524f8fbf25d71ee1cf017e3306d7e0d089e5e0..b3f158b12b2976cd1001093d57c306e7f1cc2bab 100644 (file)
@@ -11,9 +11,9 @@ package org.opendaylight.netconf.nettyutil.handler.exi;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
index c3ff3496625e0f84f154692f49d71b924d67ca15..2d080ef3fca0e4372937b8bcb11c807fd5a1264a 100644 (file)
@@ -119,9 +119,10 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
             session = future.getSession();
             final AuthFuture authenticateFuture = authenticationHandler.authenticate(session);
+            final ClientSession localSession = session;
             authenticateFuture.addListener(future1 -> {
                 if (future1.isSuccess()) {
-                    handleSshAuthenticated(session, ctx);
+                    handleSshAuthenticated(localSession, ctx);
                 } else {
                     // Exception does not have to be set in the future, add simple exception in such case
                     final Throwable exception = future1.getException() == null
@@ -164,8 +165,9 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
         // TODO we should also read from error stream and at least log from that
 
+        ClientChannel localChannel = channel;
         sshReadAsyncListener = new AsyncSshHandlerReader(() -> AsyncSshHandler.this.disconnect(ctx, ctx.newPromise()),
-            msg -> ctx.fireChannelRead(msg), channel.toString(), channel.getAsyncOut());
+            msg -> ctx.fireChannelRead(msg), localChannel.toString(), localChannel.getAsyncOut());
 
         // if readAsyncListener receives immediate close,
         // it will close this handler and closing this handler sets channel variable to null
@@ -198,10 +200,9 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
         this.connectPromise = promise;
 
         if (negotiationFuture != null) {
-
             negotiationFutureListener = future -> {
                 if (future.isSuccess()) {
-                    connectPromise.setSuccess();
+                    promise.setSuccess();
                 }
             };
             //complete connection promise with netconf negotiation future
@@ -249,10 +250,12 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
         if (session != null && !session.isClosed() && !session.isClosing()) {
             session.close(false).addListener(future -> {
-                if (!future.isClosed()) {
-                    session.close(true);
+                synchronized (this) {
+                    if (!future.isClosed()) {
+                        session.close(true);
+                    }
+                    session = null;
                 }
-                session = null;
             });
         }
 
index af64d2901576d1d1cc993b475e36c407eed300c3..a2e628366c3a9f53776e260f32ef797d74788937 100644 (file)
@@ -41,12 +41,12 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.opendaylight.netconf.api.NetconfSessionPreferences;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
 import org.opendaylight.netconf.nettyutil.handler.EOMFramingMechanismEncoder;
 import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory;
@@ -192,4 +192,4 @@ public class AbstractNetconfSessionNegotiatorTest {
     }
 
 
-}
\ No newline at end of file
+}
index c372ecb34c7b17e0b9d74752c60d99407b4c75e5..3626fc008bd453a2fc80f83e81dd25aefe559c37 100644 (file)
@@ -26,6 +26,7 @@ import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToByteEncoder;
@@ -35,13 +36,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
 import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
 
@@ -56,7 +54,7 @@ public class AbstractNetconfSessionTest {
     @Mock
     private EventLoop eventLoop;
     @Mock
-    private ChannelFuture writeFuture;
+    private ChannelPromise writeFuture;
 
     private NetconfHelloMessage clientHello;
 
@@ -71,7 +69,9 @@ public class AbstractNetconfSessionTest {
 
         doReturn(writeFuture).when(writeFuture).addListener(any(GenericFutureListener.class));
 
+        doReturn(writeFuture).when(channel).newPromise();
         doReturn(writeFuture).when(channel).writeAndFlush(any(NetconfMessage.class));
+        doReturn(writeFuture).when(channel).writeAndFlush(any(NetconfMessage.class), any(ChannelPromise.class));
         doReturn(pipeline).when(channel).pipeline();
         doReturn("mockChannel").when(channel).toString();
         doReturn(mock(ChannelFuture.class)).when(channel).close();
@@ -79,18 +79,12 @@ public class AbstractNetconfSessionTest {
         doReturn(null).when(pipeline).replace(anyString(), anyString(), any(ChannelHandler.class));
 
         doReturn(eventLoop).when(channel).eventLoop();
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final Runnable runnable = (Runnable) args[0];
-                runnable.run();
-                return null;
-            }
+        doAnswer(invocation -> {
+            invocation.getArgumentAt(0, Runnable.class).run();
+            return null;
         }).when(eventLoop).execute(any(Runnable.class));
 
-        clientHello = NetconfHelloMessage.createClientHello(Collections.<String>emptySet(),
-                Optional.<NetconfHelloMessageAdditionalHeader>absent());
+        clientHello = NetconfHelloMessage.createClientHello(Collections.emptySet(), Optional.absent());
     }
 
     @Test
@@ -159,10 +153,10 @@ public class AbstractNetconfSessionTest {
     @Test
     public void testSendMessage() throws Exception {
         final TestingNetconfSession testingNetconfSession = new TestingNetconfSession(listener, channel, 1L);
-        final NetconfHelloMessage hello = NetconfHelloMessage.createClientHello(Collections.<String>emptySet(),
-                Optional.<NetconfHelloMessageAdditionalHeader>absent());
+        final NetconfHelloMessage hello = NetconfHelloMessage.createClientHello(Collections.emptySet(),
+            Optional.absent());
         testingNetconfSession.sendMessage(hello);
-        verify(channel).writeAndFlush(hello);
+        verify(channel).writeAndFlush(hello, writeFuture);
     }
 
 }
index 748e55c47afd3992db4e7fc3616532465b599457..b00de8ad5f0b9d8413b4865eb4117238a2d79c2e 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertEquals;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.junit.Test;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
 
 public class EOMFramingMechanismEncoderTest {
 
@@ -24,6 +23,6 @@ public class EOMFramingMechanismEncoderTest {
         final ByteBuf destination = Unpooled.buffer();
         new EOMFramingMechanismEncoder().encode(null, source, destination);
 
-        assertEquals(Unpooled.wrappedBuffer(source.array(), NetconfMessageConstants.END_OF_MESSAGE), destination);
+        assertEquals(Unpooled.wrappedBuffer(source.array(), MessageParts.END_OF_MESSAGE), destination);
     }
-}
\ No newline at end of file
+}
index a6c5f0d3a4ddf1408c463042aafe4cd19f1827cf..193f87ce8f871c2f5334eadd92cfc4fe66c6983e 100644 (file)
@@ -26,8 +26,8 @@ import javax.xml.transform.sax.SAXResult;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
 
 public class NetconfEXIHandlersTest {
@@ -76,4 +76,4 @@ public class NetconfEXIHandlersTest {
 
         XMLUnit.compareXML(msg.getDocument(), ((NetconfMessage) out.get(0)).getDocument());
     }
-}
\ No newline at end of file
+}
index 794ce8dad2d014ac66996a954229ddddd69bf52c..899208a6702c2bb7b55f96affa5e3e6eae9fe260 100644 (file)
@@ -19,10 +19,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 
 public class NetconfHelloMessageToXMLEncoderTest {
 
@@ -65,4 +65,4 @@ public class NetconfHelloMessageToXMLEncoderTest {
                 "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
         new NetconfHelloMessageToXMLEncoder().encode(ctx, msg, null);
     }
-}
\ No newline at end of file
+}
index fc20f9585d4a8f7e1c0702bbe1f5e564bd7985e4..1581377f90a9e3020abd8f4d03445258b5de5c49 100644 (file)
@@ -20,8 +20,8 @@ import io.netty.buffer.Unpooled;
 import java.util.List;
 import org.hamcrest.CoreMatchers;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 
 public class NetconfXMLToHelloMessageDecoderTest {
 
@@ -83,4 +83,4 @@ public class NetconfXMLToHelloMessageDecoderTest {
         NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
         decoder.decode(null, msg1, out);
     }
-}
\ No newline at end of file
+}
index 272d5b30e4f53df2774249790c81d02fcd4974fc..018acdbc7f5ce5e9cdb63b97e97b635bfbffe60f 100644 (file)
@@ -17,8 +17,8 @@ import java.util.Arrays;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 
 @RunWith(Parameterized.class)
 public class EXIParametersTest {
@@ -77,4 +77,4 @@ public class EXIParametersTest {
         assertEquals(fidelity, factory.getFidelityOptions());
         assertEquals(coding, factory.getCodingMode());
     }
-}
\ No newline at end of file
+}
index 42d768bfb99fb7a848f95c62f7d458438a76969a..5af5697fa65c4e23392b267af88d9fae51720c12 100644 (file)
             <artifactId>slf4j-api</artifactId>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 3e7f562434770fe89cb0912e2d76b9c1b92c8836..87de89a5dba7f94488b6ebae6fdafd69923aa874 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netconf.notifications;
 
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.text.ParsePosition;
 import java.time.Instant;
 import java.time.LocalDateTime;
@@ -179,6 +180,7 @@ public final class NetconfNotification extends NetconfMessage {
     /**
      * Create new notification with provided timestamp.
      */
+    @SuppressFBWarnings("EI_EXPOSE_REP2") // stores a reference to an externally mutable Date object
     public NetconfNotification(final Document notificationContent, final Date eventTime) {
         super(wrapNotification(notificationContent, eventTime));
         this.eventTime = eventTime;
@@ -189,6 +191,7 @@ public final class NetconfNotification extends NetconfMessage {
      *
      * @return notification event time
      */
+    @SuppressFBWarnings("EI_EXPOSE_REP")
     public Date getEventTime() {
         return eventTime;
     }
index 4389e44f0bf0a11ac2bceb7ef87d09c0b61c3230..152d2348971bde4dd357d6dc69c2203b5209bfd7 100644 (file)
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
                     </instructions>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 </project>
index 9f79caf3f05eaea1e5e67f67cc3d1b78ecadd091..9860de76bbc73ebed93d2ab1ddd5e11b0f5cba8a 100644 (file)
@@ -13,11 +13,11 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import java.util.Date;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.SessionAwareNetconfOperation;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.notifications.NetconfNotificationListener;
index 0ff934b39d57063961f398b2b22d3c000fa3c94f..bd7c9d17f98d3bd7a55538a15184f0273aa47010 100644 (file)
@@ -12,9 +12,8 @@ import com.google.common.base.Preconditions;
 import java.io.IOException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
@@ -89,7 +88,7 @@ public class Get extends AbstractNetconfOperation implements AutoCloseable {
     private static Element getPlaceholder(final Document innerResult)
             throws DocumentedException {
         final XmlElement rootElement = XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
-                XmlMappingConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+                XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
         return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
     }
 
index f45192c3b89d3b74d786f0e52537ec8b132eed81..4da6e82868dcdb3418f5be9c76b48a3ecc1ec49b 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.notifications.impl.ops;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Iterables;
 import java.io.IOException;
@@ -19,12 +18,12 @@ import java.util.Date;
 import javassist.ClassPool;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
 import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
 import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.util.NetconfUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl;
@@ -69,12 +68,7 @@ public final class NotificationsTransformUtil {
 
     private static RpcDefinition findCreateSubscriptionRpc() {
         return Iterables.getFirst(Collections2.filter(NOTIFICATIONS_SCHEMA_CTX.getOperations(),
-            new Predicate<RpcDefinition>() {
-                @Override
-                public boolean apply(final RpcDefinition input) {
-                    return input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION);
-                }
-            }), null);
+            input -> input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION)), null);
     }
 
     /**
index 146f5e7116aa3f56c2277b687d495696ef658360..21b7d0d83d6bd9fc1f999a594fddbe1522a9763a 100644 (file)
@@ -14,8 +14,8 @@ import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.util.NetconfConstants;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
@@ -62,12 +62,7 @@ public class Activator implements BundleActivator {
             @Override
             public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
                 listener.onCapabilitiesChanged(capabilities, Collections.<Capability>emptySet());
-                return new AutoCloseable() {
-                    @Override
-                    public void close() {
-                        listener.onCapabilitiesChanged(Collections.<Capability>emptySet(), capabilities);
-                    }
-                };
+                return () -> listener.onCapabilitiesChanged(Collections.<Capability>emptySet(), capabilities);
             }
 
             @Override
index 69bdb1fb843452f305716d4e8bef179ebd87687b..c27723e05d0d2dc039360b53faf091541ad5a10e 100644 (file)
@@ -18,9 +18,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotificationListener;
 import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
 import org.opendaylight.netconf.notifications.NotificationListenerRegistration;
@@ -59,4 +59,4 @@ public class CreateSubscriptionTest {
 
         Assert.assertThat(XmlUtil.toString(element), CoreMatchers.containsString("ok"));
     }
-}
\ No newline at end of file
+}
index 0abf5cbf9c8a644e9241573d998d7026c5847c3f..90c975df4ccb22f6689e5289b8017b38de6e26c9 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.netconf.notifications.impl.ops;
 import com.google.common.collect.Lists;
 import java.io.IOException;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.StreamsBuilder;
@@ -60,4 +60,4 @@ public class GetTest {
                 + "</data>\n"
                 + "</rpc-reply>");
     }
-}
\ No newline at end of file
+}
index 4ae9d85316ab86af092c7b65327982fad49d85e4..c48590496bf399886facfe889a3c0aa9ad6f0a02 100644 (file)
@@ -18,7 +18,7 @@ import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
index 66e9370c6db9a8e2985afe6f46bad82b2d67d489..cce998a32ab9787b95797ce56b14c16b927b2aa6 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Hashtable;
 import java.util.Set;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.util.NetconfConstants;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
index ab876da3b91db3a8944a63d44ffd63ac7e3a5866..acb0b824a9e4b7a4529d391ca567daaf6699ec11 100644 (file)
@@ -55,7 +55,6 @@
           <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
         </configuration>
       </plugin>
-<!--
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>findbugs-maven-plugin</artifactId>
@@ -63,7 +62,6 @@
           <failOnError>true</failOnError>
         </configuration>
       </plugin>
--->
     </plugins>
   </build>
 </project>
index 8af48eb5630c4521d1d79f45ead149ae3586d979..3b854f85c38cbee3c7b6074695f0a2ed25f20b48 100644 (file)
   <name>${project.artifactId}</name>
   <packaging>bundle</packaging>
 
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-artifacts</artifactId>
-        <version>0.9.0-SNAPSHOT</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-impl</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>threadpool-config-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>netty-config-api</artifactId>
-    </dependency>
 
     <dependency>
       <groupId>org.opendaylight.mdsal.model</groupId>
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
index 2a198383a693c91b90b6f3faa7462d64772a2ac9..e8ec506026d24d79255e6788671d28e836b87360 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.netconf.ssh;
 
-import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
+import java.nio.charset.StandardCharsets;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.server.ExitCallback;
@@ -52,27 +52,21 @@ final class SshProxyClientHandler extends ChannelInboundHandlerAdapter {
         writeAdditionalHeader(ctx);
 
         asyncSshHandlerWriter = new AsyncSshHandlerWriter(out);
-        asyncSshHandlerReader = new AsyncSshHandlerReader(new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                // Close both sessions (delegate server and remote client)
-                ctx.fireChannelInactive();
-                ctx.disconnect();
-                ctx.close();
-                asyncSshHandlerReader.close();
-                asyncSshHandlerWriter.close();
-            }
-        }, new AsyncSshHandlerReader.ReadMsgHandler() {
-            @Override
-            public void onMessageRead(final ByteBuf msg) {
-                if (LOG.isTraceEnabled()) {
-                    LOG.trace("Forwarding message for client: {} on channel: {}, message: {}",
-                            netconfHelloMessageAdditionalHeader.getAddress(), ctx.channel(),
-                            AsyncSshHandlerWriter.byteBufToString(msg));
-                }
-                // Just forward to delegate
-                ctx.writeAndFlush(msg);
+        asyncSshHandlerReader = new AsyncSshHandlerReader(() -> {
+            // Close both sessions (delegate server and remote client)
+            ctx.fireChannelInactive();
+            ctx.disconnect();
+            ctx.close();
+            asyncSshHandlerReader.close();
+            asyncSshHandlerWriter.close();
+        }, msg -> {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Forwarding message for client: {} on channel: {}, message: {}",
+                        netconfHelloMessageAdditionalHeader.getAddress(), ctx.channel(),
+                        AsyncSshHandlerWriter.byteBufToString(msg));
             }
+            // Just forward to delegate
+            ctx.writeAndFlush(msg);
         }, "ssh" + netconfHelloMessageAdditionalHeader.getAddress(), in);
 
 
@@ -80,7 +74,8 @@ final class SshProxyClientHandler extends ChannelInboundHandlerAdapter {
     }
 
     private void writeAdditionalHeader(final ChannelHandlerContext ctx) {
-        ctx.writeAndFlush(Unpooled.copiedBuffer(netconfHelloMessageAdditionalHeader.toFormattedString().getBytes()));
+        ctx.writeAndFlush(Unpooled.copiedBuffer(netconfHelloMessageAdditionalHeader.toFormattedString()
+                .getBytes(StandardCharsets.UTF_8)));
     }
 
     @Override
index 406a28aee4722740fdd04364f851832d2d40a522..f638a2bfbf13e35e53adbdc8f2e800ffeb6e308e 100644 (file)
@@ -12,9 +12,7 @@ import com.google.common.collect.ImmutableList;
 import io.netty.channel.EventLoopGroup;
 import java.io.IOException;
 import java.nio.channels.AsynchronousChannelGroup;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -84,15 +82,6 @@ public class SshProxyServer implements AutoCloseable {
         sshServer.start();
     }
 
-    private static Map<String, String> getProperties(final SshProxyServerConfiguration sshProxyServerConfiguration) {
-        final Map<String, String> ret = new HashMap<>();
-        ret.put(ServerFactoryManager.IDLE_TIMEOUT, String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
-        // TODO make auth timeout configurable on its own
-        ret.put(ServerFactoryManager.AUTH_TIMEOUT, String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
-
-        return ret;
-    }
-
     @Override
     public void close() throws IOException {
         try {
index 1447f5e94a68d1c4dd84785f832a165acf3e5550..040bd496469abed3624825a73f8f43766efd0993 100644 (file)
   <name>${project.artifactId}</name>
   <packaging>bundle</packaging>
 
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>config-artifacts</artifactId>
-        <version>0.9.0-SNAPSHOT</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-util</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>threadpool-config-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>netty-config-api</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.compendium</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
index 780b11dce16be9236a4eb74fe61df951a9f3bdb8..2ed1044b38d02b773712ad472653f3558e355dcd 100644 (file)
             <artifactId>akka-testkit_2.12</artifactId>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 62508a2c3b1d9ec9ccb0155ca147290217252662..0ac355d6dc0e4b53059e953b43d474cbd21b2ac4 100644 (file)
@@ -18,6 +18,7 @@ import akka.util.Timeout;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
@@ -47,7 +48,7 @@ class NetconfTopologyContext implements ClusterSingletonService {
     private NetconfNodeManager netconfNodeManager;
     private ActorRef masterActorRef;
     private boolean finalClose = false;
-    private boolean closed = false;
+    private final AtomicBoolean closed = new AtomicBoolean(false);
     private boolean isMaster;
 
     NetconfTopologyContext(final NetconfTopologySetup netconfTopologyDeviceSetup,
@@ -164,8 +165,8 @@ class NetconfTopologyContext implements ClusterSingletonService {
         }
     }
 
-    private synchronized void stopDeviceConnectorAndActor() {
-        if (closed) {
+    private void stopDeviceConnectorAndActor() {
+        if (!closed.compareAndSet(false, true)) {
             return;
         }
         if (remoteDeviceConnector != null) {
@@ -176,6 +177,5 @@ class NetconfTopologyContext implements ClusterSingletonService {
             netconfTopologyDeviceSetup.getActorSystem().stop(masterActorRef);
             masterActorRef = null;
         }
-        closed = true;
     }
 }
index fd1d84168c99ab021024bf158fa8dcae24e62176..40511bf781367eeffe2823de3a336a3251fe8f51 100644 (file)
@@ -153,11 +153,11 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
     NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node,
                                                  final ActorRef deviceContextActorRef) {
         //setup default values since default value is not supported in mdsal
-        final Long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
+        final long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
                 ? NetconfTopologyUtils.DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
-        final Long keepaliveDelay = node.getKeepaliveDelay() == null
+        final long keepaliveDelay = node.getKeepaliveDelay() == null
                 ? NetconfTopologyUtils.DEFAULT_KEEPALIVE_DELAY : node.getKeepaliveDelay();
-        final Boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
+        final boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
                 ? NetconfTopologyUtils.DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
 
         RemoteDeviceHandler<NetconfSessionPreferences> salFacade = new MasterSalFacade(remoteDeviceId,
@@ -352,11 +352,8 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
 
         @Override
         public ReconnectStrategy createReconnectStrategy() {
-            final Long maxSleep = null;
-            final Long deadline = null;
-
             return new TimedReconnectStrategy(executor, minSleep,
-                    minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
+                    minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);
         }
     }
 }
index 89547421c7c50d352ec7f9c4e660709631592f01..3a3fad9ce46a4628a6b8d8b6d717462e02dd2399 100644 (file)
@@ -259,7 +259,7 @@ public final class NetconfNodeActor extends UntypedActor {
 
         Futures.addCallback(remoteSchemaContext, new FutureCallback<SchemaContext>() {
             @Override
-            public void onSuccess(final SchemaContext result) {
+            public void onSuccess(@Nonnull final SchemaContext result) {
                 LOG.info("{}: Schema context resolved: {}", id, result.getModules());
                 slaveSalManager.registerSlaveMountPoint(result, deviceRpcService, masterReference);
             }
index 3d881e65def18fd6ff0a15c21064922e8a2bee45..6b79f621257ad0abcc2a7d19996b41db4ce86325 100644 (file)
@@ -56,7 +56,7 @@ class ReadAdapter {
         Futures.addCallback(read, new FutureCallback<Optional<NormalizedNode<?, ?>>>() {
 
             @Override
-            public void onSuccess(final Optional<NormalizedNode<?, ?>> result) {
+            public void onSuccess(@Nonnull final Optional<NormalizedNode<?, ?>> result) {
                 if (!result.isPresent()) {
                     sender.tell(new EmptyReadResponse(), self);
                     return;
index dae2c40d80b02d4885df3e6589a5001f2fcc85a8..21ff0010526bb8f6f9ec8fa49999490f8db49478 100644 (file)
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
index 45fd4df0f6e66f2e63ba8633a6ec2c7d78af8fd5..b9ce540fd6df321902418a256ffe4d7373e8cd78 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.topology.singleton.messages;
 
-import java.io.Serializable;
 import java.util.List;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
@@ -17,9 +16,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 /**
  * Master sends this message to the own actor to set necessary parameters.
  */
-public class CreateInitialMasterActorData implements Serializable {
-    private static final long serialVersionUID = 1L;
-
+public class CreateInitialMasterActorData {
     private final DOMDataBroker deviceDataBroker;
     private final List<SourceIdentifier> allSourceIdentifiers;
     private final DOMRpcService deviceRpc;
index 2f6e2e250696fb3d44af54c55db094ef28d2c5fb..47befecaad425575634763ee72a848a87347e594 100644 (file)
@@ -8,16 +8,13 @@
 
 package org.opendaylight.netconf.topology.singleton.messages;
 
-import java.io.Serializable;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
 
 /**
  * Master sends this message to the own actor to refresh setup data.
  */
-public class RefreshSetupMasterActorData implements Serializable {
-    private static final long serialVersionUID = 1L;
-
+public class RefreshSetupMasterActorData {
     private final NetconfTopologySetup netconfTopologyDeviceSetup;
     private final RemoteDeviceId remoteDeviceId;
 
index 47023f219fd96643c0474ef0d20c00a60e70fcf8..95798f66ac0a883c037e9ce26a3e8ee5b0057dfc 100644 (file)
@@ -9,13 +9,12 @@
 package org.opendaylight.netconf.topology.singleton.messages;
 
 import akka.util.Timeout;
-import java.io.Serializable;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 
-public class RefreshSlaveActor implements Serializable {
+public class RefreshSlaveActor {
 
     private final SchemaRepository schemaRepository;
     private final RemoteDeviceId id;
index 319b375340262e221b9dc4e0027fbbc88777ec79..a34697885e7d37b1ac3843b1df5c3cc536ce9dd1 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netconf.topology.singleton.messages;
 
 import com.google.common.collect.Iterables;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -20,7 +21,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 public class SchemaPathMessage implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    private SchemaPath schemaPath;
+    @SuppressFBWarnings("SE_BAD_FIELD")
+    private final SchemaPath schemaPath;
 
     public SchemaPathMessage(final SchemaPath schemaPath) {
         this.schemaPath = schemaPath;
@@ -39,7 +41,8 @@ public class SchemaPathMessage implements Serializable {
 
         private SchemaPathMessage schemaPathMessage;
 
-        Proxy() {
+        @SuppressWarnings("checkstyle:RedundantModifier")
+        public Proxy() {
             //due to Externalizable
         }
 
index 9a0e5c35e5fe57a32e3765e99f821aadc9e975a0..d540e23f8d6b3dbf066dc5daedcc5c195d1970d4 100644 (file)
@@ -50,7 +50,8 @@ public class InvokeRpcMessage implements Serializable {
 
         private InvokeRpcMessage invokeRpcMessage;
 
-        Proxy() {
+        @SuppressWarnings("checkstyle:RedundantModifier")
+        public Proxy() {
             //due to Externalizable
         }
 
index ba658ba92f83b41db87812160987743a37a4564c..b70582354cc6cd476fd72e93d0303a0211d7babf 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.netconf.topology.singleton.messages.rpc;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -21,6 +22,7 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 public class InvokeRpcMessageReply implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    @SuppressFBWarnings("SE_BAD_FIELD")
     private final Collection<RpcError> rpcErrors;
     private final NormalizedNodeMessage normalizedNodeMessage;
 
@@ -47,7 +49,8 @@ public class InvokeRpcMessageReply implements Serializable {
 
         private InvokeRpcMessageReply invokeRpcMessageReply;
 
-        Proxy() {
+        @SuppressWarnings("checkstyle:RedundantModifier")
+        public Proxy() {
             //due to Externalizable
         }
 
index b9a1bad196dde7b5ad24a1c3a9be78fa3befae98..12adb7c9b14b20577e7acb581d8a1804628a277d 100644 (file)
@@ -20,9 +20,9 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse;
@@ -121,4 +121,4 @@ public class ProxyReadTransactionTest {
         }
     }
 
-}
\ No newline at end of file
+}
index ee692518db5dce88f4addd1ccd9d6d1246fff50e..54b887cbb8319c7fe5f14a3ac4c36867bcc61db6 100644 (file)
@@ -22,10 +22,10 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest;
index 507ebfa0e3c413faaf2400d6d45e1be82f6f3023..f60f24cdbde305ce6d32878fd1d0b5964d620fcc 100644 (file)
             <version>0.8.0-SNAPSHOT</version>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
index 9bc6b59e7e8ccc7788df3144a801c11ee9bfa4a2..e3a84195332f6713962567f1307e7cc4af1a41d4 100644 (file)
@@ -278,11 +278,11 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
     protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId,
                                                            final NetconfNode node) {
         //setup default values since default value is not supported in mdsal
-        final Long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
+        final long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
                 ? DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
-        final Long keepaliveDelay = node.getKeepaliveDelay() == null
+        final long keepaliveDelay = node.getKeepaliveDelay() == null
                 ? DEFAULT_KEEPALIVE_DELAY : node.getKeepaliveDelay();
-        final Boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
+        final boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
                 ? DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
 
         final IpAddress ipAddress = node.getHost().getIpAddress();
@@ -579,11 +579,8 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
 
         @Override
         public ReconnectStrategy createReconnectStrategy() {
-            final Long maxSleep = null;
-            final Long deadline = null;
-
             return new TimedReconnectStrategy(executor, minSleep,
-                    minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
+                    minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);
         }
     }
 
index 1f74df2fdb6776b0ff885eb02c7e08ee44c8249b..7642915fae035dbcda71243f81b9dd4b65177d94 100644 (file)
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
 
index 134aefecc23e4ef19b6ccb85117d249c2870cda4..46bb6cbcd323b10401607814b3057eee4af78743 100644 (file)
@@ -13,11 +13,10 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 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;
@@ -42,7 +41,7 @@ public final class NetconfUtil {
 
     public static Document checkIsMessageOk(final Document response) throws DocumentedException {
         XmlElement element = XmlElement.fromDomDocument(response);
-        Preconditions.checkState(element.getName().equals(XmlMappingConstants.RPC_REPLY_KEY));
+        Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
         element = element.getOnlyChildElement();
         if (element.getName().equals(XmlNetconfConstants.OK)) {
             return response;
index e66e59f3e7ebddacf65820a8d4daf088f2eb3a95..ef78be50cc0aaee85ad195181cd185ca9a63f09f 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.netconf.util.mapping;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.w3c.dom.Document;
index 4d988112eae8ad078b426e781015cc46eb6ae7fe..fb6a8ed26e522a07e3993ac965d09e64e5305c94 100644 (file)
@@ -10,11 +10,10 @@ package org.opendaylight.netconf.util.mapping;
 
 import com.google.common.base.Optional;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
@@ -102,7 +101,7 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         Map<String, Attr> attributes = requestElement.getAttributes();
 
         Element response = handle(document, operationElement, subsequentOperation);
-        Element rpcReply = XmlUtil.createElement(document, XmlMappingConstants.RPC_REPLY_KEY,
+        Element rpcReply = XmlUtil.createElement(document, XmlNetconfConstants.RPC_REPLY_KEY,
                 Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
 
         if (XmlElement.fromDomElement(response).hasNamespace()) {
index 34ab61f96ea3afdefec8dfb0f7637305b2abdefc..77d4bb340049b4a034c6917ffbee2dd98e25ffe9 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.netconf.util.mapping;
 
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.w3c.dom.Document;
index 4117918d5322ae79e8cfa9b0e8138c08ddb3ce7e..df5b4bc8d320af34d6444d3352b9a53a357341d0 100644 (file)
@@ -8,27 +8,22 @@
 
 package org.opendaylight.netconf.util.messages;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-public final class NetconfMessageConstants {
-
-    private NetconfMessageConstants(){}
+public interface NetconfMessageConstants {
 
     /**
      * The NETCONF 1.0 old-style message separator. This is framing mechanism
      * is used by default.
      */
-    public static final byte[] END_OF_MESSAGE = "]]>]]>".getBytes(UTF_8);
+    String END_OF_MESSAGE = "]]>]]>";
 
     // bytes
 
-    public static final int MIN_HEADER_LENGTH = 4;
+    int MIN_HEADER_LENGTH = 4;
 
     // bytes
 
-    public static final int MAX_HEADER_LENGTH = 13;
-
-    public static final byte[] START_OF_CHUNK = "\n#".getBytes(UTF_8);
-    public static final byte[] END_OF_CHUNK = "\n##\n".getBytes(UTF_8);
+    int MAX_HEADER_LENGTH = 13;
 
+    String START_OF_CHUNK = "\n#";
+    String END_OF_CHUNK = "\n##\n";
 }
index 967633f357a9212bbe6957ae5c6b0e6ee82cce78..a3f37d6c92e7cde366e881cf8476ea73fb26d4f7 100644 (file)
@@ -13,10 +13,10 @@ import com.google.common.collect.Collections2;
 import java.util.Collection;
 import java.util.List;
 import javax.annotation.Nonnull;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 4768fad00ecea66354528281f700e8ff74f3afe5..f09ca513b36d7c340bc987eb18fa6679bea4a5bc 100644 (file)
@@ -12,12 +12,11 @@ import com.google.common.base.Preconditions;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSession;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Attr;
@@ -66,8 +65,8 @@ public final class SendErrorExceptionUtil {
                     "Missing %s element", XmlNetconfConstants.RPC_KEY);
 
             final Element rpcReply = errorDocument.getDocumentElement();
-            Preconditions.checkState(rpcReply.getTagName().equals(XmlMappingConstants.RPC_REPLY_KEY),
-                    "Missing %s element", XmlMappingConstants.RPC_REPLY_KEY);
+            Preconditions.checkState(rpcReply.getTagName().equals(XmlNetconfConstants.RPC_REPLY_KEY),
+                    "Missing %s element", XmlNetconfConstants.RPC_REPLY_KEY);
 
             final NamedNodeMap incomingAttributes = incommingRpc.getAttributes();
             for (int i = 0; i < incomingAttributes.getLength(); i++) {
index 373d7095b5b62f01d7d04fa93bc7348f1b55a1ea..3b803b6a43e16bdee112fe129cf610e30be9a37e 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.netconf.util.messages;
 
 import com.google.common.base.Optional;
 import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index c263a0769231fe73d553bfacd68bf87b7443ff30..1a8ebca07dc656a7fb4a50a7300698ad4bcab6b2 100644 (file)
@@ -18,8 +18,8 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.$YangModuleInfoImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
index f9de09342a4c71b0315ca1dc8d779892914be4af..59d5ce4e1b670b9b6d2f4965c921a2adcbd41104 100644 (file)
@@ -15,8 +15,8 @@ import static org.mockito.Mockito.mock;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.w3c.dom.Document;
index 75b870f7f66313b8a5fbd10543062c2402471555..ad3ab9eaa0b2b143a37758f0e212dd2f331274b8 100644 (file)
@@ -16,9 +16,9 @@ import static org.mockito.Mockito.mock;
 import java.io.IOException;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
index 9ba35770e4ee67e1ec002ce509c9f262dbf1739b..7c2c9e86fe5dc34fdd6249a63421083120cdd723 100644 (file)
@@ -11,8 +11,8 @@ package org.opendaylight.netconf.util.mapping;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
index 4109756949ed4d1009fac4a7fe3967ead7a316c6..ef375b1990ae63ee8d25832988337f7da4cd8f30 100644 (file)
@@ -19,7 +19,7 @@ import io.netty.channel.ChannelFuture;
 import io.netty.util.concurrent.GenericFutureListener;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSession;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
index 96f179a112290f4ae74fcbab97c76abc2bc3931e..341c1c46e88a3f8c4c3075ecdc02f0b7c675da93 100644 (file)
@@ -23,8 +23,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
index d5b4a24a842f87d3342eaf6dfefacab67663cd50..aa701658b50c8da83a39fec9c0376640bb2ad652 100644 (file)
@@ -21,7 +21,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
index d62d40df5ecb2acd16e1f37f69c8c284d868231e..e21820839cae162070720f615ea4026c88a649a9 100644 (file)
@@ -14,8 +14,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import javax.xml.parsers.ParserConfigurationException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
index 6677a42c8f18948eadb9c20c863e159e753a16b2..78fc364032b4be4fffb38c6025955f28cc88e222 100644 (file)
@@ -16,7 +16,7 @@ import org.custommonkey.xmlunit.AbstractNodeTester;
 import org.custommonkey.xmlunit.NodeTest;
 import org.custommonkey.xmlunit.NodeTestException;
 import org.custommonkey.xmlunit.NodeTester;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
index 3ca07d4dd438e21e73db8a11837bae2146ae6839..bf3c573c1faba45bb174189e2be2c94a8b7f2a76 100644 (file)
@@ -15,7 +15,7 @@ import static org.junit.Assert.fail;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Element;
 
 public class XMLNetconfUtilTest {
@@ -34,4 +34,4 @@ public class XMLNetconfUtilTest {
         assertEquals("value", ((Element) value).getTextContent());
     }
 
-}
\ No newline at end of file
+}
index c768ac9593ecc82479531022a4658c2e546d1d6f..57ac7cbaf469fc0f2dd5f96e40c810ad7df4cc00 100644 (file)
@@ -27,7 +27,6 @@
     <module>netconf-api</module>
     <module>netconf-config</module>
     <module>netconf-impl</module>
-    <module>config-netconf-connector</module>
     <module>mdsal-netconf-ssh</module>
     <module>mdsal-netconf-tcp</module>
     <module>mdsal-netconf-connector</module>
index 2f2a091302fb20acc90594c866b4855aea1cd850..d1306f1acab1a5e609f120083619cc3455ee16b5 100644 (file)
       <groupId>xmlunit</groupId>
       <artifactId>xmlunit</artifactId>
     </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>config-netconf-connector</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-impl</artifactId>
     <tag>HEAD</tag>
     <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
   </scm>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <configuration>
-          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
index 68fb36018b7e26cd2a8da7921b0c536b0323efe5..9e62919cf688852953d57c428f2e363d22262c31 100644 (file)
@@ -24,16 +24,22 @@ import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.AbstractMap;
 import java.util.Collections;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.regex.Pattern;
 import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
@@ -67,6 +73,7 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 /**
  * Holds URLs with YANG schema resources for all yang modules reported in
@@ -130,7 +137,7 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
             if (connection instanceof HttpURLConnection) {
                 connection.setRequestProperty("Accept", "application/xml");
                 final String userpass = username + ":" + password;
-                final String basicAuth = "Basic " + printBase64Binary(userpass.getBytes());
+                final String basicAuth = "Basic " + printBase64Binary(userpass.getBytes(StandardCharsets.UTF_8));
 
                 connection.setRequestProperty("Authorization", basicAuth);
             }
@@ -291,7 +298,7 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
         String extension = "";
         final int i = fileName.lastIndexOf(46);
         if (i != -1) {
-            extension = fileName.substring(i).toLowerCase();
+            extension = fileName.substring(i).toLowerCase(Locale.ROOT);
         }
 
         return extension.equals(".json");
@@ -302,14 +309,13 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
         final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
 
         final JsonParserStream jsonParser = JsonParserStream.create(writer, LIBRARY_CONTEXT);
-        final JsonReader reader = new JsonReader(new InputStreamReader(in));
+        final JsonReader reader = new JsonReader(new InputStreamReader(in, Charset.defaultCharset()));
 
         jsonParser.parse(reader);
 
         return resultHolder.isFinished() ? Optional.of(resultHolder.getResult()) : Optional.empty();
     }
 
-    @SuppressWarnings("checkstyle:IllegalCatch")
     private static Optional<NormalizedNode<?, ?>> readXml(final InputStream in) {
         try {
             final DocumentBuilder docBuilder = UntrustedXML.newDocumentBuilder();
@@ -338,7 +344,8 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
             xmlParser.traverse(new DOMSource(doc.getDocumentElement()));
             final NormalizedNode<?, ?> parsed = resultHolder.getResult();
             return Optional.of(parsed);
-        } catch (final Exception e) {
+        } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+                | SAXException e) {
             LOG.warn("Unable to parse yang library xml content", e);
         }
 
@@ -394,9 +401,8 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
 
     private static Optional<String> getValueOfSimpleNode(
             final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {
-        final Object value = node.getValue();
-        return value == null || Strings.isNullOrEmpty(value.toString()) ? Optional.empty()
-                : Optional.of(value.toString().trim());
+        final String valueStr = node.getValue().toString();
+        return Strings.isNullOrEmpty(valueStr) ? Optional.empty() : Optional.of(valueStr.trim());
     }
 
     @Override
index 2dc16331726e2857897b372bcd55745e3ad36daa..9efd1dfaba5c24d2336bbf1d58d0c7171ce25954 100644 (file)
@@ -29,6 +29,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
@@ -149,7 +150,7 @@ public class NetconfDevice
 
         final FutureCallback<DeviceSources> resolvedSourceCallback = new FutureCallback<DeviceSources>() {
             @Override
-            public void onSuccess(final DeviceSources result) {
+            public void onSuccess(@Nonnull final DeviceSources result) {
                 addProvidedSourcesToSchemaRegistry(result);
                 setUpSchema(result);
             }
@@ -250,7 +251,7 @@ public class NetconfDevice
         updateTransformer(null);
     }
 
-    private void updateTransformer(final MessageTransformer<NetconfMessage> transformer) {
+    private synchronized void updateTransformer(final MessageTransformer<NetconfMessage> transformer) {
         messageTransformer = transformer;
     }
 
@@ -511,7 +512,7 @@ public class NetconfDevice
 
                     if (cause instanceof MissingSchemaSourceException) {
                         requiredSources = handleMissingSchemaSourceException(
-                                requiredSources, (MissingSchemaSourceException) e.getCause());
+                                requiredSources, (MissingSchemaSourceException) cause);
                         continue;
                     }
                     if (cause instanceof SchemaResolutionException) {
index 6ce2d0f145a79ee4de95997792205a6a91ee7e18..822a43a22aace8b4706faf479fb3152193620b3c 100644 (file)
@@ -256,9 +256,8 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
         private static Optional<String> getValueOfSimpleNode(
                 final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {
-            final Object value = node.getValue();
-            return value == null || Strings.isNullOrEmpty(value.toString())
-                    ? Optional.empty() : Optional.of(value.toString().trim());
+            final String valueStr = node.getValue().toString();
+            return Strings.isNullOrEmpty(valueStr) ? Optional.empty() : Optional.of(valueStr.trim());
         }
 
         @Override
index 28dc94ed49656a8d45a6df6f9cc5626c73b59e3d..5e9b33efab4995754839085d27dc975bb7b2a2bf 100644 (file)
@@ -11,9 +11,9 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.LinkedList;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
index d8eace1fc99c41f0628030281dc593ca72f1ca43..0e240dde64d74b728da856540d8f57c0f71a96bb 100644 (file)
@@ -22,13 +22,13 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.FailedNetconfMessage;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
@@ -275,7 +275,7 @@ public class NetconfDeviceCommunicator
         try {
             request = requests.peek();
             if (request != null && request.future.isUncancellable()) {
-                requests.poll();
+                request = requests.poll();
                 // we have just removed one request from the queue
                 // we can also release one permit
                 if (semaphore != null) {
@@ -343,18 +343,15 @@ public class NetconfDeviceCommunicator
     @Override
     public ListenableFuture<RpcResult<NetconfMessage>> sendRequest(final NetconfMessage message, final QName rpc) {
         sessionLock.lock();
-
-        if (semaphore != null && !semaphore.tryAcquire()) {
-            LOG.warn("Limit of concurrent rpc messages was reached (limit :"
-                    + concurentRpcMsgs + "). Rpc reply message is needed. Discarding request of Netconf device with id"
-                    + id.getName());
-            sessionLock.unlock();
-            return Futures.immediateFailedFuture(new NetconfDocumentedException(
-                    "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
-                            + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
-        }
-
         try {
+            if (semaphore != null && !semaphore.tryAcquire()) {
+                LOG.warn("Limit of concurrent rpc messages was reached (limit :" + concurentRpcMsgs
+                    + "). Rpc reply message is needed. Discarding request of Netconf device with id" + id.getName());
+                return Futures.immediateFailedFuture(new NetconfDocumentedException(
+                        "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
+                        + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
+            }
+
             return sendRequestWithLock(message, rpc);
         } finally {
             sessionLock.unlock();
index 8f010e778057e7dbd77eed8b0e23e3ad8abfe8fc..77b7d1c142cc3ef4071e9d34a16ed63703700c57 100644 (file)
@@ -10,17 +10,15 @@ package org.opendaylight.netconf.sal.connect.netconf.listener;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AbstractFuture;
 import javax.annotation.Nullable;
-import javax.annotation.concurrent.GuardedBy;
 
 final class UncancellableFuture<V> extends AbstractFuture<V> {
-    @GuardedBy("this")
-    private boolean uncancellable = false;
+    private volatile boolean uncancellable = false;
 
     UncancellableFuture(final boolean uncancellable) {
         this.uncancellable = uncancellable;
     }
 
-    public synchronized boolean setUncancellable() {
+    public boolean setUncancellable() {
         if (isCancelled()) {
             return false;
         }
@@ -29,17 +27,17 @@ final class UncancellableFuture<V> extends AbstractFuture<V> {
         return true;
     }
 
-    public synchronized boolean isUncancellable() {
+    public boolean isUncancellable() {
         return uncancellable;
     }
 
     @Override
-    public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
+    public boolean cancel(final boolean mayInterruptIfRunning) {
         return !uncancellable && super.cancel(mayInterruptIfRunning);
     }
 
     @Override
-    public synchronized boolean set(@Nullable final V value) {
+    public boolean set(@Nullable final V value) {
         Preconditions.checkState(uncancellable);
         return super.set(value);
     }
index a92ad42c709044a031e9c65095358a4c16b665fd..590e5e4cdac1944f0d813f5e2cf483243b357340 100644 (file)
@@ -211,11 +211,11 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
             if (result != null && result.getResult() != null) {
                 LOG.debug("{}: Keepalive RPC successful with response: {}", id, result.getResult());
                 scheduleKeepalive();
-            } else if (result != null && result.getErrors() != null) {
+            } else if (result != null && !result.getErrors().isEmpty()) {
                 LOG.warn("{}: Keepalive RPC failed with error: {}", id, result.getErrors());
                 scheduleKeepalive();
             } else {
-                LOG.warn("{} Keepalive RPC returned null with response: {}. Reconnecting netconf session", id, result);
+                LOG.warn("{} Keepalive RPC returned null with response. Reconnecting netconf session", id);
                 reconnect();
             }
         }
@@ -276,7 +276,7 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
     public static final class KeepaliveDOMRpcService implements DOMRpcService {
 
         private final DOMRpcService deviceRpc;
-        private ResetKeepalive resetKeepaliveTask;
+        private final ResetKeepalive resetKeepaliveTask;
         private final long defaultRequestTimeoutMillis;
         private final ScheduledExecutorService executor;
 
index 1b5ae10ec4955b74ecc5660a6ff19deb0cab45ca..897cdaa5c73267039b1438aed9054cb69c37b9d9 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.connect.netconf.sal;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -68,13 +67,8 @@ public final class NetconfDeviceRpc implements DOMRpcService {
                 }
             }, MoreExecutors.directExecutor());
 
-        return Futures.makeChecked(transformed, new Function<Exception, DOMRpcException>() {
-            @Nullable
-            @Override
-            public DOMRpcException apply(@Nullable final Exception exception) {
-                return new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type);
-            }
-        });
+        return Futures.makeChecked(transformed, exception ->
+            new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type));
     }
 
     @Nonnull
index 8fbf058850685e660b9ca639a3355fe0a33ccf30..9e247018e19638d1d169f69a58e648e91b15d9c7 100644 (file)
@@ -248,11 +248,6 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         }, MoreExecutors.directExecutor());
     }
 
-    private static Node getNodeWithId(final RemoteDeviceId id) {
-        final NodeBuilder builder = getNodeIdBuilder(id);
-        return builder.build();
-    }
-
     private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) {
         final NodeBuilder nodeBuilder = new NodeBuilder();
         nodeBuilder.setKey(new NodeKey(new NodeId(id.getName())));
index 9701c984105cb0cb7a925005d01a2d1122ad5909..79482c564c029206f29fa5928f2aafb6a181ca2c 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.connect.netconf.sal;
 
-import com.google.common.base.Function;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -77,16 +76,15 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
                 listener.sendRequest(netconfMessage, type.getLastComponent());
 
         final ListenableFuture<DOMRpcResult> transformed =
-            Futures.transform(rpcResultListenableFuture, (Function<RpcResult<NetconfMessage>, DOMRpcResult>) input1 -> {
+            Futures.transform(rpcResultListenableFuture, input1 -> {
                 if (input1.isSuccessful()) {
                     return transformer.toRpcResult(input1.getResult(), type);
-                } else {
-                    return new DefaultDOMRpcResult(input1.getErrors());
                 }
+
+                return new DefaultDOMRpcResult(input1.getErrors());
             }, MoreExecutors.directExecutor());
 
-        return Futures.makeChecked(transformed,
-            e -> new DOMRpcImplementationNotAvailableException(e,
+        return Futures.makeChecked(transformed, e -> new DOMRpcImplementationNotAvailableException(e,
                 "Unable to invoke rpc %s on device %s", type, deviceId));
     }
 
@@ -99,5 +97,4 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
     public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull final T lsnr) {
         throw new UnsupportedOperationException("Not available for netconf 1.0");
     }
-
 }
index 8e5c4de458f22a6a6703c9f72db2958fe4cf9dd9..cc0d037e00e694ec1b05e7b7786b83c03285a095 100644 (file)
@@ -18,12 +18,12 @@ import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-import javax.annotation.Nullable;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
@@ -48,7 +48,7 @@ public abstract class AbstractWriteTx implements DOMDataWriteTransaction {
     protected final List<ListenableFuture<DOMRpcResult>> resultsFutures;
     private final List<TxListener> listeners = new CopyOnWriteArrayList<>();
     // Allow commit to be called only once
-    protected boolean finished = false;
+    protected volatile boolean finished = false;
 
     public AbstractWriteTx(final NetconfBaseOps netOps, final RemoteDeviceId id, final boolean rollbackSupport) {
         this.netOps = netOps;
@@ -105,7 +105,7 @@ public abstract class AbstractWriteTx implements DOMDataWriteTransaction {
         final DataContainerChild<?, ?> editStructure =
                 netOps.createEditConfigStrcture(Optional.<NormalizedNode<?, ?>>fromNullable(data),
                         Optional.of(ModifyAction.REPLACE), path);
-        editConfig(path, Optional.fromNullable(data), editStructure, Optional.of(ModifyAction.NONE), "put");
+        editConfig(path, Optional.fromNullable(data), editStructure, Optional.<ModifyAction>absent(), "put");
     }
 
     @Override
@@ -153,13 +153,13 @@ public abstract class AbstractWriteTx implements DOMDataWriteTransaction {
         final ListenableFuture<RpcResult<Void>> result = performCommit();
         Futures.addCallback(result, new FutureCallback<RpcResult<Void>>() {
             @Override
-            public void onSuccess(@Nullable final RpcResult<Void> result) {
-                if (result != null && result.isSuccessful()) {
+            public void onSuccess(@Nonnull final RpcResult<Void> rpcResult) {
+                if (rpcResult.isSuccessful()) {
                     listeners.forEach(txListener -> txListener.onTransactionSuccessful(AbstractWriteTx.this));
                 } else {
                     final TransactionCommitFailedException cause =
                             new TransactionCommitFailedException("Transaction failed",
-                                    result.getErrors().toArray(new RpcError[result.getErrors().size()]));
+                                    rpcResult.getErrors().toArray(new RpcError[rpcResult.getErrors().size()]));
                     listeners.forEach(listener -> listener.onTransactionFailed(AbstractWriteTx.this, cause));
                 }
             }
@@ -189,7 +189,7 @@ public abstract class AbstractWriteTx implements DOMDataWriteTransaction {
 
         Futures.addCallback(Futures.allAsList(resultsFutures), new FutureCallback<List<DOMRpcResult>>() {
             @Override
-            public void onSuccess(final List<DOMRpcResult> domRpcResults) {
+            public void onSuccess(@Nonnull final List<DOMRpcResult> domRpcResults) {
                 domRpcResults.forEach(domRpcResult -> {
                     if (!domRpcResult.getErrors().isEmpty() && !transformed.isDone()) {
                         final NetconfDocumentedException exception =
index 23803f575129cebf226c0f98f891ef03d695574e..ac24ac8f35acd592e2a855ba671a14b4bc25cda1 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
@@ -16,6 +15,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
@@ -68,7 +68,7 @@ public class WriteCandidateTx extends AbstractWriteTx {
     private void lock() {
         final FutureCallback<DOMRpcResult> lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
             @Override
-            public void onSuccess(final DOMRpcResult result) {
+            public void onSuccess(@Nonnull final DOMRpcResult result) {
                 if (isSuccess(result)) {
                     if (LOG.isTraceEnabled()) {
                         LOG.trace("Lock candidate successful");
@@ -95,12 +95,11 @@ public class WriteCandidateTx extends AbstractWriteTx {
 
     @Override
     public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
-        final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commitConfiguration(),
-            (Function<RpcResult<Void>, Void>) input -> {
-                Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
-                        "Submit failed with errors: %s", input.getErrors());
-                return null;
-            }, MoreExecutors.directExecutor());
+        final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commitConfiguration(), input -> {
+            Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
+                "Submit failed with errors: %s", input.getErrors());
+            return null;
+        }, MoreExecutors.directExecutor());
 
         return Futures.makeChecked(commitFutureAsVoid, input -> new TransactionCommitFailedException(
                 "Submit of transaction " + getIdentifier() + " failed", input));
index 068fc10a5150d0b8065cdc9bf9bcedc89af544a3..0ba6cead958387ab434fd5bd40cbfc03b2cd1411 100644 (file)
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
+import javax.annotation.Nonnull;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
@@ -144,7 +145,7 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource
         }
 
         @Override
-        public YangTextSchemaSource apply(final DOMRpcResult input) {
+        public YangTextSchemaSource apply(@Nonnull final DOMRpcResult input) {
 
             if (input.getErrors().isEmpty()) {
 
index d7d4948e4c4efa22b62aeb6ffd54be6588f89f57..4fa5127c6e32f328e08f0d282824443b5986240e 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.nio.charset.Charset;
 import java.util.Map;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -51,7 +52,7 @@ public final class YangLibrarySchemaYangSourceProvider implements SchemaSourcePr
     private ListenableFuture<? extends YangTextSchemaSource> download(final SourceIdentifier sourceIdentifier) {
         final URL url = availableSources.get(sourceIdentifier);
         try (InputStream in = url.openStream()) {
-            final String schemaContent = new String(ByteStreams.toByteArray(in));
+            final String schemaContent = new String(ByteStreams.toByteArray(in), Charset.defaultCharset());
             final NetconfRemoteSchemaYangSourceProvider.NetconfYangTextSchemaSource yangSource =
                     new NetconfRemoteSchemaYangSourceProvider
                             .NetconfYangTextSchemaSource(id, sourceIdentifier, Optional.of(schemaContent));
index cbf1f03a25abae4bcd0928287620b9d200cf869f..aff7f8327bf00e8bc9d8ee315f7ebacc69cf714f 100644 (file)
@@ -13,12 +13,12 @@ import java.util.Map;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
@@ -74,7 +74,7 @@ public class BaseRpcSchemalessTransformer implements MessageTransformer<NetconfM
         final DOMResult result = domResult;
 
         try {
-            NetconfMessageTransformUtil.writeNormalizedRpc(((ContainerNode) payload), result,
+            NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result,
                     inputPath, SCHEMA_CONTEXT);
         } catch (final XMLStreamException | IOException | IllegalStateException e) {
             throw new IllegalStateException("Unable to serialize " + inputPath, e);
index 8428a48df63a45d6fb73751b74dffe6f333fa960..8b68b22b2d4f3f117592d5ff52622753a5572f26 100644 (file)
@@ -16,21 +16,23 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Map;
 import javax.annotation.Nonnull;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.MissingNameSpaceException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.MissingNameSpaceException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
@@ -54,6 +56,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
 
 public class NetconfMessageTransformer implements MessageTransformer<NetconfMessage> {
 
@@ -82,7 +85,6 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
         this.strictParsing = strictParsing;
     }
 
-    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public synchronized DOMNotification toNotification(final NetconfMessage message) {
         final Map.Entry<Date, XmlElement> stripped = NetconfMessageTransformUtil.stripNotification(message);
@@ -113,7 +115,8 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
                     notificationAsContainerSchemaNode, strictParsing);
             xmlParser.traverse(new DOMSource(element));
             content = (ContainerNode) resultHolder.getResult();
-        } catch (final Exception e) {
+        } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+                | SAXException | UnsupportedOperationException e) {
             throw new IllegalArgumentException(String.format("Failed to parse notification %s", element), e);
         }
         return new NetconfDeviceNotification(content, stripped.getKey());
@@ -175,7 +178,6 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
                 || rpc.getNamespace().equals(NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME.getNamespace());
     }
 
-    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public synchronized DOMRpcResult toRpcResult(final NetconfMessage message, final SchemaPath rpc) {
         final NormalizedNode<?, ?> normalizedNode;
@@ -193,7 +195,8 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
                         strictParsing);
                 xmlParser.traverse(new DOMSource(xmlData));
                 dataNode = (ContainerNode) resultHolder.getResult();
-            } catch (final Exception e) {
+            } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+                    | SAXException e) {
                 throw new IllegalArgumentException(String.format("Failed to parse data response %s", xmlData), e);
             }
 
@@ -232,7 +235,8 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
                             rpcDefinition.getOutput(), strictParsing);
                     xmlParser.traverse(new DOMSource(element));
                     normalizedNode = resultHolder.getResult();
-                } catch (final Exception e) {
+                } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+                        | SAXException e) {
                     throw new IllegalArgumentException(String.format("Failed to parse RPC response %s", element), e);
                 }
             }
index 21835b590329328d50f5e440274dcb7c7d516c3d..08f50877d90acf2348d4a0ef91683ee6edcdaaf7 100644 (file)
@@ -10,12 +10,12 @@ package org.opendaylight.netconf.sal.connect.netconf.schema.mapping;
 import java.util.Date;
 import java.util.Map;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.MissingNameSpaceException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.MissingNameSpaceException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
index 71a60bb18efbe22dfe9269361a105440d19ae626..2c055b9cf18a4349b0b82862d25a4ffe97792b89 100644 (file)
@@ -33,6 +33,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Locale;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade.KeepaliveDOMRpcService;
@@ -304,7 +305,7 @@ public final class NetconfBaseOps {
 
         // Default operation
         if (defaultOperation.isPresent()) {
-            final String opString = defaultOperation.get().name().toLowerCase();
+            final String opString = defaultOperation.get().name().toLowerCase(Locale.ROOT);
             editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_DEFAULT_OPERATION_QNAME))
                     .withValue(opString).build());
         }
index 100073ce83a95f0eaa2bf99635f2dc68323f3e6d..b7f9dfb96476643e1fce4f48d144d5235333a1c2 100644 (file)
@@ -25,12 +25,12 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.FailedNetconfMessage;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
 import org.opendaylight.netconf.util.NetconfUtil;
index e5eaab1d7d92944350067eb6eef3026d489426bc..7e45856e5b7e9d0d0a1b3e8132c98149493bbc1d 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netconf.sal.connect.netconf.util;
 
 import com.google.common.util.concurrent.FutureCallback;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.slf4j.Logger;
@@ -29,7 +30,7 @@ public class NetconfRpcFutureCallback implements FutureCallback<DOMRpcResult> {
     }
 
     @Override
-    public void onSuccess(final DOMRpcResult result) {
+    public void onSuccess(@Nonnull final DOMRpcResult result) {
         if (result.getErrors().isEmpty()) {
             LOG.trace("{}: {} invoked successfully", id, type);
         } else {
index 28c69e72ab0857d8ef653ec7770c1ca15cb5a83d..34a865ef01293d1a102616725f27d41e8de38820 100644 (file)
@@ -13,11 +13,13 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -156,7 +158,8 @@ class SchemalessRpcStructureTransformer implements RpcStructureTransformer {
         final YangInstanceIdentifier.NodeIdentifierWithPredicates keyedId =
                 (YangInstanceIdentifier.NodeIdentifierWithPredicates) lastPathArgument;
         final Map<QName, Object> keyValues = keyedId.getKeyValues();
-        for (QName qualifiedName : keyValues.keySet()) {
+        for (Entry<QName, Object> entry : keyValues.entrySet()) {
+            QName qualifiedName = entry.getKey();
             final List<XmlElement> key =
                     dataElement.getChildElementsWithinNamespace(qualifiedName.getLocalName(),
                             qualifiedName.getNamespace().toString());
@@ -172,7 +175,7 @@ class SchemalessRpcStructureTransformer implements RpcStructureTransformer {
             } catch (DocumentedException e) {
                 throw new IllegalStateException("Key value not present in key element", e);
             }
-            if (!keyValues.get(qualifiedName).equals(textContent)) {
+            if (!entry.getValue().equals(textContent)) {
                 throw new IllegalStateException("Key value in path not equal to key value in xml");
             }
         }
@@ -225,7 +228,7 @@ class SchemalessRpcStructureTransformer implements RpcStructureTransformer {
     }
 
     private static String toOperationString(final ModifyAction operation) {
-        return operation.name().toLowerCase();
+        return operation.name().toLowerCase(Locale.ROOT);
     }
 
     private static Element getSourceElement(final DOMSource source) {
index c568b1b0136851f1ae047f7c27af6d9daed0a96a..ab52fc6b3b82a2b6d8fa0471fe4833f386037bc8 100644 (file)
@@ -39,13 +39,13 @@ import java.util.concurrent.Executors;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
index a117aea103be452071ce5c648caecbe4ba1b2a63..d9525a07f36d8dda9e83639b3af835b4fecbb250 100644 (file)
@@ -17,10 +17,10 @@ import java.io.InputStream;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
index 3f153d20a5e39998a893278e410642c1d5658981..2e5ef1c4102207bf8a3b7be662bf334e48228858 100644 (file)
@@ -17,8 +17,8 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import java.util.Set;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 3cc75f230ac289be80ea97122f40ff9edb1a0eaf..f9d57e149e54f9c645af33bd9083e318d7cf0675 100644 (file)
@@ -51,9 +51,9 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
+import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
@@ -258,7 +258,7 @@ public class NetconfDeviceCommunicatorTest {
             throws ParserConfigurationException {
         Document doc = UntrustedXML.newDocumentBuilder().newDocument();
         Element rpcReply =
-                doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlMappingConstants.RPC_REPLY_KEY);
+                doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.RPC_REPLY_KEY);
         rpcReply.setAttribute("message-id", messageID);
         Element element = doc.createElementNS("ns", "data");
         element.setTextContent(messageID);
index f81440f4adbc85ea48a412ab2329e4bf776cb950..0d9679b486f7f909c18b4608cadfe5213c5e3610 100644 (file)
@@ -22,13 +22,13 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.$YangModuleInfoImpl;
index 6777c1659144601b7f4162d39cb4a6217ee8e3ba..727614f6b56adf33fdee75d47db2545166164643 100644 (file)
@@ -22,11 +22,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017._private.keys.PrivateKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017._private.keys.PrivateKeyBuilder;
index 8448e9372aa16ec73ab8a88fe859a7d417d56676..e1c540af36c125eaeb9b375649576231e044c032 100644 (file)
@@ -20,8 +20,8 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer;
index 0b3f3677c1d1c787959f47818ddf3ab40217455e..fe73bb61981846172f62389266bfab864f5bf891 100644 (file)
@@ -16,9 +16,9 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget;
@@ -130,4 +130,4 @@ public class BaseRpcSchemalessTransformerTest {
         Assert.assertTrue(diff.toString(), diff.similar());
     }
 
-}
\ No newline at end of file
+}
index a2050628aec2ec4562da1a887a07e080ade29a82..5ddbfa5c2a20d64827d551f8609b3e88f709c57f 100644 (file)
@@ -45,10 +45,10 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.hamcrest.CoreMatchers;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.schema.NetconfRemoteSchemaYangSourceProvider;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
index ab99752c77ecfe353c884244adfdc8b2dfda7dd5..6810ca7becc0717ce5da92b61e1f6a09454f5cb4 100644 (file)
@@ -14,10 +14,10 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.MessageCounter;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -106,4 +106,4 @@ public class SchemalessMessageTransformerTest {
         Assert.assertNull(result.getResult());
     }
 
-}
\ No newline at end of file
+}
index 177aede376866bdb268391dd50ca790305efb0f0..4ece5f4ae313530e430d2726456a5efcebe8d3bb 100644 (file)
@@ -29,9 +29,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
index 7f305767dbf052219c25221b6e52e13c397b7b5a..2b98e5050cfd7d1c14509f8b0bd2d224ebb1ae9d 100644 (file)
@@ -21,11 +21,11 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.util.NetconfSalKeystoreService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyInputBuilder;
index 71928d2495d620f9b9bd4b7652ad5410176d897d..99849cf17426107ad26f7bec4abdb3cc611d225b 100644 (file)
@@ -26,8 +26,8 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index a2ea516d17f39fa980ede76ede9d96c155929a31..e972912934d7b5c7506378d265196540055a7ba8 100644 (file)
         <sonar.skip>true</sonar.skip>
     </properties>
 
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.opendaylight.controller</groupId>
-                <artifactId>config-artifacts</artifactId>
-                <version>0.9.0-SNAPSHOT</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
-
     <dependencies>
         <dependency>
             <groupId>org.codehaus.janino</groupId>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-auth</artifactId>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>config-netconf-connector</artifactId>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>sal-netconf-connector</artifactId>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-ssh</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>netty-config-api</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-inmemory-datastore</artifactId>
                       </execution>
                   </executions>
               </plugin>
-              <plugin>
-                  <groupId>org.apache.maven.plugins</groupId>
-                  <artifactId>maven-checkstyle-plugin</artifactId>
-                  <configuration>
-                      <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                  </configuration>
-              </plugin>
           </plugins>
       </build>
 
index 5ece664e179a54113b7824b3bd38327fd491f8e0..53c89f1895d53129bb9a8a2f5d19acbb5dc8d076 100644 (file)
@@ -16,8 +16,9 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import java.util.Collections;
 import java.util.Set;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.NetconfManagementSession;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.api.monitoring.SessionEvent;
@@ -39,18 +40,13 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.mon
 public class DummyMonitoringService implements NetconfMonitoringService {
 
     private static final Sessions EMPTY_SESSIONS = new SessionsBuilder().setSession(Collections.emptyList()).build();
-    private static final Function<Capability, Uri> CAPABILITY_URI_FUNCTION = new Function<Capability, Uri>() {
-        @Nullable
-        @Override
-        public Uri apply(Capability capability) {
-            return new Uri(capability.getCapabilityUri());
-        }
-    };
+    private static final Function<Capability, Uri> CAPABILITY_URI_FUNCTION =
+        capability -> new Uri(capability.getCapabilityUri());
 
     private static final Function<Capability, Schema> CAPABILITY_SCHEMA_FUNCTION = new Function<Capability, Schema>() {
         @Nullable
         @Override
-        public Schema apply(@Nullable Capability capability) {
+        public Schema apply(@Nonnull Capability capability) {
             return new SchemaBuilder()
                     .setIdentifier(capability.getModuleName().get())
                     .setNamespace(new Uri(capability.getModuleNamespace().get()))
index e55f2de636d679b406ca87de432eb8d7301a8c7c..d4e6683278d10178e5613fe1a81edc273a6c0b1e 100644 (file)
@@ -13,7 +13,6 @@ import com.ning.http.client.AsyncCompletionHandler;
 import com.ning.http.client.AsyncHttpClient;
 import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.HttpResponseStatus;
-import com.ning.http.client.ListenableFuture;
 import com.ning.http.client.Realm;
 import com.ning.http.client.Request;
 import com.ning.http.client.Response;
@@ -112,7 +111,6 @@ public class Execution implements Callable<Void> {
     }
 
     private void invokeAsync() {
-        final ArrayList<ListenableFuture<Response>> futures = new ArrayList<>();
         LOG.info("Begin sending async requests");
 
         for (final Request request : payloads) {
@@ -121,7 +119,7 @@ public class Execution implements Callable<Void> {
             } catch (InterruptedException e) {
                 LOG.warn("Semaphore acquire interrupted");
             }
-            futures.add(asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
+            asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
                 @Override
                 public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
                     super.onStatusReceived(status);
@@ -143,7 +141,7 @@ public class Execution implements Callable<Void> {
                     semaphore.release();
                     return response;
                 }
-            }));
+            });
         }
         LOG.info("Requests sent, waiting for responses");
 
index 92512d4451f8875648e564cc7c6bf6f5a4327bd1..921c09a9364a59793c30b6ad305529c27bf93947 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.netconf.test.tool;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.YangModuleCapability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.YangModuleCapability;
 
 /**
  * Can be passed instead of YangModuleCapability when building capabilities
index 6ec885d44cb687029c7ac6f8d5fa7d538318b09d..cff30f51bb48348592f004d57315cf1bccf0d743 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.collect.Lists;
 import com.google.common.io.ByteStreams;
 import com.google.common.io.CharStreams;
 import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -42,6 +43,7 @@ import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressFBWarnings("DM_DEFAULT_ENCODING")
 public final class Main {
     private static final Logger LOG = LoggerFactory.getLogger(Main.class);
 
@@ -50,6 +52,7 @@ public final class Main {
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
+    @SuppressFBWarnings({"UW_UNCOND_WAIT", "WA_NOT_IN_LOOP"})
     public static void main(final String[] args) {
         final TesttoolParameters params = TesttoolParameters.parseArgs(args, TesttoolParameters.getParser());
         params.validate();
@@ -84,7 +87,7 @@ public final class Main {
                     } else {
                         try {
                             future.get();
-                        } catch (final ExecutionException e) {
+                        } catch (final ExecutionException | InterruptedException e) {
                             LOG.info("{}. thread failed.", threadNum, e);
                         }
                     }
@@ -102,7 +105,7 @@ public final class Main {
                 configGenerator.updateFeatureFile(generated);
                 configGenerator.changeLoadOrder();
             }
-        } catch (final Exception e) {
+        } catch (RuntimeException | InterruptedException e) {
             LOG.error("Unhandled exception", e);
             netconfDeviceSimulator.close();
             System.exit(1);
@@ -150,9 +153,12 @@ public final class Main {
                 Preconditions.checkState(configDir.mkdirs(), "Unable to create directory " + configDir);
             }
 
-            for (final File file : configDir.listFiles(pathname ->
-                    !pathname.isDirectory() && pathname.getName().startsWith(SIM_DEVICE_CFG_PREFIX))) {
-                Preconditions.checkState(file.delete(), "Unable to clean previous generated file %s", file);
+            final File[] files = configDir.listFiles(pathname ->
+                    !pathname.isDirectory() && pathname.getName().startsWith(SIM_DEVICE_CFG_PREFIX));
+            if (files != null) {
+                for (final File file : files) {
+                    Preconditions.checkState(file.delete(), "Unable to clean previous generated file %s", file);
+                }
             }
 
             try (InputStream stream = Main.class.getResourceAsStream(NETCONF_CONNECTOR_XML)) {
@@ -183,7 +189,7 @@ public final class Main {
                         String configContent = String.format(
                             middleBlueprint, name, address, String.valueOf(openDevice), String.valueOf(!useSsh));
                         configContent = String.format(
-                            "%s%s%d%s\n%s\n", configContent, "<connection-timeout-millis>",
+                            "%s%s%d%s%n%s%n", configContent, "<connection-timeout-millis>",
                             generateConfigsTimeout, "</connection-timeout-millis>", "</module>");
 
                         builder.append(configContent);
index fd5c68946953740224500ec75278b7aa2fcf70f0..268e705e7c35fe5735099e3fed6e3e87219f63ad 100644 (file)
@@ -16,7 +16,6 @@ import java.util.EnumMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
@@ -25,6 +24,7 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroke
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
index 42b162b2def8895f543eecc6422ab05cbe1e4e57..c19cc5574575f48298f8e7cb6bbde2150f16d361 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.local.LocalAddress;
@@ -38,9 +39,9 @@ import java.util.concurrent.ScheduledExecutorService;
 import org.apache.sshd.common.keyprovider.KeyPairProvider;
 import org.apache.sshd.common.util.security.SecurityUtils;
 import org.apache.sshd.common.util.threads.ThreadUtils;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.controller.config.util.capability.YangModuleCapability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
+import org.opendaylight.netconf.api.capability.YangModuleCapability;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
 import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
@@ -75,6 +76,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressFBWarnings("DM_DEFAULT_ENCODING")
 public class NetconfDeviceSimulator implements Closeable {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSimulator.class);
index 78f5b85434d7833034076069df8599f5e5e95d35..c8929e5132741974efe851d5eeacf2edd7565825 100644 (file)
@@ -15,6 +15,7 @@ import com.ning.http.client.AsyncHttpClient;
 import com.ning.http.client.AsyncHttpClientConfig.Builder;
 import com.ning.http.client.Request;
 import com.ning.http.client.Response;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -30,13 +31,12 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import net.sourceforge.argparse4j.inf.ArgumentParser;
-import net.sourceforge.argparse4j.inf.ArgumentParserException;
 import org.opendaylight.netconf.test.tool.config.Configuration;
 import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
 public final class ScaleUtil {
     private static final ScheduledExecutorService EXECUTOR = new LoggingWrapperExecutor(4);
     private static final Semaphore SEMAPHORE = new Semaphore(0);
@@ -73,16 +73,20 @@ public final class ScaleUtil {
                     root.error("Failed to start any simulated devices, exiting...");
                     System.exit(1);
                 }
-                if (params.distroFolder != null) {
-                    final Main.ConfigGenerator configGenerator = new Main.ConfigGenerator(
-                        params.distroFolder, openDevices);
-                    final List<File> generated = configGenerator.generate(
-                            params.ssh, params.generateConfigBatchSize,
-                            params.generateConfigsTimeout, params.generateConfigsAddress,
-                            params.devicesPerPort);
-                    configGenerator.updateFeatureFile(generated);
-                    configGenerator.changeLoadOrder();
+
+                if (params.distroFolder == null) {
+                    root.error("Distro folder is not set, exiting...");
+                    System.exit(1);
                 }
+
+                final Main.ConfigGenerator configGenerator = new Main.ConfigGenerator(
+                        params.distroFolder, openDevices);
+                final List<File> generated = configGenerator.generate(
+                        params.ssh, params.generateConfigBatchSize,
+                        params.generateConfigsTimeout, params.generateConfigsAddress,
+                        params.devicesPerPort);
+                configGenerator.updateFeatureFile(generated);
+                configGenerator.changeLoadOrder();
             } catch (final Exception e) {
                 root.error("Unhandled exception", e);
                 netconfDeviceSimulator.close();
@@ -181,24 +185,15 @@ public final class ScaleUtil {
                 if (f.isDirectory()) {
                     deleteFolder(f);
                 } else {
-                    f.delete();
+                    if (!f.delete()) {
+                        root.warn("Failed to delete {}", f);
+                    }
                 }
             }
         }
-        folder.delete();
-    }
-
-    private static TesttoolParameters parseArgs(final String[] args, final ArgumentParser parser) {
-        final TesttoolParameters parameters = new TesttoolParameters();
-        try {
-            parser.parseArgs(args, parameters);
-            return parameters;
-        } catch (ArgumentParserException e) {
-            parser.handleError(e);
+        if (!folder.delete()) {
+            root.warn("Failed to delete {}", folder);
         }
-
-        System.exit(1);
-        return null;
     }
 
     private static class ScaleVerifyCallable implements Callable {
@@ -287,8 +282,8 @@ public final class ScaleUtil {
             return new LogOnExceptionCallable(callable);
         }
 
-        private class LogOnExceptionCallable implements Callable {
-            private Callable theCallable;
+        private static class LogOnExceptionCallable implements Callable {
+            private final Callable theCallable;
 
             LogOnExceptionCallable(Callable theCallable) {
                 this.theCallable = theCallable;
index 3847ce9bfaef117b7233a9b2d59986a17636cd61..b49f39998b8222b269e4a1a6bad7a49aeaa7eb20 100644 (file)
@@ -13,7 +13,7 @@ import com.google.common.collect.Sets;
 import java.io.File;
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
@@ -51,10 +51,7 @@ class SimulatedOperationProvider implements NetconfOperationServiceFactory {
     public AutoCloseable registerCapabilityListener(
             final CapabilityListener listener) {
         listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-            }
+        return () -> {
         };
     }
 
index dde89e478c94064545a7480840103b3a8ff2a8a9..6310eab644e398e7c4e8f85736c3599e561e177f 100644 (file)
@@ -13,6 +13,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.base.Preconditions;
 import com.google.common.io.CharStreams;
 import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -23,6 +24,7 @@ import java.lang.reflect.Field;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringJoiner;
@@ -34,6 +36,7 @@ import net.sourceforge.argparse4j.annotation.Arg;
 import net.sourceforge.argparse4j.inf.ArgumentParser;
 import net.sourceforge.argparse4j.inf.ArgumentParserException;
 
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
 public class TesttoolParameters {
 
     private static final String HOST_KEY = "{HOST}";
@@ -303,13 +306,12 @@ public class TesttoolParameters {
             checkArgument(schemasDir.isDirectory(), "Schemas dir has to be a directory");
             checkArgument(schemasDir.canRead(), "Schemas dir has to be readable");
 
-            final List<File> files = Arrays.asList(schemasDir.listFiles());
+            final File[] filesArray = schemasDir.listFiles();
+            final List<File> files = filesArray != null ? Arrays.asList(filesArray) : Collections.emptyList();
             for (final File file : files) {
                 final Matcher matcher = YANG_FILENAME_PATTERN.matcher(file.getName());
                 if (!matcher.matches()) {
-                    final BufferedReader reader;
-                    try {
-                        reader = new BufferedReader(new FileReader(file));
+                    try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
                         String line = reader.readLine();
                         while (!DATE_PATTERN.matcher(line).find()) {
                             line = reader.readLine();
@@ -324,7 +326,9 @@ public class TesttoolParameters {
                             final String revision = m.group(1);
                             final String correctName = moduleName + "@" + revision + ".yang";
                             final File correctNameFile = new File(correctName);
-                            file.renameTo(correctNameFile);
+                            if (!file.renameTo(correctNameFile)) {
+                                System.err.println("Failed to rename " + file);
+                            }
                         }
                     } catch (final IOException e) {
                         // print error to console (test tool is running from console)
@@ -361,8 +365,8 @@ public class TesttoolParameters {
 
             final int batchedRequests = openDevices.size() / generateConfigBatchSize;
             final int batchedRequestsPerThread = batchedRequests / threadAmount;
-            final int leftoverBatchedRequests = (batchedRequests) % threadAmount;
-            final int leftoverRequests = openDevices.size() - (batchedRequests * generateConfigBatchSize);
+            final int leftoverBatchedRequests = batchedRequests % threadAmount;
+            final int leftoverRequests = openDevices.size() - batchedRequests * generateConfigBatchSize;
 
             final StringBuilder destBuilder = new StringBuilder(DEST);
             destBuilder.replace(destBuilder.indexOf(ADDRESS_PORT),
@@ -370,16 +374,16 @@ public class TesttoolParameters {
                 controllerDestination);
 
             for (int l = 0; l < threadAmount; l++) {
-                from = l * (batchedRequests * batchedRequestsPerThread);
-                to = from + (batchedRequests * batchedRequestsPerThread);
+                from = l * batchedRequests * batchedRequestsPerThread;
+                to = from + batchedRequests * batchedRequestsPerThread;
                 iterator = openDevices.subList(from, to).iterator();
                 allThreadsPayloads.add(createBatchedPayloads(batchedRequestsPerThread, iterator, editContentString,
                     destBuilder.toString()));
             }
             ArrayList<Execution.DestToPayload> payloads = null;
             if (leftoverBatchedRequests > 0) {
-                from = threadAmount * (batchedRequests * batchedRequestsPerThread);
-                to = from + (batchedRequests * batchedRequestsPerThread);
+                from = threadAmount * batchedRequests * batchedRequestsPerThread;
+                to = from + batchedRequests * batchedRequestsPerThread;
                 iterator = openDevices.subList(from, to).iterator();
                 payloads = createBatchedPayloads(leftoverBatchedRequests, iterator, editContentString,
                     destBuilder.toString());
@@ -413,7 +417,7 @@ public class TesttoolParameters {
             }
 
             if (leftoverRequests > 0) {
-                from = (threadAmount) * requestPerThreads;
+                from = threadAmount * requestPerThreads;
                 to = from + leftoverRequests;
                 iterator = openDevices.subList(from, to).iterator();
                 allThreadsPayloads.add(createPayloads(iterator, editContentString));
@@ -464,13 +468,13 @@ public class TesttoolParameters {
         final ArrayList<Execution.DestToPayload> payloads = new ArrayList<>();
 
         for (int i = 0; i < batchedRequestsCount; i++) {
-            String payload = "";
+            StringBuilder payload = new StringBuilder();
             for (int j = 0; j < generateConfigBatchSize; j++) {
                 final StringBuilder payloadBuilder = new StringBuilder(
                     prepareMessage(openDevices.next(), editContentString));
-                payload += modifyMessage(payloadBuilder, j, generateConfigBatchSize);
+                payload.append(modifyMessage(payloadBuilder, j, generateConfigBatchSize));
             }
-            payloads.add(new Execution.DestToPayload(destination, payload));
+            payloads.add(new Execution.DestToPayload(destination, payload.toString()));
         }
         return payloads;
     }
index 180dad7d120fd42bbc8bc8777f1305a4530ae467..98d38dd475e46d4cafe5f426e301c94d73fe9b82 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.netconf.test.tool.client.http.perf;
 import com.ning.http.client.AsyncCompletionHandler;
 import com.ning.http.client.AsyncHttpClient;
 import com.ning.http.client.HttpResponseStatus;
-import com.ning.http.client.ListenableFuture;
 import com.ning.http.client.Request;
 import com.ning.http.client.Response;
 import java.util.ArrayList;
@@ -39,7 +38,6 @@ public class AsyncExecutionStrategy implements ExecutionStrategy {
 
     @Override
     public void invoke() {
-        final ArrayList<ListenableFuture<Response>> futures = new ArrayList<>();
         LOG.info("Begin sending async requests");
 
         for (final Request request : payloads) {
@@ -48,7 +46,7 @@ public class AsyncExecutionStrategy implements ExecutionStrategy {
             } catch (InterruptedException e) {
                 LOG.warn("Semaphore acquire interrupted");
             }
-            futures.add(asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
+            asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
                 @Override
                 public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
                     super.onStatusReceived(status);
@@ -64,7 +62,7 @@ public class AsyncExecutionStrategy implements ExecutionStrategy {
                     semaphore.release();
                     return response;
                 }
-            }));
+            });
         }
         LOG.info("Requests sent, waiting for responses");
 
index 334556704b3a946aaebc096bca30c7930d9b3c18..94eff3d25d8e64de4c06bf335651d7622df11ddd 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netconf.test.tool.client.http.perf;
 
 import com.google.common.base.Stopwatch;
 import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -25,6 +26,7 @@ import org.opendaylight.netconf.test.tool.TestToolUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressFBWarnings("DM_EXIT")
 public final class RestPerfClient {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestPerfClient.class);
@@ -188,7 +190,7 @@ public final class RestPerfClient {
         // and do not log it
         if (allThreadsCompleted) {
             LOG.info(
-                "Requests per second: {}", (parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+                "Requests per second: {}", parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
         }
         System.exit(0);
     }
index 4bfd765ab4bdf48368eb9e1c25f571c5a62f5193..c5833ddef5885096c00eb4a6696dfe975df5546a 100644 (file)
@@ -16,8 +16,8 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
@@ -39,7 +39,7 @@ class AsyncExecutionStrategy extends AbstractExecutionStrategy {
         int batchI = 0;
         for (final Integer editBatch : getEditBatches()) {
             for (int i = 0; i < editBatch; i++) {
-                final int msgId = i + (batchI * getParams().editBatchSize);
+                final int msgId = i + batchI * getParams().editBatchSize;
                 final NetconfMessage msg = getPreparedMessages().get(msgId);
                 LOG.debug("Sending message {}", msgId);
                 if (LOG.isDebugEnabled()) {
index 90728207b05f584864e5bcc167aa0ed7d04028f4..763a7b8b67d7c4ad5624edb83a67478027c27ea5 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.netconf.test.tool.client.stress;
 import ch.qos.logback.classic.Level;
 import com.google.common.base.Stopwatch;
 import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timer;
@@ -26,8 +27,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import net.sourceforge.argparse4j.inf.ArgumentParser;
 import net.sourceforge.argparse4j.inf.ArgumentParserException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
@@ -44,6 +45,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
 
+@SuppressFBWarnings("DM_EXIT")
 public final class StressClient {
 
     private static final Logger LOG = LoggerFactory.getLogger(StressClient.class);
@@ -183,7 +185,7 @@ public final class StressClient {
         started.stop();
 
         LOG.info("FINISHED. Execution time: {}", started);
-        LOG.info("Requests per second: {}", (params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+        LOG.info("Requests per second: {}", params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
 
         // Cleanup
         timer.stop();
index e0f13da038f234160d18d11be1ab259b55a76465..087eeb0937766ae4c2f7862d7d5f88e3a70f2423 100644 (file)
@@ -15,8 +15,8 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
@@ -30,13 +30,14 @@ class SyncExecutionStrategy extends AbstractExecutionStrategy {
         super(params, preparedMessages, sessionListener);
     }
 
+    @Override
     public void invoke() {
         final AtomicInteger responseCounter = new AtomicInteger(0);
 
         int batchI = 0;
         for (final Integer editBatch : getEditBatches()) {
             for (int i = 0; i < editBatch; i++) {
-                final int msgId = i + (batchI * getParams().editBatchSize);
+                final int msgId = i + batchI * getParams().editBatchSize;
                 final NetconfMessage msg = getPreparedMessages().get(msgId);
                 LOG.debug("Sending message {}", msgId);
                 if (LOG.isDebugEnabled()) {
index a1faa4495069910ee3d0b99a9cf3994a03935033..c62107f4925f56bd36ba31e171bcbc8f427b860c 100644 (file)
@@ -18,9 +18,9 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Stream;
 import javax.xml.bind.JAXB;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 
@@ -125,7 +125,7 @@ class RpcMapping {
                 }
             }
 
-            if (e1Children.isEmpty() && e1Children.isEmpty()) {
+            if (e1Children.isEmpty() && e2Children.isEmpty()) {
                 try {
                     return e1.getTextContent().equals(e2.getTextContent());
                 } catch (final DocumentedException e) {
index d0e19cef972c2df31bd4390e80a69569292be978..480643c6743efe0ccef4491c997e0ac4e62fc902 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.netconf.test.tool.customrpc;
 import java.io.File;
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
index 49a60da37fd970ea9f62eafda20ad2678a5b30da..d806f768df47172845b67954a18759f92a8822b1 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.netconf.test.tool.customrpc;
 
 import java.io.File;
 import java.util.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
index d528df5b5164cbe74a678cdc9ed2da655047d095..edfdf6ef7490f5a0c6eaa9a839a7df83c73f70c6 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.netconf.test.tool.operations;
 import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
index 0cf0d476872bd3ad08e54b386bd036199fc5dcb8..cdf58603630bd0a844c288214d1555c206356ed8 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.netconf.test.tool.operations;
 
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 
index 91384f6e9e6c798195ae5927ba539e1d77184aef..b93f59a41fbfe6b6a0ca85c0d907a14e64b6b98c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.test.tool.operations;
 
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
@@ -45,10 +45,7 @@ public class OperationsProvider implements NetconfOperationServiceFactory {
     public AutoCloseable registerCapabilityListener(
         final CapabilityListener listener) {
         listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-            }
+        return () -> {
         };
     }
 
index 7dfacea1a91b054cbc63ca98da1b71bffea5fae9..2743e88be7b34006175fd0cb203fd59846d148cf 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.test.tool.rpc;
 
 import java.util.Collections;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlElement;
 
 public class DataList {
 
index 15204fe4b606257fe8acd261f24f8c4a4f140dd0..4276e5fb2f52c01a0ffa462b799b1fdc2e19a171 100644 (file)
@@ -9,18 +9,18 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedCommit extends AbstractConfigNetconfOperation {
+public class SimulatedCommit extends AbstractLastNetconfOperation {
 
     public SimulatedCommit(final String netconfSessionIdForReporting) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
     }
 
     @Override
index 682723af1714969c00fb07cfcbeae0313cb14c7c..c6f7fac0db34e99026e3a9e2c9ec82c3d72b72cb 100644 (file)
@@ -25,11 +25,11 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.impl.mapping.operations.DefaultNetconfOperation;
 import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
index 83bcb9545e2630082c486c08befd66772f92c26a..ef5d06beb232a5643e145a773a236f79b0ab99e9 100644 (file)
@@ -9,18 +9,18 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedDiscardChanges extends AbstractConfigNetconfOperation {
+public class SimulatedDiscardChanges extends AbstractLastNetconfOperation {
 
     public SimulatedDiscardChanges(final String netconfSessionIdForReporting) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
     }
 
     @Override
index fd8c49838d26ae162deeeb23a507e9c52be33f74..2e902c054ccf0065908145f2475c32acf6d627a2 100644 (file)
@@ -9,24 +9,23 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfigXmlParser;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedEditConfig extends AbstractConfigNetconfOperation {
+public class SimulatedEditConfig extends AbstractLastNetconfOperation {
     private static final String DELETE_EDIT_CONFIG = "delete";
     private static final String OPERATION = "operation";
     private static final String REMOVE_EDIT_CONFIG = "remove";
     private final DataList storage;
 
     public SimulatedEditConfig(final String netconfSessionIdForReporting, final DataList storage) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
         this.storage = storage;
     }
 
@@ -47,7 +46,7 @@ public class SimulatedEditConfig extends AbstractConfigNetconfOperation {
 
     @Override
     protected String getOperationName() {
-        return EditConfigXmlParser.EDIT_CONFIG;
+        return "edit-config";
     }
 
     private boolean containsDelete(final XmlElement element) {
index 0f19b117983ba11fd4a6197efd1c39b7dddf5f47..83897d0c98b81d1c50626039d5f2a62ce8f5669a 100644 (file)
@@ -9,20 +9,20 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedGet extends AbstractConfigNetconfOperation {
+public class SimulatedGet extends AbstractLastNetconfOperation {
 
     private final DataList storage;
 
     public SimulatedGet(final String netconfSessionIdForReporting, final DataList storage) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
         this.storage = storage;
     }
 
index f139a9000d50976943fdc56448377ea8c2cecf9e..572fd961b742b1e9b90228651821aa749c37d05a 100644 (file)
@@ -11,20 +11,19 @@ package org.opendaylight.netconf.test.tool.rpc;
 import com.google.common.base.Optional;
 import java.io.File;
 import java.io.IOException;
-import java.util.Collections;
 import java.util.List;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-public class SimulatedGetConfig extends AbstractConfigNetconfOperation {
+public class SimulatedGetConfig extends AbstractLastNetconfOperation {
 
     private final DataList storage;
     private static final Logger LOG = LoggerFactory
@@ -32,7 +31,7 @@ public class SimulatedGetConfig extends AbstractConfigNetconfOperation {
 
     public SimulatedGetConfig(final String netconfSessionIdForReporting, final DataList storage,
                               final Optional<File> initialConfigXMLFile) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
 
         if (initialConfigXMLFile.isPresent()) {
             LOG.info("File is present: {}", initialConfigXMLFile.get()
@@ -46,11 +45,10 @@ public class SimulatedGetConfig extends AbstractConfigNetconfOperation {
     private static DataList loadInitialConfigXMLFile(final File file) {
         LOG.info("Loading initial config xml file: {}", file.getName());
         DataList configData = new DataList();
-        List<XmlElement> xmlElementList = Collections.emptyList();
         try {
             Element element = XmlUtil.readXmlToElement(file);
             XmlElement xmlElement = XmlElement.fromDomElement(element);
-            xmlElementList = xmlElement.getChildElements();
+            List<XmlElement> xmlElementList = xmlElement.getChildElements();
             configData.setConfigList(xmlElementList);
         } catch (IOException e) {
             LOG.info("IO exception loading xml file: {} ", e.getMessage());
index ffb9d4d65db336a9a0a0f25fc2c0c2966b83d9b8..c7d4e0c13aa16bf31db82d89c119218287ca92b2 100644 (file)
@@ -9,18 +9,18 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedLock extends AbstractConfigNetconfOperation {
+public class SimulatedLock extends AbstractLastNetconfOperation {
 
     public SimulatedLock(final String netconfSessionIdForReporting) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
     }
 
     @Override
index 6c709e636825c2c6723b29a426debb9acda4f72c..ce06534a9cd378398db21024d0744914252aaa7e 100644 (file)
@@ -9,18 +9,18 @@
 package org.opendaylight.netconf.test.tool.rpc;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class SimulatedUnLock extends AbstractConfigNetconfOperation {
+public class SimulatedUnLock extends AbstractLastNetconfOperation {
 
     public SimulatedUnLock(final String netconfSessionIdForReporting) {
-        super(null, netconfSessionIdForReporting);
+        super(netconfSessionIdForReporting);
     }
 
     @Override
index ec0105b77968936434ad7cfdfbf023e4ba452877..44a15f65cf9f07855ee9b5719d57a51ca9a6c0aa 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.netconf.test.tool.rpchandler;
 
 import java.util.Optional;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.w3c.dom.Document;
 
 public interface RpcHandler {
index f817575d26286e2c4ee2c7b557438334c17d6c42..04a34b3cb2061d8142a7e9bfd07d4d556337d5c3 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.netconf.test.tool.rpchandler;
 
 import java.util.Optional;
-import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
index ed36c443981629d633811966385ff1b2d2283bb3..dc74c9d604df9c497e689a3e743850d0134daf85 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.test.tool.rpchandler;
 
 import java.util.Collections;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
index a85136564ae9b2617a3f481064d3c55b460af4b3..a3e449f05a1d971515d59e2a296f4f706a205c84 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.netconf.test.tool.rpchandler;
 
 import java.util.Optional;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
index 1cc85ae216af554549e3241f843047a9a3e9253d..cd8d546082b90b3465d1887b3980d3401f0986eb 100644 (file)
@@ -8,12 +8,14 @@
 
 package org.opendaylight.netconf.test.tool.scale.util;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.File;
 import net.sourceforge.argparse4j.ArgumentParsers;
 import net.sourceforge.argparse4j.annotation.Arg;
 import net.sourceforge.argparse4j.inf.ArgumentParser;
 import net.sourceforge.argparse4j.inf.ArgumentParserException;
 
+@SuppressFBWarnings("DM_EXIT")
 public class ScaleUtilParameters {
 
     @Arg(dest = "distro-folder")
index e502bc7b78bc7849d724afe3e0cb54c3fc8e60fe..1bcc7b371c627217a14c1895dbbc50019242988a 100644 (file)
                 <configuration>
                     <instructions>
                         <Bundle-Name>YangLib</Bundle-Name>
-                        <Import-Package>*,
-                            com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets</Import-Package>
+                        <Import-Package>
+                            com.sun.jersey.spi.container.servlet,
+                            org.eclipse.jetty.servlets,
+                            !javax.annotation,
+                            javax.ws.rs.*;version="[1.1.0,2.0.0)",
+                            *
+                        </Import-Package>
                         <Web-ContextPath>/yanglib</Web-ContextPath>
                     </instructions>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 
index ba7e22a025bc26bcb5ef251821293bd85f9fdecd..d969f0b40fddfeaa1713daccc36104efd8967a7e 100644 (file)
@@ -41,9 +41,6 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaListenerRegistration
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
 import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,21 +58,18 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
         input -> YangTextSchemaSource.class.isAssignableFrom(input.getRepresentation());
 
     private final DataBroker dataBroker;
-    private final YangLibServiceImpl yangLibService;
     private final YanglibConfig yanglibConfig;
     private SchemaListenerRegistration schemaListenerRegistration;
     private SharedSchemaRepository schemaRepository;
 
-    public YangLibProvider(final YanglibConfig yanglibConfig, final DataBroker dataBroker,
-            final YangLibServiceImpl yangLibService) {
+    public YangLibProvider(final YanglibConfig yanglibConfig, final DataBroker dataBroker) {
         this.yanglibConfig = Preconditions.checkNotNull(yanglibConfig);
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
-        this.yangLibService = Preconditions.checkNotNull(yangLibService);
     }
 
     @Override
     public void close() {
-        yangLibService.setSchemaRepository(null);
+        YangLibServiceImpl.setSchemaRepository(null);
         if (schemaListenerRegistration != null) {
             schemaListenerRegistration.close();
         }
@@ -98,7 +92,7 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
         schemaRepository.registerSchemaSourceListener(cache);
 
         schemaListenerRegistration = schemaRepository.registerSchemaSourceListener(this);
-        yangLibService.setSchemaRepository(schemaRepository);
+        YangLibServiceImpl.setSchemaRepository(schemaRepository);
 
         LOG.info("Started yang library with sources from {}", cacheFolderFile);
     }
@@ -192,10 +186,4 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
         return sourceIdentifier.getRevision().map(rev -> new OptionalRevision(new RevisionIdentifier(rev.toString())))
                 .orElse(NO_REVISION);
     }
-
-    private <T> T getObjectFromBundleContext(final Class<T> type, final String serviceRefName) {
-        final BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
-        final ServiceReference<?> serviceReference = bundleContext.getServiceReference(serviceRefName);
-        return (T) bundleContext.getService(serviceReference);
-    }
 }
index cafcd116234467bc5b9875dfb143dbe58841d76d..308e9bb7a3cab77da49d663737d8a42678c0a39f 100644 (file)
@@ -12,17 +12,9 @@ import java.util.Collections;
 import java.util.Set;
 import javax.ws.rs.core.Application;
 import org.opendaylight.yanglib.api.YangLibRestAppService;
-import org.osgi.framework.FrameworkUtil;
 
 public class YangLibRestApp extends Application implements YangLibRestAppService {
-
-    private final YangLibServiceImpl yangLibService;
-
-    public YangLibRestApp() {
-        this.yangLibService = new YangLibServiceImpl();
-        FrameworkUtil.getBundle(getClass()).getBundleContext().registerService(YangLibRestAppService.class.getName(),
-                this, null);
-    }
+    private final YangLibServiceImpl yangLibService = new YangLibServiceImpl();
 
     @Override
     public Set<Object> getSingletons() {
index e75776f84b533c6f7baefa94ab5d0b198ffce754..949d8f577393c35baaf747ae4a1b51266d3aa0fb 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.io.ByteStreams;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.yanglib.api.YangLibService;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -28,15 +29,15 @@ import org.slf4j.LoggerFactory;
 public class YangLibServiceImpl implements YangLibService {
     private static final Logger LOG = LoggerFactory.getLogger(YangLibServiceImpl.class);
 
-    private volatile SchemaRepository schemaRepository;
+    private static volatile SchemaRepository schemaRepository;
 
     public YangLibServiceImpl() {
 
     }
 
-    public void setSchemaRepository(final SchemaRepository schemaRepository) {
+    public static void setSchemaRepository(final SchemaRepository schemaRepository) {
         LOG.debug("Setting schema repository {}", schemaRepository);
-        this.schemaRepository = schemaRepository;
+        YangLibServiceImpl.schemaRepository = schemaRepository;
     }
 
     @Override
@@ -51,7 +52,7 @@ public class YangLibServiceImpl implements YangLibService {
 
         try {
             final YangTextSchemaSource source = sourceFuture.get();
-            return new String(ByteStreams.toByteArray(source.openStream()));
+            return new String(ByteStreams.toByteArray(source.openStream()), Charset.defaultCharset());
         } catch (InterruptedException | ExecutionException | IOException e) {
             throw new IllegalStateException("Unable to get schema " + sourceId, e);
         }
index ec758fb8275bc8748551c4f134dcc89255cc6467..73f005fcfcb8d2283a41b86fa7826606dfa2e3f1 100644 (file)
             <param-name>javax.ws.rs.Application</param-name>
             <param-value>org.opendaylight.yanglib.impl.YangLibRestApp</param-value>
         </init-param>
+        <load-on-startup>1</load-on-startup>
     </servlet>
 
     <servlet-mapping>
         <servlet-name>JAXRSYanglib</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
-</web-app>
\ No newline at end of file
+</web-app>
index 890d72bbdf45b3618ae8320d35e513cc0f35ad70..d16f601db647caf1f0bf5dc1027d07dbb9cb333f 100644 (file)
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig"/>
 
   <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
-  <reference id="yangLibRestAppService" interface="org.opendaylight.yanglib.api.YangLibRestAppService"/>
 
   <bean id="yangLibProvider" class="org.opendaylight.yanglib.impl.YangLibProvider"
           init-method="init" destroy-method="close">
     <argument ref="yanglibConfig"/>
     <argument ref="dataBroker"/>
-    <argument>
-      <bean factory-ref="yangLibRestAppService" factory-method="getYangLibService"/>
-    </argument>
   </bean>
 
 </blueprint>
index 5372a072605f4e243d216a438fa0b07eff6d2e8c..36db57aa783c2e2e9206a7c43315aab8e9bf8669 100644 (file)
@@ -89,7 +89,7 @@ public class YangLibProviderTest {
 
         final YanglibConfig yanglibConfig = new YanglibConfigBuilder().setBindingAddr("www.fake.com")
                 .setBindingPort(300L).setCacheFolder(CACHE_DIR.getAbsolutePath()).build();
-        yangLibProvider = new YangLibProvider(yanglibConfig, dataBroker, new YangLibServiceImpl());
+        yangLibProvider = new YangLibProvider(yanglibConfig, dataBroker);
     }
 
     @Test
index 62b81599db10ba7911872e0aeedb4e953cfd5f47..c72366d6f8676c987f40751a88f134077140b93d 100644 (file)
@@ -9,44 +9,17 @@
 package org.opendaylight.yanglib.impl;
 
 import static junit.framework.TestCase.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.then;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
 
 import java.util.Set;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.opendaylight.yanglib.api.YangLibRestAppService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(FrameworkUtil.class)
 public class YangLibRestAppTest {
 
     @Test
     public void testYangLibRestApp() {
-        PowerMockito.mockStatic(FrameworkUtil.class);
-
-        final BundleContext bundleContext = mock(BundleContext.class);
-        final Bundle bundle = mock(Bundle.class);
-
-        given(FrameworkUtil.getBundle(any())).willReturn(bundle);
-        given(bundle.getBundleContext()).willReturn(bundleContext);
-
         final YangLibRestApp yangLibRestApp = new YangLibRestApp();
         final Set singleton = yangLibRestApp.getSingletons();
 
         assertTrue(singleton.contains(yangLibRestApp.getYangLibService()));
-
-        then(bundleContext).should(times(1))
-                .registerService(eq(YangLibRestAppService.class.getName()), eq(yangLibRestApp), eq(null));
     }
 }
index a883eaf4ea1fa55980f3f897d4dcb45ca500c2bf..a7ec22f56ab723edfe6da3e546c1aa3c1eb61b57 100644 (file)
@@ -7,17 +7,14 @@
  */
 package org.opendaylight.protocol.framework;
 
+import com.google.common.base.Preconditions;
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.util.concurrent.Promise;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 /**
  * Abstract base class for session negotiators. It implements the basic
  * substrate to implement SessionNegotiator API specification, with subclasses
@@ -27,7 +24,8 @@ import com.google.common.base.Preconditions;
  * @param <S> Protocol session type, has to extend {@code ProtocolSession<M>}
  */
 @Deprecated
-public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>> extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
+public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>>
+        extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
     private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class);
     private final Promise<S> promise;
     protected final Channel channel;
@@ -59,15 +57,14 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
      * @param msg Message which should be sent.
      */
     protected final void sendMessage(final M msg) {
-        this.channel.writeAndFlush(msg).addListener(
-                (ChannelFutureListener) f -> {
-                    if (!f.isSuccess()) {
-                        LOG.info("Failed to send message {}", msg, f.cause());
-                        negotiationFailed(f.cause());
-                    } else {
-                        LOG.trace("Message {} sent to socket", msg);
-                    }
-                });
+        this.channel.writeAndFlush(msg).addListener(f -> {
+            if (!f.isSuccess()) {
+                LOG.info("Failed to send message {}", msg, f.cause());
+                negotiationFailed(f.cause());
+            } else {
+                LOG.trace("Message {} sent to socket", msg);
+            }
+        });
     }
 
     @Override
index f449b51d0deff211b5469e56f4504ea4788e0bbc..87313f4e4cfb1140bc8f2c59e63dc39bddb06bcf 100644 (file)
@@ -14,7 +14,6 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.util.concurrent.DefaultPromise;
 import io.netty.util.concurrent.EventExecutor;
 import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
 import java.net.InetSocketAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +52,7 @@ final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionList
             channel.pipeline().addLast(new ClosedChannelHandler(ReconnectPromise.this));
         });
 
-        pending.addListener((GenericFutureListener<Future<Object>>) future -> {
+        pending.addListener(future -> {
             if (!future.isSuccess() && !ReconnectPromise.this.isDone()) {
                 ReconnectPromise.this.setFailure(future.cause());
             }