Merge "Clean up netconf-parent root pom"
authorJakub Morvay <jakub.morvay@gmail.com>
Fri, 12 Jan 2018 14:00:54 +0000 (14:00 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 12 Jan 2018 14:00:54 +0000 (14:00 +0000)
411 files changed:
features/netconf-connector/features-netconf-connector/pom.xml
features/netconf-connector/odl-message-bus/pom.xml
features/netconf-connector/odl-netconf-callhome-ssh/pom.xml
features/netconf-connector/odl-netconf-clustered-topology/pom.xml
features/netconf-connector/odl-netconf-connector-all/pom.xml
features/netconf-connector/odl-netconf-connector-ssh/pom.xml
features/netconf-connector/odl-netconf-connector/pom.xml
features/netconf-connector/odl-netconf-console/pom.xml
features/netconf-connector/odl-netconf-topology/pom.xml
features/netconf-connector/pom.xml
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
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-mapping-api/pom.xml
features/netconf/odl-netconf-mdsal/pom.xml
features/netconf/odl-netconf-monitoring/pom.xml
features/netconf/odl-netconf-netty-util/pom.xml
features/netconf/odl-netconf-netty-util/src/main/feature/feature.xml
features/netconf/odl-netconf-notifications-api/pom.xml
features/netconf/odl-netconf-notifications-impl/pom.xml
features/netconf/odl-netconf-ssh/pom.xml
features/netconf/odl-netconf-tcp/pom.xml
features/netconf/odl-netconf-util/pom.xml
features/netconf/pom.xml
features/pom.xml
features/protocol-framework/features-protocol-framework/pom.xml
features/protocol-framework/odl-protocol-framework/pom.xml
features/protocol-framework/pom.xml
features/restconf/features-restconf/pom.xml
features/restconf/odl-mdsal-apidocs/pom.xml
features/restconf/odl-restconf-all/pom.xml
features/restconf/odl-restconf-nb-rfc8040-all/pom.xml
features/restconf/odl-restconf-nb-rfc8040-noauth/pom.xml
features/restconf/odl-restconf-nb-rfc8040-noauth/src/main/feature/feature.xml [new file with mode: 0644]
features/restconf/odl-restconf-nb-rfc8040/pom.xml
features/restconf/odl-restconf-noauth/pom.xml
features/restconf/odl-restconf-noauth/src/main/feature/feature.xml
features/restconf/odl-restconf/pom.xml
features/restconf/pom.xml
features/yanglib/features-yanglib/pom.xml
features/yanglib/odl-yanglib/pom.xml
features/yanglib/odl-yanglib/src/main/feature/feature.xml [new file with mode: 0644]
features/yanglib/pom.xml
karaf/pom.xml
netconf/aaa-authn-odl-plugin/pom.xml
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/AuthorizedKeysDecoder.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/MinaSshNettyChannel.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServer.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServerBuilder.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorizationTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContextTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/MinaSshNettyChannelTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServerTest.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/CallhomeStatusReporter.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java
netconf/config-netconf-connector/pom.xml
netconf/config-netconf-connector/src/test/java/org/opendaylight/netconf/confignetconfconnector/NetconfMappingTest.java
netconf/mdsal-netconf-connector/pom.xml
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/EditConfig.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/EditOperationNormalizedNodeStreamWriter.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/get/AbstractGet.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/FilterContentValidator.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-impl/pom.xml
netconf/mdsal-netconf-monitoring/pom.xml
netconf/mdsal-netconf-notification/pom.xml
netconf/mdsal-netconf-ssh/pom.xml
netconf/mdsal-netconf-tcp/pom.xml
netconf/mdsal-netconf-yang-library/pom.xml
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriter.java
netconf/mdsal-netconf-yang-library/src/test/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriterTest.java
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/NetconfEventSourceRegistration.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NotificationTopicRegistration.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java
netconf/models/pom.xml
netconf/netconf-api/pom.xml
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/monitoring/SessionEvent.java
netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/util/NetconfConstants.java
netconf/netconf-api/src/test/java/org/opendaylight/netconf/api/messages/NetconfHelloMessageAdditionalHeaderTest.java
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/SimpleNetconfClientSessionListener.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfigurationBuilder.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfReconnectingClientConfigurationBuilder.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java
netconf/netconf-config/pom.xml
netconf/netconf-console/pom.xml
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfCommandUtils.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/utils/NetconfConsoleConstants.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/utils/NetconfConsoleUtils.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/utils/NetconfIidFactory.java
netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java
netconf/netconf-impl/pom.xml
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultCloseSession.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/NetconfOperationRouterImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationServiceFactoryTracker.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/util/DeserializerExceptionHandler.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorTest.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/osgi/NetconfCapabilityMonitoringServiceTest.java
netconf/netconf-mapping-api/pom.xml
netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.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-netty-util/pom.xml
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/BufferedWriter.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/AuthenticationHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/LoginPasswordHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/PublicKeyAuth.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.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/ssh/authentication/LoginPasswordHandlerTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerTest.java
netconf/netconf-notifications-api/pom.xml
netconf/netconf-notifications-impl/pom.xml
netconf/netconf-ssh/pom.xml
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/NetconfNorthboundSshServer.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyServer.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyServerConfiguration.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/SshProxyServerConfigurationBuilder.java
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/osgi/NetconfSSHActivator.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClientHandler.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/netty/SSHTest.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/authentication/SSHServerTest.java
netconf/netconf-tcp/pom.xml
netconf/netconf-topology-config/pom.xml
netconf/netconf-topology-singleton/pom.xml
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/MasterSalFacade.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.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/ReadTransactionActor.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/ReadWriteTransactionActor.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/WriteTransactionActor.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImplTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/actors/ReadTransactionActorTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/actors/ReadWriteTransactionActorTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/actors/WriteTransactionActorTest.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-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyWriteTransactionTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ReadOnlyTransactionTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ReadWriteTransactionTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/WriteOnlyTransactionTest.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/CloseableUtil.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/SubtreeFilter.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/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/auth/DatastoreBackedPublicKeyAuth.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/NetconfSessionPreferences.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/NetconfDeviceSalProvider.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/WriteCandidateTx.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.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/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/NetconfRpcStructureTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NodeContainerProxy.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/SchemalessRpcStructureTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemasTest.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/NetconfStateSchemasTest.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/KeepaliveSalFacadeTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationServiceTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/TxChainTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/TxTestUtils.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTxTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTxTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTxTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProviderTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/YangLibrarySchemaYangSourceProviderTest.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/util/NetconfBaseOpsTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfTopologyRPCProviderTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NodeContainerProxyTest.java
netconf/tools/netconf-testtool/pom.xml
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/TestToolUtils.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/RestPerfClient.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/ConfigurableClientDispatcher.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/config/Configuration.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/config/ConfigurationBuilder.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/rpc/SimulatedCreateSubscription.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/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/schemacache/SchemaSourceCache.java
netconf/tools/pom.xml
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibServiceImpl.java
netconf/yanglib/src/test/java/org/opendaylight/yanglib/impl/YangLibProviderTest.java
netconf/yanglib/src/test/java/org/opendaylight/yanglib/impl/YangLibServiceImplTest.java
pom.xml
protocol-framework/pom.xml
restconf/pom.xml
restconf/restconf-artifacts/pom.xml
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/errors/RestconfDocumentedException.java
restconf/restconf-common/src/test/java/org/opendaylight/restconf/common/util/RestconfSchemaUtilTest.java
restconf/restconf-models/pom.xml
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaRetrievalServiceImpl.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDelegatingNormalizedNodeWriter.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/StringModuleInstanceIdentifierCodec.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/FakeContainerSchemaNode.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/FakeImportedModule.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/FakeLeafSchemaNode.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/FakeModuleImport.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/FakeRestconfModule.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/QueryParametersParser.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestCodec.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/StatisticsRestconfServiceWrapper.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractQueryParams.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/Notificator.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/websockets/WebSocketServer.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/InstanceIdentifierTypeLeafTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug3595Test.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug8072Test.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CutDataToCorrectDepthTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyRpcResult.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyType.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ExpressionParserTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestOperationUtils.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplNotificationSubscribingTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriterTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/restconf/impl/InstanceIdentifierCodecImplTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapterTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java
restconf/restconf-nb-bierman02/src/test/resources/datastore-and-scope-specification/sal-remote-augment.yang
restconf/restconf-nb-bierman02/src/test/resources/invoke-rpc/invoke-rpc-module.yang
restconf/restconf-nb-bierman02/src/test/resources/json-to-nn/identityref/identity-module.yang
restconf/restconf-nb-bierman02/src/test/resources/json-to-nn/identityref/identityref-module.yang
restconf/restconf-nb-bierman02/src/test/resources/modules/nested-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-json/identityref/identity-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-json/identityref/identityref-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-json/leafref/cont-augment-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-json/leafref/main-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-xml/instance_identifier/aug-referenced-elements-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-xml/instance_identifier/eferenced-elements-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-xml/instance_identifier/rinstance-identifier-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-xml/yang/basic-module.yang
restconf/restconf-nb-bierman02/src/test/resources/nn-to-xml/yang/referenced-module.yang
restconf/restconf-nb-bierman02/src/test/resources/xml-to-cnsn/identityref/identity-module.yang
restconf/restconf-nb-bierman02/src/test/resources/xml-to-cnsn/identityref/identityref-module.yang
restconf/restconf-nb-bierman02/src/test/resources/xml-to-cnsn/identityref/yang-augments/identity-module.yang
restconf/restconf-nb-bierman02/src/test/resources/xml-to-cnsn/identityref/yang-augments/identityref-module.yang
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/Rfc8040.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/StringModuleInstanceIdentifierCodec.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandler.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/TransactionChainHandler.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/schema/SchemaExportContentYangBodyWriter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/references/SchemaContextRef.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/TransactionVarsWrapper.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ParametersUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfDataServiceConstant.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfStreamsConstants.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/SubscribeToStreamUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/FakeContainerSchemaNode.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/FakeImportedModule.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/FakeLeafSchemaNode.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/FakeModuleImport.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/FakeRestconfModule.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapperImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractNotificationsData.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractQueryParams.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerAdapter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/Notificator.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/websockets/WebSocketServer.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserFieldsParameter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/validations/RestconfValidation.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/TestRestconfUtils.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/TestUtils.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandlerTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfStreamsSubscriptionServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PatchDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PostDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserFieldsParameterTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/validations/RestconfValidationTest.java
restconf/restconf-nb-rfc8040/src/test/resources/invoke-rpc/invoke-rpc-module.yang
restconf/restconf-nb-rfc8040/src/test/resources/modules/nested-module.yang
restconf/sal-rest-connector-config/pom.xml
restconf/sal-rest-docgen-maven/pom.xml
restconf/sal-rest-docgen-maven/src/main/java/org/opendaylight/netconf/sal/rest/doc/maven/StaticDocGenerator.java
restconf/sal-rest-docgen/pom.xml
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGenTestHelper.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java
restconf/sal-rest-docgen/src/test/resources/yang/toaster_augmented.yang

index 14e019c25ecb17c78798fe664e3c16334c952065..639742b2d93364d0ffdddba6c6feff4681d3a67b 100644 (file)
@@ -14,7 +14,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>feature-repo-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index fac05202fe7970c707d38251ba2fcf1dba20322f..b3f76b916c5f8f33456ff2a8a7caf5192a410c2d 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index bd07645b71785fe65460a81a02feaf6cb40a40f5..a609dd5b62205215be91c7c024969545c476b497 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 367f51f3d052e70262bd01359f37e50eac37efbd..50f8132834e0f19a769d82236f41853649b219df 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 1e4a128fb1a6bde254d5bea9099948f4e3b7c17c..6e184c2603b3906a8ac1a8a32a6e1ec18da1f5de 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index a6c5ea3a558cd0731dd81c6c073e4443f3ab62bf..31df4aa2047afd91fb83238fdf13401f41912bb3 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 66988da7824551f58cb4dd8feeabeddec05c8c2f..f8443c2a7b13139d7f135bfc6c0756f5e0c2383f 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 0efc72f91a7171b21d3e4e2b56085c18083eb4e6..c4aa54d0bc902998bc1a87525ef0d1efdb74a52b 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 08a26bba011f0e488e2f1bfc1a0daea10220ce4e..2c5f754f4524ecb965bc7be51fb384ae547fe5b8 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 85a07ab71494e8f0a7d970d6125652b338ecfd45..068b7595a367b3f6c9556908642e111c03620721 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
     <groupId>org.opendaylight.netconf</groupId>
@@ -28,7 +28,7 @@
       <mdsal.model.version>0.12.0-SNAPSHOT</mdsal.model.version>
       <netconf.version>1.4.0-SNAPSHOT</netconf.version>
       <netconf.connector.version>1.7.0-SNAPSHOT</netconf.connector.version>
-      <yangtools.version>1.2.0</yangtools.version>
+      <yangtools.version>2.0.0</yangtools.version>
     </properties>
 
     <modules>
index 0f708c3a1def3cbe6e95a09afb39f2191ca43cef..f4f65033b29b7c1d182798f85c6a2d2ccc5507ac 100644 (file)
@@ -14,7 +14,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>feature-repo-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index def02796b1aacdc2595a88c96ce28eee42492a30..a00757da549e6609142c78c20c01de40aa29500e 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 491ee67e05bf764becb0c0e0a6d0bc082810fcd7..e6f6ff5ed1161844b58c4a8f248a33ea7b879326 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index a677e12d085234509c5ee7715e848c0e842ba1cc..4cad56afa9be8054c830e70a6209bd5bf9ffa2f8 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index bda2395f195c6eafe78e39c64096e7e6e07afc9b..32d04ab09e65d66df715b2aed8ddebcfc244a45c 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 140607d1a022d34679e3d60b11d930135b2b99dd..5821f68c647d1c70777b56ae75da1012853d7910 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -37,7 +37,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
@@ -53,7 +53,7 @@
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>odl-yangtools-yang-data</artifactId>
+            <artifactId>odl-yangtools-data</artifactId>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
index 2a11d2fa435a2ab9d6a3917c64d74c4b1df16c8c..581588bc604357c6bbb1884a81c8ef593b715c2c 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 25a1c6ff8c21f4ce8d6908961f3d83420491e9bd..91b0c297dd99ab0b0f94439ade72e0ba6e20d4e5 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index f0e06e1d123a5b6c56e8b78dc8c8650f2900d4e6..af29c2188bc2d71220ecaafbc3c8f41d66e9838d 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index c93c49539cee70df68c5ee6ba8f251f8e318fb82..d34ea6177ceea9847f923c25fcc2b00cca104a38 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 9c37415c883c0f4ff35f35893bf57df5b71d4851..782e9e79caa0bcc13a6fb19e002c3fef66d3cc93 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 1ec298de152c2bf408a09cd64fe82beb4c44216d..6cd9a2171c285fb65c934a08788a4639ead23e75 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index b02171eac31b4a2135fc7b047cdaa52dc5bf3279..c89db4861425c0460a7c73111a0eddaf568e582d 100644 (file)
@@ -9,5 +9,6 @@
 <features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
     <feature name="odl-netconf-netty-util" version="${project.version}">
         <feature version="${karaf.version}">ssh</feature>
+        <feature version="[3.0.0,4)">odl-netty-4</feature>
     </feature>
 </features>
index 192148fe567f4d98a3ed0ba4bb4c5488636c9afb..d636008a15fb1a51995f459c4544feacecdcf81d 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index a8849d09ec3a1e716e28ad64347074d8fc2b8488..127f2c4188e98b42a1f8b1c3ec06299f5fe68741 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 0e2e1bbc899b379e7619ccaca7f182bcf5260fb1..4f3849eb8b6aef78e3af791289cacd992f1e2736 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 612ade282596ba6e9af45ba2e56596efa00aa42b..3973439092d46a88a5550aefa17a2b1e5633c60d 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 8600a1a79e4e7b6933f1d211eba2a30d0b5a3a5c..c3e555dfdd3bc00f115c1b461fadc7af95dc822f 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -33,8 +33,8 @@
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>odl-yangtools-yang-data</artifactId>
-            <version>1.2.0</version>
+            <artifactId>odl-yangtools-data</artifactId>
+            <version>2.0.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
index 12cf69b033ddec4e91b426bc5f35c0c8472bec60..8e22532dfda67acfe500dae38b20ec898b056282 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 03a743780f71e48b34b375a9d4f4ecda74c36030..325a662fe3820a9763d7daf46fb1579dfdbcd70b 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 0cce249b255517e2f302cae82188e5ea551bf80c..8b4bd293656ffda9e9bfea98ab95ca805d6e833e 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 741eba8570b18f588e1f35dc6e78c2290ddeb3b0..bc610a81d87840012e666e2f0b414ebb6749dfe7 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 271895bd198e2033f2883e9acdbf377a6dcec20e..34bf326d336585701fb03bc4b05c696c75013adc 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 160e4dd96d7cc6a264bea6859ba07b130077efee..86c6fee2a52d2c31a2fe4e8be2932cd9439f6ff3 100644 (file)
@@ -14,7 +14,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>feature-repo-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 16201c967a0ec9ab85070f20250b5cd11b4a1a36..8b102f7429526991612637eaa175b965df14b80f 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index c8f2f20d23f368d6427f308f2d1e529adc7a4b13..1edc784ecef3477d95efaaec87eacb3d96801dfd 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index d6b36ae45287daff972120a8a736bdfc0156a7d5..cb5ed4f2e1bda1ed081f9798fbfa8185d5104d8d 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index a787aac7280dbcb0ff1ba0da194dfd91e35e6736..2b6dba1bc690cbd73a3209c8ee2dba8a4b2fa723 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
             <dependency>
                 <groupId>org.opendaylight.odlparent</groupId>
                 <artifactId>odlparent-artifacts</artifactId>
-                <version>2.0.5</version>
+                <version>3.0.2</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
diff --git a/features/restconf/odl-restconf-nb-rfc8040-noauth/src/main/feature/feature.xml b/features/restconf/odl-restconf-nb-rfc8040-noauth/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..a190dfc
--- /dev/null
@@ -0,0 +1,14 @@
+<?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
+  -->
+<features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+    <feature name="odl-restconf-nb-rfc8040-noauth" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-karaf-feat-jetty</feature>
+        <feature version="[3.0.0,4)">odl-netty-4</feature>
+    </feature>
+</features>
index bd690ace87c714ead3b00ae88baf09ac0bb7c32a..eb68f851ffca7102598e1a7df188c59cac8f1693 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index da2033f117416b0fa533d7c41d9e9673c50cc535..204e198a712536e204630466d7b68e8ebe84a8e1 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
             <dependency>
                 <groupId>org.opendaylight.odlparent</groupId>
                 <artifactId>odlparent-artifacts</artifactId>
-                <version>2.0.5</version>
+                <version>3.0.2</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 2b246c9d9b0741f68e3fa07ca667e039fd225060..341cd50769a3db0db2ce68dcba0bcaf716a900ae 100644 (file)
@@ -11,5 +11,7 @@
         <configfile finalname="etc/org.opendaylight.restconf.cfg">
             mvn:org.opendaylight.netconf/sal-rest-connector-config/${project.version}/cfg/restconf
         </configfile>
+        <feature version="[3.0.0,4)">odl-karaf-feat-jetty</feature>
+        <feature version="[3.0.0,4)">odl-netty-4</feature>
     </feature>
 </features>
index ce3fb9411aca37794c8b6bba4319ffaf8ae6c437..e106def77670bde46e0c8662f30f0794eaea6a0a 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 48ae66f61d8f19497e6909671babd12eeab47c4b..ec4c19727bc1f06503ef5081fc2fcde0f34a0019 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
     <artifactId>features-restconf-aggregator</artifactId>
index ce012a979a3805050ac33274a39c2dd28095a056..a2e6b71e83fca4cfc2ea57c859f31fcb0cb7de74 100644 (file)
@@ -15,7 +15,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index ef7bad3de8d274930e74a3dad66d227d1109aa3a..65d02262e42d913da3b786118a1e1e41df4fdb52 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -33,8 +33,8 @@
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>odl-yangtools-yang-data</artifactId>
-            <version>1.2.0</version>
+            <artifactId>odl-yangtools-data</artifactId>
+            <version>2.0.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
diff --git a/features/yanglib/odl-yanglib/src/main/feature/feature.xml b/features/yanglib/odl-yanglib/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..2093186
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright Â© 2018 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
+  -->
+<features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+    <feature name="odl-yanglib" version="${project.version}">
+        <feature version="[3.0.0,4)">odl-karaf-feat-jetty</feature>
+    </feature>
+</features>
index 3b513717146dfc82ace285cbb447e83ca3f67bb4..f80b4e383c46c73a045e1e191cc909e3eb94aabf 100644 (file)
@@ -11,7 +11,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 1c577cedfa76f35d5a7b5940544407c21ce6e90d..8a68d4a0d5a37b590f6753f4a85fa631a596eff4 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>karaf4-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
   <groupId>org.opendaylight.netconf</groupId>
index 7c74022d2abf89ae7343937dc7cd0f419953fc29..1cdae8523fe84697effeb1e27b64e01b424e1045 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index ac476c6c9115879d5785a6f0df64c7d178db37fe..e544195fd8045c32bcc8ffb6d008e45b9fbc6584 100644 (file)
@@ -11,9 +11,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.math.BigInteger;
+import java.security.GeneralSecurityException;
 import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
 import java.security.PublicKey;
 import java.security.interfaces.DSAParams;
 import java.security.interfaces.DSAPublicKey;
@@ -21,13 +20,12 @@ import java.security.interfaces.RSAPublicKey;
 import java.security.spec.DSAPublicKeySpec;
 import java.security.spec.ECPoint;
 import java.security.spec.ECPublicKeySpec;
-import java.security.spec.InvalidKeySpecException;
 import java.security.spec.RSAPublicKeySpec;
 import java.util.Arrays;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
-import org.apache.sshd.common.util.Base64;
-import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.util.security.SecurityUtils;
 import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
 import org.bouncycastle.jce.ECNamedCurveTable;
 import org.bouncycastle.jce.ECPointUtil;
@@ -61,12 +59,11 @@ public class AuthorizedKeysDecoder {
     private byte[] bytes = new byte[0];
     private int pos = 0;
 
-    public PublicKey decodePublicKey(String keyLine)
-            throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
+    public PublicKey decodePublicKey(final String keyLine) throws GeneralSecurityException {
 
         // 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.decodeBase64(keyLine.getBytes());
+        bytes = Base64.getDecoder().decode(keyLine.getBytes());
         if (bytes.length == 0) {
             throw new IllegalArgumentException("No Base64 part to decode in " + keyLine);
         }
@@ -89,8 +86,7 @@ public class AuthorizedKeysDecoder {
         throw new IllegalArgumentException("Unknown decode key type " + type + " in " + keyLine);
     }
 
-    private PublicKey decodeAsEcDSA()
-            throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
+    private PublicKey decodeAsEcDSA() throws GeneralSecurityException {
         KeyFactory ecdsaFactory = SecurityUtils.getKeyFactory(KEY_FACTORY_TYPE_ECDSA);
 
         ECNamedCurveParameterSpec spec256r1 = ECNamedCurveTable.getParameterSpec(ECDSA_SUPPORTED_CURVE_NAME_SPEC);
@@ -103,7 +99,7 @@ public class AuthorizedKeysDecoder {
         return ecdsaFactory.generatePublic(pubKeySpec);
     }
 
-    private PublicKey decodeAsDSA() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
+    private PublicKey decodeAsDSA() throws GeneralSecurityException {
         KeyFactory dsaFactory = SecurityUtils.getKeyFactory(KEY_FACTORY_TYPE_DSA);
         BigInteger prime = decodeBigInt();
         BigInteger subPrime = decodeBigInt();
@@ -114,7 +110,7 @@ public class AuthorizedKeysDecoder {
         return dsaFactory.generatePublic(spec);
     }
 
-    private PublicKey decodeAsRSA() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
+    private PublicKey decodeAsRSA() throws GeneralSecurityException {
         KeyFactory rsaFactory = SecurityUtils.getKeyFactory(KEY_FACTORY_TYPE_RSA);
         BigInteger exponent = decodeBigInt();
         BigInteger modulus = decodeBigInt();
@@ -131,8 +127,8 @@ public class AuthorizedKeysDecoder {
     }
 
     private int decodeInt() {
-        return ((bytes[pos++] & 0xFF) << 24) | ((bytes[pos++] & 0xFF) << 16)
-                | ((bytes[pos++] & 0xFF) << 8) | (bytes[pos++] & 0xFF);
+        return (bytes[pos++] & 0xFF) << 24 | (bytes[pos++] & 0xFF) << 16
+                | (bytes[pos++] & 0xFF) << 8 | bytes[pos++] & 0xFF;
     }
 
     private BigInteger decodeBigInt() {
@@ -143,7 +139,7 @@ public class AuthorizedKeysDecoder {
         return new BigInteger(bigIntBytes);
     }
 
-    public static String encodePublicKey(PublicKey publicKey) throws IOException {
+    public static String encodePublicKey(final PublicKey publicKey) throws IOException {
         String publicKeyEncoded;
         ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
         if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_RSA)) {
@@ -186,7 +182,7 @@ public class AuthorizedKeysDecoder {
         } else {
             throw new IllegalArgumentException("Unknown public key encoding: " + publicKey.getAlgorithm());
         }
-        publicKeyEncoded = new String(Base64.encodeBase64(byteOs.toByteArray()));
+        publicKeyEncoded = new String(Base64.getEncoder().encodeToString(byteOs.toByteArray()));
         return publicKeyEncoded;
     }
 }
index 1896b2b0054a81fc2d4862cf8ddab656da965857..886021ed3c600d8da303fcd40201b91b42c64ef0 100644 (file)
@@ -13,7 +13,7 @@ import java.security.KeyPair;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
 
 /**
@@ -35,7 +35,7 @@ public abstract class CallHomeAuthorization {
         }
 
         @Override
-        protected void applyTo(ClientSession session) {
+        protected void applyTo(final ClientSession session) {
             throw new IllegalStateException("Server is not allowed.");
         }
     };
@@ -69,7 +69,7 @@ public abstract class CallHomeAuthorization {
      * @param username    Username to be used for authorization
      * @return Builder which allows to specify credentials.
      */
-    public static final Builder serverAccepted(String sessionName, String username) {
+    public static final Builder serverAccepted(final String sessionName, final String username) {
         return new Builder(sessionName, username);
     }
 
@@ -103,7 +103,7 @@ public abstract class CallHomeAuthorization {
         private final Set<String> passwords = new HashSet<>();
         private final Set<KeyPair> clientKeys = new HashSet<>();
 
-        private Builder(String nodeId, String username) {
+        Builder(final String nodeId, final String username) {
             this.nodeId = Preconditions.checkNotNull(nodeId);
             this.username = Preconditions.checkNotNull(username);
         }
@@ -114,7 +114,7 @@ public abstract class CallHomeAuthorization {
          * @param password Password to be used for password-based authorization.
          * @return this builder.
          */
-        public Builder addPassword(String password) {
+        public Builder addPassword(final String password) {
             this.passwords.add(password);
             return this;
         }
@@ -125,7 +125,7 @@ public abstract class CallHomeAuthorization {
          * @param clientKey Keys to be used for authorization.
          * @return this builder.
          */
-        public Builder addClientKeys(KeyPair clientKey) {
+        public Builder addClientKeys(final KeyPair clientKey) {
             this.clientKeys.add(clientKey);
             return this;
         }
@@ -144,8 +144,8 @@ public abstract class CallHomeAuthorization {
         private final Set<String> passwords;
         private final Set<KeyPair> clientKeyPair;
 
-        ServerAllowed(String nodeId, String username, Collection<String> passwords,
-                      Collection<KeyPair> clientKeyPairs) {
+        ServerAllowed(final String nodeId, final String username, final Collection<String> passwords,
+                      final Collection<KeyPair> clientKeyPairs) {
             this.username = Preconditions.checkNotNull(username);
             this.passwords = ImmutableSet.copyOf(passwords);
             this.clientKeyPair = ImmutableSet.copyOf(clientKeyPairs);
@@ -163,7 +163,7 @@ public abstract class CallHomeAuthorization {
         }
 
         @Override
-        protected void applyTo(ClientSession session) {
+        protected void applyTo(final ClientSession session) {
             Preconditions.checkArgument(session instanceof ClientSessionImpl);
             ((ClientSessionImpl) session).setUsername(username);
 
index 05c9991677f58d54e93766b7c8f829fdac4b1968..c1bb615ff2b005b5bb79d5f00ead466bdfdd66b8 100644 (file)
@@ -21,13 +21,13 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
-import org.apache.sshd.common.Session;
 import org.apache.sshd.common.future.SshFutureListener;
+import org.apache.sshd.common.session.Session;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
@@ -51,8 +51,8 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
     private final InetSocketAddress remoteAddress;
     private final PublicKey serverKey;
 
-    CallHomeSessionContext(ClientSession sshSession, CallHomeAuthorization authorization,
-                           SocketAddress remoteAddress, Factory factory) {
+    CallHomeSessionContext(final ClientSession sshSession, final CallHomeAuthorization authorization,
+                           final SocketAddress remoteAddress, final Factory factory) {
         this.authorization = Preconditions.checkNotNull(authorization, "authorization");
         Preconditions.checkArgument(this.authorization.isServerAllowed(), "Server was not allowed.");
         Preconditions.checkArgument(sshSession instanceof ClientSessionImpl,
@@ -64,7 +64,7 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         this.serverKey = this.sshSession.getKex().getServerKey();
     }
 
-    static CallHomeSessionContext getFrom(ClientSession sshSession) {
+    static CallHomeSessionContext getFrom(final ClientSession sshSession) {
         return sshSession.getAttribute(SESSION_KEY);
     }
 
@@ -94,19 +94,19 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         };
     }
 
-    private void channelOpenFailed(Throwable throwable) {
+    private void channelOpenFailed(final Throwable throwable) {
         LOG.error("Unable to open netconf subsystem, disconnecting.", throwable);
         sshSession.close(false);
     }
 
-    private void netconfChannelOpened(ClientChannel netconfChannel) {
+    private void netconfChannelOpened(final ClientChannel netconfChannel) {
         nettyChannel = newMinaSshNettyChannel(netconfChannel);
         factory.getChannelOpenListener().onNetconfSubsystemOpened(
             CallHomeSessionContext.this, this::doActivate);
     }
 
     @GuardedBy("this")
-    private synchronized Promise<NetconfClientSession> doActivate(NetconfClientSessionListener listener) {
+    private synchronized Promise<NetconfClientSession> doActivate(final NetconfClientSessionListener listener) {
         if (activated) {
             return newSessionPromise().setFailure(new IllegalStateException("Session already activated."));
         }
@@ -118,11 +118,11 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         return activationPromise;
     }
 
-    protected MinaSshNettyChannel newMinaSshNettyChannel(ClientChannel netconfChannel) {
+    protected MinaSshNettyChannel newMinaSshNettyChannel(final ClientChannel netconfChannel) {
         return new MinaSshNettyChannel(this, sshSession, netconfChannel);
     }
 
-    private Promise<NetconfClientSession> newSessionPromise() {
+    private static Promise<NetconfClientSession> newSessionPromise() {
         return GlobalEventExecutor.INSTANCE.newPromise();
     }
 
@@ -157,18 +157,18 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         private final CallHomeNetconfSubsystemListener subsystemListener;
         private final ConcurrentMap<String, CallHomeSessionContext> sessions = new ConcurrentHashMap<>();
 
-        Factory(EventLoopGroup nettyGroup, NetconfClientSessionNegotiatorFactory negotiatorFactory,
-                CallHomeNetconfSubsystemListener subsystemListener) {
+        Factory(final EventLoopGroup nettyGroup, final NetconfClientSessionNegotiatorFactory negotiatorFactory,
+                final CallHomeNetconfSubsystemListener subsystemListener) {
             this.nettyGroup = Preconditions.checkNotNull(nettyGroup, "nettyGroup");
             this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory, "negotiatorFactory");
             this.subsystemListener = Preconditions.checkNotNull(subsystemListener);
         }
 
-        void remove(CallHomeSessionContext session) {
+        void remove(final CallHomeSessionContext session) {
             sessions.remove(session.getSessionName(), session);
         }
 
-        ReverseSshChannelInitializer getChannelInitializer(NetconfClientSessionListener listener) {
+        ReverseSshChannelInitializer getChannelInitializer(final NetconfClientSessionListener listener) {
             return ReverseSshChannelInitializer.create(negotiatorFactory, listener);
         }
 
@@ -177,8 +177,8 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         }
 
         @Nullable
-        CallHomeSessionContext createIfNotExists(ClientSession sshSession, CallHomeAuthorization authorization,
-                                                 SocketAddress remoteAddress) {
+        CallHomeSessionContext createIfNotExists(final ClientSession sshSession,
+                final CallHomeAuthorization authorization, final SocketAddress remoteAddress) {
             CallHomeSessionContext session = new CallHomeSessionContext(sshSession, authorization,
                     remoteAddress, this);
             CallHomeSessionContext preexisting = sessions.putIfAbsent(session.getSessionName(), session);
index 9975c94962815fce280f59113e0bbb957e716ad5..02b9d3d0dac2311f357b1e450ec0438fd9361c05 100644 (file)
@@ -20,8 +20,8 @@ import io.netty.channel.ChannelPromise;
 import io.netty.channel.DefaultChannelConfig;
 import io.netty.channel.EventLoop;
 import java.net.SocketAddress;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.session.ClientSession;
 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerReader;
 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerReader.ReadMsgHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter;
@@ -41,7 +41,8 @@ class MinaSshNettyChannel extends AbstractServerChannel {
 
     private volatile boolean nettyClosed = false;
 
-    MinaSshNettyChannel(CallHomeSessionContext context, ClientSession session, ClientChannel sshChannel) {
+    MinaSshNettyChannel(final CallHomeSessionContext context, final ClientSession session,
+        final ClientChannel sshChannel) {
         this.context = Preconditions.checkNotNull(context);
         this.session = Preconditions.checkNotNull(session);
         this.sshChannel = Preconditions.checkNotNull(sshChannel);
@@ -53,12 +54,11 @@ class MinaSshNettyChannel extends AbstractServerChannel {
 
     private ChannelOutboundHandlerAdapter createChannelAdapter() {
         return new ChannelOutboundHandlerAdapter() {
-
             @Override
-            public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+            public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise)
+                throws Exception {
                 sshWriteAsyncHandler.write(ctx, msg, promise);
             }
-
         };
     }
 
@@ -67,7 +67,7 @@ class MinaSshNettyChannel extends AbstractServerChannel {
         return config;
     }
 
-    private boolean notClosing(org.apache.sshd.common.Closeable sshCloseable) {
+    private static boolean notClosing(final org.apache.sshd.common.Closeable sshCloseable) {
         return !sshCloseable.isClosing() && !sshCloseable.isClosed();
     }
 
@@ -92,7 +92,7 @@ class MinaSshNettyChannel extends AbstractServerChannel {
     }
 
     @Override
-    protected boolean isCompatible(EventLoop loop) {
+    protected boolean isCompatible(final EventLoop loop) {
         return true;
     }
 
@@ -107,11 +107,11 @@ class MinaSshNettyChannel extends AbstractServerChannel {
     }
 
     @Override
-    protected void doBind(SocketAddress localAddress) throws Exception {
+    protected void doBind(final SocketAddress localAddress) throws Exception {
         throw new UnsupportedOperationException("Bind not supported.");
     }
 
-    void doMinaDisconnect(boolean blocking) {
+    void doMinaDisconnect(final boolean blocking) {
         if (notClosing(session)) {
             sshChannel.close(blocking);
             session.close(blocking);
@@ -149,13 +149,13 @@ class MinaSshNettyChannel extends AbstractServerChannel {
     }
 
     @Override
-    protected void doWrite(ChannelOutboundBuffer in) throws Exception {
+    protected void doWrite(final ChannelOutboundBuffer in) throws Exception {
         throw new IllegalStateException("Outbound writes to SSH should be done by SSH Write handler");
     }
 
     private final class FireReadMessage implements ReadMsgHandler {
         @Override
-        public void onMessageRead(ByteBuf msg) {
+        public void onMessageRead(final ByteBuf msg) {
             pipeline().fireChannelRead(msg);
         }
     }
@@ -172,9 +172,9 @@ class MinaSshNettyChannel extends AbstractServerChannel {
     }
 
     private class SshUnsafe extends AbstractUnsafe {
-
         @Override
-        public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
+        public void connect(final SocketAddress remoteAddress, final SocketAddress localAddress,
+                final ChannelPromise promise) {
             throw new UnsupportedOperationException("Unsafe is not supported.");
         }
     }
index 723273a763577bd1b7aee25840a106e72ca21586..6b88df398755205c4e82c16ef3e41b2798f3602b 100644 (file)
@@ -13,20 +13,20 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.security.PublicKey;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
-import org.apache.sshd.client.ServerKeyVerifier;
-import org.apache.sshd.client.SessionFactory;
+import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
-import org.apache.sshd.common.KeyExchange;
-import org.apache.sshd.common.Session;
-import org.apache.sshd.common.SessionListener;
+import org.apache.sshd.client.session.SessionFactory;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoServiceFactory;
 import org.apache.sshd.common.io.mina.MinaServiceFactory;
 import org.apache.sshd.common.io.nio2.Nio2ServiceFactory;
+import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionListener;
 import org.opendaylight.netconf.callhome.protocol.CallHomeSessionContext.Factory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,8 +42,8 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
     private final InetSocketAddress bindAddress;
     private final StatusRecorder recorder;
 
-    NetconfCallHomeServer(SshClient sshClient, CallHomeAuthorizationProvider authProvider, Factory factory,
-                          InetSocketAddress socketAddress, StatusRecorder recorder) {
+    NetconfCallHomeServer(final SshClient sshClient, final CallHomeAuthorizationProvider authProvider,
+            final Factory factory, final InetSocketAddress socketAddress, final StatusRecorder recorder) {
         this.client = Preconditions.checkNotNull(sshClient);
         this.authProvider = Preconditions.checkNotNull(authProvider);
         this.sessionFactory = Preconditions.checkNotNull(factory);
@@ -51,32 +51,28 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
         this.recorder = recorder;
 
         sshClient.setServerKeyVerifier(this);
+        sshClient.addSessionListener(createSessionListener());
 
-        SessionFactory clientSessions = new SessionFactory();
-        clientSessions.setClient(sshClient);
-        clientSessions.addListener(createSessionListener());
-
-        IoServiceFactory minaFactory = createServiceFactory(sshClient);
-        this.acceptor = minaFactory.createAcceptor(clientSessions);
+        this.acceptor = createServiceFactory(sshClient).createAcceptor(new SessionFactory(sshClient));
     }
 
-    private IoServiceFactory createServiceFactory(SshClient sshClient) {
+    private IoServiceFactory createServiceFactory(final SshClient sshClient) {
         try {
             return createMinaServiceFactory(sshClient);
         } catch (NoClassDefFoundError e) {
             LOG.warn("Mina is not available, defaulting to NIO.");
-            return new Nio2ServiceFactory(sshClient);
+            return new Nio2ServiceFactory(sshClient, sshClient.getScheduledExecutorService(), false);
         }
     }
 
-    protected IoServiceFactory createMinaServiceFactory(SshClient sshClient) {
-        return new MinaServiceFactory(sshClient);
+    protected IoServiceFactory createMinaServiceFactory(final SshClient sshClient) {
+        return new MinaServiceFactory(sshClient, sshClient.getScheduledExecutorService(), false);
     }
 
     SessionListener createSessionListener() {
         return new SessionListener() {
             @Override
-            public void sessionEvent(Session session, Event event) {
+            public void sessionEvent(final Session session, final Event event) {
                 ClientSession clientSession = (ClientSession) session;
                 LOG.debug("SSH session {} event {}", session, event);
                 switch (event) {
@@ -92,12 +88,12 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
             }
 
             @Override
-            public void sessionCreated(Session session) {
+            public void sessionCreated(final Session session) {
                 LOG.debug("SSH session {} created", session);
             }
 
             @Override
-            public void sessionClosed(Session session) {
+            public void sessionClosed(final Session session) {
                 CallHomeSessionContext ctx = CallHomeSessionContext.getFrom((ClientSession) session);
                 if (ctx != null) {
                     ctx.removeSelf();
@@ -107,7 +103,7 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
         };
     }
 
-    private void doPostAuth(final ClientSession session) {
+    private static void doPostAuth(final ClientSession session) {
         CallHomeSessionContext.getFrom(session).openNetconfChannel();
     }
 
@@ -123,7 +119,7 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
     private SshFutureListener<AuthFuture> newAuthSshFutureListener(final ClientSession session) {
         return new SshFutureListener<AuthFuture>() {
             @Override
-            public void operationComplete(AuthFuture authFuture) {
+            public void operationComplete(final AuthFuture authFuture) {
                 if (authFuture.isSuccess()) {
                     onSuccess();
                 } else if (authFuture.isFailure()) {
@@ -138,7 +134,7 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
                 LOG.debug("Authorize success");
             }
 
-            private void onFailure(Throwable throwable) {
+            private void onFailure(final Throwable throwable) {
                 ClientSessionImpl impl = (ClientSessionImpl) session;
                 LOG.error("Authorize failed for session {}", session, throwable);
 
@@ -157,7 +153,8 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
     }
 
     @Override
-    public boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) {
+    public boolean verifyServerKey(final ClientSession sshClientSession, final SocketAddress remoteAddress,
+            final PublicKey serverKey) {
         final CallHomeAuthorization authorization = authProvider.provideAuth(remoteAddress, serverKey);
         // server is not authorized
         if (!authorization.isServerAllowed()) {
index de8eb106d0237fb778e4af0f8b91eda5f751e3bf..decb75968961db396cecac9736788a64fd4197d2 100644 (file)
@@ -14,7 +14,7 @@ import io.netty.channel.local.LocalEventLoopGroup;
 import io.netty.util.HashedWheelTimer;
 import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
 import org.opendaylight.netconf.callhome.protocol.CallHomeSessionContext.Factory;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
 import org.opendaylight.yangtools.concepts.Builder;
@@ -33,8 +33,8 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
     private final CallHomeNetconfSubsystemListener subsystemListener;
     private final StatusRecorder recorder;
 
-    public NetconfCallHomeServerBuilder(CallHomeAuthorizationProvider authProvider,
-                                        CallHomeNetconfSubsystemListener subsystemListener, StatusRecorder recorder) {
+    public NetconfCallHomeServerBuilder(final CallHomeAuthorizationProvider authProvider,
+            final CallHomeNetconfSubsystemListener subsystemListener, final StatusRecorder recorder) {
         this.authProvider = authProvider;
         this.subsystemListener = subsystemListener;
         this.recorder = recorder;
@@ -51,7 +51,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return sshClient;
     }
 
-    public void setSshClient(SshClient sshClient) {
+    public void setSshClient(final SshClient sshClient) {
         this.sshClient = sshClient;
     }
 
@@ -59,7 +59,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return nettyGroup;
     }
 
-    public void setNettyGroup(EventLoopGroup nettyGroup) {
+    public void setNettyGroup(final EventLoopGroup nettyGroup) {
         this.nettyGroup = nettyGroup;
     }
 
@@ -67,7 +67,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return negotiationFactory;
     }
 
-    public void setNegotiationFactory(NetconfClientSessionNegotiatorFactory negotiationFactory) {
+    public void setNegotiationFactory(final NetconfClientSessionNegotiatorFactory negotiationFactory) {
         this.negotiationFactory = negotiationFactory;
     }
 
@@ -75,7 +75,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return bindAddress;
     }
 
-    public void setBindAddress(InetSocketAddress bindAddress) {
+    public void setBindAddress(final InetSocketAddress bindAddress) {
         this.bindAddress = bindAddress;
     }
 
@@ -107,20 +107,20 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return sshClient != null ? sshClient : defaultSshClient();
     }
 
-    private SshClient defaultSshClient() {
+    private static SshClient defaultSshClient() {
         return SshClient.setUpDefaultClient();
     }
 
-    private NetconfClientSessionNegotiatorFactory defaultNegotiationFactory() {
+    private static NetconfClientSessionNegotiatorFactory defaultNegotiationFactory() {
         return new NetconfClientSessionNegotiatorFactory(new HashedWheelTimer(),
                                                          Optional.absent(), DEFAULT_SESSION_TIMEOUT_MILLIS);
     }
 
-    private EventLoopGroup defaultNettyGroup() {
+    private static EventLoopGroup defaultNettyGroup() {
         return new LocalEventLoopGroup();
     }
 
-    private InetSocketAddress defaultBindAddress() {
+    private static InetSocketAddress defaultBindAddress() {
         return new InetSocketAddress(DEFAULT_CALL_HOME_PORT);
     }
 }
index aa742581ec17af8d1a369bbd3b46a044cd7e1809..1e3a3dcac83ef64da7590d964bbe3ff253f58b74 100644 (file)
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.verify;
 import java.security.KeyPair;
 import java.security.PrivateKey;
 import java.security.PublicKey;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
 import org.junit.Test;
 
index 032679e94d5789d3cd4f2712843b080daa80c09c..d989ca1b09d4e4bee144defdc0b763cd72999660 100644 (file)
@@ -24,20 +24,20 @@ import io.netty.channel.EventLoopGroup;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.security.PublicKey;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientChannel.Streaming;
-import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.channel.ChannelSubsystem;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.channel.ClientChannel.Streaming;
 import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
-import org.apache.sshd.common.KeyExchange;
-import org.apache.sshd.common.Session.AttributeKey;
+import org.apache.sshd.common.AttributeStore.AttributeKey;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoReadFuture;
 import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.util.buffer.Buffer;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -121,12 +121,12 @@ public class CallHomeSessionContextTest {
     public void creatingAChannelSuccessfullyShouldResultInAnAttachedListener() throws IOException {
         // given
         OpenFuture mockFuture = mock(OpenFuture.class);
-        ChannelSubsystem mockChannel = mock(ChannelSubsystem.class);
-        Mockito.doReturn(mockFuture).when(mockChannel).open();
-        Mockito.doReturn(mockChannel).when(mockSession).createSubsystemChannel(anyString());
+        ChannelSubsystem mockChannelSubsystem = mock(ChannelSubsystem.class);
+        Mockito.doReturn(mockFuture).when(mockChannelSubsystem).open();
+        Mockito.doReturn(mockChannelSubsystem).when(mockSession).createSubsystemChannel(anyString());
 
         Mockito.doReturn(null).when(mockFuture).addListener(any(SshFutureListener.class));
-        doNothing().when(mockChannel).setStreaming(any(Streaming.class));
+        doNothing().when(mockChannelSubsystem).setStreaming(any(Streaming.class));
         instance = realFactory.createIfNotExists(mockSession, mockAuth, address);
         // when
         instance.openNetconfChannel();
@@ -137,15 +137,15 @@ public class CallHomeSessionContextTest {
     static class TestableContext extends CallHomeSessionContext {
         MinaSshNettyChannel minaMock;
 
-        TestableContext(ClientSession sshSession, CallHomeAuthorization authorization,
-                        InetSocketAddress address, CallHomeSessionContext.Factory factory,
-                        MinaSshNettyChannel minaMock) {
+        TestableContext(final ClientSession sshSession, final CallHomeAuthorization authorization,
+                        final InetSocketAddress address, final CallHomeSessionContext.Factory factory,
+                        final MinaSshNettyChannel minaMock) {
             super(sshSession, authorization, address, factory);
             this.minaMock = minaMock;
         }
 
         @Override
-        protected MinaSshNettyChannel newMinaSshNettyChannel(ClientChannel netconfChannel) {
+        protected MinaSshNettyChannel newMinaSshNettyChannel(final ClientChannel netconfChannel) {
             return minaMock;
         }
     }
index c846f1feeaab348730fecaa13ca235bf80fa644e..5832780f4bd4593aecc63234ba4930b306e18492 100644 (file)
@@ -21,13 +21,13 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelOutboundHandlerAdapter;
 import io.netty.channel.ChannelPromise;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoReadFuture;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.util.buffer.Buffer;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
index d96f17a1f4f44b0b06c38e81e398383248496ac2..373a79f7dea47753a69638a472b5433d1eed230d 100644 (file)
@@ -20,16 +20,16 @@ import java.net.SocketAddress;
 import java.security.PublicKey;
 import java.util.HashMap;
 import java.util.Map;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
-import org.apache.sshd.common.Session;
-import org.apache.sshd.common.SessionListener;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoHandler;
 import org.apache.sshd.common.io.IoServiceFactory;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionListener;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -105,7 +105,6 @@ public class NetconfCallHomeServerTest {
         Mockito.doReturn("testAddr").when(mockSocketAddr).toString();
         PublicKey mockPublicKey = mock(PublicKey.class);
 
-        CallHomeAuthorization mockAuth = mock(CallHomeAuthorization.class);
         Mockito.doReturn("test").when(mockAuth).toString();
         Mockito.doReturn(true).when(mockAuth).isServerAllowed();
         Mockito.doReturn("some-session-name").when(mockAuth).getSessionName();
@@ -137,22 +136,22 @@ public class NetconfCallHomeServerTest {
     static class TestableCallHomeServer extends NetconfCallHomeServer {
         static IoServiceFactory minaServiceFactory;
 
-        static SshClient factoryHook(SshClient client, IoServiceFactory minaFactory) {
+        static SshClient factoryHook(final SshClient client, final IoServiceFactory minaFactory) {
             minaServiceFactory = minaFactory;
             return client;
         }
 
         SshClient client;
 
-        TestableCallHomeServer(SshClient sshClient, CallHomeAuthorizationProvider authProvider,
-                               CallHomeSessionContext.Factory factory, InetSocketAddress socketAddress,
-                               IoServiceFactory minaFactory, StatusRecorder recorder) {
+        TestableCallHomeServer(final SshClient sshClient, final CallHomeAuthorizationProvider authProvider,
+                               final CallHomeSessionContext.Factory factory, final InetSocketAddress socketAddress,
+                               final IoServiceFactory minaFactory, final StatusRecorder recorder) {
             super(factoryHook(sshClient, minaFactory), authProvider, factory, socketAddress, recorder);
             client = sshClient;
         }
 
         @Override
-        protected IoServiceFactory createMinaServiceFactory(SshClient sshClient) {
+        protected IoServiceFactory createMinaServiceFactory(final SshClient sshClient) {
             return minaServiceFactory;
         }
     }
index 9e91562cf570f5454a01f23e0fa796ad280903c7..29632c247f1f4caf420b94009db530aab6b7d864 100644 (file)
@@ -12,10 +12,8 @@ import com.google.common.net.InetAddresses;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
+import java.security.GeneralSecurityException;
 import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
 import java.util.Collection;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -64,7 +62,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
 
     private final CallhomeStatusReporter statusReporter;
 
-    CallHomeAuthProviderImpl(DataBroker broker) {
+    CallHomeAuthProviderImpl(final DataBroker broker) {
         configReg = broker.registerDataTreeChangeListener(GLOBAL, globalConfig);
         deviceReg = broker.registerDataTreeChangeListener(ALLOWED_DEVICES, deviceConfig);
         deviceOpReg = broker.registerDataTreeChangeListener(ALLOWED_OP_DEVICES, deviceOp);
@@ -73,7 +71,8 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
 
     @Nonnull
     @Override
-    public CallHomeAuthorization provideAuth(@Nonnull SocketAddress remoteAddress, @Nonnull PublicKey serverKey) {
+    public CallHomeAuthorization provideAuth(@Nonnull final SocketAddress remoteAddress,
+            @Nonnull final PublicKey serverKey) {
         Device deviceSpecific = deviceConfig.get(serverKey);
         String sessionName;
         Credentials deviceCred;
@@ -119,7 +118,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         deviceOpReg.close();
     }
 
-    private String fromRemoteAddress(SocketAddress remoteAddress) {
+    private static String fromRemoteAddress(final SocketAddress remoteAddress) {
         if (remoteAddress instanceof InetSocketAddress) {
             InetSocketAddress socketAddress = (InetSocketAddress) remoteAddress;
             return InetAddresses.toAddrString(socketAddress.getAddress()) + ":" + socketAddress.getPort();
@@ -134,14 +133,14 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         private final ConcurrentMap<PublicKey, Device> byPublicKey = new ConcurrentHashMap<>();
 
         @Override
-        public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Device>> mods) {
+        public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<Device>> mods) {
             for (DataTreeModification<Device> dataTreeModification : mods) {
                 DataObjectModification<Device> rootNode = dataTreeModification.getRootNode();
                 process(rootNode);
             }
         }
 
-        private void process(DataObjectModification<Device> deviceMod) {
+        private void process(final DataObjectModification<Device> deviceMod) {
             Device before = deviceMod.getDataBefore();
             Device after = deviceMod.getDataAfter();
 
@@ -159,7 +158,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
             }
         }
 
-        private void putDevice(Device device) {
+        private void putDevice(final Device device) {
             PublicKey key = publicKey(device);
             if (key == null) {
                 return;
@@ -167,7 +166,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
             byPublicKey.put(key, device);
         }
 
-        private void removeDevice(Device device) {
+        private void removeDevice(final Device device) {
             PublicKey key = publicKey(device);
             if (key == null) {
                 return;
@@ -175,17 +174,17 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
             byPublicKey.remove(key);
         }
 
-        private PublicKey publicKey(Device device) {
+        private PublicKey publicKey(final Device device) {
             String hostKey = device.getSshHostKey();
             try {
                 return keyDecoder.decodePublicKey(hostKey);
-            } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) {
+            } catch (GeneralSecurityException e) {
                 LOG.error("Unable to decode SSH key for {}. Ignoring update for this device", device.getUniqueId(), e);
                 return null;
             }
         }
 
-        private Device get(PublicKey key) {
+        private Device get(final PublicKey key) {
             return byPublicKey.get(key);
         }
     }
@@ -195,14 +194,14 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         private final ConcurrentMap<String, Device> byPublicKey = new ConcurrentHashMap<>();
 
         @Override
-        public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Device>> mods) {
+        public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<Device>> mods) {
             for (DataTreeModification<Device> dataTreeModification : mods) {
                 DataObjectModification<Device> rootNode = dataTreeModification.getRootNode();
                 process(rootNode);
             }
         }
 
-        private void process(DataObjectModification<Device> deviceMod) {
+        private void process(final DataObjectModification<Device> deviceMod) {
             Device before = deviceMod.getDataBefore();
             Device after = deviceMod.getDataAfter();
 
@@ -220,17 +219,17 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
             }
         }
 
-        private void putDevice(Device device) {
+        private void putDevice(final Device device) {
             String key = device.getSshHostKey();
             byPublicKey.put(key, device);
         }
 
-        private void removeDevice(Device device) {
+        private void removeDevice(final Device device) {
             String key = device.getSshHostKey();
             byPublicKey.remove(key);
         }
 
-        Device get(PublicKey serverKey) {
+        Device get(final PublicKey serverKey) {
             String skey = "";
 
             try {
@@ -248,7 +247,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         private volatile Global current = null;
 
         @Override
-        public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Global>> mods) {
+        public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<Global>> mods) {
             for (DataTreeModification<Global> dataTreeModification : mods) {
                 current = dataTreeModification.getRootNode().getDataAfter();
             }
index 6f547f885cf8d5485852f1e1ba8ab50621d82a7f..226fd27d78ae5728e34acdeacd09b8c243c94f2b 100644 (file)
@@ -11,10 +11,8 @@ package org.opendaylight.netconf.callhome.mount;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
+import java.security.GeneralSecurityException;
 import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -63,14 +61,14 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
     private final DataBroker dataBroker;
     private final ListenerRegistration<CallhomeStatusReporter> reg;
 
-    CallhomeStatusReporter(DataBroker broker) {
+    CallhomeStatusReporter(final DataBroker broker) {
         this.dataBroker = broker;
         this.reg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
             NETCONF_TOPO_IID.child(Node.class)), this);
     }
 
     @Override
-    public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) {
+    public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<Node>> changes) {
         for (DataTreeModification<Node> change: changes) {
             final DataObjectModification<Node> rootNode = change.getRootNode();
             final InstanceIdentifier<Node> identifier = change.getRootPath().getRootIdentifier();
@@ -99,16 +97,16 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    private boolean isNetconfNode(Node node) {
+    private static boolean isNetconfNode(final Node node) {
         return node.getAugmentation(NetconfNode.class) != null;
     }
 
-    private NodeId getNodeId(final InstanceIdentifier<?> path) {
+    private static NodeId getNodeId(final InstanceIdentifier<?> path) {
         NodeKey key = path.firstKeyOf(Node.class);
         return key != null ? key.getNodeId() : null;
     }
 
-    private void handledNetconfNode(NodeId nodeId, NetconfNode nnode) {
+    private void handledNetconfNode(final NodeId nodeId, final NetconfNode nnode) {
         NetconfNodeConnectionStatus.ConnectionStatus csts = nnode.getConnectionStatus();
 
         switch (csts) {
@@ -124,7 +122,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    private void handleConnectedNetconfNode(NodeId nodeId) {
+    private void handleConnectedNetconfNode(final NodeId nodeId) {
         // Fully connected, all services for remote device are
         // available from the MountPointService.
         LOG.debug("NETCONF Node: {} is fully connected", nodeId.getValue());
@@ -142,7 +140,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    private void handleDisconnectedNetconfNode(NodeId nodeId) {
+    private void handleDisconnectedNetconfNode(final NodeId nodeId) {
         LOG.debug("NETCONF Node: {} disconnected", nodeId.getValue());
 
         Device opDev = readAndGetDevice(nodeId);
@@ -158,7 +156,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    private void handleUnableToConnectNetconfNode(NodeId nodeId) {
+    private void handleUnableToConnectNetconfNode(final NodeId nodeId) {
         // The maximum configured number of reconnect attempts
         // have been reached. No more reconnects will be
         // attempted by the Netconf Connector.
@@ -177,19 +175,19 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    void asForceListedDevice(String id, PublicKey serverKey) {
+    void asForceListedDevice(final String id, final PublicKey serverKey) {
         NodeId nid = new NodeId(id);
         Device device = newDevice(id, serverKey, Device1.DeviceStatus.DISCONNECTED);
         writeDevice(nid, device);
     }
 
-    void asUnlistedDevice(String id, PublicKey serverKey) {
+    void asUnlistedDevice(final String id, final PublicKey serverKey) {
         NodeId nid = new NodeId(id);
         Device device = newDevice(id, serverKey, Device1.DeviceStatus.FAILEDNOTALLOWED);
         writeDevice(nid, device);
     }
 
-    private Device newDevice(String id, PublicKey serverKey, Device1.DeviceStatus status) {
+    private static Device newDevice(final String id, final PublicKey serverKey, final Device1.DeviceStatus status) {
         String sshEncodedKey = serverKey.toString();
         try {
             sshEncodedKey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
@@ -206,12 +204,12 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         return builder.build();
     }
 
-    private Device readAndGetDevice(NodeId nodeId) {
+    private Device readAndGetDevice(final NodeId nodeId) {
         return readDevice(nodeId).orNull();
     }
 
     @Nonnull
-    private Optional<Device> readDevice(NodeId nodeId) {
+    private Optional<Device> readDevice(final NodeId nodeId) {
         ReadOnlyTransaction opTx = dataBroker.newReadOnlyTransaction();
 
         InstanceIdentifier<Device> deviceIID = buildDeviceInstanceIdentifier(nodeId);
@@ -223,43 +221,43 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         }
     }
 
-    private void writeDevice(NodeId nodeId, Device modifiedDevice) {
+    private void writeDevice(final NodeId nodeId, final Device modifiedDevice) {
         ReadWriteTransaction opTx = dataBroker.newReadWriteTransaction();
         opTx.merge(LogicalDatastoreType.OPERATIONAL, buildDeviceInstanceIdentifier(nodeId), modifiedDevice);
         opTx.submit();
     }
 
-    private InstanceIdentifier<Device> buildDeviceInstanceIdentifier(NodeId nodeId) {
+    private static InstanceIdentifier<Device> buildDeviceInstanceIdentifier(final NodeId nodeId) {
         return InstanceIdentifier.create(NetconfCallhomeServer.class)
                 .child(AllowedDevices.class)
                 .child(Device.class, new DeviceKey(nodeId.getValue()));
     }
 
-    private Device withConnectedStatus(Device opDev) {
+    private static Device withConnectedStatus(final Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.CONNECTED).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
                 .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
-    private Device withFailedStatus(Device opDev) {
+    private static Device withFailedStatus(final Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILED).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
                 .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
-    private Device withDisconnectedStatus(Device opDev) {
+    private static Device withDisconnectedStatus(final Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
                 .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
-    private Device withFailedAuthStatus(Device opDev) {
+    private static Device withFailedAuthStatus(final Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDAUTHFAILURE).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
                 .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
-    private void setDeviceStatus(Device device) {
+    private void setDeviceStatus(final Device device) {
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         InstanceIdentifier<Device> deviceIId =
                 InstanceIdentifier.create(NetconfCallhomeServer.class)
@@ -288,7 +286,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
     }
 
     @Override
-    public void reportFailedAuth(PublicKey sshKey) {
+    public void reportFailedAuth(final PublicKey sshKey) {
         AuthorizedKeysDecoder decoder = new AuthorizedKeysDecoder();
 
         for (Device device : getDevicesAsList()) {
@@ -305,7 +303,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
                     setDeviceStatus(failedDevice);
                     return;
                 }
-            } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) {
+            } catch (GeneralSecurityException e) {
                 LOG.error("Failed decoding a device key with host key: {} {}", keyString, e);
                 return;
             }
index cb83bc9deb131e7114a518148e148477509d5300..713b7ec4a5837c7dcf1f038f3cf78bc0a41eb90e 100644 (file)
@@ -16,17 +16,17 @@ import java.util.Properties;
 
 public class Configuration {
     public abstract static class ConfigurationException extends RuntimeException {
-        ConfigurationException(String msg) {
+        ConfigurationException(final String msg) {
             super(msg);
         }
 
-        ConfigurationException(String msg, Exception cause) {
+        ConfigurationException(final String msg, final Exception cause) {
             super(msg, cause);
         }
     }
 
     public static class ReadException extends ConfigurationException {
-        ReadException(String msg, Exception exc) {
+        ReadException(final String msg, final Exception exc) {
             super(msg, exc);
         }
     }
@@ -34,7 +34,7 @@ public class Configuration {
     public static class MissingException extends ConfigurationException {
         private final String key;
 
-        MissingException(String key) {
+        MissingException(final String key) {
             super("Key not found: " + key);
             this.key = key;
         }
@@ -48,12 +48,18 @@ public class Configuration {
         private final String key;
         private final String value;
 
-        IllegalValueException(String key, String value) {
+        IllegalValueException(final String key, final String value) {
             super("Key has an illegal value. Key: " + key + ", Value: " + value);
             this.key = key;
             this.value = value;
         }
 
+        IllegalValueException(final String key, final String value, final Exception cause) {
+            super("Key has an illegal value. Key: " + key + ", Value: " + value, cause);
+            this.key = key;
+            this.value = value;
+        }
+
         public String getKey() {
             return key;
         }
@@ -71,7 +77,7 @@ public class Configuration {
         properties = new Properties();
     }
 
-    public Configuration(String path) throws ConfigurationException {
+    public Configuration(final String path) throws ConfigurationException {
         this.path = path;
         try {
             this.properties = readFromPath(path);
@@ -80,27 +86,27 @@ public class Configuration {
         }
     }
 
-    private Properties readFromPath(String path) throws IOException {
-        return readFromFile(new File(path));
+    private Properties readFromPath(final String filePath) throws IOException {
+        return readFromFile(new File(filePath));
     }
 
-    private Properties readFromFile(File file) throws IOException {
+    private Properties readFromFile(final File file) throws IOException {
         FileInputStream stream = new FileInputStream(file);
         properties = readFrom(stream);
         return properties;
     }
 
-    private Properties readFrom(InputStream stream) throws IOException {
+    private static Properties readFrom(final InputStream stream) throws IOException {
         Properties properties = new Properties();
         properties.load(stream);
         return properties;
     }
 
-    public void set(String key, String value) {
+    public void set(final String key, final String value) {
         properties.setProperty(key, value);
     }
 
-    String get(String key) {
+    String get(final String key) {
         String result = (String) properties.get(key);
         if (result == null) {
             throw new MissingException(key);
@@ -108,7 +114,7 @@ public class Configuration {
         return result;
     }
 
-    public int getAsPort(String key) {
+    public int getAsPort(final String key) {
         String keyValue = get(key);
         try {
             int newPort = Integer.parseInt(keyValue);
@@ -117,7 +123,7 @@ public class Configuration {
             }
             return newPort;
         } catch (NumberFormatException e) {
-            throw new IllegalValueException(key, keyValue);
+            throw new IllegalValueException(key, keyValue, e);
         }
     }
 }
index e8b96e671b47b724bd05d35ab061db9e476fb6b5..987fcc03646c64f3806674a533986c8cf96d8db6 100644 (file)
@@ -62,7 +62,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
     private int port = 0; // 0 = use default in NetconfCallHomeBuilder
     private final CallhomeStatusReporter statusReporter;
 
-    public IetfZeroTouchCallHomeServerProvider(DataBroker dataBroker, CallHomeMountDispatcher mountDispacher) {
+    public IetfZeroTouchCallHomeServerProvider(final DataBroker dataBroker,
+            final CallHomeMountDispatcher mountDispacher) {
         this.dataBroker = dataBroker;
         this.mountDispacher = mountDispacher;
         this.authProvider = new CallHomeAuthProviderImpl(dataBroker);
@@ -82,7 +83,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
         }
     }
 
-    public void setPort(String portStr) {
+    public void setPort(final String portStr) {
         try {
             Configuration configuration = new Configuration();
             configuration.set(CALL_HOME_PORT_KEY, portStr);
@@ -112,7 +113,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
     }
 
     @VisibleForTesting
-    void assertValid(Object obj, String description) {
+    void assertValid(final Object obj, final String description) {
         if (obj == null) {
             throw new RuntimeException(
                     String.format("Failed to find %s in IetfZeroTouchCallHomeProvider.initialize()", description));
@@ -136,7 +137,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
     }
 
     @Override
-    public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<AllowedDevices>> changes) {
+    public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<AllowedDevices>> changes) {
         // In case of any changes to the devices datatree, register the changed values with callhome server
         // As of now, no way to add a new callhome client key to the CallHomeAuthorization instance since
         // its created under CallHomeAuthorizationProvider.
@@ -169,7 +170,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
         }
     }
 
-    private void handleDeletedDevices(Set<InstanceIdentifier<?>> deletedDevices) {
+    private void handleDeletedDevices(final Set<InstanceIdentifier<?>> deletedDevices) {
         if (deletedDevices.isEmpty()) {
             return;
         }
@@ -188,8 +189,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
         }
     }
 
-    private List<Device> getReadDevices(
-            ListenableFuture<Optional<AllowedDevices>> devicesFuture) throws InterruptedException, ExecutionException {
+    private static List<Device> getReadDevices(final ListenableFuture<Optional<AllowedDevices>> devicesFuture)
+            throws InterruptedException, ExecutionException {
         Optional<AllowedDevices> opt = devicesFuture.get();
         return opt.isPresent() ? opt.get().getDevice() : Collections.emptyList();
     }
index b633bd568f17b693367e4e367e0a63ac71c79491..ed9e8d12fdb913c810cbc2488145a9b26b350f81 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -48,7 +48,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index fe7977172481ec0b0c92ca340fea83b84e3e3733..923141f8a617665c73b89dcefdea86eb3f8b6851 100644 (file)
@@ -33,19 +33,14 @@ 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.Maps;
 import com.google.common.collect.Sets;
 import io.netty.channel.Channel;
 import java.io.IOException;
-import java.io.InputStream;
 import java.math.BigInteger;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -117,9 +112,7 @@ 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.api.SchemaContextProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceListener;
@@ -260,12 +253,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
         final BindingRuntimeContext ret = super.getBindingRuntimeContext();
         doReturn(TestIdentity1.class).when(ret).getIdentityClass(TestIdentity1.QNAME);
         doReturn(TestIdentity2.class).when(ret).getIdentityClass(TestIdentity2.QNAME);
-        final List<InputStream> streams = getYangs();
-        try {
-            doReturn(YangParserTestUtils.parseYangStreams(streams)).when(ret).getSchemaContext();
-        } catch (final ReactorException e) {
-            throw new RuntimeException("Unable to build schema context from " + streams, e);
-        }
+        doReturn(getSchemaContext()).when(ret).getSchemaContext();
         return ret;
     }
 
@@ -754,22 +742,16 @@ public class NetconfMappingTest extends AbstractConfigTest {
         }
     }
 
-    private Map<String, Map<String, ModuleMXBeanEntry>> getMbes() throws Exception {
-        final List<InputStream> yangDependencies = getYangs();
-
-        final Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries = Maps.newHashMap();
+    private static Map<String, Map<String, ModuleMXBeanEntry>> getMbes() {
 
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangStreams(yangDependencies);
-        final YangStoreService yangStoreService = new YangStoreService(new SchemaContextProvider() {
-            @Override
-            public SchemaContext getSchemaContext() {
-                return schemaContext;
-            }
-        }, mock(SchemaSourceProvider.class));
+        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;
@@ -785,9 +767,8 @@ public class NetconfMappingTest extends AbstractConfigTest {
         return enumBiMap;
     }
 
-    private Set<org.opendaylight.yangtools.yang.model.api.Module> getModules() throws Exception {
-        final SchemaContext resolveSchemaContext = YangParserTestUtils.parseYangStreams(getYangs());
-        return resolveSchemaContext.getModules();
+    private static Set<org.opendaylight.yangtools.yang.model.api.Module> getModules() {
+        return getSchemaContext().getModules();
     }
 
     @Test
@@ -865,19 +846,12 @@ public class NetconfMappingTest extends AbstractConfigTest {
         return response;
     }
 
-    private List<InputStream> getYangs() {
-        final List<String> paths = Arrays.asList("/META-INF/yang/config@2013-04-05.yang",
-                "/META-INF/yang/rpc-context@2013-06-17.yang",
-                "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang",
-                "/META-INF/yang/test-types.yang", "/META-INF/yang/test-groups.yang",
-                "/META-INF/yang/ietf-inet-types@2013-07-15.yang");
-        final Collection<InputStream> yangDependencies = new ArrayList<>();
-        for (final String path : paths) {
-            final InputStream is = Preconditions
-                    .checkNotNull(getClass().getResourceAsStream(path), path + " not found");
-            yangDependencies.add(is);
-        }
-        return Lists.newArrayList(yangDependencies);
+    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,
index f3711eed4cfd6483e56c48998511061b39509a29..cbb002e0ab15a09ebcd9548e2c0e3c1bba0ffd30 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 273709db1c61a33ec9cd1d4ebda65b7c9033aad8..d957097ae8fe68b45d4430c39ad0905600701a76 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.mdsal.connector;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.CharStreams;
 import java.io.IOException;
@@ -16,7 +15,9 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 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;
@@ -25,11 +26,9 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
@@ -118,16 +117,14 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
             final Module module, final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency) {
 
         final SourceIdentifier moduleSourceIdentifier = RevisionSourceIdentifier.create(module.getName(),
-                SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.absent() :
-                        Optional.of(module.getQNameModule().getFormattedRevision()));
+                module.getRevision());
 
         InputStream sourceStream = null;
         String source;
         try {
-            sourceStream = rootSchemaSourceProviderDependency.getSource(moduleSourceIdentifier).checkedGet()
-                    .openStream();
+            sourceStream = rootSchemaSourceProviderDependency.getSource(moduleSourceIdentifier).get().openStream();
             source = CharStreams.toString(new InputStreamReader(sourceStream, StandardCharsets.UTF_8));
-        } catch (IOException | SchemaSourceException e) {
+        } catch (ExecutionException | InterruptedException | IOException e) {
             LOG.warn("Ignoring source for module {}. Unable to read content", moduleSourceIdentifier, e);
             source = null;
         }
@@ -146,7 +143,7 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
 
         LOG.warn("Missing source for module {}. This module will not be available from netconf server",
             moduleSourceIdentifier);
-        return Optional.absent();
+        return Optional.empty();
     }
 
     @Override
index 8e5119a886f56594417d3c09939db6317823911d..78680e00ba24ef08f5a69a26127c64203b9dfd53 100644 (file)
@@ -83,7 +83,7 @@ public class TransactionProvider implements AutoCloseable {
             LOG.debug("Transaction {} failed on", candidateTransaction, e);
             final String cause = e.getCause() != null ? (" Cause: " + e.getCause().getMessage()) : "";
             throw new DocumentedException(
-                    "Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting + cause,
+                    "Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting + cause, e,
                     ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         } finally {
             allOpenReadWriteTransactions.remove(candidateTransaction);
index 7c86dd26b44b8307ca4e0f08a1619139f4af1359..cfb59b871f0df643b9c8febb89bb4591ca8b8aa5 100644 (file)
@@ -15,9 +15,11 @@ import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
@@ -27,7 +29,6 @@ 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.NetconfDocumentedException;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
@@ -129,14 +130,14 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
             case CREATE:
                 try {
                     final Optional<NormalizedNode<?, ?>> readResult =
-                            rwtx.read(LogicalDatastoreType.CONFIGURATION, path).checkedGet();
+                            rwtx.read(LogicalDatastoreType.CONFIGURATION, path).get();
                     if (readResult.isPresent()) {
                         throw new DocumentedException("Data already exists, cannot execute CREATE operation",
                             ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, ErrorSeverity.ERROR);
                     }
                     mergeParentMixin(rwtx, path, changeData);
                     rwtx.put(LogicalDatastoreType.CONFIGURATION, path, changeData);
-                } catch (final ReadFailedException e) {
+                } catch (final InterruptedException | ExecutionException e) {
                     LOG.warn("Read from datastore failed when trying to read data for create operation", change, e);
                 }
                 break;
@@ -147,13 +148,13 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
             case DELETE:
                 try {
                     final Optional<NormalizedNode<?, ?>> readResult =
-                            rwtx.read(LogicalDatastoreType.CONFIGURATION, path).checkedGet();
+                            rwtx.read(LogicalDatastoreType.CONFIGURATION, path).get();
                     if (!readResult.isPresent()) {
                         throw new DocumentedException("Data is missing, cannot execute DELETE operation",
                             ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, ErrorSeverity.ERROR);
                     }
                     rwtx.delete(LogicalDatastoreType.CONFIGURATION, path);
-                } catch (final ReadFailedException e) {
+                } catch (final InterruptedException | ExecutionException e) {
                     LOG.warn("Read from datastore failed when trying to read data for delete operation", change, e);
                 }
                 break;
@@ -166,7 +167,7 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
     }
 
     private void mergeParentMixin(final DOMDataReadWriteTransaction rwtx, final YangInstanceIdentifier path,
-                                final NormalizedNode change) {
+                                final NormalizedNode<?, ?> change) {
         final YangInstanceIdentifier parentNodeYid = path.getParent();
         if (change instanceof MapEntryNode) {
             final SchemaNode schemaNode = SchemaContextUtil.findNodeInSchemaContext(
@@ -232,33 +233,36 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
 
     private Optional<DataSchemaNode> getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
             throws DocumentedException {
-        Optional<DataSchemaNode> dataSchemaNode = Optional.absent();
+        final Iterator<Module> it;
         try {
             // returns module with newest revision since findModuleByNamespace returns a set of modules and we only
             // need the newest one
-            final Module module =
-                    schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(new URI(namespace), null);
-            if (module == null) {
-                // no module is present with this namespace
-                throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
-                        ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
-            }
-            final DataSchemaNode schemaNode =
-                    module.getDataChildByName(QName.create(module.getQNameModule(), element.getName()));
+            it = schemaContext.getCurrentContext().findModules(new URI(namespace)).iterator();
+        } catch (final URISyntaxException e) {
+            LOG.debug("Unable to create URI for namespace : {}", namespace);
+            return Optional.absent();
+        }
+
+        if (!it.hasNext()) {
+            // no module is present with this namespace
+            throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
+                ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
+        }
+
+        final Module module = it.next();
+        final java.util.Optional<DataSchemaNode> schemaNode =
+                module.findDataChildByName(QName.create(module.getQNameModule(), element.getName()));
+        if (!schemaNode.isPresent()) {
             if (schemaNode != null) {
-                dataSchemaNode = Optional.of(schemaNode);
-            } else {
                 throw new DocumentedException(
-                        "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
-                        ErrorType.APPLICATION,
-                        ErrorTag.UNKNOWN_NAMESPACE,
-                        ErrorSeverity.ERROR);
+                    "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
+                    ErrorType.APPLICATION,
+                    ErrorTag.UNKNOWN_NAMESPACE,
+                    ErrorSeverity.ERROR);
             }
-        } catch (final URISyntaxException e) {
-            LOG.debug("Unable to create URI for namespace : {}", namespace);
         }
 
-        return dataSchemaNode;
+        return Optional.fromJavaUtil(schemaNode);
     }
 
     private static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
index 7a983428df0fa07f91fd090dc1d428af4167de68..d64375a887e8b6edeb8990cc5d34827d550cfef7 100644 (file)
@@ -33,7 +33,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNo
 
 final class EditOperationNormalizedNodeStreamWriter extends ImmutableNormalizedNodeStreamWriter
         implements NormalizedNodeStreamAttributeWriter {
-    private static final QName OPERATION_ATTRIBUTE = QName.create(EditConfigInput.QNAME.getNamespace(), null,
+    private static final QName OPERATION_ATTRIBUTE = QName.create(EditConfigInput.QNAME.getNamespace(),
             XmlNetconfConstants.OPERATION_ATTR_KEY);
 
     private final DataTreeChangeTracker dataTreeChangeTracker;
index 00d9b81e4a729870c9c54efc24500e1df0e6d1a6..6d4ba4305ae99a1799d5e8ed90f768e76f44172a 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.netconf.mdsal.connector.ops;
 
 import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.io.IOException;
 import java.net.URI;
@@ -107,8 +106,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
 
     //this returns module with the newest revision if more then 1 module with same namespace is found
     private Optional<Module> getModule(final URI namespaceURI) {
-        return Optional.fromNullable(
-                schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(namespaceURI, null));
+        return Optional.fromJavaUtil(schemaContext.getCurrentContext().findModule(namespaceURI));
     }
 
     private static Optional<RpcDefinition> getRpcDefinitionFromModule(final Module module, final URI namespaceURI,
@@ -132,7 +130,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
             netconfOperationNamespace = operationElement.getNamespace();
         } catch (final DocumentedException e) {
             LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
-            throw new DocumentedException("Cannot retrieve netconf operation namespace from message",
+            throw new DocumentedException("Cannot retrieve netconf operation namespace from message", e,
                     ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
         }
 
@@ -246,7 +244,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
             nnWriter.flush();
             xmlWriter.flush();
         } catch (XMLStreamException | IOException e) {
-            Throwables.propagate(e);
+            throw new RuntimeException(e);
         }
     }
 
index e04766a1d71c295fca7958d921cb68d64121345e..4fa0baa805aa25d8915c17cb67524422ecb99c96 100644 (file)
@@ -161,7 +161,7 @@ public abstract class AbstractGet extends AbstractSingletonNetconfOperation {
             try {
                 validateInputRpc(xml, operationName);
             } catch (final DocumentedException e) {
-                throw new DocumentedException("Incorrect RPC: " + e.getMessage(), e.getErrorType(), e.getErrorTag(),
+                throw new DocumentedException("Incorrect RPC: " + e.getMessage(), e, e.getErrorType(), e.getErrorTag(),
                         e.getErrorSeverity(), e.getErrorInfo());
             }
 
@@ -169,8 +169,8 @@ public abstract class AbstractGet extends AbstractSingletonNetconfOperation {
             try {
                 sourceDatastore = parseSource(xml);
             } catch (final DocumentedException e) {
-                throw new DocumentedException("Get-config source attribute error: " + e.getMessage(), e.getErrorType(),
-                        e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo());
+                throw new DocumentedException("Get-config source attribute error: " + e.getMessage(), e,
+                        e.getErrorType(), e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo());
             }
 
             return new GetConfigExecution(sourceDatastore);
index c6f5714e1f295403336ab0bac32f402b3d8ed1f5..d104fddb96cdb86f18a76c3c80e901d768655a0b 100644 (file)
@@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceI
 import org.opendaylight.yangtools.yang.data.codec.xml.XmlCodecFactory;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.data.util.codec.TypeAwareCodec;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
@@ -65,16 +65,16 @@ public class FilterContentValidator {
     public YangInstanceIdentifier validate(final XmlElement filterContent) throws DocumentedException {
         try {
             final URI namespace = new URI(filterContent.getNamespace());
-            final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(namespace, null);
+            final Module module = schemaContext.getCurrentContext().findModules(namespace).iterator().next();
             final DataSchemaNode schema = getRootDataSchemaNode(module, namespace, filterContent.getName());
             final FilterTree filterTree = validateNode(
                     filterContent, schema, new FilterTree(schema.getQName(), Type.OTHER, schema));
             return getFilterDataRoot(filterTree, filterContent, YangInstanceIdentifier.builder());
         } catch (final URISyntaxException e) {
-            throw new RuntimeException("Wrong namespace in element + " + filterContent.toString());
+            throw new RuntimeException("Wrong namespace in element + " + filterContent.toString(), e);
         } catch (final ValidationException e) {
             LOG.debug("Filter content isn't valid", e);
-            throw new DocumentedException("Validation failed. Cause: " + e.getMessage(),
+            throw new DocumentedException("Validation failed. Cause: " + e.getMessage(), e,
                     DocumentedException.ErrorType.APPLICATION,
                     DocumentedException.ErrorTag.UNKNOWN_NAMESPACE,
                     DocumentedException.ErrorSeverity.ERROR);
@@ -132,7 +132,7 @@ public class FilterContentValidator {
                 final DataSchemaNode childSchema = path.getLast();
                 validateNode(childElement, childSchema, subtree);
             } catch (URISyntaxException | MissingNameSpaceException e) {
-                throw new RuntimeException("Wrong namespace in element + " + childElement.toString());
+                throw new RuntimeException("Wrong namespace in element + " + childElement.toString(), e);
             }
         }
         return tree;
@@ -249,20 +249,20 @@ public class FilterContentValidator {
         }
 
         FilterTree addChild(final DataSchemaNode data) {
-            final Type type;
-            if (data instanceof ChoiceCaseNode) {
-                type = Type.CHOICE_CASE;
+            final Type childType;
+            if (data instanceof CaseSchemaNode) {
+                childType = Type.CHOICE_CASE;
             } else if (data instanceof ListSchemaNode) {
-                type = Type.LIST;
+                childType = Type.LIST;
             } else {
-                type = Type.OTHER;
+                childType = Type.OTHER;
             }
-            final QName name = data.getQName();
-            FilterTree childTree = children.get(name);
+            final QName childName = data.getQName();
+            FilterTree childTree = children.get(childName);
             if (childTree == null) {
-                childTree = new FilterTree(name, type, data);
+                childTree = new FilterTree(childName, childType, data);
             }
-            children.put(name, childTree);
+            children.put(childName, childTree);
             return childTree;
         }
 
index c23155a2b3e87f7dc568e52c84e8ec386907f7cc..ad35b0dfa55d5498815cfdf59b074a565308769d 100644 (file)
@@ -17,12 +17,8 @@ import static org.mockito.Mockito.doAnswer;
 
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
 import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.List;
 import java.util.concurrent.ExecutorService;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
@@ -133,7 +129,8 @@ public class NetconfMDSalMappingTest {
         XMLUnit.setIgnoreWhitespace(true);
         XMLUnit.setIgnoreAttributeOrder(true);
 
-        this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        this.schemaContext = YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
+            "/META-INF/yang/config@2013-04-05.yang", "/yang/mdsal-netconf-mapping-test.yang");
         schemaContext.getModules();
         final SchemaService schemaService = createSchemaService();
 
@@ -145,7 +142,7 @@ public class NetconfMDSalMappingTest {
         datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
 
         final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures");
+                16, 16, "CommitFutures", NetconfMDSalMappingTest.class);
 
         final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
         this.transactionProvider = new TransactionProvider(cdb, SESSION_ID_FOR_REPORTING);
@@ -154,7 +151,7 @@ public class NetconfMDSalMappingTest {
             final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
             final YangTextSchemaSource yangTextSchemaSource =
                     YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
-            return Futures.immediateCheckedFuture(yangTextSchemaSource);
+            return Futures.immediateFuture(yangTextSchemaSource);
 
         }).when(sourceProvider).getSource(any(SourceIdentifier.class));
 
@@ -556,7 +553,7 @@ public class NetconfMDSalMappingTest {
                         + "  </edit-config>\n"
                         + "</rpc>";
         XmlElement xe = getXmlElement(stringWithoutPrefix);
-        NodeList nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+        NodeList nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
         Assert.assertEquals(1, nodeList.getLength());
 
         String stringWithPrefix =
@@ -569,7 +566,7 @@ public class NetconfMDSalMappingTest {
                         + "</nc:rpc>";
 
         xe = getXmlElement(stringWithPrefix);
-        nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+        nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
         Assert.assertEquals(1, nodeList.getLength());
 
         String stringWithoutTarget =
@@ -582,7 +579,7 @@ public class NetconfMDSalMappingTest {
         xe = getXmlElement(stringWithoutTarget);
 
         try {
-            nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+            nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
             XmlElement.fromDomElement((Element) nodeList.item(0)).getOnlyChildElement();
             Assert.fail("Not specified target, we should fail");
         } catch (DocumentedException documentedException) {
@@ -591,7 +588,7 @@ public class NetconfMDSalMappingTest {
 
     }
 
-    private XmlElement getXmlElement(final String elementAsString) throws Exception {
+    private static XmlElement getXmlElement(final String elementAsString) throws Exception {
         Document document = XmlUtil.readXmlToDocument(elementAsString);
         Element element = document.getDocumentElement();
         return XmlElement.fromDomElement(element);
@@ -824,19 +821,6 @@ public class NetconfMDSalMappingTest {
         return response;
     }
 
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Arrays.asList("/META-INF/yang/config@2013-04-05.yang",
-                "/yang/mdsal-netconf-mapping-test.yang");
-        final List<InputStream> schemas = new ArrayList<>();
-
-        for (final String schemaPath : schemaPaths) {
-            final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-
-        return schemas;
-    }
-
     private SchemaService createSchemaService() {
         return new SchemaService() {
 
index 7df0ff59e05d232e9b2023544e368e01a714e30d..60ac65ab688f0c6a51264b99f79784cc66db5299 100644 (file)
@@ -20,12 +20,9 @@ import com.google.common.base.Preconditions;
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
 import java.net.URI;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.custommonkey.xmlunit.DetailedDiff;
@@ -88,7 +85,7 @@ public class RuntimeRpcTest {
         return doc;
     }
 
-    private final DOMRpcService rpcServiceVoidInvoke = new DOMRpcService() {
+    private static final DOMRpcService RPC_SERVICE_VOID_INVOKER = new DOMRpcService() {
         @Nonnull
         @Override
         public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
@@ -104,7 +101,7 @@ public class RuntimeRpcTest {
         }
     };
 
-    private final DOMRpcService rpcServiceFailedInvocation = new DOMRpcService() {
+    private static final DOMRpcService RPC_SERVICE_FAILED_INVOCATION = new DOMRpcService() {
         @Nonnull
         @Override
         public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
@@ -122,15 +119,14 @@ public class RuntimeRpcTest {
         }
     };
 
-    private final DOMRpcService rpcServiceSuccesfullInvocation = new DOMRpcService() {
+    private final DOMRpcService rpcServiceSuccessfulInvocation = new DOMRpcService() {
         @Nonnull
         @Override
         public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
                 @Nonnull final SchemaPath type, @Nullable final NormalizedNode<?, ?> input) {
             final Collection<DataContainerChild<? extends PathArgument, ?>> children =
                     (Collection<DataContainerChild<? extends PathArgument, ?>>) input.getValue();
-            final Module module = schemaContext.findModuleByNamespaceAndRevision(
-                type.getLastComponent().getNamespace(), null);
+            final Module module = schemaContext.findModule(type.getLastComponent().getNamespace()).orElse(null);
             final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(
                 module, module.getNamespace(), type.getLastComponent().getLocalName());
             final ContainerSchemaNode outputSchemaNode = rpcDefinition.getOutput();
@@ -144,7 +140,7 @@ public class RuntimeRpcTest {
         @Nonnull
         @Override
         public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(
-                @Nonnull final T listener) {
+                @Nonnull final T lsnr) {
             return null;
         }
     };
@@ -186,13 +182,13 @@ public class RuntimeRpcTest {
 
         }).when(sourceProvider).getSource(any(SourceIdentifier.class));
 
-        this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        this.schemaContext = YangParserTestUtils.parseYangResource("/yang/mdsal-netconf-rpc-test.yang");
         this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
     }
 
     @Test
     public void testVoidOutputRpc() throws Exception {
-        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
 
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-void-output.xml");
         final HandlingPriority priority = rpc.canHandle(rpcDocument);
@@ -206,7 +202,7 @@ public class RuntimeRpcTest {
     @Test
     public void testSuccesfullNonVoidInvocation() throws Exception {
         final RuntimeRpc rpc = new RuntimeRpc(
-            SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccesfullInvocation);
+            SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccessfulInvocation);
 
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-nonvoid.xml");
         final HandlingPriority priority = rpc.canHandle(rpcDocument);
@@ -219,7 +215,7 @@ public class RuntimeRpcTest {
     @Test
     public void testSuccesfullContainerInvocation() throws Exception {
         final RuntimeRpc rpc = new RuntimeRpc(
-            SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccesfullInvocation);
+            SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccessfulInvocation);
 
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-container.xml");
         final HandlingPriority priority = rpc.canHandle(rpcDocument);
@@ -232,7 +228,7 @@ public class RuntimeRpcTest {
     @Test
     public void testFailedInvocation() throws Exception {
         final RuntimeRpc rpc = new RuntimeRpc(
-            SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceFailedInvocation);
+            SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_FAILED_INVOCATION);
 
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-nonvoid.xml");
         final HandlingPriority priority = rpc.canHandle(rpcDocument);
@@ -250,7 +246,7 @@ public class RuntimeRpcTest {
 
     @Test
     public void testVoidInputOutputRpc() throws Exception {
-        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
 
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-void-input-output.xml");
         final HandlingPriority priority = rpc.canHandle(rpcDocument);
@@ -263,7 +259,7 @@ public class RuntimeRpcTest {
 
     @Test
     public void testBadNamespaceInRpc() throws Exception {
-        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+        final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
         final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-bad-namespace.xml");
 
         try {
@@ -294,16 +290,4 @@ public class RuntimeRpcTest {
 
         return null;
     }
-
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Collections.singletonList("/yang/mdsal-netconf-rpc-test.yang");
-        final List<InputStream> schemas = new ArrayList<>();
-
-        for (final String schemaPath : schemaPaths) {
-            final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-
-        return schemas;
-    }
-}
\ No newline at end of file
+}
index 466c7dbc025176f7b341546cf8dfe81948bc5a3c..d90e31b071a524588099e184ae205c613797b8a9 100644 (file)
@@ -11,12 +11,9 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
-import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import org.junit.Test;
 import org.opendaylight.controller.config.util.xml.XmlElement;
@@ -35,11 +32,9 @@ public class Bug8084 {
 
     @Test
     public void testValidateTypes() throws Exception {
-        final List<InputStream> sources = new ArrayList<>();
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-mod-0.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-augment.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/mdsal-netconf-mapping-test.yang"));
-        final SchemaContext context = YangParserTestUtils.parseYangStreams(sources);
+        final SchemaContext context = YangParserTestUtils.parseYangResources(Bug8084.class,
+            "/yang/filter-validator-test-mod-0.yang", "/yang/filter-validator-test-augment.yang",
+            "/yang/mdsal-netconf-mapping-test.yang");
         final CurrentSchemaContext currentContext = mock(CurrentSchemaContext.class);
         doReturn(context).when(currentContext).getCurrentContext();
         final FilterContentValidator validator = new FilterContentValidator(currentContext);
index 8ee3e38a33964a06099f40cbc53d50f20fb1c16e..cec6855c4609f2312488f4876aea1be3ce09d82f 100644 (file)
@@ -11,7 +11,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.base.Preconditions;
-import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -73,11 +72,10 @@ public class FilterContentValidatorTest {
 
     @Before
     public void setUp() throws Exception {
-        final List<InputStream> sources = new ArrayList<>();
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-mod-0.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-augment.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/mdsal-netconf-mapping-test.yang"));
-        final SchemaContext context = YangParserTestUtils.parseYangStreams(sources);
+        final SchemaContext context = YangParserTestUtils.parseYangResources(FilterContentValidatorTest.class,
+            "/yang/filter-validator-test-mod-0.yang", "/yang/filter-validator-test-augment.yang",
+            "/yang/mdsal-netconf-mapping-test.yang");
+
         final CurrentSchemaContext currentContext = mock(CurrentSchemaContext.class);
         doReturn(context).when(currentContext).getCurrentContext();
         validator = new FilterContentValidator(currentContext);
@@ -89,8 +87,7 @@ public class FilterContentValidatorTest {
         if (expected.startsWith("success")) {
             final String expId = expected.replace("success=", "");
             final YangInstanceIdentifier actual = validator.validate(filterContent);
-            final YangInstanceIdentifier expected = fromString(expId);
-            Assert.assertEquals(expected, actual);
+            Assert.assertEquals(fromString(expId), actual);
         } else if (expected.startsWith("error")) {
             try {
                 validator.validate(filterContent);
@@ -142,11 +139,10 @@ public class FilterContentValidatorTest {
     }
 
     private static QName createNodeQName(final QName prev, final String input) {
-        final QName qName = QName.create(input);
-        if (qName.getModule().getNamespace() != null) {
-            return qName;
+        try {
+            return QName.create(input);
+        } catch (IllegalArgumentException e) {
+            return QName.create(Preconditions.checkNotNull(prev), input);
         }
-
-        return QName.create(Preconditions.checkNotNull(prev), input);
     }
 }
index 338b7912c2bac70f58206f13e6ff9caffbf3ab89..5720697bbf7e8cea0fcb243a28405f9c3f430144 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 8496ad8886daec4848fa491aacc1cffc4e6e74c1..10ec13a47a0ea4709826052544fda0f9d5f89c94 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -40,7 +40,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index e70a1e242df4961fea6e6de96dc9d0cf51051e91..ada4c1b71746d708383d68c6cc1c88f2f9a8c5f4 100644 (file)
@@ -11,7 +11,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -40,7 +40,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index b462de62b14fbe78217f9454034dacde741713b7..94a7e45a2e5c91e008c400fa4611167a77325dc2 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 3ba60c63187b9dfe1bd3369ba75e7c4dbff33809..902ea00dbae65d421ab5e7c19c66f8649b7d86a5 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 09d86c2ab2add23d4d17786f7bc77dee85a01155..1d2cfe45ab824f79826cc4807043b33227255baa 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -48,7 +48,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index d0d383a2bb0dbfe28f2d59ef3cf94f4dc2aa163b..918e71d13f9aae83c3bf3a72fad293e702c0e2dc 100644 (file)
@@ -115,21 +115,24 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCl
 
         // TODO Conformance type is always set to Implement value, but it should it really be like this?
         // TODO Add also deviations and features lists to module entries
-        moduleBuilder.setName(new YangIdentifier(module.getName()))
-                .setRevision(new OptionalRevision(module.getQNameModule().getFormattedRevision()))
-                .setNamespace(new Uri(module.getNamespace().toString()))
-                .setConformanceType(ConformanceType.Implement)
-                .setSubmodules(createSubmodulesForModule(module));
+        moduleBuilder.setName(new YangIdentifier(module.getName()));
+
+        module.getQNameModule().getRevision().ifPresent(rev -> moduleBuilder.setRevision(
+            new OptionalRevision(rev.toString())));
 
-        return moduleBuilder.build();
+        return moduleBuilder.setNamespace(new Uri(module.getNamespace().toString()))
+                .setConformanceType(ConformanceType.Implement)
+                .setSubmodules(createSubmodulesForModule(module))
+                .build();
     }
 
-    private Submodules createSubmodulesForModule(final Module module) {
+    private static Submodules createSubmodulesForModule(final Module module) {
         final List<Submodule> submodulesList = Lists.newArrayList();
         for (final Module subModule : module.getSubmodules()) {
-            final SubmoduleBuilder subModuleEntryBuilder = new SubmoduleBuilder();
-            subModuleEntryBuilder.setName(new YangIdentifier(subModule.getName()))
-                    .setRevision(new OptionalRevision(subModule.getQNameModule().getFormattedRevision()));
+            final SubmoduleBuilder subModuleEntryBuilder = new SubmoduleBuilder()
+                    .setName(new YangIdentifier(subModule.getName()));
+            subModule.getQNameModule().getRevision().ifPresent(
+                rev -> subModuleEntryBuilder.setRevision(new OptionalRevision(rev.toString())));
             submodulesList.add(subModuleEntryBuilder.build());
         }
 
index 5e6457ac8e2d0b7f406b269a63f9483e0381b2e7..1b8b6dd6a3cce87fd3438f164c1a4e3326b7209f 100644 (file)
@@ -16,8 +16,6 @@ import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
-import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -91,17 +89,13 @@ public class SchemaServiceToMdsalWriterTest {
                 eq(MODULES_STATE_INSTANCE_IDENTIFIER), eq(createTestModuleState()));
     }
 
-    private SchemaContext getSchema() throws Exception {
-        final List<InputStream> modelsToParse = Lists.newArrayList(
-                SchemaServiceToMdsalWriterTest.class.getResourceAsStream("/test-module.yang"),
-                SchemaServiceToMdsalWriterTest.class.getResourceAsStream("/test-submodule.yang")
-        );
-        return YangParserTestUtils.parseYangStreams(modelsToParse);
+    private static SchemaContext getSchema() {
+        return YangParserTestUtils.parseYangResources(SchemaServiceToMdsalWriterTest.class, "/test-module.yang",
+            "/test-submodule.yang");
     }
 
-    private ModulesState createTestModuleState() {
+    private static ModulesState createTestModuleState() {
         Submodule sub = new SubmoduleBuilder().setName(new YangIdentifier("test-submodule"))
-                .setRevision(new OptionalRevision("1970-01-01"))
                 .build();
 
         Module module = new ModuleBuilder().setName(new YangIdentifier("test-module"))
index 46e1291530287cfd8193d3e78a6216419f38eebb..7af2c4eb9eb0f44774ccd71eb5615f2f645918bb 100644 (file)
@@ -14,7 +14,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -43,7 +43,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 69abbad23f0ad4d1ab823fac4a99a43211710f95..26609d21e31196c1291d72e516b6847727ecc28e 100644 (file)
@@ -12,7 +12,6 @@ import static com.google.common.util.concurrent.Futures.immediateFuture;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
@@ -235,7 +234,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         try {
             domPublish.putNotification(new TopicDOMNotification(topicNotification));
         } catch (final InterruptedException e) {
-            throw Throwables.propagate(e);
+            throw new RuntimeException(e);
         }
     }
 
@@ -254,7 +253,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
             return Builders.anyXmlBuilder().withNodeIdentifier(PAYLOAD_ARG).withValue(new DOMSource(element)).build();
         } catch (IOException | XMLStreamException e) {
             LOG.error("Unable to encapsulate notification.", e);
-            throw Throwables.propagate(e);
+            throw new RuntimeException(e);
         }
     }
 
index 9089e92ee1ab999298f58200a88ccf7bb7876a51..649454ef11c866b945e81f70a7d806297c1ee645 100644 (file)
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Helper class to keep connection status of netconf node  and event source registration object.
  */
-public class NetconfEventSourceRegistration implements AutoCloseable {
+public final class NetconfEventSourceRegistration implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfEventSourceRegistration.class);
     private static final YangInstanceIdentifier NETCONF_DEVICE_DOM_PATH = YangInstanceIdentifier.builder()
index d10ce66249f73cedcc961b9516c22b9a69fd2534..d9b3543167572f7376fd8d666d7d38ba3b6a1c45 100644 (file)
@@ -37,8 +37,8 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
     private Date lastEventTime;
     protected final ConcurrentHashMap<SchemaPath, Set<TopicId>> notificationTopicMap = new ConcurrentHashMap<>();
 
-    protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName,
-                                            String notificationUrnPrefix) {
+    protected NotificationTopicRegistration(final NotificationSourceType notificationSourceType,
+            final String sourceName, final String notificationUrnPrefix) {
         this.notificationSourceType = notificationSourceType;
         this.sourceName = sourceName;
         this.notificationUrnPrefix = notificationUrnPrefix;
@@ -50,7 +50,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
         return active;
     }
 
-    protected void setActive(boolean active) {
+    protected void setActive(final boolean active) {
         this.active = active;
     }
 
@@ -72,7 +72,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
      * @param notificationPath path
      * @return topicIds
      */
-    Set<TopicId> getTopicsForNotification(SchemaPath notificationPath) {
+    Set<TopicId> getTopicsForNotification(final SchemaPath notificationPath) {
         final Set<TopicId> topicIds = notificationTopicMap.get(notificationPath);
         return topicIds != null ? topicIds : Sets.newHashSet();
     }
@@ -83,7 +83,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
      * @param notificationPath path
      * @return true, if notification belongs to registration namespace
      */
-    boolean checkNotificationPath(SchemaPath notificationPath) {
+    boolean checkNotificationPath(final SchemaPath notificationPath) {
         if (notificationPath == null) {
             return false;
         }
@@ -97,7 +97,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
         return Optional.fromNullable(lastEventTime);
     }
 
-    void setLastEventTime(Date lastEventTime) {
+    void setLastEventTime(final Date lastEventTime) {
         this.lastEventTime = lastEventTime;
     }
 
@@ -120,7 +120,6 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
      * Registers associated event source notification to topic.
      *
      * @param topicId topic id
-     * @return true, if successful
      */
     abstract void unRegisterNotificationTopic(TopicId topicId);
 
@@ -128,7 +127,7 @@ abstract class NotificationTopicRegistration implements AutoCloseable {
         return replaySupported;
     }
 
-    protected void setReplaySupported(boolean replaySupported) {
+    protected void setReplaySupported(final boolean replaySupported) {
         this.replaySupported = replaySupported;
     }
 
index d64e1a6415f539584f67ac409a5fda2325d0f424..04be595ed238bc6e8eab05ece4684a604090699d 100644 (file)
@@ -135,7 +135,7 @@ public class NetconfEventSourceMountTest {
         final List<String> streamNames = Lists.transform(availableStreams, new Function<Stream, String>() {
             @Nullable
             @Override
-            public String apply(@Nullable Stream input) {
+            public String apply(@Nullable final Stream input) {
                 return input.getName().getValue();
             }
         });
@@ -143,15 +143,15 @@ public class NetconfEventSourceMountTest {
         streamNames.contains(STREAM_2);
     }
 
-    private String getStreamName(ContainerNode value) {
+    private static String getStreamName(final ContainerNode value) {
         YangInstanceIdentifier.NodeIdentifier stream =
                 new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "stream"));
         return (String) value.getChild(stream).get().getValue();
     }
 
-    private Optional<?> getDate(ContainerNode value) {
+    private static Optional<?> getDate(final ContainerNode value) {
         YangInstanceIdentifier.NodeIdentifier startTime =
                 new YangInstanceIdentifier.NodeIdentifier(QName.create(CreateSubscriptionInput.QNAME, "startTime"));
-        return value.getChild(startTime);
+        return Optional.fromJavaUtil(value.getChild(startTime));
     }
 }
\ No newline at end of file
index 56ce4ee61ad9bfc3a29b01cf68928b738d96ee63..7e94e2348663e4663c8373c7cc2f4ac45da5a37c 100644 (file)
@@ -98,6 +98,7 @@ public class NetconfEventSourceTest {
         final Node nodeId1 = NetconfTestUtils.getNetconfNode("NodeId1", "node.test.local", ConnectionStatus
                 .Connected, NetconfTestUtils.NOTIFICATION_CAPABILITY_PREFIX);
         doReturn(nodeId1).when(mount).getNode();
+        doReturn(nodeId1.getNodeId().getValue()).when(mount).getNodeId();
 
         Map<String, String> streamMap = new HashMap<>();
         streamMap.put(NOTIFICATION_1_PATH.getLastComponent().getNamespace().toString(), "stream-1");
@@ -126,8 +127,7 @@ public class NetconfEventSourceTest {
         final TopicDOMNotification value = (TopicDOMNotification) captor.getValue();
         final QName qname = TopicNotification.QNAME;
         final YangInstanceIdentifier.NodeIdentifier topicIdNode =
-                new YangInstanceIdentifier.NodeIdentifier(QName.create(qname.getNamespace().toString(), qname
-                        .getFormattedRevision(), "topic-id"));
+                new YangInstanceIdentifier.NodeIdentifier(QName.create(qname, "topic-id"));
         final Object actualTopicId = value.getBody().getChild(topicIdNode).get().getValue();
         Assert.assertEquals(topic1.getTopicId(), actualTopicId);
     }
@@ -151,14 +151,14 @@ public class NetconfEventSourceTest {
         verify(domNotificationPublishServiceMock, only()).putNotification(any());
     }
 
-    private Stream createStream(String name) {
+    private static Stream createStream(final String name) {
         return new StreamBuilder()
                 .setName(new StreamNameType(name))
                 .setReplaySupport(true)
                 .build();
     }
 
-    private NotificationDefinition getNotificationDefinitionMock(QName qualifiedName) {
+    private static NotificationDefinition getNotificationDefinitionMock(final QName qualifiedName) {
         NotificationDefinition notification = mock(NotificationDefinition.class);
         doReturn(qualifiedName).when(notification).getQName();
         doReturn(SchemaPath.create(true, qualifiedName)).when(notification).getPath();
index 331aa5183f8e7169467143044f5c22fcd081615a..bedebab7e7116dfbca5254faa394b946608cb186 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 9ed072181935e4cfe3d8892cc401897e6ab74b37..6fb4db2a56452b3833dc80476dc3ceced765ec9f 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index d6c87c3ed82c81c329712fc8a5730cdfa4abc30e..6918335e5b775591f41613d39dd45c9995cb048d 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.api.monitoring;
 /**
  * Class represents change in netconf session.
  */
-public class SessionEvent {
+public final class SessionEvent {
     private final NetconfManagementSession session;
     private final Type type;
 
index e3ffdd0ae5e213ad7919489d44b50896c261fc99..3abeeea40c4e0a68f00ebd29e8f8d6ccf3533353 100644 (file)
@@ -27,4 +27,8 @@ public final class NetconfConstants {
 
     public static final Set<String> CONFIG_SERVICE_MARKERS = Sets.newHashSet(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR,
             NETCONF_MONITORING, NETCONF_NOTIFICATION);
+
+    private NetconfConstants() {
+
+    }
 }
index b7b2b2db209530dd9c111ecdf6ca67a7cbaf6b8a..5de0f0a35c2bc4f80aa662926150ae1b38469640 100644 (file)
@@ -35,8 +35,8 @@ public class NetconfHelloMessageAdditionalHeaderTest {
 
     @Test
     public void testStaticConstructor() throws Exception {
-        NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(customHeader);
-        assertEquals(header.toString(), this.header.toString());
-        assertEquals(header.toFormattedString(), this.header.toFormattedString());
+        NetconfHelloMessageAdditionalHeader hdr = NetconfHelloMessageAdditionalHeader.fromString(customHeader);
+        assertEquals(hdr.toString(), this.header.toString());
+        assertEquals(hdr.toFormattedString(), this.header.toFormattedString());
     }
 }
index 699395b2488dbb315e7a4387a31166c7d8dd6047..62c822c123a8c8b7021c52aa21a931221d26a241 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
       <groupId>org.opendaylight.odlparent</groupId>
       <artifactId>odlparent-lite</artifactId>
-      <version>2.0.5</version>
+      <version>3.0.2</version>
       <relativePath/>
     </parent>
 
index bbabd5061db2dd4265585cdd41e146bb7fb62dcc..fbac2c037d5daa5da600dde49bc0a797bfac4ac5 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index ea6ccef15892768778b7544aba08a44072258fe7..2394c7152d819eb14c524a789e027225aad56baa 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 654210a4a0e1685b032cdf3cb60fb10c9bd3a1d8..82e72045d44d258f770100980056d5e6e34e4eb8 100644 (file)
@@ -55,6 +55,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public final synchronized void onSessionUp(NetconfClientSession clientSession) {
         this.clientSession = Preconditions.checkNotNull(clientSession);
         LOG.debug("Client session {} went up", clientSession);
@@ -71,12 +72,14 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public final void onSessionDown(NetconfClientSession clientSession, Exception exception) {
         LOG.debug("Client Session {} went down unexpectedly", clientSession, exception);
         tearDown(exception);
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public final void onSessionTerminated(NetconfClientSession clientSession,
                                           NetconfTerminationReason netconfTerminationReason) {
         LOG.debug("Client Session {} terminated, reason: {}", clientSession,
index 8047d60f1cca6cdc9101b9a782d117349992e137..73f664cdceaa8dcc18e84affa840b37ca9ed614c 100644 (file)
@@ -34,38 +34,45 @@ public class NetconfClientConfigurationBuilder {
         return new NetconfClientConfigurationBuilder();
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAddress(final InetSocketAddress address) {
         this.address = address;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withConnectionTimeoutMillis(final long connectionTimeoutMillis) {
         this.connectionTimeoutMillis = connectionTimeoutMillis;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withProtocol(
             final NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
         this.clientProtocol = clientProtocol;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAdditionalHeader(
             final NetconfHelloMessageAdditionalHeader additionalHeader) {
         this.additionalHeader = additionalHeader;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withSessionListener(final NetconfClientSessionListener sessionListener) {
         this.sessionListener = sessionListener;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withReconnectStrategy(final ReconnectStrategy reconnectStrategy) {
         this.reconnectStrategy = reconnectStrategy;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAuthHandler(final AuthenticationHandler authHandler) {
         this.authHandler = authHandler;
         return this;
index 4597dca75eb2cc4ba0e5c07a919af1e6e485392f..e705d3cca62e3fb8798f554d22ceca0f8b90a1c7 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.Authenticat
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 
-public class NetconfReconnectingClientConfigurationBuilder extends NetconfClientConfigurationBuilder {
+public final class NetconfReconnectingClientConfigurationBuilder extends NetconfClientConfigurationBuilder {
 
     private ReconnectStrategyFactory connectStrategyFactory;
 
@@ -25,7 +25,7 @@ public class NetconfReconnectingClientConfigurationBuilder extends NetconfClient
         return new NetconfReconnectingClientConfigurationBuilder();
     }
 
-
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfReconnectingClientConfigurationBuilder withConnectStrategyFactory(
             final ReconnectStrategyFactory connectStrategyFactory) {
         this.connectStrategyFactory = connectStrategyFactory;
index 8ca1d8c8115098cf447a467eaba49f867acca0a6..63c24c24195bb5571694fdd27123dea1d8c2cd48 100644 (file)
@@ -80,17 +80,17 @@ public class NetconfClientSessionNegotiatorTest {
     }
 
     private Channel mockChannel() {
-        Channel channel = mock(Channel.class);
+        Channel ret = mock(Channel.class);
         ChannelHandler channelHandler = mockChannelHandler();
-        doReturn("").when(channel).toString();
-        doReturn(future).when(channel).close();
-        doReturn(future).when(channel).writeAndFlush(anyObject());
-        doReturn(true).when(channel).isOpen();
-        doReturn(pipeline).when(channel).pipeline();
+        doReturn("").when(ret).toString();
+        doReturn(future).when(ret).close();
+        doReturn(future).when(ret).writeAndFlush(anyObject());
+        doReturn(true).when(ret).isOpen();
+        doReturn(pipeline).when(ret).pipeline();
         doReturn("").when(pipeline).toString();
         doReturn(pipeline).when(pipeline).remove(any(ChannelHandler.class));
         doReturn(channelHandler).when(pipeline).remove(anyString());
-        return channel;
+        return ret;
     }
 
     private static ChannelFuture mockChannelFuture() {
@@ -178,7 +178,7 @@ public class NetconfClientSessionNegotiatorTest {
 
         negotiator.channelActive(null);
         Set<String> caps = Sets.newSet("exi:1.0");
-        NetconfHelloMessage helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
+        NetconfHelloMessage message = NetconfHelloMessage.createServerHello(caps, 10);
 
         doAnswer(new Answer<Object>() {
             @Override
@@ -190,7 +190,7 @@ public class NetconfClientSessionNegotiatorTest {
 
         ChannelHandlerContext handlerContext = mock(ChannelHandlerContext.class);
         doReturn(pipeline).when(handlerContext).pipeline();
-        negotiator.handleMessage(helloMessage);
+        negotiator.handleMessage(message);
         Document expectedResult = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
         channelInboundHandlerAdapter.channelRead(handlerContext, new NetconfMessage(expectedResult));
 
index 593a6bc7dc9f9eb1572053505d634c78db80c258..95ec2737694f651544590ea204d1bcafe6c83701 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index aed2e66f45b2427e922ff1863664c4fe028f32ec..60b69733d4a13bf3efb95cc14996b34e59c502ea 100644 (file)
@@ -11,7 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -40,7 +40,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -99,22 +99,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-          <configuration>
-            <instructions>
-              <!-- This bundle works with Karaf 3 and 4.0 -->
-              <Import-Package>
-                  org.apache.karaf.shell.commands;version="[3.0.0,4.1)",
-                  org.apache.karaf.shell.console;version="[3.0.0,4.1)",
-                  org.apache.karaf.shell.table;version="[3.0.0,4.1)",
-                  *
-              </Import-Package>
-            </instructions>
-          </configuration>
-        </plugin>
         <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-checkstyle-plugin</artifactId>
index e7c9eda71f697b784f3ae4c5c8ab94cd3cca7f54..f705c94062021b393c5b1d72aa1618ef0143720b 100644 (file)
@@ -12,7 +12,7 @@ import com.google.common.base.Strings;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-public class NetconfCommandUtils {
+public final class NetconfCommandUtils {
 
     private static final Pattern IP_PATTERN = Pattern.compile(
             "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
@@ -20,6 +20,10 @@ public class NetconfCommandUtils {
                     + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
                     + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
 
+    private NetconfCommandUtils() {
+
+    }
+
     public static boolean isPortValid(final String devicePort) {
         if (Strings.isNullOrEmpty(devicePort)) {
             return false;
index ea7741cbbd0d5946fda8438f0f9461d7707ce628..4d24bbb6bb0161073e94a2682433e3845b2560d3 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.netconf.console.utils;
 
-public class NetconfConsoleConstants {
+public final class NetconfConsoleConstants {
 
     private NetconfConsoleConstants() {
         throw new IllegalStateException("Instantiating utility class.");
index 385f0f9e82f348a7c2e9c1f98baffd5e682d98e1..560ddcae4a02923fb683b24e7f03d2115467191a 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfConsoleUtils {
+public final class NetconfConsoleUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfConsoleUtils.class);
 
index 8df16c66420cf22ce05c5c7cf5163ddcb6a049de..1ea1f715f85f50c56c180caf926006baa3190d6a 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class NetconfIidFactory {
+public final class NetconfIidFactory {
 
     private NetconfIidFactory() {
         throw new IllegalStateException("Instantiating utility class.");
@@ -29,7 +29,7 @@ public class NetconfIidFactory {
             .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
             .build();
 
-    public static final InstanceIdentifier<Node> netconfNodeIid(final String nodeId) {
+    public static InstanceIdentifier<Node> netconfNodeIid(final String nodeId) {
         return NETCONF_TOPOLOGY_IID.child(Node.class, new NodeKey(new NodeId(nodeId)));
     }
 }
index 9cd198128509ca4c4f4eecc3c5a07f5e9e4a4f5b..8301b0fe000c48f5a943ed4e94938d32bab6468c 100644 (file)
@@ -15,9 +15,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import com.google.common.collect.ImmutableList;
-import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.List;
@@ -90,7 +88,9 @@ public class NetconfCommandsImplTest {
 
     @Before
     public void setUp() throws Exception {
-        schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        schemaContext = YangParserTestUtils.parseYangResources(NetconfCommandsImplTest.class,
+            "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang",
+            "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang");
         schemaContext.getModules();
         final SchemaService schemaService = createSchemaService();
 
@@ -102,7 +102,7 @@ public class NetconfCommandsImplTest {
         datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
 
         final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures");
+                16, 16, "CommitFutures", NetconfCommandsImplTest.class);
 
         final ConcurrentDOMDataBroker cDOMDataBroker =
                 new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
@@ -127,11 +127,11 @@ public class NetconfCommandsImplTest {
     public void testListDevice() throws TimeoutException, TransactionCommitFailedException {
         createTopology(LogicalDatastoreType.OPERATIONAL);
 
-        final Map map = netconfCommands.listDevices();
+        final Map<?, ?> map = netconfCommands.listDevices();
         map.containsKey(NetconfConsoleConstants.NETCONF_ID);
         assertTrue(map.containsKey(NODE_ID));
 
-        final Map mapNode = (Map) map.get(NODE_ID);
+        final Map<?, ?> mapNode = (Map<?, ?>) map.get(NODE_ID);
         assertBaseNodeAttributes(mapNode);
     }
 
@@ -139,19 +139,19 @@ public class NetconfCommandsImplTest {
     public void testShowDevice() throws TimeoutException, TransactionCommitFailedException {
         createTopology(LogicalDatastoreType.OPERATIONAL);
 
-        final Map mapCorrect = netconfCommands.showDevice(IP, String.valueOf(PORT));
+        final Map<?, ?> mapCorrect = netconfCommands.showDevice(IP, String.valueOf(PORT));
         mapCorrect.containsKey(NetconfConsoleConstants.NETCONF_ID);
         assertTrue(mapCorrect.containsKey(NODE_ID));
 
-        assertBaseNodeAttributesImmutableList((Map) mapCorrect.get(NODE_ID));
+        assertBaseNodeAttributesImmutableList((Map<?, ?>) mapCorrect.get(NODE_ID));
 
-        final Map mapWrongPort = netconfCommands.showDevice(IP, "1");
+        final Map<?, ?> mapWrongPort = netconfCommands.showDevice(IP, "1");
         assertFalse(mapWrongPort.containsKey(NODE_ID));
 
-        final Map mapWrongIP = netconfCommands.showDevice("1.1.1.1", String.valueOf(PORT));
+        final Map<?, ?> mapWrongIP = netconfCommands.showDevice("1.1.1.1", String.valueOf(PORT));
         assertFalse(mapWrongIP.containsKey(NODE_ID));
 
-        final Map mapId = netconfCommands.showDevice(NODE_ID);
+        final Map<?, ?> mapId = netconfCommands.showDevice(NODE_ID);
         assertTrue(mapId.containsKey(NODE_ID));
         assertBaseNodeAttributesImmutableList((Map) mapId.get(NODE_ID));
     }
@@ -230,7 +230,7 @@ public class NetconfCommandsImplTest {
         assertEquals(1, nodes.size());
     }
 
-    private void createTopology(LogicalDatastoreType dataStoreType)
+    private void createTopology(final LogicalDatastoreType dataStoreType)
             throws TransactionCommitFailedException, TimeoutException {
         final List<Node> nodes = new ArrayList<>();
         final Node node = getNetconfNode(NODE_ID, IP, PORT, CONN_STATUS, CAP_PREFIX);
@@ -245,8 +245,8 @@ public class NetconfCommandsImplTest {
         writeTransaction.submit().checkedGet(2, TimeUnit.SECONDS);
     }
 
-    private Node getNetconfNode(String nodeIdent, String ip, int portNumber,
-                                NetconfNodeConnectionStatus.ConnectionStatus cs, String notificationCapabilityPrefix) {
+    private static Node getNetconfNode(final String nodeIdent, final String ip, final int portNumber,
+            final NetconfNodeConnectionStatus.ConnectionStatus cs, final String notificationCapabilityPrefix) {
 
         final Host host = HostBuilder.getDefaultInstance(ip);
         final PortNumber port = new PortNumber(portNumber);
@@ -269,8 +269,7 @@ public class NetconfCommandsImplTest {
         return nb.build();
     }
 
-    private void assertBaseNodeAttributes(Map mapNode) {
-
+    private static void assertBaseNodeAttributes(final Map<?, ?> mapNode) {
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_ID));
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_IP));
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_PORT));
@@ -282,7 +281,7 @@ public class NetconfCommandsImplTest {
         assertEquals(CONN_STATUS.name().toLowerCase(), mapNode.get(NetconfConsoleConstants.STATUS));
     }
 
-    private void assertBaseNodeAttributesImmutableList(Map mapNode) {
+    private static void assertBaseNodeAttributesImmutableList(final Map<?, ?> mapNode) {
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_ID));
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_IP));
         assertTrue(mapNode.containsKey(NetconfConsoleConstants.NETCONF_PORT));
@@ -294,28 +293,15 @@ public class NetconfCommandsImplTest {
         assertEquals(ImmutableList.of(CONN_STATUS.name()), mapNode.get(NetconfConsoleConstants.STATUS));
     }
 
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Arrays.asList("/schemas/network-topology@2013-10-21.yang",
-                "/schemas/ietf-inet-types@2013-07-15.yang", "/schemas/yang-ext.yang",
-                "/schemas/netconf-node-topology.yang");
-
-        final List<InputStream> schemas = new ArrayList<>();
-        for (String schemaPath : schemaPaths) {
-            final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-        return schemas;
-    }
-
     private SchemaService createSchemaService() {
         return new SchemaService() {
 
             @Override
-            public void addModule(Module module) {
+            public void addModule(final Module module) {
             }
 
             @Override
-            public void removeModule(Module module) {
+            public void removeModule(final Module module) {
 
             }
 
index cdfa4a4693bcd7b1117c245310ba77c96714e379..8e2a890b0d039c8d9c9d091bc40debade0b469e4 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index d98f07b069560c3eb4e1394e0d13613f268c9af8..1cf2d41c08555a8ffd358fceb871db53f659b50d 100644 (file)
@@ -55,7 +55,7 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation imple
             LOG.info("Session {} closing", session.getSessionId());
         } catch (final Exception e) {
             throw new DocumentedException("Unable to properly close session "
-                    + getNetconfSessionIdForReporting(), DocumentedException.ErrorType.APPLICATION,
+                    + getNetconfSessionIdForReporting(), e, DocumentedException.ErrorType.APPLICATION,
                     DocumentedException.ErrorTag.OPERATION_FAILED,
                     DocumentedException.ErrorSeverity.ERROR, Collections.singletonMap(
                     DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
index f48a477a58e6b8dc145a7c5c188b4cd0b0f73b09..78041d00ba4bb84c436f144aea357499d337232f 100644 (file)
@@ -223,9 +223,9 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         }
     }
 
-    private void notifyCapabilityChanged(final Capabilities capabilities) {
+    private void notifyCapabilityChanged(final Capabilities newCapabilities) {
         for (NetconfMonitoringService.CapabilitiesListener listener : listeners) {
-            listener.onCapabilitiesChanged(capabilities);
+            listener.onCapabilitiesChanged(newCapabilities);
             listener.onSchemasChanged(getSchemas());
         }
     }
index b7db507ca577133acf9be0b6728ca0e962a9c61e..bc1618b0d44a986d3295a551b955334c6d0b09e3 100644 (file)
@@ -104,9 +104,8 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
                 Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), exception.toString()));
     }
 
-    private Document executeOperationWithHighestPriority(final Document message,
-                                                         final NetconfOperationExecution netconfOperationExecution)
-            throws DocumentedException {
+    private static Document executeOperationWithHighestPriority(final Document message,
+            final NetconfOperationExecution netconfOperationExecution) throws DocumentedException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Forwarding netconf message {} to {}", XmlUtil.toString(message), netconfOperationExecution
                     .netconfOperation);
@@ -154,7 +153,7 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         return sortedPriority;
     }
 
-    private static class NetconfOperationExecution implements NetconfOperationChainedExecution {
+    private static final class NetconfOperationExecution implements NetconfOperationChainedExecution {
         private final NetconfOperation netconfOperation;
         private final NetconfOperationChainedExecution subsequentExecution;
 
index b1a084424c67ba9192a9607255787cd04f0a0343..f1845b1038207a8239dc3a58f305f89e722d5fd7 100644 (file)
@@ -18,14 +18,15 @@ class NetconfOperationServiceFactoryTracker extends
         ServiceTracker<NetconfOperationServiceFactory, NetconfOperationServiceFactory> {
     private final NetconfOperationServiceFactoryListener factoriesListener;
 
-    NetconfOperationServiceFactoryTracker(BundleContext context,
+    NetconfOperationServiceFactoryTracker(final BundleContext context,
                                           final NetconfOperationServiceFactoryListener factoriesListener) {
         super(context, NetconfOperationServiceFactory.class, null);
         this.factoriesListener = factoriesListener;
     }
 
     @Override
-    public NetconfOperationServiceFactory addingService(ServiceReference<NetconfOperationServiceFactory> reference) {
+    public NetconfOperationServiceFactory addingService(
+            final ServiceReference<NetconfOperationServiceFactory> reference) {
         Object property = reference.getProperty(NetconfConstants.SERVICE_NAME);
         if (property != null && isMarkedForConfig(property)) {
             NetconfOperationServiceFactory netconfOperationServiceFactory = super.addingService(reference);
@@ -37,14 +38,14 @@ class NetconfOperationServiceFactoryTracker extends
     }
 
     @Override
-    public void removedService(ServiceReference<NetconfOperationServiceFactory> reference,
-                               NetconfOperationServiceFactory netconfOperationServiceFactory) {
+    public void removedService(final ServiceReference<NetconfOperationServiceFactory> reference,
+                               final NetconfOperationServiceFactory netconfOperationServiceFactory) {
         if (netconfOperationServiceFactory != null) {
             factoriesListener.onRemoveNetconfOperationServiceFactory(netconfOperationServiceFactory);
         }
     }
 
-    private boolean isMarkedForConfig(Object property) {
+    private static boolean isMarkedForConfig(final Object property) {
         return NetconfConstants.CONFIG_SERVICE_MARKERS.contains(property);
     }
 
index d02fe9848004f60eb13fbc78b2794e87d1970c5f..ad996748566d1bb7e06478dc2e40a0e734e34006 100644 (file)
@@ -37,7 +37,7 @@ public final class DeserializerExceptionHandler implements ChannelHandler {
         handleDeserializerException(ctx, cause);
     }
 
-    private void handleDeserializerException(final ChannelHandlerContext ctx, final Throwable cause) {
+    private static void handleDeserializerException(final ChannelHandlerContext ctx, final Throwable cause) {
 
         final Map<String, String> info = Maps.newHashMap();
         info.put("cause", cause.getMessage());
index 78931f19bcf8b57fd71aad827d9cd397a152f411..36a5d25a4c04d686f6d4587021147726d0b324e8 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull;
 
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
-import org.apache.sshd.common.SshdSocketAddress;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
 import org.junit.Test;
 
 public class NetconfServerSessionNegotiatorTest {
index 84603bc5114c172058c27da99f53790b70762465..01320b4ec197766bb803cde341753bc40a060976 100644 (file)
@@ -92,12 +92,12 @@ public class NetconfServerSessionTest {
     public void testSendNotification() throws Exception {
         doNothing().when(listener).onNotification(any(), any());
         final Document msgDoc = XmlUtil.readXmlToDocument("<notification></notification>");
-        final NetconfNotification msg = new NetconfNotification(msgDoc);
-        session.sendMessage(msg);
+        final NetconfNotification notif = new NetconfNotification(msgDoc);
+        session.sendMessage(notif);
         channel.runPendingTasks();
         final Object o = channel.readOutbound();
-        Assert.assertEquals(msg, o);
-        verify(listener).onNotification(session, msg);
+        Assert.assertEquals(notif, o);
+        verify(listener).onNotification(session, notif);
     }
 
     @Test
@@ -134,8 +134,8 @@ public class NetconfServerSessionTest {
     public void testToManagementSession() throws Exception {
         final NetconfHelloMessageAdditionalHeader header =
                 new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, TCP_TRANSPORT, SESSION_ID);
-        final EmbeddedChannel channel = new EmbeddedChannel();
-        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        final EmbeddedChannel ch = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, ch, 1L, header);
         tcpSession.sessionUp();
         final Session managementSession = tcpSession.toManagementSession();
         Assert.assertEquals(new String(managementSession.getSourceHost().getValue()), HOST);
@@ -148,8 +148,8 @@ public class NetconfServerSessionTest {
     public void testToManagementSessionUnknownTransport() throws Exception {
         final NetconfHelloMessageAdditionalHeader header =
                 new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, "http", SESSION_ID);
-        final EmbeddedChannel channel = new EmbeddedChannel();
-        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        final EmbeddedChannel ch = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, ch, 1L, header);
         tcpSession.sessionUp();
         tcpSession.toManagementSession();
     }
@@ -158,8 +158,8 @@ public class NetconfServerSessionTest {
     public void testToManagementSessionIpv6() throws Exception {
         final NetconfHelloMessageAdditionalHeader header =
                 new NetconfHelloMessageAdditionalHeader(USER, "::1", PORT, SSH_TRANSPORT, SESSION_ID);
-        final EmbeddedChannel channel = new EmbeddedChannel();
-        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        final EmbeddedChannel ch = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, ch, 1L, header);
         tcpSession.sessionUp();
         final Session managementSession = tcpSession.toManagementSession();
         Assert.assertEquals(new String(managementSession.getSourceHost().getValue()), "::1");
@@ -201,4 +201,4 @@ public class NetconfServerSessionTest {
         Assert.assertTrue(NetconfMessageToXMLEncoder.class.equals(encoder.getClass()));
     }
 
-}
\ No newline at end of file
+}
index 068ebf6eb4a3a28edb2f9f35254cdd633ec3eb0d..2566e070224e0fdffe987e1462cee71412e02227 100644 (file)
@@ -22,8 +22,6 @@ import io.netty.channel.ChannelFuture;
 import io.netty.channel.EventLoop;
 import io.netty.util.concurrent.GenericFutureListener;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
@@ -37,17 +35,14 @@ import org.w3c.dom.Document;
 
 public class DefaultCloseSessionTest {
 
-    private void mockEventLoop(final Channel channel) {
+    private static void mockEventLoop(final Channel channel) {
         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 -> {
+            final Object[] args = invocation.getArguments();
+            final Runnable runnable = (Runnable) args[0];
+            runnable.run();
+            return null;
         }).when(eventLoop).execute(any(Runnable.class));
         doReturn(true).when(eventLoop).inEventLoop();
     }
@@ -67,12 +62,9 @@ public class DefaultCloseSessionTest {
         doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
 
         final ChannelFuture sendFuture = mock(ChannelFuture.class);
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                ((GenericFutureListener) invocation.getArguments()[0]).operationComplete(sendFuture);
-                return null;
-            }
+        doAnswer(invocation -> {
+            ((GenericFutureListener) invocation.getArguments()[0]).operationComplete(sendFuture);
+            return null;
         }).when(sendFuture).addListener(any(GenericFutureListener.class));
         doReturn(sendFuture).when(channel).writeAndFlush(anyObject());
         doReturn(true).when(sendFuture).isSuccess();
index 7acef9165feb986171294676aadf05884490f1da..c322737993202eb9d6709c170a6bae7032638cbe 100644 (file)
@@ -17,13 +17,11 @@ import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
@@ -44,7 +42,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.mon
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.SessionBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
 public class NetconfCapabilityMonitoringServiceTest {
@@ -55,8 +53,8 @@ public class NetconfCapabilityMonitoringServiceTest {
     private static final String TEST_MODULE_REV2 = "1970-01-02";
     private static final Uri TEST_MODULE_NAMESPACE = new Uri("testModuleNamespace");
     private static final String TEST_MODULE_NAME = "testModule";
-    private static Date TEST_MODULE_DATE;
-    private static Date TEST_MODULE_DATE2;
+    private static final Revision  TEST_MODULE_DATE = Revision.of(TEST_MODULE_REV);
+    private static final Revision TEST_MODULE_DATE2 = Revision.of(TEST_MODULE_REV2);
 
     private YangModuleCapability moduleCapability1;
     private YangModuleCapability moduleCapability2;
@@ -84,26 +82,20 @@ public class NetconfCapabilityMonitoringServiceTest {
 
     private NetconfCapabilityMonitoringService monitoringService;
 
-    @BeforeClass
-    public static void suiteSetUp() throws Exception {
-        TEST_MODULE_DATE = SimpleDateFormatUtil.getRevisionFormat().parse(TEST_MODULE_REV);
-        TEST_MODULE_DATE2 = SimpleDateFormatUtil.getRevisionFormat().parse(TEST_MODULE_REV2);
-    }
-
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         doReturn(new URI(TEST_MODULE_NAMESPACE.getValue())).when(moduleMock).getNamespace();
         doReturn(TEST_MODULE_NAME).when(moduleMock).getName();
-        doReturn(TEST_MODULE_DATE).when(moduleMock).getRevision();
+        doReturn(java.util.Optional.of(TEST_MODULE_DATE)).when(moduleMock).getRevision();
         moduleCapability1 = new YangModuleCapability(moduleMock, TEST_MODULE_CONTENT);
 
         capabilities.add(moduleCapability1);
 
         doReturn(new URI(TEST_MODULE_NAMESPACE.getValue())).when(moduleMock2).getNamespace();
         doReturn(TEST_MODULE_NAME).when(moduleMock2).getName();
-        doReturn(TEST_MODULE_DATE2).when(moduleMock2).getRevision();
+        doReturn(java.util.Optional.of(TEST_MODULE_DATE2)).when(moduleMock2).getRevision();
         moduleCapability2 = new YangModuleCapability(moduleMock2, TEST_MODULE_CONTENT2);
 
         capabilities.add(new BasicCapability("urn:ietf:params:netconf:base:1.0"));
@@ -200,7 +192,7 @@ public class NetconfCapabilityMonitoringServiceTest {
         //remove capability
         monitoringService.onCapabilitiesChanged(Collections.emptySet(), testCaps);
 
-        verify(listener, times(3)).onCapabilitiesChanged((monitoringListenerCaptor.capture()));
+        verify(listener, times(3)).onCapabilitiesChanged(monitoringListenerCaptor.capture());
         verify(notificationPublisher, times(2)).onCapabilityChanged(capabilityChangeCaptor.capture());
 
         //verify listener calls
index 1d9450c2bfc91da2efa609fbf4d9f0d97730c0c1..1b8c6aed88b17d64010c8b4ae0d00a80426ff449 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index c308aa8e7b68cfac756ecb6612184d396fe3efd8..4d3e025ebecd80e506f148e4d44813e22cac2785 100644 (file)
@@ -54,24 +54,25 @@ public final class HandlingPriority implements Comparable<HandlingPriority> {
     }
 
     @Override
-    public int compareTo(HandlingPriority priority) {
-        if (this == priority) {
+    @SuppressWarnings("checkstyle:parameterName")
+    public int compareTo(HandlingPriority o) {
+        if (this == o) {
             return 0;
         }
         if (isCannotHandle()) {
             return -1;
         }
-        if (priority.isCannotHandle()) {
+        if (o.isCannotHandle()) {
             return 1;
         }
 
-        if (this.priority > priority.priority) {
+        if (priority > o.priority) {
             return 1;
         }
-        if (this.priority.equals(priority.priority)) {
+        if (priority.equals(o.priority)) {
             return 0;
         }
-        if (this.priority < priority.priority) {
+        if (priority < o.priority) {
             return -1;
         }
 
index 85d83f4f159aa5657fde90c170df6c7a08deb3d3..fb2fffe23af1cf9af0821227e1b14925eebf1425 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index a3601fe7b60da17bc88156bae70f366db0faf820..9e122e36c35e39b37972ba96f4592fe1d73a763d 100644 (file)
@@ -77,7 +77,7 @@ public class Get extends AbstractNetconfOperation {
             final String errorMessage = "Get operation for netconf-state subtree failed";
             LOG.warn(errorMessage, e);
 
-            throw new DocumentedException(errorMessage, DocumentedException.ErrorType.APPLICATION,
+            throw new DocumentedException(errorMessage, e, DocumentedException.ErrorType.APPLICATION,
                     DocumentedException.ErrorTag.OPERATION_FAILED,
                     DocumentedException.ErrorSeverity.ERROR,
                     Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
index 84801b1476bed92a97613cd80e3fa8eba151cffc..c3527a29be17ad499e8c574615eee0b1e2823d96 100644 (file)
@@ -59,7 +59,7 @@ public class GetSchema extends AbstractSingletonNetconfOperation {
             final Map<String, String> errorInfo = Maps.newHashMap();
             errorInfo.put(DocumentedException.ErrorTag.OPERATION_FAILED.toString(), e.getMessage());
             LOG.warn("Rpc error: {}", DocumentedException.ErrorTag.OPERATION_FAILED, e);
-            throw new DocumentedException(e.getMessage(), DocumentedException.ErrorType.APPLICATION,
+            throw new DocumentedException(e.getMessage(), e, DocumentedException.ErrorType.APPLICATION,
                     DocumentedException.ErrorTag.OPERATION_FAILED,
                     DocumentedException.ErrorSeverity.ERROR, errorInfo);
         }
index ba17417ada9580561fe8725b8e9590d858096604..37779348d64ca574e6cf5b1e3f6ac99bb3dfd41b 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -76,7 +76,7 @@
     <dependency>
       <groupId>org.apache.sshd</groupId>
       <artifactId>sshd-core</artifactId>
-      <version>0.14.0</version>
+      <version>1.6.0</version>
     </dependency>
     <dependency>
       <groupId>openexi</groupId>
index 1a548f41da16a221dd130458246803389127af8d..a9adf2a668177af9dc0e5c165e028a96cea5def1 100644 (file)
@@ -117,6 +117,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
 
         timeout = this.timer.newTimeout(new TimerTask() {
             @Override
+            @SuppressWarnings("checkstyle:hiddenField")
             public void run(final Timeout timeout) {
                 synchronized (this) {
                     if (state != State.ESTABLISHED) {
@@ -226,6 +227,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         return channel.pipeline().replace(handlerKey, handlerKey, decoder);
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     protected abstract S getSession(L sessionListener, Channel channel, NetconfHelloMessage message)
             throws NetconfDocumentedException;
 
index 7f3dd3854fdf23df5cefbeab7165b277f999b212..1ec0af6ef1ce192561fa4837a232937d5257d31b 100644 (file)
@@ -66,6 +66,7 @@ public final class BufferedWriter extends Writer {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void write(final char[] buffer, final int offset, final int length) throws IOException {
         if ((offset < 0) || (offset > buffer.length)
                 || (length < 0) || ((offset + length) > buffer.length) || ((offset + length) < 0)) {
index aed43347d863ee9269911ed4cb66fb7b49535b78..72d9fb7fbc4b3d0bca8e7d5acea68c4bc348dccf 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
 
 import java.io.IOException;
-import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.session.ClientSession;
 
 /**
  * Class providing authentication facility to SSH handler.
index 84682226aa2e1ee5e907cfcdef70ca698cc960b9..f824084c13d43bfec614d0c3f639b5aeb3856a21 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
 
 import java.io.IOException;
-import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.session.ClientSession;
 
 /**
  * Class Providing username/password authentication option to
index 70367c04ceb5d8ca0f06a1059b5cfd847518fca4..7bc7935cf257d0105be51a309c3042dd22eaecfe 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
 import com.google.common.base.Strings;
 import java.io.IOException;
 import java.security.KeyPair;
-import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.opendaylight.aaa.encrypt.PKIUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,7 +23,7 @@ public class PublicKeyAuth extends LoginPasswordHandler {
     private KeyPair keyPair = null;
     private static final Logger LOG = LoggerFactory.getLogger(PublicKeyAuth.class);
 
-    public PublicKeyAuth(String username, String password, String keyPath,
+    public PublicKeyAuth(final String username, final String password, final String keyPath,
                          String passPhrase) {
         super(username, password);
         try {
index 44444683c4812d14456491451b067b273f7a3e41..c3ff3496625e0f84f154692f49d71b924d67ca15 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
 
 import com.google.common.base.Preconditions;
-import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelOutboundHandlerAdapter;
 import io.netty.channel.ChannelPromise;
@@ -17,16 +16,11 @@ import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GenericFutureListener;
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.client.future.OpenFuture;
-import org.apache.sshd.common.future.CloseFuture;
-import org.apache.sshd.common.future.SshFutureListener;
+import org.apache.sshd.client.session.ClientSession;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,13 +40,10 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
     public static final SshClient DEFAULT_CLIENT;
 
     static {
-        final Map<String, String> props = new HashMap<>();
-        props.put(SshClient.AUTH_TIMEOUT, Long.toString(DEFAULT_TIMEOUT));
-        props.put(SshClient.IDLE_TIMEOUT, Long.toString(DEFAULT_TIMEOUT));
-
         final SshClient c = SshClient.setUpDefaultClient();
+        c.getProperties().put(SshClient.AUTH_TIMEOUT, Long.toString(DEFAULT_TIMEOUT));
+        c.getProperties().put(SshClient.IDLE_TIMEOUT, Long.toString(DEFAULT_TIMEOUT));
 
-        c.setProperties(props);
         // TODO make configurable, or somehow reuse netty threadpool
         c.setNioWorkers(SSH_DEFAULT_NIO_WORKERS);
         c.start();
@@ -109,18 +100,15 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
         return new AsyncSshHandler(authenticationHandler, DEFAULT_CLIENT, negotiationFuture);
     }
 
-    private void startSsh(final ChannelHandlerContext ctx, final SocketAddress address) {
+    private void startSsh(final ChannelHandlerContext ctx, final SocketAddress address) throws IOException {
         LOG.debug("Starting SSH to {} on channel: {}", address, ctx.channel());
 
         final ConnectFuture sshConnectionFuture = sshClient.connect(authenticationHandler.getUsername(), address);
-        sshConnectionFuture.addListener(new SshFutureListener<ConnectFuture>() {
-            @Override
-            public void operationComplete(final ConnectFuture future) {
-                if (future.isConnected()) {
-                    handleSshSessionCreated(future, ctx);
-                } else {
-                    handleSshSetupFailure(ctx, future.getException());
-                }
+        sshConnectionFuture.addListener(future -> {
+            if (future.isConnected()) {
+                handleSshSessionCreated(future, ctx);
+            } else {
+                handleSshSetupFailure(ctx, future.getException());
             }
         });
     }
@@ -131,17 +119,14 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
             session = future.getSession();
             final AuthFuture authenticateFuture = authenticationHandler.authenticate(session);
-            authenticateFuture.addListener(new SshFutureListener<AuthFuture>() {
-                @Override
-                public void operationComplete(final AuthFuture future) {
-                    if (future.isSuccess()) {
-                        handleSshAuthenticated(session, ctx);
-                    } else {
-                        // Exception does not have to be set in the future, add simple exception in such case
-                        final Throwable exception = future.getException() == null
-                                ? new IllegalStateException("Authentication failed") : future.getException();
-                        handleSshSetupFailure(ctx, exception);
-                    }
+            authenticateFuture.addListener(future1 -> {
+                if (future1.isSuccess()) {
+                    handleSshAuthenticated(session, ctx);
+                } else {
+                    // Exception does not have to be set in the future, add simple exception in such case
+                    final Throwable exception = future1.getException() == null
+                            ? new IllegalStateException("Authentication failed") : future1.getException();
+                    handleSshSetupFailure(ctx, exception);
                 }
             });
         } catch (final IOException e) {
@@ -149,21 +134,18 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
         }
     }
 
-    private synchronized void handleSshAuthenticated(final ClientSession session, final ChannelHandlerContext ctx) {
+    private synchronized void handleSshAuthenticated(final ClientSession newSession, final ChannelHandlerContext ctx) {
         try {
             LOG.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(),
-                    session.getServerVersion());
+                    newSession.getServerVersion());
 
-            channel = session.createSubsystemChannel(SUBSYSTEM);
+            channel = newSession.createSubsystemChannel(SUBSYSTEM);
             channel.setStreaming(ClientChannel.Streaming.Async);
-            channel.open().addListener(new SshFutureListener<OpenFuture>() {
-                @Override
-                public void operationComplete(final OpenFuture future) {
-                    if (future.isOpened()) {
-                        handleSshChanelOpened(ctx);
-                    } else {
-                        handleSshSetupFailure(ctx, future.getException());
-                    }
+            channel.open().addListener(future -> {
+                if (future.isOpened()) {
+                    handleSshChanelOpened(ctx);
+                } else {
+                    handleSshSetupFailure(ctx, future.getException());
                 }
             });
 
@@ -182,17 +164,8 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
         // TODO we should also read from error stream and at least log from that
 
-        sshReadAsyncListener = new AsyncSshHandlerReader(new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                AsyncSshHandler.this.disconnect(ctx, ctx.newPromise());
-            }
-        }, new AsyncSshHandlerReader.ReadMsgHandler() {
-            @Override
-            public void onMessageRead(final ByteBuf msg) {
-                ctx.fireChannelRead(msg);
-            }
-        }, channel.toString(), channel.getAsyncOut());
+        sshReadAsyncListener = new AsyncSshHandlerReader(() -> AsyncSshHandler.this.disconnect(ctx, ctx.newPromise()),
+            msg -> ctx.fireChannelRead(msg), channel.toString(), channel.getAsyncOut());
 
         // if readAsyncListener receives immediate close,
         // it will close this handler and closing this handler sets channel variable to null
@@ -226,12 +199,9 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
         if (negotiationFuture != null) {
 
-            negotiationFutureListener = new GenericFutureListener<Future<?>>() {
-                @Override
-                public void operationComplete(final Future<?> future) {
-                    if (future.isSuccess()) {
-                        connectPromise.setSuccess();
-                    }
+            negotiationFutureListener = future -> {
+                if (future.isSuccess()) {
+                    connectPromise.setSuccess();
                 }
             };
             //complete connection promise with netconf negotiation future
@@ -278,14 +248,11 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
         }
 
         if (session != null && !session.isClosed() && !session.isClosing()) {
-            session.close(false).addListener(new SshFutureListener<CloseFuture>() {
-                @Override
-                public void operationComplete(final CloseFuture future) {
-                    if (!future.isClosed()) {
-                        session.close(true);
-                    }
-                    session = null;
+            session.close(false).addListener(future -> {
+                if (!future.isClosed()) {
+                    session.close(true);
                 }
+                session = null;
             });
         }
 
index c79b71308ace4d270c15d93564f91cd1877ec880..b905f7ad2145a126a07396af2f2065ecb840014a 100644 (file)
@@ -13,7 +13,8 @@ import io.netty.buffer.Unpooled;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoReadFuture;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +42,7 @@ public final class AsyncSshHandlerReader implements SshFutureListener<IoReadFutu
         this.readHandler = readHandler;
         this.channelId = channelId;
         this.asyncOut = asyncOut;
-        buf = new Buffer(BUFFER_SIZE);
+        buf = new ByteArrayBuffer(BUFFER_SIZE);
         asyncOut.read(buf).addListener(this);
     }
 
@@ -73,7 +74,7 @@ public final class AsyncSshHandlerReader implements SshFutureListener<IoReadFutu
             readHandler.onMessageRead(msg);
 
             // Schedule next read
-            buf = new Buffer(BUFFER_SIZE);
+            buf = new ByteArrayBuffer(BUFFER_SIZE);
             currentReadFuture = asyncOut.read(buf);
             currentReadFuture.addListener(this);
         }
index 35f5d972c053ea07a861cf71640c9866f45f0177..bab4a7be632ffd58b98bb0208c8096bdffd5d4a5 100644 (file)
@@ -16,11 +16,10 @@ import java.nio.charset.StandardCharsets;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.Queue;
-import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoOutputStream;
-import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.io.WritePendingException;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,45 +85,41 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
             if (LOG.isTraceEnabled()) {
                 LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
             }
-            asyncIn.write(toBuffer(byteBufMsg)).addListener(new SshFutureListener<IoWriteFuture>() {
-
-                @Override
-                public void operationComplete(final IoWriteFuture future) {
-                    // synchronized block due to deadlock that happens on ssh window resize
-                    // writes and pending writes would lock the underlyinch channel session
-                    // window resize write would try to write the message on an already locked channelSession,
-                    // while the pending write was in progress from the write callback
-                    synchronized (asyncInLock) {
-                        if (LOG.isTraceEnabled()) {
-                            LOG.trace(
-                                "Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}",
-                                ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg));
-                        }
-
-                        // Notify success or failure
-                        if (future.isWritten()) {
-                            promise.setSuccess();
-                        } else {
-                            LOG.warn("Ssh write request failed on channel: {} for message: {}", ctx.channel(),
-                                    byteBufToString(byteBufMsg), future.getException());
-                            promise.setFailure(future.getException());
-                        }
-
-                        // Not needed anymore, release
-                        byteBufMsg.release();
-
-                        //rescheduling message from queue after successfully sent
-                        if (wasPending) {
-                            byteBufMsg.resetReaderIndex();
-                            pending.remove();
-                        }
+            asyncIn.write(toBuffer(byteBufMsg)).addListener(future -> {
+                // synchronized block due to deadlock that happens on ssh window resize
+                // writes and pending writes would lock the underlyinch channel session
+                // window resize write would try to write the message on an already locked channelSession,
+                // while the pending write was in progress from the write callback
+                synchronized (asyncInLock) {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace(
+                            "Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}",
+                            ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg));
                     }
 
-                    // Check pending queue and schedule next
-                    // At this time we are guaranteed that we are not in pending state anymore
-                    // so the next request should succeed
-                    writePendingIfAny();
+                    // Notify success or failure
+                    if (future.isWritten()) {
+                        promise.setSuccess();
+                    } else {
+                        LOG.warn("Ssh write request failed on channel: {} for message: {}", ctx.channel(),
+                                byteBufToString(byteBufMsg), future.getException());
+                        promise.setFailure(future.getException());
+                    }
+
+                    // Not needed anymore, release
+                    byteBufMsg.release();
+
+                    //rescheduling message from queue after successfully sent
+                    if (wasPending) {
+                        byteBufMsg.resetReaderIndex();
+                        pending.remove();
+                    }
                 }
+
+                // Check pending queue and schedule next
+                // At this time we are guaranteed that we are not in pending state anymore
+                // so the next request should succeed
+                writePendingIfAny();
             });
 
         } catch (final WritePendingException e) {
@@ -183,7 +178,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
         msg.resetReaderIndex();
         final byte[] temp = new byte[msg.readableBytes()];
         msg.readBytes(temp, 0, msg.readableBytes());
-        return new Buffer(temp);
+        return new ByteArrayBuffer(temp);
     }
 
     private static final class PendingWriteRequest {
index 7dda1cdac8dcf67d2a3ee269e5e283fb84d92ec9..f1dad80c6c225c659e509ce0bd3716c490ce3f15 100644 (file)
@@ -159,10 +159,10 @@ public class AbstractNetconfSessionTest {
     @Test
     public void testSendMessage() throws Exception {
         final TestingNetconfSession testingNetconfSession = new TestingNetconfSession(listener, channel, 1L);
-        final NetconfHelloMessage clientHello = NetconfHelloMessage.createClientHello(Collections.<String>emptySet(),
+        final NetconfHelloMessage hello = NetconfHelloMessage.createClientHello(Collections.<String>emptySet(),
                 Optional.<NetconfHelloMessageAdditionalHeader>absent());
-        testingNetconfSession.sendMessage(clientHello);
-        verify(channel).writeAndFlush(clientHello);
+        testingNetconfSession.sendMessage(hello);
+        verify(channel).writeAndFlush(hello);
     }
 
-}
\ No newline at end of file
+}
index 905c0c03da07aa05abce159f929efdbbb00e218a..d2ce899e0ac4306849c64a65bc5bea4f8da11d7e 100644 (file)
@@ -14,8 +14,8 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.junit.Test;
 
 public class LoginPasswordHandlerTest {
index df9ece7dd92983cfd72285b789a1055f7d843f83..bc57f3c7a1c578306a3c1fba604a0b72962c8695 100644 (file)
@@ -37,13 +37,13 @@ import io.netty.channel.DefaultChannelPromise;
 import io.netty.channel.EventLoop;
 import java.io.IOException;
 import java.net.SocketAddress;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.channel.ChannelSubsystem;
+import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.SshFuture;
 import org.apache.sshd.common.future.SshFutureListener;
@@ -51,7 +51,8 @@ import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoReadFuture;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -59,8 +60,6 @@ import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 
 public class AsyncSshHandlerTest {
@@ -129,12 +128,9 @@ public class AsyncSshHandlerTest {
     private static <T extends SshFuture<T>> ListenableFuture<SshFutureListener<T>> stubAddListener(final T future) {
         final SettableFuture<SshFutureListener<T>> listenerSettableFuture = SettableFuture.create();
 
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                listenerSettableFuture.set((SshFutureListener<T>) invocation.getArguments()[0]);
-                return null;
-            }
+        doAnswer(invocation -> {
+            listenerSettableFuture.set((SshFutureListener<T>) invocation.getArguments()[0]);
+            return null;
         }).when(future).addListener(any(SshFutureListener.class));
 
         return listenerSettableFuture;
@@ -162,7 +158,7 @@ public class AsyncSshHandlerTest {
         doReturn(Boolean.TRUE).when(eventLoop).inEventLoop();
     }
 
-    private void stubSshClient() {
+    private void stubSshClient() throws IOException {
         doNothing().when(sshClient).start();
         final ConnectFuture connectFuture = mock(ConnectFuture.class);
         Futures.addCallback(stubAddListener(connectFuture), new SuccessFutureListener<ConnectFuture>() {
@@ -519,7 +515,7 @@ public class AsyncSshHandlerTest {
         doReturn(null).when(ioReadFuture).getException();
         doReturn(ioReadFuture).when(ioReadFuture).removeListener(Matchers.<SshFutureListener<IoReadFuture>>any());
         doReturn(5).when(ioReadFuture).getRead();
-        doReturn(new Buffer(new byte[]{0, 1, 2, 3, 4})).when(ioReadFuture).getBuffer();
+        doReturn(new ByteArrayBuffer(new byte[]{0, 1, 2, 3, 4})).when(ioReadFuture).getBuffer();
         doReturn(ioReadFuture).when(ioReadFuture).addListener(Matchers.<SshFutureListener<IoReadFuture>>any());
 
         // Always success for read
index 6d4aba8b21cd58ea42e5e49e397c477ebfc72774..1e8b3a8d3e0cdffc624900826fcf774e9ce0eb25 100644 (file)
@@ -15,7 +15,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index d65a69516a1612a486a6c5e4d32ad2d46674a895..8253e09fa58a18e2a436e1618e318d361f038407 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -49,7 +49,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index a90a669d347cb2657bc78c2d4dbc2f091ffccfb8..4e2160b30321f59e6f4c61033ddd463c5a9b4dc4 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -33,7 +33,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 65de77be96fb6c75c18f91a94abfb8c757aec57b..f478029323821c1f6e1f8193a8ddb6def06ac456 100644 (file)
@@ -15,7 +15,7 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.concurrent.Executors;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
 import org.opendaylight.netconf.api.NetconfServerDispatcher;
 import org.opendaylight.netconf.auth.AuthProvider;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
@@ -55,8 +55,7 @@ public class NetconfNorthboundSshServer {
         sshProxyServerConfigurationBuilder.setLocalAddress(localAddress);
         sshProxyServerConfigurationBuilder.setAuthenticator(authProvider);
         sshProxyServerConfigurationBuilder.setIdleTimeout(Integer.MAX_VALUE);
-        sshProxyServerConfigurationBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider(DEFAULT_PRIVATE_KEY_PATH,
-                DEFAULT_ALGORITHM, DEFAULT_KEY_SIZE));
+        sshProxyServerConfigurationBuilder.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
 
         localServer.addListener(future -> {
             if (future.isDone() && !future.isCancelled()) {
@@ -79,7 +78,7 @@ public class NetconfNorthboundSshServer {
         return new InetSocketAddress(inetAd, Integer.parseInt(portNumber));
     }
 
-    public void close() {
+    public void close() throws IOException {
         sshProxyServer.close();
 
         if (localServer.isDone()) {
index d8d4148a9e3425847fa4ca45a8eb26b7258f6f23..3d91f3aeb4ab35cd1fee451e869860968f584cf0 100644 (file)
@@ -63,11 +63,13 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setIoInputStream(final IoInputStream in) {
         this.in = in;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setIoOutputStream(final IoOutputStream out) {
         this.out = out;
     }
@@ -78,11 +80,13 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setInputStream(final InputStream in) {
         throw new UnsupportedOperationException("Synchronous IO is unsupported");
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setOutputStream(final OutputStream out) {
         throw new UnsupportedOperationException("Synchronous IO is unsupported");
 
@@ -95,6 +99,7 @@ public class RemoteNetconfCommand implements AsyncCommand, SessionAware {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setExitCallback(final ExitCallback callback) {
         this.callback = callback;
     }
index f525674436d9a9e01eef95575199edfc032e9187..406a28aee4722740fdd04364f851832d2d40a522 100644 (file)
@@ -18,13 +18,11 @@ import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.SshServer;
-import org.apache.sshd.common.Cipher;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.RuntimeSshException;
-import org.apache.sshd.common.cipher.ARCFOUR128;
-import org.apache.sshd.common.cipher.ARCFOUR256;
+import org.apache.sshd.common.cipher.BuiltinCiphers;
+import org.apache.sshd.common.cipher.Cipher;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoConnector;
 import org.apache.sshd.common.io.IoHandler;
@@ -33,17 +31,15 @@ import org.apache.sshd.common.io.IoServiceFactoryFactory;
 import org.apache.sshd.common.io.nio2.Nio2Acceptor;
 import org.apache.sshd.common.io.nio2.Nio2Connector;
 import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
-import org.apache.sshd.common.util.CloseableUtils;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 import org.apache.sshd.server.ServerFactoryManager;
+import org.apache.sshd.server.SshServer;
 
 /**
  * Proxy SSH server that just delegates decrypted content to a delegate server within same VM.
  * Implemented using Apache Mina SSH lib.
  */
 public class SshProxyServer implements AutoCloseable {
-
-    private static final ARCFOUR128.Factory DEFAULT_ARCFOUR128_FACTORY = new ARCFOUR128.Factory();
-    private static final ARCFOUR256.Factory DEFAULT_ARCFOUR256_FACTORY = new ARCFOUR256.Factory();
     private final SshServer sshServer;
     private final ScheduledExecutorService minaTimerExecutor;
     private final EventLoopGroup clientGroup;
@@ -64,8 +60,8 @@ public class SshProxyServer implements AutoCloseable {
 
         //remove rc4 ciphers
         final List<NamedFactory<Cipher>> cipherFactories = sshServer.getCipherFactories();
-        cipherFactories.removeIf(factory -> factory.getName().contains(DEFAULT_ARCFOUR128_FACTORY.getName())
-                || factory.getName().contains(DEFAULT_ARCFOUR256_FACTORY.getName()));
+        cipherFactories.removeIf(factory -> factory.getName().contains(BuiltinCiphers.arcfour128.getName())
+                || factory.getName().contains(BuiltinCiphers.arcfour256.getName()));
         sshServer.setPasswordAuthenticator(
             (username, password, session)
                 -> sshProxyServerConfiguration.getAuthenticator().authenticated(username, password));
@@ -76,7 +72,10 @@ public class SshProxyServer implements AutoCloseable {
 
         sshServer.setIoServiceFactoryFactory(nioServiceWithPoolFactoryFactory);
         sshServer.setScheduledExecutorService(minaTimerExecutor);
-        sshServer.setProperties(getProperties(sshProxyServerConfiguration));
+        sshServer.getProperties().put(ServerFactoryManager.IDLE_TIMEOUT,
+            String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
+        sshServer.getProperties().put(ServerFactoryManager.AUTH_TIMEOUT,
+            String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
 
         final RemoteNetconfCommand.NetconfCommandFactory netconfCommandFactory =
                 new RemoteNetconfCommand.NetconfCommandFactory(clientGroup,
@@ -95,11 +94,9 @@ public class SshProxyServer implements AutoCloseable {
     }
 
     @Override
-    public void close() {
+    public void close() throws IOException {
         try {
             sshServer.stop(true);
-        } catch (final InterruptedException e) {
-            throw new RuntimeException("Interrupted while stopping sshServer", e);
         } finally {
             sshServer.close(true);
         }
@@ -108,8 +105,7 @@ public class SshProxyServer implements AutoCloseable {
     /**
      * Based on Nio2ServiceFactory with one addition: injectable executor.
      */
-    private static final class NioServiceWithPoolFactory
-            extends CloseableUtils.AbstractCloseable implements IoServiceFactory {
+    private static final class NioServiceWithPoolFactory extends AbstractCloseable implements IoServiceFactory {
 
         private final FactoryManager manager;
         private final AsynchronousChannelGroup group;
index 75692ba575f604f314a45ebde1a577acdeeb0b5c..935241a3904288762439e84efcb59f724cf1a535 100644 (file)
@@ -12,8 +12,8 @@ import com.google.common.base.Preconditions;
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
 import java.util.Optional;
-import org.apache.sshd.common.KeyPairProvider;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.common.keyprovider.KeyPairProvider;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.opendaylight.netconf.auth.AuthProvider;
 
 public final class SshProxyServerConfiguration {
index 6d9a364af9aadacd70601fd4b48851a431949a21..11706a823d29e58884dc9a78197933084499c264 100644 (file)
@@ -5,13 +5,12 @@
  * 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.ssh;
 
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
-import org.apache.sshd.common.KeyPairProvider;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.common.keyprovider.KeyPairProvider;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.opendaylight.netconf.auth.AuthProvider;
 
 public final class SshProxyServerConfigurationBuilder {
@@ -20,7 +19,7 @@ public final class SshProxyServerConfigurationBuilder {
     private AuthProvider authenticator;
     private KeyPairProvider keyPairProvider;
     private int idleTimeout;
-    private PublickeyAuthenticator publicKeyAuthenticator = null;
+    private PublickeyAuthenticator publickeyAuthenticator = null;
 
     public SshProxyServerConfigurationBuilder setBindingAddress(final InetSocketAddress bindingAddress) {
         this.bindingAddress = bindingAddress;
@@ -37,8 +36,9 @@ public final class SshProxyServerConfigurationBuilder {
         return this;
     }
 
-    public SshProxyServerConfigurationBuilder setPublickeyAuthenticator(final PublickeyAuthenticator authenticator) {
-        this.publicKeyAuthenticator = authenticator;
+    public SshProxyServerConfigurationBuilder setPublickeyAuthenticator(
+            final PublickeyAuthenticator publickeyAuthenticator) {
+        this.publickeyAuthenticator = publickeyAuthenticator;
         return this;
     }
 
@@ -53,11 +53,11 @@ public final class SshProxyServerConfigurationBuilder {
     }
 
     public SshProxyServerConfiguration createSshProxyServerConfiguration() {
-        return new SshProxyServerConfiguration(bindingAddress, localAddress, authenticator, publicKeyAuthenticator,
+        return new SshProxyServerConfiguration(bindingAddress, localAddress, authenticator, publickeyAuthenticator,
                 keyPairProvider, idleTimeout);
     }
 
     public static SshProxyServerConfigurationBuilder create() {
         return new SshProxyServerConfigurationBuilder();
     }
-}
\ No newline at end of file
+}
index e498b56e7375e3be20574ee6851c8e0a11970f6a..0a15fdb608c3bde1774ab265ddb9a9ae2ddc9e06 100644 (file)
@@ -9,13 +9,15 @@ package org.opendaylight.netconf.ssh.osgi;
 
 import io.netty.channel.local.LocalAddress;
 import io.netty.channel.nio.NioEventLoopGroup;
+import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import org.apache.sshd.common.util.ThreadUtils;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.common.util.security.SecurityUtils;
+import org.apache.sshd.common.util.threads.ThreadUtils;
+import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
 import org.opendaylight.netconf.ssh.SshProxyServer;
 import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
 import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
@@ -88,12 +90,16 @@ public class NetconfSSHActivator implements BundleActivator {
         LOG.trace("Starting netconf SSH server with path to ssh private key {}", path);
 
         final SshProxyServer sshProxyServer = new SshProxyServer(minaTimerExecutor, clientGroup, nioExecutor);
+        final AbstractGeneratorHostKeyProvider keyPairProvider = SecurityUtils.createGeneratorHostKeyProvider(null);
+        keyPairProvider.setAlgorithm(ALGORITHM);
+        keyPairProvider.setKeySize(KEY_SIZE);
+        keyPairProvider.setFile(new File(path));
         sshProxyServer.bind(
                 new SshProxyServerConfigurationBuilder()
                         .setBindingAddress(sshSocketAddress)
                         .setLocalAddress(localAddress)
                         .setAuthenticator(authProviderTracker)
-                        .setKeyPairProvider(new PEMGeneratorHostKeyProvider(path, ALGORITHM, KEY_SIZE))
+                        .setKeyPairProvider(keyPairProvider)
                         .setIdleTimeout(DEFAULT_IDLE_TIMEOUT)
                         .createSshProxyServerConfiguration());
         return sshProxyServer;
index 2a94d38161e9763322e5b77b80f0f2174c9cad4f..8f990380a331abdb24a58d9b7d55774745392cb4 100644 (file)
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
 public class EchoClientHandler extends ChannelInboundHandlerAdapter implements ChannelFutureListener {
     private static final Logger LOG = LoggerFactory.getLogger(EchoClientHandler.class);
 
-    private ChannelHandlerContext ctx;
+    private ChannelHandlerContext context;
     private final StringBuilder fromServer = new StringBuilder();
 
     public enum State {
@@ -40,9 +40,9 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
 
     @Override
     public synchronized void channelActive(ChannelHandlerContext ctx) {
-        checkState(this.ctx == null);
+        checkState(context == null);
         LOG.info("channelActive");
-        this.ctx = ctx;
+        context = ctx;
         state = State.CONNECTED;
     }
 
@@ -64,14 +64,14 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
     public synchronized void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
         // Close the connection when an exception is raised.
         LOG.warn("Unexpected exception from downstream.", cause);
-        checkState(this.ctx.equals(ctx));
+        checkState(context.equals(ctx));
         ctx.close();
-        this.ctx = null;
+        context = null;
     }
 
     public synchronized void write(String message) {
         ByteBuf byteBuf = Unpooled.copiedBuffer(message.getBytes());
-        ctx.writeAndFlush(byteBuf);
+        context.writeAndFlush(byteBuf);
     }
 
     public synchronized boolean isConnected() {
index a2da0dafb761e61744b319c6cd7290a90a5f27e4..38907bcf509e2a93ae1b19e020a40fc5f6ccbe56 100644 (file)
@@ -26,7 +26,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.common.util.security.SecurityUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -75,8 +75,7 @@ public class SSHTest {
         sshProxyServer.bind(new SshProxyServerConfigurationBuilder()
                 .setBindingAddress(addr).setLocalAddress(NetconfConfiguration.NETCONF_LOCAL_ADDRESS)
                 .setAuthenticator((username, password) -> true)
-                .setKeyPairProvider(new PEMGeneratorHostKeyProvider(sshKeyPair.toPath().toAbsolutePath().toString(),
-                        "RSA", 4096))
+                .setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(sshKeyPair.toPath()))
                 .setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
 
         final EchoClientHandler echoClientHandler = connectClient(addr);
index 1d31f6b77a8064ad57da00bbf143ae7d35fc7c29..e660628a67653d9c1c4bfe39da4277100fa108ae 100644 (file)
@@ -21,11 +21,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.common.util.security.SecurityUtils;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -74,8 +74,7 @@ public class SSHServerTest {
         server.bind(new SshProxyServerConfigurationBuilder()
                 .setBindingAddress(addr).setLocalAddress(NetconfConfiguration.NETCONF_LOCAL_ADDRESS)
                 .setAuthenticator((username, password) -> true)
-                .setKeyPairProvider(new PEMGeneratorHostKeyProvider(sshKeyPair.toPath().toAbsolutePath().toString(),
-                        "RSA", 4096))
+                .setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(sshKeyPair.toPath()))
                 .setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
         LOG.info("SSH server started on {}", PORT);
     }
index e759a8b686f5c98cf8d160c008fc79518d92a9c5..7f3e89073dfb4c5bfabde8bbb3867cc5f5babd77 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index f896d918e55d214c5ae43ccd83da977ff3488987..33fc7c994cc605610b74c965801c7fba006e55a9 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 692086e29c177e9d886eee3269c96672e783d32e..cce95d91ec9cda13995f4ee9bf7450f568f20806 100644 (file)
     <dependencies>
         <dependency>
             <groupId>com.typesafe.akka</groupId>
-            <artifactId>akka-actor_${scala.version}</artifactId>
+            <artifactId>akka-actor_2.12</artifactId>
         </dependency>
         <dependency>
             <groupId>com.typesafe.akka</groupId>
-            <artifactId>akka-cluster_${scala.version}</artifactId>
+            <artifactId>akka-cluster_2.12</artifactId>
         </dependency>
 
         <dependency>
@@ -91,7 +91,7 @@
         </dependency>
         <dependency>
             <groupId>com.typesafe.akka</groupId>
-            <artifactId>akka-testkit_${scala.version}</artifactId>
+            <artifactId>akka-testkit_2.12</artifactId>
         </dependency>
     </dependencies>
 
index 2e683734da5820e520d304c16a96ca9df3ffc19a..1ebbad07001604248f0d4778b30669baa973d6a5 100644 (file)
@@ -14,7 +14,6 @@ import akka.cluster.Cluster;
 import akka.dispatch.OnComplete;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -31,10 +30,10 @@ import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificatio
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -49,7 +48,7 @@ class MasterSalFacade implements AutoCloseable, RemoteDeviceHandler<NetconfSessi
     private final ActorRef masterActorRef;
     private final ActorSystem actorSystem;
 
-    private SchemaContext remoteSchemaContext = null;
+    private SchemaContext currentSchemaContext = null;
     private NetconfSessionPreferences netconfSessionPreferences = null;
     private DOMRpcService deviceRpc = null;
     private DOMDataBroker deviceDataBroker = null;
@@ -68,10 +67,11 @@ class MasterSalFacade implements AutoCloseable, RemoteDeviceHandler<NetconfSessi
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void onDeviceConnected(final SchemaContext remoteSchemaContext,
                                   final NetconfSessionPreferences netconfSessionPreferences,
                                   final DOMRpcService deviceRpc) {
-        this.remoteSchemaContext = remoteSchemaContext;
+        this.currentSchemaContext = remoteSchemaContext;
         this.netconfSessionPreferences = netconfSessionPreferences;
         this.deviceRpc = deviceRpc;
 
@@ -115,7 +115,7 @@ class MasterSalFacade implements AutoCloseable, RemoteDeviceHandler<NetconfSessi
 
     private void registerMasterMountPoint() {
         Preconditions.checkNotNull(id);
-        Preconditions.checkNotNull(remoteSchemaContext,
+        Preconditions.checkNotNull(currentSchemaContext,
                 "Device has no remote schema context yet. Probably not fully connected.");
         Preconditions.checkNotNull(netconfSessionPreferences,
                 "Device has no capabilities yet. Probably not fully connected.");
@@ -124,22 +124,20 @@ class MasterSalFacade implements AutoCloseable, RemoteDeviceHandler<NetconfSessi
 
         LOG.info("{}: Creating master data broker for device", id);
 
-        deviceDataBroker = new NetconfDeviceDataBroker(id, remoteSchemaContext, deviceRpc, netconfSessionPreferences);
+        deviceDataBroker = new NetconfDeviceDataBroker(id, currentSchemaContext, deviceRpc, netconfSessionPreferences);
         // We need to create ProxyDOMDataBroker so accessing mountpoint
         // on leader node would be same as on follower node
         final ProxyDOMDataBroker proxyDataBroker =
                 new ProxyDOMDataBroker(actorSystem, id, masterActorRef, actorResponseWaitTime);
         salProvider.getMountInstance()
-                .onTopologyDeviceConnected(remoteSchemaContext, proxyDataBroker, deviceRpc, notificationService);
+                .onTopologyDeviceConnected(currentSchemaContext, proxyDataBroker, deviceRpc, notificationService);
     }
 
     private Future<Object> sendInitialDataToActor() {
         final List<SourceIdentifier> sourceIdentifiers =
-                remoteSchemaContext.getAllModuleIdentifiers().stream().map(mi ->
-                        RevisionSourceIdentifier.create(mi.getName(),
-                                (SimpleDateFormatUtil.DEFAULT_DATE_REV == mi.getRevision() ? Optional.<String>absent() :
-                                    Optional.of(mi.getQNameModule().getFormattedRevision()))))
-                        .collect(Collectors.toList());
+                SchemaContextUtil.getConstituentModuleIdentifiers(currentSchemaContext).stream()
+                .map(mi -> RevisionSourceIdentifier.create(mi.getName(), mi.getRevision()))
+                .collect(Collectors.toList());
 
         // send initial data to master actor and create actor for providing it
         return Patterns.ask(masterActorRef, new CreateInitialMasterActorData(deviceDataBroker, sourceIdentifiers,
index 48f063e92049400aa34995a201e3d27da2d67a51..82e340d9171649d57752af5c733b570764542f13 100644 (file)
@@ -108,7 +108,7 @@ public class NetconfTopologyManager
 
     // Blueprint init method
     public void init() {
-        dataChangeListenerRegistration = registerDataTreeChangeListener(topologyId);
+        dataChangeListenerRegistration = registerDataTreeChangeListener();
     }
 
     @Override
@@ -242,10 +242,10 @@ public class NetconfTopologyManager
         this.privateKeyPassphrase = privateKeyPassphrase;
     }
 
-    private ListenerRegistration<NetconfTopologyManager> registerDataTreeChangeListener(final String topologyId) {
+    private ListenerRegistration<NetconfTopologyManager> registerDataTreeChangeListener() {
         final WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
-        initTopology(wtx, LogicalDatastoreType.CONFIGURATION, topologyId);
-        initTopology(wtx, LogicalDatastoreType.OPERATIONAL, topologyId);
+        initTopology(wtx, LogicalDatastoreType.CONFIGURATION);
+        initTopology(wtx, LogicalDatastoreType.OPERATIONAL);
         Futures.addCallback(wtx.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
@@ -264,8 +264,7 @@ public class NetconfTopologyManager
                         NetconfTopologyUtils.createTopologyListPath(topologyId).child(Node.class)), this);
     }
 
-    private void initTopology(final WriteTransaction wtx, final LogicalDatastoreType datastoreType,
-                              final String topologyId) {
+    private void initTopology(final WriteTransaction wtx, final LogicalDatastoreType datastoreType) {
         final NetworkTopology networkTopology = new NetworkTopologyBuilder().build();
         final InstanceIdentifier<NetworkTopology> networkTopologyId =
                 InstanceIdentifier.builder(NetworkTopology.class).build();
index 2e46cd4a1bfbb033f2b5948116503124eb3bf567..89547421c7c50d352ec7f9c4e660709631592f01 100644 (file)
@@ -15,12 +15,14 @@ import akka.util.Timeout;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.io.IOException;
 import java.util.List;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
 import org.opendaylight.controller.cluster.schema.provider.impl.RemoteSchemaProvider;
 import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy;
@@ -60,8 +62,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -72,7 +72,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.duration.Duration;
 
-public class NetconfNodeActor extends UntypedActor {
+public final class NetconfNodeActor extends UntypedActor {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfNodeActor.class);
 
@@ -168,7 +168,7 @@ public class NetconfNodeActor extends UntypedActor {
             }
         } else if (message instanceof InvokeRpcMessage) { // master
 
-            final InvokeRpcMessage invokeRpcMessage = ((InvokeRpcMessage) message);
+            final InvokeRpcMessage invokeRpcMessage = (InvokeRpcMessage) message;
             invokeSlaveRpc(invokeRpcMessage.getSchemaPath(), invokeRpcMessage.getNormalizedNodeMessage(), sender());
 
         } else if (message instanceof RegisterMountPoint) { //slaves
@@ -198,7 +198,7 @@ public class NetconfNodeActor extends UntypedActor {
     }
 
     private void sendYangTextSchemaSourceProxy(final SourceIdentifier sourceIdentifier, final ActorRef sender) {
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> yangTextSchemaSource =
+        final ListenableFuture<@NonNull YangTextSchemaSource> yangTextSchemaSource =
                 schemaRepository.getSchemaSource(sourceIdentifier, YangTextSchemaSource.class);
 
         Futures.addCallback(yangTextSchemaSource, new FutureCallback<YangTextSchemaSource>() {
@@ -254,15 +254,14 @@ public class NetconfNodeActor extends UntypedActor {
         slaveSalManager = new SlaveSalFacade(id, setup.getActorSystem(), actorResponseWaitTime,
                 mountPointService);
 
-        final CheckedFuture<SchemaContext, SchemaResolutionException> remoteSchemaContext =
-                getSchemaContext(masterReference);
-        final DOMRpcService deviceRpc = getDOMRpcService(masterReference);
+        final ListenableFuture<SchemaContext> remoteSchemaContext = getSchemaContext(masterReference);
+        final DOMRpcService deviceRpcService = getDOMRpcService(masterReference);
 
         Futures.addCallback(remoteSchemaContext, new FutureCallback<SchemaContext>() {
             @Override
             public void onSuccess(final SchemaContext result) {
                 LOG.info("{}: Schema context resolved: {}", id, result.getModules());
-                slaveSalManager.registerSlaveMountPoint(result, deviceRpc, masterReference);
+                slaveSalManager.registerSlaveMountPoint(result, deviceRpcService, masterReference);
             }
 
             @Override
@@ -276,7 +275,7 @@ public class NetconfNodeActor extends UntypedActor {
         return new ProxyDOMRpcService(setup.getActorSystem(), masterReference, id, actorResponseWaitTime);
     }
 
-    private CheckedFuture<SchemaContext, SchemaResolutionException> getSchemaContext(final ActorRef masterReference) {
+    private ListenableFuture<SchemaContext> getSchemaContext(final ActorRef masterReference) {
 
         final RemoteYangTextSourceProvider remoteYangTextSourceProvider =
                 new ProxyYangTextSourceProvider(masterReference, getContext(), actorResponseWaitTime);
index 777140cd4fc2974fdc4e9f6aad71d09a62ad3b7c..efa471360897b34409b592ed8a7bd6625d192fe7 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.netconf.topology.singleton.messages.transactions.ReadAct
 /**
  * ReadTransactionActor is an interface to device's {@link DOMDataReadOnlyTransaction} for cluster nodes.
  */
-public class ReadTransactionActor extends UntypedActor {
+public final class ReadTransactionActor extends UntypedActor {
 
     private final ReadAdapter readAdapter;
 
index 1c263c019158075106c5f782061450a640d39cf7..229cdf528c95b7c93613e3962ec0ffada164a13f 100644 (file)
@@ -18,7 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.duration.Duration;
 
-public class ReadWriteTransactionActor extends UntypedActor {
+public final class ReadWriteTransactionActor extends UntypedActor {
 
     private static final Logger LOG = LoggerFactory.getLogger(ReadWriteTransactionActor.class);
 
index 8a1f53af5297a0772d4e8ca3f80656c1fbe532a4..a1305dbab201017820ae49e818a1873df8eb5c07 100644 (file)
@@ -21,7 +21,7 @@ import scala.concurrent.duration.Duration;
 /**
  * WriteTransactionActor is an interface to device's {@link DOMDataReadOnlyTransaction} for cluster nodes.
  */
-public class WriteTransactionActor extends UntypedActor {
+public final class WriteTransactionActor extends UntypedActor {
 
     private static final Logger LOG = LoggerFactory.getLogger(WriteTransactionActor.class);
 
index 6eb78007afab6f9a9ec1e28daac7e3d7fccc1f84..65daa1544e28edddb8fe7066a2b85f47ff2bf812 100644 (file)
@@ -41,7 +41,7 @@ public class NetconfTopologySetup {
     private final String privateKeyPassphrase;
     private final AAAEncryptionService encryptionService;
 
-    private NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
+    NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
         this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
         this.rpcProviderRegistry = builder.getRpcProviderRegistry();
         this.dataBroker = builder.getDataBroker();
index 1324e8ad44d7c3025c9fcb8403797397dff06bcf..dae2c40d80b02d4885df3e6589a5001f2fcc85a8 100644 (file)
@@ -37,11 +37,11 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfTopologyUtils {
+public final class NetconfTopologyUtils {
     private static Logger LOG = LoggerFactory.getLogger(NetconfTopologyUtils.class);
 
     private static final String DEFAULT_SCHEMA_REPOSITORY_NAME = "sal-netconf-connector";
@@ -102,6 +102,10 @@ public class NetconfTopologyUtils {
                 TextToASTTransformer.create(DEFAULT_SCHEMA_REPOSITORY, DEFAULT_SCHEMA_REPOSITORY));
     }
 
+    private NetconfTopologyUtils() {
+
+    }
+
     public static NetconfDevice.SchemaResourcesDTO setupSchemaCacheDTO(final Node node) {
         final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
         final String moduleSchemaCacheDirectory = netconfNode.getSchemaCacheDirectory();
index 4e50b34943c0adb019b3a1c6ca1231fed336ada5..485f3c506beed160d9062ed208fda31b50a016a7 100644 (file)
@@ -29,12 +29,12 @@ import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import com.google.common.net.InetAddresses;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -81,6 +81,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
@@ -166,7 +167,7 @@ public class NetconfNodeActorTest {
 
         final DOMDataBroker domDataBroker = mock(DOMDataBroker.class);
         final List<SourceIdentifier> sourceIdentifiers =
-                Lists.newArrayList(RevisionSourceIdentifier.create("testID", Optional.absent()));
+                Lists.newArrayList(RevisionSourceIdentifier.create("testID"));
 
         // init master data
 
@@ -198,12 +199,12 @@ public class NetconfNodeActorTest {
         final RevisionSourceIdentifier yang2 = RevisionSourceIdentifier.create("yang2");
         final SchemaSourceRegistry registry = mock(SchemaSourceRegistry.class);
         final SchemaRepository schemaRepository = mock(SchemaRepository.class);
-        final SchemaSourceRegistration regYang1 = mock(SchemaSourceRegistration.class);
-        final SchemaSourceRegistration regYang2 = mock(SchemaSourceRegistration.class);
+        final SchemaSourceRegistration<?> regYang1 = mock(SchemaSourceRegistration.class);
+        final SchemaSourceRegistration<?> regYang2 = mock(SchemaSourceRegistration.class);
         doReturn(regYang1).when(registry).registerSchemaSource(any(), withSourceId(yang1));
         doReturn(regYang2).when(registry).registerSchemaSource(any(), withSourceId(yang2));
         final SchemaContextFactory schemaContextFactory = mock(SchemaContextFactory.class);
-        doReturn(schemaContextFactory).when(schemaRepository).createSchemaContextFactory(any());
+        doReturn(schemaContextFactory).when(schemaRepository).createSchemaContextFactory(any(SchemaSourceFilter.class));
         final SettableFuture<SchemaContext> schemaContextFuture = SettableFuture.create();
         final CheckedFuture<SchemaContext, SchemaResolutionException> checkedFuture =
                 Futures.makeChecked(schemaContextFuture, e -> new SchemaResolutionException("fail", e));
@@ -227,7 +228,7 @@ public class NetconfNodeActorTest {
     @Test
     public void testYangTextSchemaSourceRequestMessage() throws Exception {
         final SchemaRepository schemaRepository = mock(SchemaRepository.class);
-        final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("testID", Optional.absent());
+        final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("testID");
         final Props props = NetconfNodeActor.props(mock(NetconfTopologySetup.class), remoteDeviceId,
                 DEFAULT_SCHEMA_REPOSITORY, schemaRepository, TIMEOUT, mountPointService);
 
@@ -253,8 +254,7 @@ public class NetconfNodeActorTest {
         };
 
 
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> result =
-                Futures.immediateCheckedFuture(yangTextSchemaSource);
+        final ListenableFuture<YangTextSchemaSource> result = Futures.immediateFuture(yangTextSchemaSource);
 
         doReturn(result).when(schemaRepository).getSchemaSource(sourceIdentifier, YangTextSchemaSource.class);
 
@@ -290,7 +290,7 @@ public class NetconfNodeActorTest {
 
         final DOMDataBroker domDataBroker = mock(DOMDataBroker.class);
         final List<SourceIdentifier> sourceIdentifiers =
-                Lists.newArrayList(RevisionSourceIdentifier.create("testID", Optional.absent()));
+                Lists.newArrayList(RevisionSourceIdentifier.create("testID"));
 
         // init master data
 
@@ -307,10 +307,11 @@ public class NetconfNodeActorTest {
         final ProxyDOMRpcService slaveDomRPCService =
                 new ProxyDOMRpcService(system, masterRef, remoteDeviceId, TIMEOUT);
 
-        final SchemaPath schemaPath = SchemaPath.create(true, QName.create("TestQname"));
+        final QName testQName = QName.create("", "TestQname");
+        final SchemaPath schemaPath = SchemaPath.create(true, testQName);
         final NormalizedNode<?, ?> outputNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("TestQname")))
-                .withChild(ImmutableNodes.leafNode(QName.create("NodeQname"), "foo")).build();
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(testQName))
+                .withChild(ImmutableNodes.leafNode(testQName, "foo")).build();
         final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.RPC, null, "Rpc invocation failed.");
         // EmptyResultResponse message
 
index 5855dd44b93bbbfe612178ef50631e9639238f6a..d4432d185d11339474dc36538cd0750b67745473 100644 (file)
@@ -219,8 +219,6 @@ public class RemoteDeviceConnectorImplTest {
                 .setKeepaliveDelay(1L)
                 .build();
 
-        final RemoteDeviceId remoteDeviceId = new RemoteDeviceId(TOPOLOGY_ID,
-                new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
         final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(NetconfNode.class, netconfNode).build();
         builder.setSchemaResourceDTO(NetconfTopologyUtils.setupSchemaCacheDTO(node));
 
index 30d279aef4ee5fb96126a6f04e45439253159838..d41e6955f80fe55fff8aa7dd2404044dfce46880 100644 (file)
@@ -61,7 +61,7 @@ public class ReadTransactionActorTest {
     @Test
     public void testRead() throws Exception {
         final ContainerNode node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         when(deviceReadTx.read(STORE, PATH)).thenReturn(Futures.immediateCheckedFuture(Optional.of(node)));
         actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
index e9eee1851a2aaf77d286679927df98f303c05869..2ccf8744497b6e590d23556e47f700fad48f33ed 100644 (file)
@@ -47,7 +47,6 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
@@ -64,7 +63,7 @@ public class ReadWriteTransactionActorTest {
     private TestProbe probe;
     private ActorSystem system;
     private TestActorRef<WriteTransactionActor> actorRef;
-    private NormalizedNode<?, ?> node;
+    private ContainerNode node;
 
     @Before
     public void setUp() throws Exception {
@@ -72,7 +71,7 @@ public class ReadWriteTransactionActorTest {
         system = ActorSystem.apply();
         probe = TestProbe.apply(system);
         node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         actorRef = TestActorRef.create(system, ReadWriteTransactionActor.props(deviceReadWriteTx,
                 Duration.apply(2, TimeUnit.SECONDS)), "testA");
@@ -85,9 +84,6 @@ public class ReadWriteTransactionActorTest {
 
     @Test
     public void testRead() throws Exception {
-        final ContainerNode node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
-                .build();
         when(deviceReadWriteTx.read(STORE, PATH)).thenReturn(Futures.immediateCheckedFuture(Optional.of(node)));
         actorRef.tell(new ReadRequest(STORE, PATH), probe.ref());
         verify(deviceReadWriteTx).read(STORE, PATH);
@@ -182,9 +178,9 @@ public class ReadWriteTransactionActorTest {
 
     @Test
     public void testIdleTimeout() throws Exception {
-        final TestProbe probe = new TestProbe(system);
-        probe.watch(actorRef);
+        final TestProbe testProbe = new TestProbe(system);
+        testProbe.watch(actorRef);
         verify(deviceReadWriteTx, timeout(3000)).cancel();
-        probe.expectTerminated(actorRef, TIMEOUT.duration());
+        testProbe.expectTerminated(actorRef, TIMEOUT.duration());
     }
-}
\ No newline at end of file
+}
index cd2b9829142bc96d15a44bbb1066eb1a81d12262..e21ec46e9c6cbb7dc9f6c5641729426a79729aaa 100644 (file)
@@ -65,7 +65,7 @@ public class WriteTransactionActorTest {
         system = ActorSystem.apply();
         probe = TestProbe.apply(system);
         node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         actorRef = TestActorRef.create(system, WriteTransactionActor.props(deviceWriteTx,
                 Duration.apply(2, TimeUnit.SECONDS)), "testA");
@@ -130,10 +130,10 @@ public class WriteTransactionActorTest {
 
     @Test
     public void testIdleTimeout() throws Exception {
-        final TestProbe probe = new TestProbe(system);
-        probe.watch(actorRef);
+        final TestProbe testProbe = new TestProbe(system);
+        testProbe.watch(actorRef);
         verify(deviceWriteTx, timeout(3000)).cancel();
-        probe.expectTerminated(actorRef, TIMEOUT.duration());
+        testProbe.expectTerminated(actorRef, TIMEOUT.duration());
     }
 
-}
\ No newline at end of file
+}
index df4be27b7726f24859324b3d820324500c6f7942..b9a1bad196dde7b5ad24a1c3a9be78fa3befae98 100644 (file)
@@ -49,7 +49,7 @@ public class ProxyReadTransactionTest {
         masterActor = new TestProbe(system);
         final RemoteDeviceId id = new RemoteDeviceId("dev1", InetSocketAddress.createUnresolved("localhost", 17830));
         node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         tx = new ProxyReadTransaction(masterActor.ref(), id, system, Timeout.apply(5, TimeUnit.SECONDS));
     }
index a24f2b124a1ce16090b5069c107f280cc7e75229..30a6867f1a0189177b1a963645a3ebfd3eb4a2fd 100644 (file)
@@ -61,7 +61,7 @@ public class ProxyReadWriteTransactionTest {
         masterActor = new TestProbe(system);
         final RemoteDeviceId id = new RemoteDeviceId("dev1", InetSocketAddress.createUnresolved("localhost", 17830));
         node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         tx = new ProxyReadWriteTransaction(masterActor.ref(), id, system, Timeout.apply(5, TimeUnit.SECONDS));
     }
index 05ad6be8dd82cd92becafcd30f693ab79f1f4cad..b51375b14558803e1c873c358b01b04407e87f5a 100644 (file)
@@ -53,7 +53,7 @@ public class ProxyWriteTransactionTest {
         masterActor = new TestProbe(system);
         final RemoteDeviceId id = new RemoteDeviceId("dev1", InetSocketAddress.createUnresolved("localhost", 17830));
         node = Builders.containerBuilder()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("cont")))
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont")))
                 .build();
         tx = new ProxyWriteTransaction(masterActor.ref(), id, system, Timeout.apply(5, TimeUnit.SECONDS));
     }
@@ -73,10 +73,10 @@ public class ProxyWriteTransactionTest {
 
     @Test
     public void testCancelSubmitted() throws Exception {
-        final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
+        final ListenableFuture<Void> submitFuture = tx.submit();
         masterActor.expectMsgClass(SubmitRequest.class);
         masterActor.reply(new SubmitReply());
-        submitFuture.checkedGet();
+        submitFuture.get();
         final Future<Boolean> submit = Executors.newSingleThreadExecutor().submit(() -> tx.cancel());
         masterActor.expectNoMsg();
         Assert.assertFalse(submit.get());
@@ -84,18 +84,18 @@ public class ProxyWriteTransactionTest {
 
     @Test
     public void testSubmit() throws Exception {
-        final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
+        final ListenableFuture<Void> submitFuture = tx.submit();
         masterActor.expectMsgClass(SubmitRequest.class);
         masterActor.reply(new SubmitReply());
-        submitFuture.checkedGet();
+        submitFuture.get();
     }
 
     @Test
     public void testDoubleSubmit() throws Exception {
-        final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
+        final ListenableFuture<Void> submitFuture = tx.submit();
         masterActor.expectMsgClass(SubmitRequest.class);
         masterActor.reply(new SubmitReply());
-        submitFuture.checkedGet();
+        submitFuture.get();
         try {
             tx.submit().checkedGet();
             Assert.fail("Should throw IllegalStateException");
index 366a75b26752893f5a997edd0ed25967aaf67d7a..825a812f0354e4b08c7d4322647b9db496344889 100644 (file)
@@ -119,8 +119,8 @@ public class ReadOnlyTransactionTest {
     public void testRead() throws Exception {
         // Message: NormalizedNodeMessage
         final NormalizedNode<?, ?> outputNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("TestQname")))
-                .withChild(ImmutableNodes.leafNode(QName.create("NodeQname"), "foo")).build();
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "TestQname")))
+                .withChild(ImmutableNodes.leafNode(QName.create("", "NodeQname"), "foo")).build();
         final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> resultNormalizedNodeMessage =
                 Futures.immediateCheckedFuture(Optional.of(outputNode));
         doReturn(resultNormalizedNodeMessage).when(readTx).read(storeType, instanceIdentifier);
@@ -147,7 +147,7 @@ public class ReadOnlyTransactionTest {
                         instanceIdentifier);
 
         final Optional<NormalizedNode<?, ?>> resultEmptyMessage =
-                resultEmptyResponse.checkedGet(TIMEOUT_SEC, TimeUnit.SECONDS);
+                resultEmptyResponse.get(TIMEOUT_SEC, TimeUnit.SECONDS);
 
         assertEquals(resultEmptyMessage, Optional.absent());
     }
index ccf2d59660ed1470c4121f9efd20af71ae2aacf7..441a4caaa3a708432233650c051625ac80843a60 100644 (file)
@@ -115,8 +115,8 @@ public class ReadWriteTransactionTest {
                 new ProxyDOMDataBroker(system, remoteDeviceId, masterRef, Timeout.apply(5, TimeUnit.SECONDS));
         initializeDataTest();
         testNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("TestQname")))
-                .withChild(ImmutableNodes.leafNode(QName.create("NodeQname"), "foo")).build();
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "TestQname")))
+                .withChild(ImmutableNodes.leafNode(QName.create("", "NodeQname"), "foo")).build();
         instanceIdentifier = YangInstanceIdentifier.EMPTY;
         storeType = LogicalDatastoreType.CONFIGURATION;
     }
@@ -151,15 +151,12 @@ public class ReadWriteTransactionTest {
 
     @Test
     public void testDelete() throws Exception {
-        final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.EMPTY;
-        final LogicalDatastoreType storeType = LogicalDatastoreType.CONFIGURATION;
-
         // Test of invoking delete on master through slave proxy
         final DOMDataWriteTransaction wTx = slaveDataBroker.newReadWriteTransaction();
-        wTx.delete(storeType, instanceIdentifier);
+        wTx.delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
         wTx.cancel();
 
-        verify(readWriteTx, timeout(2000)).delete(storeType, instanceIdentifier);
+        verify(readWriteTx, timeout(2000)).delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
     }
 
     @Test
@@ -240,8 +237,8 @@ public class ReadWriteTransactionTest {
     public void testRead() throws Exception {
         // Message: NormalizedNodeMessage
         final NormalizedNode<?, ?> outputNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("TestQname")))
-                .withChild(ImmutableNodes.leafNode(QName.create("NodeQname"), "foo")).build();
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "TestQname")))
+                .withChild(ImmutableNodes.leafNode(QName.create("", "NodeQname"), "foo")).build();
         final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> resultNormalizedNodeMessage =
                 Futures.immediateCheckedFuture(Optional.of(outputNode));
         doReturn(resultNormalizedNodeMessage).when(readWriteTx).read(storeType, instanceIdentifier);
index 6267e73dbcf9d1261deed659dd18976bb5ff613a..a13c9536254e6101c2b21f2bcf22fea53e1f2ae2 100644 (file)
@@ -116,8 +116,8 @@ public class WriteOnlyTransactionTest {
                 new ProxyDOMDataBroker(system, remoteDeviceId, masterRef, Timeout.apply(5, TimeUnit.SECONDS));
         initializeDataTest();
         testNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("TestQname")))
-                .withChild(ImmutableNodes.leafNode(QName.create("NodeQname"), "foo")).build();
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "TestQname")))
+                .withChild(ImmutableNodes.leafNode(QName.create("", "NodeQname"), "foo")).build();
         instanceIdentifier = YangInstanceIdentifier.EMPTY;
         storeType = LogicalDatastoreType.CONFIGURATION;
     }
@@ -152,15 +152,12 @@ public class WriteOnlyTransactionTest {
 
     @Test
     public void testDelete() throws Exception {
-        final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.EMPTY;
-        final LogicalDatastoreType storeType = LogicalDatastoreType.CONFIGURATION;
-
         // Test of invoking delete on master through slave proxy
         final DOMDataWriteTransaction wTx = slaveDataBroker.newWriteOnlyTransaction();
-        wTx.delete(storeType, instanceIdentifier);
+        wTx.delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
         wTx.cancel();
 
-        verify(writeTx, timeout(2000)).delete(storeType, instanceIdentifier);
+        verify(writeTx, timeout(2000)).delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
     }
 
     @Test
index d620c473d4203971e31108d3985e39237c83c7ca..a76c9561ac3328a9bdc2c5ffb7d4222d0db2d762 100644 (file)
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -41,7 +41,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index ebd5795821592ea0495c799f0d4d90cde87e1a80..df3eff0976e846a854bbe2f0ad66880ed54674a7 100644 (file)
@@ -82,7 +82,7 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -389,14 +389,14 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
      */
     private NetconfDevice.SchemaResourcesDTO createSchemaResourcesDTO(final String moduleSchemaCacheDirectory) {
         final SharedSchemaRepository repository = new SharedSchemaRepository(moduleSchemaCacheDirectory);
-        final SchemaContextFactory schemaContextFactory
+        final SchemaContextFactory contextFactory
                 = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
         setSchemaRegistry(repository);
-        setSchemaContextFactory(schemaContextFactory);
+        setSchemaContextFactory(contextFactory);
         final FilesystemSchemaSourceCache<YangTextSchemaSource> deviceCache =
                 createDeviceFilesystemCache(moduleSchemaCacheDirectory);
         repository.registerSchemaSourceListener(deviceCache);
-        return new NetconfDevice.SchemaResourcesDTO(repository, repository, schemaContextFactory,
+        return new NetconfDevice.SchemaResourcesDTO(repository, repository, contextFactory,
                 new NetconfStateSchemasResolverImpl());
     }
 
@@ -416,14 +416,14 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
     /**
      * Sets the private key path from location specified in configuration file using blueprint.
      */
-    public void setPrivateKeyPath(String privateKeyPath) {
+    public void setPrivateKeyPath(final String privateKeyPath) {
         this.privateKeyPath = privateKeyPath;
     }
 
     /**
      * Sets the private key passphrase from location specified in configuration file using blueprint.
      */
-    public void setPrivateKeyPassphrase(String privateKeyPassphrase) {
+    public void setPrivateKeyPassphrase(final String privateKeyPassphrase) {
         this.privateKeyPassphrase = privateKeyPassphrase;
     }
 
index 98a8bdacc19895f3978c0b5ea2cc2c9851cc9364..35c213373728d26d0e3e7a25137fb2be8609ab3b 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -34,7 +34,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 1067da9d91a619dfad978dd8b3b44945e551b57e..f9dab601821fd0d816c46a52075eacd354adca7f 100644 (file)
@@ -5,10 +5,12 @@
  * 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.util;
 
-public class CloseableUtil {
+public final class CloseableUtil {
+    private CloseableUtil() {
+
+    }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static void closeAll(Iterable<? extends AutoCloseable> autoCloseables) throws Exception {
index 4f6d852e69ff5ede136e6de883331d3bba11e762..373d7095b5b62f01d7d04fa93bc7348f1b55a1ea 100644 (file)
@@ -25,9 +25,13 @@ import org.w3c.dom.Node;
 /**
  * See <a href="http://tools.ietf.org/html/rfc6241#section-6">rfc6241</a> for details.
  */
-public class SubtreeFilter {
+public final class SubtreeFilter {
     private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilter.class);
 
+    private SubtreeFilter() {
+
+    }
+
     public static Document applyRpcSubtreeFilter(Document requestDocument,
                                                  Document rpcReply) throws DocumentedException {
         OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
index ed51ae000e592701a5abd8e996d34ada6beb7a55..d62d40df5ecb2acd16e1f37f69c8c284d868231e 100644 (file)
@@ -20,7 +20,11 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-public class XmlFileLoader {
+public final class XmlFileLoader {
+
+    private XmlFileLoader() {
+
+    }
 
     public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
             ParserConfigurationException {
index 9ce2be2013e3c5e7ad11d7ceb0d8a5717ae5fa12..6677a42c8f18948eadb9c20c863e159e753a16b2 100644 (file)
@@ -22,7 +22,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
-public class XmlUnitUtil {
+public final class XmlUnitUtil {
 
     private XmlUnitUtil() {}
 
index 5e24837ccc49163815f712a9282d90569cab48a6..ad25af12302f486532b99ae734c32403e50b9a7e 100644 (file)
@@ -13,7 +13,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index a3e258248d8808ccb93dadaca3b309459eec5618..68fb36018b7e26cd2a8da7921b0c536b0323efe5 100644 (file)
@@ -13,7 +13,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
@@ -30,6 +29,7 @@ import java.net.URLConnection;
 import java.util.AbstractMap;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.regex.Pattern;
@@ -45,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.librar
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -71,7 +72,7 @@ import org.w3c.dom.Node;
  * Holds URLs with YANG schema resources for all yang modules reported in
  * ietf-netconf-yang-library/modules-state/modules node.
  */
-public class LibraryModulesSchemas implements NetconfDeviceSchemas {
+public final class LibraryModulesSchemas implements NetconfDeviceSchemas {
 
     private static final Logger LOG = LoggerFactory.getLogger(LibraryModulesSchemas.class);
     private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})");
@@ -106,7 +107,7 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
         final Map<SourceIdentifier, URL> result = Maps.newHashMap();
         for (final Map.Entry<QName, URL> entry : availableModels.entrySet()) {
             final SourceIdentifier sId = RevisionSourceIdentifier
-                .create(entry.getKey().getLocalName(), Optional.fromNullable(entry.getKey().getFormattedRevision()));
+                .create(entry.getKey().getLocalName(), entry.getKey().getRevision());
             result.put(sId, entry.getValue());
         }
 
@@ -170,11 +171,11 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
         if (modulesStateNode.isPresent()) {
             Preconditions.checkState(modulesStateNode.get() instanceof ContainerNode,
                     "Expecting container containing schemas, but was %s", modulesStateNode.get());
-            return create(((ContainerNode) modulesStateNode.get()));
-        } else {
-            LOG.warn("{}: Unable to detect available schemas, get to {} was empty", deviceId, toId(ModulesState.QNAME));
-            return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+            return create((ContainerNode) modulesStateNode.get());
         }
+
+        LOG.warn("{}: Unable to detect available schemas, get to {} was empty", deviceId, toId(ModulesState.QNAME));
+        return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
     }
 
     private static LibraryModulesSchemas create(final ContainerNode modulesStateNode) {
@@ -224,12 +225,12 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
 
     private static Optional<? extends NormalizedNode<?, ?>> findModulesStateNode(final NormalizedNode<?, ?> result) {
         if (result == null) {
-            return Optional.absent();
+            return Optional.empty();
         }
         final Optional<DataContainerChild<?, ?>> dataNode =
                 ((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME));
         if (dataNode.isPresent() == false) {
-            return Optional.absent();
+            return Optional.empty();
         }
 
         return ((DataContainerNode<?>) dataNode.get()).getChild(toId(ModulesState.QNAME));
@@ -305,8 +306,7 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
 
         jsonParser.parse(reader);
 
-        return resultHolder.isFinished()
-                ? Optional.of(resultHolder.getResult()) : Optional.<NormalizedNode<?, ?>>absent();
+        return resultHolder.isFinished() ? Optional.of(resultHolder.getResult()) : Optional.empty();
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
@@ -342,7 +342,7 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
             LOG.warn("Unable to parse yang library xml content", e);
         }
 
-        return Optional.<NormalizedNode<?, ?>>absent();
+        return Optional.empty();
     }
 
     private static Optional<Map.Entry<QName, URL>> createFromEntry(final MapEntryNode moduleNode) {
@@ -356,9 +356,9 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
         childNodeId = new YangInstanceIdentifier.NodeIdentifier(QName.create(Module.QNAME, "revision"));
         final Optional<String> revision = getSingleChildNodeValue(moduleNode, childNodeId);
         if (revision.isPresent()) {
-            if (!SourceIdentifier.REVISION_PATTERN.matcher(revision.get()).matches()) {
+            if (!Revision.STRING_FORMAT_PATTERN.matcher(revision.get()).matches()) {
                 LOG.warn("Skipping library schema for {}. Revision {} is in wrong format.", moduleNode, revision.get());
-                return Optional.<Map.Entry<QName, URL>>absent();
+                return Optional.empty();
             }
         }
 
@@ -372,7 +372,7 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
 
         final QName moduleQName = revision.isPresent()
                 ? QName.create(moduleNameSpace, revision.get(), moduleName)
-                : QName.create(URI.create(moduleNameSpace), null, moduleName);
+                : QName.create(URI.create(moduleNameSpace), moduleName);
 
         try {
             return Optional.<Map.Entry<QName, URL>>of(new AbstractMap.SimpleImmutableEntry<>(
@@ -380,7 +380,7 @@ public class LibraryModulesSchemas implements NetconfDeviceSchemas {
         } catch (final MalformedURLException e) {
             LOG.warn("Skipping library schema for {}. URL {} representing yang schema resource is not valid",
                     moduleNode, schemaUriAsString.get());
-            return Optional.<Map.Entry<QName, URL>>absent();
+            return Optional.empty();
         }
     }
 
@@ -395,8 +395,8 @@ public 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.<String>absent() : Optional.of(value.toString().trim());
+        return value == null || Strings.isNullOrEmpty(value.toString()) ? Optional.empty()
+                : Optional.of(value.toString().trim());
     }
 
     @Override
index 22fa4cb92ed49cbd25c38ed9fa119b3f814b0783..2dc16331726e2857897b372bcd55745e3ad36daa 100644 (file)
@@ -26,6 +26,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.stream.Collectors;
 import javax.annotation.concurrent.GuardedBy;
@@ -60,7 +61,6 @@ import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -68,7 +68,7 @@ import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
-import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -431,8 +431,7 @@ public class NetconfDevice
         }
 
         private static SourceIdentifier toSourceId(final QName input) {
-            return RevisionSourceIdentifier.create(input.getLocalName(),
-                Optional.fromNullable(input.getFormattedRevision()));
+            return RevisionSourceIdentifier.create(input.getLocalName(), input.getRevision());
         }
     }
 
@@ -467,15 +466,13 @@ public class NetconfDevice
         }
 
         private Collection<SourceIdentifier> filterMissingSources(final Collection<SourceIdentifier> requiredSources) {
-
             return requiredSources.parallelStream().filter(sourceIdentifier -> {
-                boolean remove = false;
                 try {
-                    schemaRepository.getSchemaSource(sourceIdentifier, ASTSchemaSource.class).checkedGet();
-                } catch (SchemaSourceException e) {
-                    remove = true;
+                    schemaRepository.getSchemaSource(sourceIdentifier, ASTSchemaSource.class).get();
+                    return false;
+                } catch (InterruptedException | ExecutionException e) {
+                    return true;
                 }
-                return remove;
             }).collect(Collectors.toList());
         }
 
@@ -487,9 +484,9 @@ public class NetconfDevice
             while (!requiredSources.isEmpty()) {
                 LOG.trace("{}: Trying to build schema context from {}", id, requiredSources);
                 try {
-                    final CheckedFuture<SchemaContext, SchemaResolutionException> schemaBuilderFuture =
-                            schemaContextFactory.createSchemaContext(requiredSources);
-                    final SchemaContext result = schemaBuilderFuture.checkedGet();
+                    final ListenableFuture<SchemaContext> schemaBuilderFuture = schemaContextFactory
+                            .createSchemaContext(requiredSources);
+                    final SchemaContext result = schemaBuilderFuture.get();
                     LOG.debug("{}: Schema context built successfully from {}", id, requiredSources);
                     final Collection<QName> filteredQNames = Sets.difference(deviceSources.getRequiredSourcesQName(),
                             capabilities.getUnresolvedCapabilites().keySet());
@@ -506,16 +503,24 @@ public class NetconfDevice
 
                     handleSalInitializationSuccess(result, remoteSessionCapabilities, getDeviceSpecificRpc(result));
                     return;
-                } catch (final SchemaResolutionException e) {
+                } catch (final ExecutionException e) {
                     // schemaBuilderFuture.checkedGet() throws only SchemaResolutionException
                     // that might be wrapping a MissingSchemaSourceException so we need to look
                     // at the cause of the exception to make sure we don't misinterpret it.
-                    if (e.getCause() instanceof MissingSchemaSourceException) {
+                    final Throwable cause = e.getCause();
+
+                    if (cause instanceof MissingSchemaSourceException) {
                         requiredSources = handleMissingSchemaSourceException(
                                 requiredSources, (MissingSchemaSourceException) e.getCause());
                         continue;
                     }
-                    requiredSources = handleSchemaResolutionException(requiredSources, e);
+                    if (cause instanceof SchemaResolutionException) {
+                        requiredSources = handleSchemaResolutionException(requiredSources,
+                            (SchemaResolutionException) cause);
+                    } else {
+                        handleSalInitializationFailure(e, listener);
+                        return;
+                    }
                 } catch (final Exception e) {
                     // unknown error, fail
                     handleSalInitializationFailure(e, listener);
@@ -602,12 +607,7 @@ public class NetconfDevice
                     continue;
                 }
 
-                final String rev = getNullableRev(identifier);
-                if (rev == null) {
-                    if (qname.getRevision() == null) {
-                        return qname;
-                    }
-                } else if (qname.getFormattedRevision().equals(rev)) {
+                if (identifier.getRevision().equals(qname.getRevision())) {
                     return qname;
                 }
             }
@@ -617,10 +617,5 @@ public class NetconfDevice
             // this capability will be removed from required sources and not reported as unresolved-capability
             return null;
         }
-
-        private String getNullableRev(final SourceIdentifier identifier) {
-            final String rev = identifier.getRevision();
-            return rev == null || SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(rev) ? null : rev;
-        }
     }
 }
index f5ae6935b5023f8d7661c5f857b86fe4dfe51643..6ce2d0f145a79ee4de95997792205a6a91ee7e18 100644 (file)
@@ -14,13 +14,13 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Sets;
 import java.net.URI;
 import java.util.Collections;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
@@ -154,18 +154,18 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
     private static Optional<? extends NormalizedNode<?, ?>> findSchemasNode(final NormalizedNode<?, ?> result) {
         if (result == null) {
-            return Optional.absent();
+            return Optional.empty();
         }
         final Optional<DataContainerChild<?, ?>> dataNode =
                 ((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME));
         if (!dataNode.isPresent()) {
-            return Optional.absent();
+            return Optional.empty();
         }
 
         final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> nStateNode =
                 ((DataContainerNode<?>) dataNode.get()).getChild(toId(NetconfState.QNAME));
         if (!nStateNode.isPresent()) {
-            return Optional.absent();
+            return Optional.empty();
         }
 
         return ((DataContainerNode<?>) nStateNode.get()).getChild(toId(Schemas.QNAME));
@@ -193,21 +193,21 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
             if (!formatAsString.equals(Yang.QNAME.toString())) {
                 LOG.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString);
-                return Optional.absent();
+                return Optional.empty();
             }
 
             childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_LOCATION;
             final Set<String> locationsAsString = getAllChildNodeValues(schemaNode, childNode);
             if (!locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString())) {
                 LOG.debug("{}: Ignoring schema due to unsupported location: {}", id, locationsAsString);
-                return Optional.absent();
+                return Optional.empty();
             }
 
             childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE;
             final Optional<String> namespaceValue = getSingleChildNodeValue(schemaNode, childNode);
             if (!namespaceValue.isPresent()) {
                 LOG.warn("{}: Ignoring schema due to missing namespace", id);
-                return Optional.absent();
+                return Optional.empty();
             }
             final String namespaceAsString = namespaceValue.get();
 
@@ -220,7 +220,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
             final QName moduleQName = revisionAsString.isPresent()
                     ? QName.create(namespaceAsString, revisionAsString.get(), moduleNameAsString)
-                    : QName.create(URI.create(namespaceAsString), null, moduleNameAsString);
+                    : QName.create(URI.create(namespaceAsString), moduleNameAsString);
 
             return Optional.of(new RemoteYangSchema(moduleQName));
         }
@@ -250,7 +250,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
                 return getValueOfSimpleNode(node.get());
             } else {
                 LOG.debug("Child node {} not present", childNode);
-                return Optional.absent();
+                return Optional.empty();
             }
         }
 
@@ -258,7 +258,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
                 final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {
             final Object value = node.getValue();
             return value == null || Strings.isNullOrEmpty(value.toString())
-                    ? Optional.<String>absent() : Optional.of(value.toString().trim());
+                    ? Optional.empty() : Optional.of(value.toString().trim());
         }
 
         @Override
index 7db88e0d048baa09be115d015f3e0eaba8153509..28dc94ed49656a8d45a6df6f9cc5626c73b59e3d 100644 (file)
@@ -50,10 +50,10 @@ final class NotificationHandler {
 
     /**
      * Forward all cached notifications and pass all notifications from this point directly to sal facade.
-     * @param messageTransformer Message transformer
+     * @param transformer Message transformer
      */
-    synchronized void onRemoteSchemaUp(final MessageTransformer<NetconfMessage> messageTransformer) {
-        this.messageTransformer = Preconditions.checkNotNull(messageTransformer);
+    synchronized void onRemoteSchemaUp(final MessageTransformer<NetconfMessage> transformer) {
+        this.messageTransformer = Preconditions.checkNotNull(transformer);
 
         passNotifications = true;
 
@@ -90,8 +90,8 @@ final class NotificationHandler {
         }
     }
 
-    synchronized void addNotificationFilter(final NotificationFilter filter) {
-        this.filter = filter;
+    synchronized void addNotificationFilter(final NotificationFilter newFilter) {
+        this.filter = newFilter;
     }
 
     synchronized void onRemoteSchemaDown() {
index 7c750cc67f97bc7a851fb6e964eabd612aecbf5d..a33115e465283b0fd21b6e1348f80310f6616250 100644 (file)
@@ -13,8 +13,8 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.security.KeyPair;
 import java.util.Optional;
-import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
 import org.opendaylight.aaa.encrypt.PKIUtil;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
@@ -52,7 +52,7 @@ public class DatastoreBackedPublicKeyAuth extends AuthenticationHandler {
     }
 
     @Override
-    public AuthFuture authenticate(ClientSession session) throws IOException {
+    public AuthFuture authenticate(final ClientSession session) throws IOException {
         // if we have keypair set the identity, otherwise retry the retrieval from the adapter
         // if successful set the identity.
         if (keyPair.isPresent() || tryToSetKeyPair()) {
index b55b42f669418683cdbabff42ee349b96cbc6ac6..d8eace1fc99c41f0628030281dc593ca72f1ca43 100644 (file)
@@ -59,7 +59,7 @@ public class NetconfDeviceCommunicator
     private final int concurentRpcMsgs;
 
     private final Queue<Request> requests = new ArrayDeque<>();
-    private NetconfClientSession session;
+    private NetconfClientSession currentSession;
 
     private Future<?> initFuture;
     private final SettableFuture<NetconfDeviceCapabilities> firstConnectionFuture;
@@ -106,7 +106,7 @@ public class NetconfDeviceCommunicator
         sessionLock.lock();
         try {
             LOG.debug("{}: Session established", id);
-            this.session = session;
+            currentSession = session;
 
             NetconfSessionPreferences netconfSessionPreferences =
                                              NetconfSessionPreferences.fromNetconfSession(session);
@@ -167,8 +167,8 @@ public class NetconfDeviceCommunicator
 
     public void disconnect() {
         // If session is already in closing, no need to close it again
-        if (session != null && isSessionClosing.compareAndSet(false, true)) {
-            session.close();
+        if (currentSession != null && isSessionClosing.compareAndSet(false, true)) {
+            currentSession.close();
         }
     }
 
@@ -180,8 +180,8 @@ public class NetconfDeviceCommunicator
         final List<UncancellableFuture<RpcResult<NetconfMessage>>> futuresToCancel = Lists.newArrayList();
         sessionLock.lock();
         try {
-            if (session != null) {
-                session = null;
+            if (currentSession != null) {
+                currentSession = null;
                 /*
                  * Walk all requests, check if they have been executing
                  * or cancelled and remove them from the queue.
@@ -367,7 +367,7 @@ public class NetconfDeviceCommunicator
             LOG.trace("{}: Sending message {}", id, msgToS(message));
         }
 
-        if (session == null) {
+        if (currentSession == null) {
             LOG.warn("{}: Session is disconnected, failing RPC request {}",
                     id, message);
             return Futures.immediateFuture(createSessionDownRpcResult());
@@ -376,7 +376,7 @@ public class NetconfDeviceCommunicator
         final Request req = new Request(new UncancellableFuture<>(true), message);
         requests.add(req);
 
-        session.sendMessage(req.request).addListener(future -> {
+        currentSession.sendMessage(req.request).addListener(future -> {
             if (!future.isSuccess()) {
                 // We expect that a session down will occur at this point
                 LOG.debug("{}: Failed to send request {}", id,
index a08996da909d9db63b76bf0c6e2a3e74ed5a6375..d5383afda7921ce54cc5ec6913f85570b5ba0531 100644 (file)
@@ -37,12 +37,7 @@ public final class NetconfSessionPreferences {
         private final int skipLength;
 
         ParameterMatcher(final String name) {
-            predicate = new Predicate<String>() {
-                @Override
-                public boolean apply(final String input) {
-                    return input.startsWith(name);
-                }
-            };
+            predicate = input -> input.startsWith(name);
 
             this.skipLength = name.length();
         }
@@ -62,12 +57,7 @@ public final class NetconfSessionPreferences {
     private static final ParameterMatcher REVISION_PARAM = new ParameterMatcher("revision=");
     private static final ParameterMatcher BROKEN_REVISON_PARAM = new ParameterMatcher("amp;revision=");
     private static final Splitter AMP_SPLITTER = Splitter.on('&');
-    private static final Predicate<String> CONTAINS_REVISION = new Predicate<String>() {
-        @Override
-        public boolean apply(final String input) {
-            return input.contains("revision=");
-        }
-    };
+    private static final Predicate<String> CONTAINS_REVISION = input -> input.contains("revision=");
 
     private final Map<QName, CapabilityOrigin> moduleBasedCaps;
     private final Map<String, CapabilityOrigin> nonModuleCaps;
@@ -218,7 +208,7 @@ public final class NetconfSessionPreferences {
     }
 
     private static QName cachedQName(final String namespace, final String moduleName) {
-        return QName.create(URI.create(namespace), null, moduleName).withoutRevision().intern();
+        return QName.create(URI.create(namespace), moduleName).withoutRevision().intern();
     }
 
     public static NetconfSessionPreferences fromStrings(final Collection<String> capabilities) {
index e34b885787709215c4c0777741c1c27c4262765d..1b5ae10ec4955b74ecc5660a6ff19deb0cab45ca 100644 (file)
@@ -37,13 +37,14 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
  */
 public final class NetconfDeviceRpc implements DOMRpcService {
 
-    private final RemoteDeviceCommunicator<NetconfMessage> listener;
+    private final RemoteDeviceCommunicator<NetconfMessage> communicator;
     private final MessageTransformer<NetconfMessage> transformer;
     private final Collection<DOMRpcIdentifier> availableRpcs;
 
-    public NetconfDeviceRpc(final SchemaContext schemaContext, final RemoteDeviceCommunicator<NetconfMessage> listener,
-                            final MessageTransformer<NetconfMessage> transformer) {
-        this.listener = listener;
+    public NetconfDeviceRpc(final SchemaContext schemaContext,
+            final RemoteDeviceCommunicator<NetconfMessage> communicator,
+            final MessageTransformer<NetconfMessage> transformer) {
+        this.communicator = communicator;
         this.transformer = transformer;
 
         availableRpcs = Collections2.transform(schemaContext.getOperations(),
@@ -56,7 +57,7 @@ public final class NetconfDeviceRpc implements DOMRpcService {
                                                                   @Nullable final NormalizedNode<?, ?> input) {
         final NetconfMessage message = transformer.toRpcRequest(type, input);
         final ListenableFuture<RpcResult<NetconfMessage>> delegateFutureWithPureResult =
-                listener.sendRequest(message, type.getLastComponent());
+                communicator.sendRequest(message, type.getLastComponent());
 
         final ListenableFuture<DOMRpcResult> transformed =
             Futures.transform(delegateFutureWithPureResult, input1 -> {
index 4ad1dde5fefac226d5ee04bb4853ec132edf51c5..e4d16e9394f4c92d22d7bf7b6dd2bc1e8faed0ca 100644 (file)
@@ -115,8 +115,8 @@ public class NetconfDeviceSalProvider implements AutoCloseable {
         }
 
         public synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
-                                                           final DOMDataBroker broker, final DOMRpcService rpc,
-                                                           final NetconfDeviceNotificationService notificationService) {
+                final DOMDataBroker broker, final DOMRpcService rpc,
+                final NetconfDeviceNotificationService newNotificationService) {
             Preconditions.checkNotNull(mountService, "Closed");
             Preconditions.checkState(topologyRegistration == null, "Already initialized");
 
@@ -126,8 +126,8 @@ public class NetconfDeviceSalProvider implements AutoCloseable {
 
             mountBuilder.addService(DOMDataBroker.class, broker);
             mountBuilder.addService(DOMRpcService.class, rpc);
-            mountBuilder.addService(DOMNotificationService.class, notificationService);
-            this.notificationService = notificationService;
+            mountBuilder.addService(DOMNotificationService.class, newNotificationService);
+            this.notificationService = newNotificationService;
 
             topologyRegistration = mountBuilder.register();
             LOG.debug("{}: TOPOLOGY Mountpoint exposed into MD-SAL {}", id, topologyRegistration);
index 84b824000eacc78103d9874e9bf7a36f97fb0ec1..9701c984105cb0cb7a925005d01a2d1122ad5909 100644 (file)
@@ -11,6 +11,7 @@ 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;
+import com.google.common.util.concurrent.MoreExecutors;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
@@ -82,7 +83,7 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
                 } else {
                     return new DefaultDOMRpcResult(input1.getErrors());
                 }
-            });
+            }, MoreExecutors.directExecutor());
 
         return Futures.makeChecked(transformed,
             e -> new DOMRpcImplementationNotAvailableException(e,
@@ -95,8 +96,7 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
 
     @Nonnull
     @Override
-    public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(
-            @Nonnull final T listener) {
+    public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull final T lsnr) {
         throw new UnsupportedOperationException("Not available for netconf 1.0");
     }
 
index 1d429022c1da73a611224a993030f2f2fa776987..d3f5b1e94de1f7a4e3a3f08fbf0da830050b101d 100644 (file)
@@ -101,7 +101,7 @@ public class WriteCandidateTx extends AbstractWriteTx {
                 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 af51c824ef1883eac9b2252756a1df309afbe351..ddc66fb5f1757080cc1ed4e5feb24b27ad1f76fe 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
@@ -73,7 +74,7 @@ public class WriteRunningTx extends AbstractWriteTx {
     @Override
     public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
         final ListenableFuture<Void> commmitFutureAsVoid = Futures.transform(commit(),
-                (Function<RpcResult<TransactionStatus>, Void>) input -> null);
+                (Function<RpcResult<TransactionStatus>, Void>) input -> null, MoreExecutors.directExecutor());
 
         return Futures.makeChecked(commmitFutureAsVoid,
             input -> new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed",
@@ -102,12 +103,12 @@ public class WriteRunningTx extends AbstractWriteTx {
         netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id));
     }
 
-    private static class Change {
+    private static final class Change {
 
         private final DataContainerChild<?, ?> editStructure;
         private final Optional<ModifyAction> defaultOperation;
 
-        private Change(final DataContainerChild<?, ?> editStructure, final Optional<ModifyAction> defaultOperation) {
+        Change(final DataContainerChild<?, ?> editStructure, final Optional<ModifyAction> defaultOperation) {
             this.editStructure = editStructure;
             this.defaultOperation = defaultOperation;
         }
index 6bb12e7e4b19e083bf6aa6c0748f7c36375650c2..068fc10a5150d0b8065cdc9bf9bcedc89af544a3 100644 (file)
@@ -15,9 +15,9 @@ import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,8 +28,8 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
@@ -40,7 +40,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
@@ -52,14 +51,6 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfRemoteSchemaYangSourceProvider.class);
 
-    private static final ExceptionMapper<SchemaSourceException> MAPPER = new ExceptionMapper<SchemaSourceException>(
-            "schemaDownload", SchemaSourceException.class) {
-        @Override
-        protected SchemaSourceException newWithCause(final String message, final Throwable throwable) {
-            return new SchemaSourceException(message, throwable);
-        }
-    };
-
     private final DOMRpcService rpc;
     private final RemoteDeviceId id;
 
@@ -103,7 +94,7 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource
             return Optional.absent();
         }
 
-        final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child =
+        final java.util.Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child =
                 ((ContainerNode) result).getChild(NETCONF_DATA_PATHARG);
 
         Preconditions.checkState(child.isPresent() && child.get() instanceof AnyXmlNode,
@@ -118,27 +109,19 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource
     }
 
     @Override
-    public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(
-            final SourceIdentifier sourceIdentifier) {
+    public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
         final String moduleName = sourceIdentifier.getName();
 
-        // If formatted revision is SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION, we have to omit it from request
-        final String badRev = sourceIdentifier.getRevision();
-        final String formattedRevision = SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(badRev) ? null : badRev;
-        final Optional<String> revision = Optional.fromNullable(formattedRevision);
+        final Optional<String> revision = Optional.fromJavaUtil(sourceIdentifier.getRevision().map(Revision::toString));
         final NormalizedNode<?, ?> getSchemaRequest = createGetSchemaRequest(moduleName, revision);
 
         LOG.trace("{}: Loading YANG schema source for {}:{}", id, moduleName,
                 revision);
 
-        final ListenableFuture<YangTextSchemaSource> transformed = Futures.transform(
-                rpc.invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), getSchemaRequest),
-                new ResultToYangSourceTransformer(id, sourceIdentifier, moduleName, revision));
-
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> checked =
-                Futures.makeChecked(transformed, MAPPER);
-
-        return checked;
+        return Futures.transform(
+            rpc.invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), getSchemaRequest),
+                new ResultToYangSourceTransformer(id, sourceIdentifier, moduleName, revision),
+                MoreExecutors.directExecutor());
     }
 
     /**
index 33af8ec298be82279c80e9d13b3170eb0a16eaf1..d7d4948e4c4efa22b62aeb6ffd54be6588f89f57 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.netconf.sal.connect.netconf.schema;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -41,15 +41,14 @@ public final class YangLibrarySchemaYangSourceProvider implements SchemaSourcePr
     }
 
     @Override
-    public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
+    public ListenableFuture<? extends YangTextSchemaSource> getSource(
             final SourceIdentifier sourceIdentifier) {
         Preconditions.checkNotNull(sourceIdentifier);
         Preconditions.checkArgument(availableSources.containsKey(sourceIdentifier));
         return download(sourceIdentifier);
     }
 
-    private CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> download(
-            final SourceIdentifier sourceIdentifier) {
+    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));
@@ -57,12 +56,11 @@ public final class YangLibrarySchemaYangSourceProvider implements SchemaSourcePr
                     new NetconfRemoteSchemaYangSourceProvider
                             .NetconfYangTextSchemaSource(id, sourceIdentifier, Optional.of(schemaContent));
             LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
-            return Futures.immediateCheckedFuture(yangSource);
+            return Futures.immediateFuture(yangSource);
         } catch (IOException e) {
             LOG.warn("Unable to download source {} from a yang library's url {}", sourceIdentifier, url, e);
-            return Futures.immediateFailedCheckedFuture(
-                    new SchemaSourceException(
-                            "Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
+            return Futures.immediateFailedFuture(new SchemaSourceException(
+                "Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
         }
     }
 }
index fc31a256aae0a4738bafe139e6f43ab456b94db7..8428a48df63a45d6fb73751b74dffe6f333fa960 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.collect.Multimaps;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.Map;
 import javax.annotation.Nonnull;
@@ -36,6 +35,7 @@ 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;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -121,10 +121,8 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
 
     private static NotificationDefinition getMostRecentNotification(
             final Collection<NotificationDefinition> notificationDefinitions) {
-        Comparator<NotificationDefinition> cmp = (o1, o2) ->
-                o1.getQName().getRevision().compareTo(o2.getQName().getRevision());
-
-        return Collections.max(notificationDefinitions, cmp);
+        return Collections.max(notificationDefinitions, (o1, o2) ->
+            Revision.compare(o1.getQName().getRevision(), o2.getQName().getRevision()));
     }
 
     @Override
index d2cb8d52267daaa3dd419890bf6ad41156c20c81..21835b590329328d50f5e440274dcb7c7d516c3d 100644 (file)
@@ -39,7 +39,8 @@ public class SchemalessMessageTransformer implements MessageTransformer<NetconfM
     // TODO maybe we should move this somewhere else as this
     // might be used in applications using schemaless mountpoints
     public static final YangInstanceIdentifier.NodeIdentifier SCHEMALESS_NOTIFICATION_PAYLOAD =
-            new YangInstanceIdentifier.NodeIdentifier(QName.create("schemaless-notification-payload"));
+            // FIXME: assign proper namespace
+            new YangInstanceIdentifier.NodeIdentifier(QName.create("", "schemaless-notification-payload"));
 
     private final MessageCounter counter;
 
@@ -76,7 +77,7 @@ public class SchemalessMessageTransformer implements MessageTransformer<NetconfM
     public NetconfMessage toRpcRequest(final SchemaPath rpc, final NormalizedNode<?, ?> input) {
         final DOMSource payload = (DOMSource) input.getValue();
         wrapPayload((Document) payload.getNode());
-        return new NetconfMessage(((Document) ((AnyXmlNode) input).getValue().getNode()));
+        return new NetconfMessage((Document) ((AnyXmlNode) input).getValue().getNode());
     }
 
     /**
index 3dee33869ede81d72aa3f8572c8ef43d5f77be8c..71a60bb18efbe22dfe9269361a105440d19ae626 100644 (file)
@@ -27,7 +27,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
@@ -41,6 +40,7 @@ import org.opendaylight.netconf.sal.connect.netconf.sal.SchemalessNetconfDeviceR
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.get.config.input.source.ConfigSource;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -66,8 +66,8 @@ public final class NetconfBaseOps {
         this.rpc = rpc;
         this.schemaContext = schemaContext;
 
-        if ((rpc instanceof KeepaliveDOMRpcService)
-                && (((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc)) {
+        if (rpc instanceof KeepaliveDOMRpcService
+                && ((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc) {
             this.transformer = new SchemalessRpcStructureTransformer();
         } else {
             this.transformer = new NetconfRpcStructureTransformer(schemaContext);
@@ -208,14 +208,14 @@ public final class NetconfBaseOps {
 
     private ListenableFuture<Optional<NormalizedNode<?, ?>>> extractData(
             final Optional<YangInstanceIdentifier> path, final ListenableFuture<DOMRpcResult> configRunning) {
-        return Futures.transform(configRunning, (Function<DOMRpcResult, Optional<NormalizedNode<?, ?>>>) result -> {
+        return Futures.transform(configRunning, result -> {
             Preconditions.checkArgument(
                     result.getErrors().isEmpty(), "Unable to read data: %s, errors: %s", path, result.getErrors());
             final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataNode =
                     ((ContainerNode) result.getResult()).getChild(
                             NetconfMessageTransformUtil.toId(NetconfMessageTransformUtil.NETCONF_DATA_QNAME)).get();
             return transformer.selectFromDataStructure(dataNode, path.get());
-        });
+        }, MoreExecutors.directExecutor());
     }
 
     public ListenableFuture<DOMRpcResult> getConfigRunning(final FutureCallback<DOMRpcResult> callback,
@@ -239,7 +239,7 @@ public final class NetconfBaseOps {
                 NetconfMessageTransformUtil.wrap(NETCONF_GET_QNAME, toFilterStructure(filterPath.get(), schemaContext)))
                 : rpc.invokeRpc(toPath(NETCONF_GET_QNAME), NetconfMessageTransformUtil.GET_RPC_CONTENT);
 
-        Futures.addCallback(future, callback);
+        Futures.addCallback(future, callback, MoreExecutors.directExecutor());
         return future;
     }
 
@@ -322,10 +322,9 @@ public final class NetconfBaseOps {
 
     public static DataContainerChild<?, ?> getSourceNode(final QName datastore) {
         return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_SOURCE_QNAME))
-                .withChild(
-                        Builders.choiceBuilder().withNodeIdentifier(toId(ConfigSource.QNAME)).withChild(
-                                Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build()
-                ).build();
+                .withChild(Builders.choiceBuilder().withNodeIdentifier(toId(ConfigSource.QNAME)).withChild(
+                    Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build())
+                    .build()).build();
     }
 
     public static ContainerNode getLockContent(final QName datastore) {
@@ -335,10 +334,9 @@ public final class NetconfBaseOps {
 
     public static DataContainerChild<?, ?> getTargetNode(final QName datastore) {
         return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_TARGET_QNAME))
-                .withChild(
-                        Builders.choiceBuilder().withNodeIdentifier(toId(ConfigTarget.QNAME)).withChild(
-                                Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build()
-                ).build();
+                .withChild(Builders.choiceBuilder().withNodeIdentifier(toId(ConfigTarget.QNAME)).withChild(
+                    Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build())
+                    .build()).build();
     }
 
     public static NormalizedNode<?, ?> getCopyConfigContent(final QName source, final QName target) {
index 4726b7aaa7f5a23a877682f2ccefa8b00d1f633f..100073ce83a95f0eaa2bf99635f2dc68323f3e6d 100644 (file)
@@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class NetconfMessageTransformUtil {
+public final class NetconfMessageTransformUtil {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageTransformUtil.class);
 
@@ -312,8 +312,8 @@ public class NetconfMessageTransformUtil {
         } else {
             final Entry<QName, ModifyAction> modifyOperation = operation.isPresent()
                     ? new AbstractMap.SimpleEntry<>(NETCONF_OPERATION_QNAME, operation.get()) : null;
-            configContent = ImmutableNodes
-                    .fromInstanceId(ctx, dataPath, lastChildOverride, Optional.fromNullable(modifyOperation));
+            configContent = ImmutableNodes.fromInstanceId(ctx, dataPath, lastChildOverride.toJavaUtil(),
+                java.util.Optional.ofNullable(modifyOperation));
         }
 
         final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_CONFIG_QNAME.getLocalName(),
@@ -363,7 +363,8 @@ public class NetconfMessageTransformUtil {
                     NetconfNotification.RFC3339_DATE_PARSER.apply(eventTimeElement.getTextContent()),
                     notificationElement);
         } catch (final DocumentedException e) {
-            throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message);
+            throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message,
+                    e);
         } catch (final DateTimeParseException e) {
             LOG.warn("Unable to parse event time from {}. Setting time to {}", eventTimeElement,
                     NetconfNotification.UNKNOWN_EVENT_TIME, e);
index 5ccab6ba66e760762fe361020bbe772e32ec9f54..47e6d9eba2bb55ca91c5d92a6c3ca5bc48a82497 100644 (file)
@@ -31,13 +31,13 @@ class NetconfRpcStructureTransformer implements RpcStructureTransformer {
     public Optional<NormalizedNode<?, ?>> selectFromDataStructure(
             final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> data,
             final YangInstanceIdentifier path) {
-        return NormalizedNodes.findNode(data, path.getPathArguments());
+        return Optional.fromJavaUtil(NormalizedNodes.findNode(data, path.getPathArguments()));
     }
 
     @Override
     public AnyXmlNode createEditConfigStructure(final Optional<NormalizedNode<?, ?>> data,
                                                 final YangInstanceIdentifier dataPath,
-                                                Optional<ModifyAction> operation) {
+                                                final Optional<ModifyAction> operation) {
         return NetconfMessageTransformUtil.createEditConfigAnyxml(schemaContext, dataPath, operation, data);
     }
 
index 07163bbaadcb50e706a0de0293750e29a45b0690..2a0830658dc8d324eb04fd868ef51f744516f425 100644 (file)
@@ -15,13 +15,17 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -35,21 +39,21 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
 
     private final Map<QName, DataSchemaNode> childNodes;
     private final QName qualifiedName;
-    private final Set<AugmentationSchema> availableAugmentations;
+    private final Set<AugmentationSchemaNode> availableAugmentations;
 
     public NodeContainerProxy(final QName qualifiedName, final Map<QName, DataSchemaNode> childNodes,
-                              final Set<AugmentationSchema> availableAugmentations) {
+                              final Set<AugmentationSchemaNode> availableAugmentations) {
         this.availableAugmentations = availableAugmentations;
         this.childNodes = Preconditions.checkNotNull(childNodes, "childNodes");
         this.qualifiedName = qualifiedName;
     }
 
     public NodeContainerProxy(final QName qualifiedName, final Collection<DataSchemaNode> childNodes) {
-        this(qualifiedName, asMap(childNodes), Collections.<AugmentationSchema>emptySet());
+        this(qualifiedName, asMap(childNodes), Collections.emptySet());
     }
 
     public NodeContainerProxy(final QName qualifiedName, final Collection<DataSchemaNode> childNodes,
-                              final Set<AugmentationSchema> availableAugmentations) {
+                              final Set<AugmentationSchemaNode> availableAugmentations) {
         this(qualifiedName, asMap(childNodes), availableAugmentations);
     }
 
@@ -73,8 +77,8 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName qualifiedName) {
-        return childNodes.get(qualifiedName);
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
+        return Optional.ofNullable(childNodes.get(name));
     }
 
     @Override
@@ -88,7 +92,7 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
     }
 
     @Override
-    public Set<AugmentationSchema> getAvailableAugmentations() {
+    public Set<AugmentationSchemaNode> getAvailableAugmentations() {
         return availableAugmentations;
     }
 
@@ -107,11 +111,6 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public ConstraintDefinition getConstraints() {
-        throw new UnsupportedOperationException();
-    }
-
     @Override
     public QName getQName() {
         return qualifiedName;
@@ -123,12 +122,12 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException();
     }
 
@@ -141,4 +140,24 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
         return Collections.emptyList();
     }
-}
\ No newline at end of file
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<ActionDefinition> getActions() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Optional<RevisionAwareXPath> getWhenCondition() {
+        return Optional.empty();
+    }
+
+    @Override
+    public Collection<MustDefinition> getMustConstraints() {
+        return Collections.emptySet();
+    }
+}
index 099d2f2dde991c7f7150d1cf57954e735ea48eba..28c69e72ab0857d8ef653ec7770c1ca15cb5a83d 100644 (file)
@@ -170,7 +170,7 @@ class SchemalessRpcStructureTransformer implements RpcStructureTransformer {
             try {
                 textContent = key.get(0).getTextContent();
             } catch (DocumentedException e) {
-                throw new IllegalStateException("Key value not present in key element");
+                throw new IllegalStateException("Key value not present in key element", e);
             }
             if (!keyValues.get(qualifiedName).equals(textContent)) {
                 throw new IllegalStateException("Key value in path not equal to key value in xml");
index c963022e06d7c00820fac5e6b792b6695117ef9b..0c5810aa1e4fef153e376c8306a45e9e230c3599 100644 (file)
@@ -61,7 +61,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
         final NetconfNode node = this.encryptPassword(input);
         final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
         final NodeId nodeId = new NodeId(input.getNodeId());
-        writeToConfigDS(node, nodeId, topologyId, futureResult);
+        writeToConfigDS(node, nodeId, futureResult);
         return futureResult;
     }
 
@@ -91,7 +91,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
         return credentials;
     }
 
-    private void writeToConfigDS(final NetconfNode node, final NodeId nodeId, final String topologyId,
+    private void writeToConfigDS(final NetconfNode node, final NodeId nodeId,
                                  final SettableFuture<RpcResult<Void>> futureResult) {
 
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
index 12345671b49010a6815c1a392f122689020fb5dd..7a8846db832f2de9ce88cc9fcb710d36734662e5 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Collections;
 import java.util.Map;
 import org.junit.Assert;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
@@ -41,15 +42,15 @@ public class LibraryModulesSchemasTest {
         Assert.assertThat(resolvedModulesSchema.size(), is(3));
 
         Assert.assertTrue(resolvedModulesSchema.containsKey(RevisionSourceIdentifier.create("module-with-revision",
-                "2014-04-08")));
+                Revision.of("2014-04-08"))));
         Assert.assertThat(resolvedModulesSchema.get(
-                RevisionSourceIdentifier.create("module-with-revision", "2014-04-08")),
+                RevisionSourceIdentifier.create("module-with-revision", Revision.of("2014-04-08"))),
                 is(new URL("http://localhost:8181/yanglib/schemas/module-with-revision/2014-04-08")));
 
         Assert.assertTrue(resolvedModulesSchema.containsKey(
-                RevisionSourceIdentifier.create("another-module-with-revision", "2013-10-21")));
+                RevisionSourceIdentifier.create("another-module-with-revision", Revision.of("2013-10-21"))));
         Assert.assertThat(resolvedModulesSchema.get(
-                RevisionSourceIdentifier.create("another-module-with-revision", "2013-10-21")),
+                RevisionSourceIdentifier.create("another-module-with-revision", Revision.of("2013-10-21"))),
                 is(new URL("http://localhost:8181/yanglib/schemas/another-module-with-revision/2013-10-21")));
 
         Assert.assertTrue(resolvedModulesSchema.containsKey(
index efa9d6f15c78ea4eb48e2fe5b7b9deacc0d90d99..c568b1b0136851f1ae047f7c27af6d9daed0a96a 100644 (file)
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.timeout;
 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.Iterables;
 import com.google.common.collect.Lists;
@@ -29,13 +28,11 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.SettableFuture;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -60,6 +57,7 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -76,7 +74,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
-import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.xml.sax.SAXException;
 
@@ -107,12 +105,12 @@ public class NetconfDeviceTest {
     public static final String TEST_MODULE = "test-module";
     public static final String TEST_REVISION = "2013-07-22";
     public static final SourceIdentifier TEST_SID =
-            RevisionSourceIdentifier.create(TEST_MODULE, Optional.of(TEST_REVISION));
+            RevisionSourceIdentifier.create(TEST_MODULE, Revision.of(TEST_REVISION));
     public static final String TEST_CAPABILITY =
             TEST_NAMESPACE + "?module=" + TEST_MODULE + "&amp;revision=" + TEST_REVISION;
 
     public static final SourceIdentifier TEST_SID2 =
-            RevisionSourceIdentifier.create(TEST_MODULE + "2", Optional.of(TEST_REVISION));
+            RevisionSourceIdentifier.create(TEST_MODULE + "2", Revision.of(TEST_REVISION));
     public static final String TEST_CAPABILITY2 =
             TEST_NAMESPACE + "?module=" + TEST_MODULE + "2" + "&amp;revision=" + TEST_REVISION;
 
@@ -132,9 +130,9 @@ public class NetconfDeviceTest {
                 new SchemaResolutionException("fail first", TEST_SID, new Throwable("YangTools parser fail"));
         doAnswer(invocation -> {
             if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
-                return Futures.immediateFailedCheckedFuture(schemaResolutionException);
+                return Futures.immediateFailedFuture(schemaResolutionException);
             } else {
-                return Futures.immediateCheckedFuture(schema);
+                return Futures.immediateFuture(schema);
             }
         }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
 
@@ -181,8 +179,7 @@ public class NetconfDeviceTest {
         final SchemaResolutionException schemaResolutionException
                 = new SchemaResolutionException("fail first",
                 Collections.<SourceIdentifier>emptyList(), HashMultimap.<SourceIdentifier, ModuleImport>create());
-        doReturn(Futures.immediateFailedCheckedFuture(
-                schemaResolutionException))
+        doReturn(Futures.immediateFailedFuture(schemaResolutionException))
                 .when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
 
         final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
@@ -216,13 +213,13 @@ public class NetconfDeviceTest {
         // Make fallback attempt to fail due to empty resolved sources
         final MissingSchemaSourceException schemaResolutionException =
                 new MissingSchemaSourceException("fail first", TEST_SID);
-        doReturn(Futures.immediateFailedCheckedFuture(schemaResolutionException))
+        doReturn(Futures.immediateFailedFuture(schemaResolutionException))
                 .when(schemaRepository).getSchemaSource(eq(TEST_SID), eq(ASTSchemaSource.class));
         doAnswer(invocation -> {
             if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
-                return Futures.immediateFailedCheckedFuture(schemaResolutionException);
+                return Futures.immediateFailedFuture(schemaResolutionException);
             } else {
-                return Futures.immediateCheckedFuture(schema);
+                return Futures.immediateFuture(schema);
             }
         }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
 
@@ -268,7 +265,7 @@ public class NetconfDeviceTest {
     private static SchemaRepository getSchemaRepository() {
         final SchemaRepository mock = mock(SchemaRepository.class);
         final SchemaSourceRepresentation mockRep = mock(SchemaSourceRepresentation.class);
-        doReturn(Futures.immediateCheckedFuture(mockRep))
+        doReturn(Futures.immediateFuture(mockRep))
                 .when(mock).getSchemaSource(any(SourceIdentifier.class), eq(ASTSchemaSource.class));
         return mock;
     }
@@ -279,8 +276,7 @@ public class NetconfDeviceTest {
         final NetconfDeviceCommunicator listener = getListener();
         final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
         final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
-        doReturn(Futures.makeChecked(schemaFuture, e -> new SchemaResolutionException("fail")))
-                .when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
+        doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
         final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO =
                 new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
                         schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
@@ -348,8 +344,7 @@ public class NetconfDeviceTest {
         final NetconfDeviceCommunicator listener = getListener();
         final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
         final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
-        doReturn(Futures.makeChecked(schemaFuture, e -> new SchemaResolutionException("fail")))
-                .when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
+        doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
         final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO
                 = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
                 schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
@@ -414,16 +409,13 @@ public class NetconfDeviceTest {
 
     private static SchemaContextFactory getSchemaFactory() throws Exception {
         final SchemaContextFactory schemaFactory = mockClass(SchemaContextFactory.class);
-        doReturn(Futures.immediateCheckedFuture(getSchema()))
+        doReturn(Futures.immediateFuture(getSchema()))
                 .when(schemaFactory).createSchemaContext(any(Collection.class));
         return schemaFactory;
     }
 
-    public static SchemaContext getSchema() throws Exception {
-        final List<InputStream> modelsToParse = Lists.newArrayList(
-                NetconfDeviceTest.class.getResourceAsStream("/schemas/test-module.yang")
-        );
-        return YangParserTestUtils.parseYangStreams(modelsToParse);
+    public static SchemaContext getSchema() {
+        return YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
     }
 
     private static RemoteDeviceHandler<NetconfSessionPreferences> getFacade() throws Exception {
index 3c8cac318136b4e89618db2fd952c8ad383c19ae..2398bc71c91e296c860ea016e845a9797c87ed2f 100644 (file)
@@ -159,7 +159,7 @@ public class NetconfStateSchemasTest {
         Assert.assertTrue(availableYangSchemasQNames.isEmpty());
     }
 
-    @SuppressWarnings("checkstyle:IllegalThrows")
+    @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
     @Test(expected = RuntimeException.class)
     public void testCreateInterrupted() throws Throwable {
         //NetconfStateSchemas.create calls Thread.currentThread().interrupt(), so it must run in its own thread
index 0b37a87e9320b6cd3c07dc244e45cbb5e7f92df6..a117aea103be452071ce5c648caecbe4ba1b2a63 100644 (file)
@@ -14,8 +14,6 @@ import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.Iterables;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -47,19 +45,16 @@ public class NetconfToNotificationTest {
         userNotification = new NetconfMessage(doc);
     }
 
-    static SchemaContext getNotificationSchemaContext(final Class<?> loadClass,
-                                                      final boolean getExceptionTest) throws Exception {
-        final List<InputStream> modelsToParse = new ArrayList<>();
-
+    static SchemaContext getNotificationSchemaContext(final Class<?> loadClass, final boolean getExceptionTest) {
+        final SchemaContext context;
         if (getExceptionTest) {
-            modelsToParse.add(loadClass.getResourceAsStream("/schemas/user-notification4.yang"));
-            modelsToParse.add(loadClass.getResourceAsStream("/schemas/user-notification3.yang"));
+            context = YangParserTestUtils.parseYangResources(loadClass, "/schemas/user-notification4.yang",
+                    "/schemas/user-notification3.yang");
         } else {
-            modelsToParse.add(loadClass.getResourceAsStream("/schemas/user-notification.yang"));
-            modelsToParse.add(loadClass.getResourceAsStream("/schemas/user-notification2.yang"));
+            context = YangParserTestUtils.parseYangResources(loadClass, "/schemas/user-notification.yang",
+                "/schemas/user-notification2.yang");
         }
 
-        final SchemaContext context = YangParserTestUtils.parseYangStreams(modelsToParse);
         final Set<Module> modules = context.getModules();
         assertTrue(!modules.isEmpty());
         assertNotNull(context);
index 10cb4e3236f4ca49a6f8da2de2b172432b87ad01..3f153d20a5e39998a893278e410642c1d5658981 100644 (file)
@@ -14,10 +14,6 @@ import static org.junit.Assert.assertTrue;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
-import com.google.common.collect.Lists;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
 import java.util.Set;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -56,16 +52,13 @@ public class NetconfToRpcRequestTest {
     static NetconfMessageTransformer messageTransformer;
 
     @BeforeClass
-    public static void setup() throws Exception {
-        List<InputStream> modelsToParse = Collections.singletonList(
-                NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/rpc-notification-subscription.yang"));
-        final Set<Module> notifModules = YangParserTestUtils.parseYangStreams(modelsToParse).getModules();
+    public static void setup() {
+        final Set<Module> notifModules = YangParserTestUtils.parseYangResource(
+            "/schemas/rpc-notification-subscription.yang").getModules();
         assertTrue(!notifModules.isEmpty());
 
-        modelsToParse = Lists.newArrayList(
-                NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/config-test-rpc.yang"),
-                NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/rpc-notification-subscription.yang"));
-        cfgCtx = YangParserTestUtils.parseYangStreams(modelsToParse);
+        cfgCtx = YangParserTestUtils.parseYangResources(NetconfToRpcRequestTest.class,
+            "/schemas/config-test-rpc.yang", "/schemas/rpc-notification-subscription.yang");
         messageTransformer = new NetconfMessageTransformer(cfgCtx, true);
     }
 
index f9724cf74ee12e2e48e85880e273401e75ef2505..3cc75f230ac289be80ea97122f40ff9edb1a0eaf 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.netconf.sal.connect.netconf.listener;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.same;
@@ -115,11 +116,11 @@ public class NetconfDeviceCommunicatorTest {
 
         ChannelFuture mockChannelFuture = mock(ChannelFuture.class);
         doReturn(mockChannelFuture).when(mockChannelFuture)
-                .addListener(any((GenericFutureListener.class)));
+                .addListener(any(GenericFutureListener.class));
         doReturn(mockChannelFuture).when(mockSession).sendMessage(same(message));
 
         ListenableFuture<RpcResult<NetconfMessage>> resultFuture =
-                communicator.sendRequest(message, QName.create("mock rpc"));
+                communicator.sendRequest(message, QName.create("", "mockRpc"));
         if (doLastTest) {
             assertNotNull("ListenableFuture is null", resultFuture);
         }
@@ -210,7 +211,7 @@ public class NetconfDeviceCommunicatorTest {
         setupSession();
 
         NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
-        QName rpc = QName.create("mock rpc");
+        QName rpc = QName.create("", "mockRpc");
 
         ArgumentCaptor<GenericFutureListener> futureListener =
                 ArgumentCaptor.forClass(GenericFutureListener.class);
@@ -241,7 +242,7 @@ public class NetconfDeviceCommunicatorTest {
     @Test
     public void testSendRequestWithNoSession() throws Exception {
         NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
-        QName rpc = QName.create("mock rpc");
+        QName rpc = QName.create("", "mockRpc");
 
         ListenableFuture<RpcResult<NetconfMessage>> resultFuture = communicator.sendRequest(message, rpc);
 
@@ -273,7 +274,7 @@ public class NetconfDeviceCommunicatorTest {
         setupSession();
 
         NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
-        QName rpc = QName.create("mock rpc");
+        QName rpc = QName.create("", "mockRpc");
 
         ArgumentCaptor<GenericFutureListener> futureListener =
                 ArgumentCaptor.forClass(GenericFutureListener.class);
@@ -355,10 +356,8 @@ public class NetconfDeviceCommunicatorTest {
 
         String errorInfo = rpcError.getInfo();
         assertNotNull("RpcError info is null", errorInfo);
-        assertEquals("Error info contains \"foo\"", true,
-                errorInfo.contains("<bad-attribute>foo</bad-attribute>"));
-        assertEquals("Error info contains \"bar\"", true,
-                errorInfo.contains("<bad-element>bar</bad-element>"));
+        assertTrue("Error info contains \"foo\"", errorInfo.contains("<bad-attribute>foo</bad-attribute>"));
+        assertTrue("Error info contains \"bar\"", errorInfo.contains("<bad-element>bar</bad-element>"));
     }
 
     /**
@@ -424,15 +423,12 @@ public class NetconfDeviceCommunicatorTest {
 
         RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), RpcError.ErrorType.PROTOCOL,
                 "bad-attribute");
-        assertEquals("RpcError message non-empty", true,
-                !Strings.isNullOrEmpty(rpcError.getMessage()));
+        assertFalse("RpcError message non-empty", Strings.isNullOrEmpty(rpcError.getMessage()));
 
         String errorInfo = rpcError.getInfo();
         assertNotNull("RpcError info is null", errorInfo);
-        assertEquals("Error info contains \"actual-message-id\"", true,
-                errorInfo.contains("actual-message-id"));
-        assertEquals("Error info contains \"expected-message-id\"", true,
-                errorInfo.contains("expected-message-id"));
+        assertTrue("Error info contains \"actual-message-id\"", errorInfo.contains("actual-message-id"));
+        assertTrue("Error info contains \"expected-message-id\"", errorInfo.contains("expected-message-id"));
     }
 
     @Test
@@ -478,7 +474,7 @@ public class NetconfDeviceCommunicatorTest {
 
     private static void verifyResponseMessage(final RpcResult<NetconfMessage> rpcResult, final String dataText) {
         assertNotNull("RpcResult is null", rpcResult);
-        assertEquals("isSuccessful", true, rpcResult.isSuccessful());
+        assertTrue("isSuccessful", rpcResult.isSuccessful());
         NetconfMessage messageResult = rpcResult.getResult();
         assertNotNull("getResult", messageResult);
 //        List<SimpleNode<?>> nodes = messageResult.getSimpleNodesByName(
@@ -491,7 +487,7 @@ public class NetconfDeviceCommunicatorTest {
     private static RpcError verifyErrorRpcResult(final RpcResult<NetconfMessage> rpcResult,
                                                  final RpcError.ErrorType expErrorType, final String expErrorTag) {
         assertNotNull("RpcResult is null", rpcResult);
-        assertEquals("isSuccessful", false, rpcResult.isSuccessful());
+        assertFalse("isSuccessful", rpcResult.isSuccessful());
         assertNotNull("RpcResult errors is null", rpcResult.getErrors());
         assertEquals("Errors size", 1, rpcResult.getErrors().size());
         RpcError rpcError = rpcResult.getErrors().iterator().next();
@@ -502,7 +498,7 @@ public class NetconfDeviceCommunicatorTest {
         final String msg = rpcError.getMessage();
         assertNotNull("getMessage is null", msg);
         assertFalse("getMessage is empty", msg.isEmpty());
-        assertFalse("getMessage is blank", CharMatcher.WHITESPACE.matchesAllOf(msg));
+        assertFalse("getMessage is blank", CharMatcher.whitespace().matchesAllOf(msg));
         return rpcError;
     }
 }
index 3f0b9d8628bacd0414119ce24a85e40a9808fd07..04f4f9dcbbba9f981aa026a10c0d7db30d94339d 100644 (file)
@@ -105,10 +105,6 @@ public class KeepaliveSalFacadeTest {
         doReturn(Futures.immediateCheckedFuture(result))
                 .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
 
-        final KeepaliveSalFacade keepaliveSalFacade =
-                new KeepaliveSalFacade(REMOTE_DEVICE_ID, underlyingSalFacade, executorServiceSpy, 1L, 1L);
-        keepaliveSalFacade.setListener(listener);
-
         keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
 
         verify(underlyingSalFacade).onDeviceConnected(
@@ -123,10 +119,6 @@ public class KeepaliveSalFacadeTest {
         doReturn(Futures.immediateFailedCheckedFuture(new IllegalStateException("illegal-state")))
                 .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
 
-        final KeepaliveSalFacade keepaliveSalFacade =
-                new KeepaliveSalFacade(REMOTE_DEVICE_ID, underlyingSalFacade, executorServiceSpy, 1L, 1L);
-        keepaliveSalFacade.setListener(listener);
-
         keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
 
         verify(underlyingSalFacade).onDeviceConnected(
@@ -167,7 +159,7 @@ public class KeepaliveSalFacadeTest {
         doReturn(Futures.immediateFailedCheckedFuture(new IllegalStateException("illegal-state")))
                 .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
 
-        final KeepaliveSalFacade keepaliveSalFacade =
+        keepaliveSalFacade =
                 new KeepaliveSalFacade(REMOTE_DEVICE_ID, underlyingSalFacade, executorServiceSpy, 100L, 1L);
         keepaliveSalFacade.setListener(listener);
 
@@ -177,4 +169,4 @@ public class KeepaliveSalFacadeTest {
 
         verify(listener, times(1)).disconnect();
     }
-}
\ No newline at end of file
+}
index 5a2539635d9c205766da6a467f865457d7b27835..2324bceb878c9e17d01b51d02c99915410fd0ebd 100644 (file)
@@ -43,8 +43,8 @@ public class NetconfDeviceNotificationServiceTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        final SchemaPath path1 = SchemaPath.create(true, new QName(new URI("namespace1"), "path1"));
-        final SchemaPath path2 = SchemaPath.create(true, new QName(new URI("namespace2"), "path2"));
+        final SchemaPath path1 = SchemaPath.create(true, QName.create(new URI("namespace1"), "path1"));
+        final SchemaPath path2 = SchemaPath.create(true, QName.create(new URI("namespace2"), "path2"));
         service = new NetconfDeviceNotificationService();
         service.registerNotificationListener(listener1, path1);
         registration = service.registerNotificationListener(listener2, path2);
index 9397635d9ec3b31fbd34e81de441e1131a0981f5..bd416339a92ac97b7a0cba8e3a5278f024b92779 100644 (file)
@@ -17,12 +17,8 @@ import static org.mockito.Mockito.verify;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import javassist.ClassPool;
@@ -72,7 +68,7 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class NetconfDeviceTopologyAdapterTest {
 
-    private RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
+    private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
 
     @Mock
     private DataBroker broker;
@@ -83,10 +79,10 @@ public class NetconfDeviceTopologyAdapterTest {
     @Mock
     private NetconfNode data;
 
-    private String txIdent = "test transaction";
+    private final String txIdent = "test transaction";
 
     private SchemaContext schemaContext = null;
-    private String sessionIdForReporting = "netconf-test-session1";
+    private final String sessionIdForReporting = "netconf-test-session1";
 
     private BindingTransactionChain transactionChain;
 
@@ -106,7 +102,10 @@ public class NetconfDeviceTopologyAdapterTest {
 
         doReturn(txIdent).when(writeTx).getIdentifier();
 
-        this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        this.schemaContext = YangParserTestUtils.parseYangResources(NetconfDeviceTopologyAdapterTest.class,
+            "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang",
+            "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang",
+            "/schemas/network-topology-augment-test@2016-08-08.yang");
         schemaContext.getModules();
         final SchemaService schemaService = createSchemaService();
 
@@ -118,7 +117,7 @@ public class NetconfDeviceTopologyAdapterTest {
         datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
 
         ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures");
+                16, 16, "CommitFutures", NetconfDeviceTopologyAdapterTest.class);
 
         concurrentDOMDataBroker = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
 
@@ -137,13 +136,13 @@ public class NetconfDeviceTopologyAdapterTest {
 
         transactionChain = dataBroker.createTransactionChain(new TransactionChainListener() {
             @Override
-            public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction,
-                                                 Throwable cause) {
+            public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+                    final AsyncTransaction<?, ?> transaction, final Throwable cause) {
 
             }
 
             @Override
-            public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+            public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
 
             }
         });
@@ -209,9 +208,9 @@ public class NetconfDeviceTopologyAdapterTest {
         NormalizedNode<?, ?> augmentNode = ImmutableLeafNodeBuilder.create().withValue(dataTestId)
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(netconfTestLeafQname)).build();
 
-        DOMDataWriteTransaction writeTx =  concurrentDOMDataBroker.newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, pathToAugmentedLeaf, augmentNode);
-        writeTx.submit();
+        DOMDataWriteTransaction wtx =  concurrentDOMDataBroker.newWriteOnlyTransaction();
+        wtx.put(LogicalDatastoreType.OPERATIONAL, pathToAugmentedLeaf, augmentNode);
+        wtx.submit();
 
         adapter.updateDeviceData(true, new NetconfDeviceCapabilities());
         Optional<NormalizedNode<?, ?>> testNode = concurrentDOMDataBroker.newReadOnlyTransaction()
@@ -229,29 +228,15 @@ public class NetconfDeviceTopologyAdapterTest {
                 dataTestId, testNode.get().getValue());
     }
 
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Arrays.asList("/schemas/network-topology@2013-10-21.yang",
-                "/schemas/ietf-inet-types@2013-07-15.yang", "/schemas/yang-ext.yang",
-                "/schemas/netconf-node-topology.yang", "/schemas/network-topology-augment-test@2016-08-08.yang");
-        final List<InputStream> schemas = new ArrayList<>();
-
-        for (String schemaPath : schemaPaths) {
-            InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-
-        return schemas;
-    }
-
     private SchemaService createSchemaService() {
         return new SchemaService() {
 
             @Override
-            public void addModule(Module module) {
+            public void addModule(final Module module) {
             }
 
             @Override
-            public void removeModule(Module module) {
+            public void removeModule(final Module module) {
 
             }
 
index 56384cdf32f10e0c93f786ff84bf69641525195d..384d83d5f144ab83ec95d62546d52d0e22d00502 100644 (file)
@@ -111,7 +111,6 @@ public class TxChainTest {
     @Test
     public void testChainFail() throws Exception {
         final AbstractWriteTx writeTx = chain.newWriteOnlyTransaction();
-        final ArgumentCaptor<TxListener> captor = ArgumentCaptor.forClass(TxListener.class);
         verify(writeOnlyTx1).addListener(captor.capture());
         writeTx.submit();
         final TransactionCommitFailedException cause = new TransactionCommitFailedException("fail");
@@ -220,4 +219,4 @@ public class TxChainTest {
         // 1 transaction failed, onTransactionChainSuccessful must not be called
         verify(listener, never()).onTransactionChainSuccessful(chain);
     }
-}
\ No newline at end of file
+}
index 3d820b683770f188630435f05b1c8cf724513f77..5e53287cde91137cd6b304a5ba9efa7ce06acc19 100644 (file)
@@ -14,11 +14,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 
-class TxTestUtils {
+final class TxTestUtils {
 
     private static final QName Q_NAME_1 = QName.create("test:namespace", "2013-07-22", "c");
     private static final QName Q_NAME_2 = QName.create(Q_NAME_1, "a");
 
+    private TxTestUtils() {
+
+    }
+
     static YangInstanceIdentifier getContainerId() {
         return YangInstanceIdentifier.builder()
                 .node(Q_NAME_1)
index fd99a54d76c95ddcc9c7aac533f5778842b6b36d..a7a427e7ef388f2880ed7c4e3c84c62e87f4c9d3 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -50,7 +51,7 @@ public class WriteCandidateRunningTxTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangStreams(getClass().getResourceAsStream("/schemas/test-module.yang"));
+                YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
         doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
         netconfOps = new NetconfBaseOps(rpc, schemaContext);
         id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
@@ -84,7 +85,8 @@ public class WriteCandidateRunningTxTest {
     }
 
     private static ContainerNode getLockContent(final QName op, final QName datastore) {
-        final LeafNode<Object> datastoreLeaf = Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build();
+        final LeafNode<Object> datastoreLeaf = Builders.leafBuilder().withNodeIdentifier(toId(datastore))
+                .withValue(Empty.getInstance()).build();
         final ChoiceNode choice = Builders.choiceBuilder()
                 .withNodeIdentifier(toId(ConfigTarget.QNAME))
                 .withChild(datastoreLeaf)
index 7370b0da5d3f6bb01cae25f816956f3d51afc1dc..917fb486b669e69502789b594f30289679634803 100644 (file)
@@ -41,7 +41,7 @@ public class WriteCandidateTxTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangStreams(getClass().getResourceAsStream("/schemas/test-module.yang"));
+                YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
         doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
         netconfOps = new NetconfBaseOps(rpc, schemaContext);
         id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
index ab53dc4f4d12e870b28df24ac8ab1665b574472d..30f75b11aca593a55a8d230915c0594d887b9811 100644 (file)
@@ -42,7 +42,7 @@ public class WriteRunningTxTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangStreams(getClass().getResourceAsStream("/schemas/test-module.yang"));
+                YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
         doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
         netconfOps = new NetconfBaseOps(rpc, schemaContext);
         id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
index c44413ded9ab9d00dced2f880b4bea94d7260a7d..edf7b96f307a1e925188807dd1a238dcf6cd8d4b 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -38,7 +39,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.w3c.dom.Document;
@@ -65,14 +66,13 @@ public class NetconfRemoteSchemaYangSourceProviderTest {
 
     @Test
     public void testGetSource() throws Exception {
-        final SourceIdentifier identifier = SourceIdentifier.create("test", Optional.of("2016-02-08"));
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> module = provider.getSource(identifier);
-        final YangTextSchemaSource source = module.checkedGet();
+        final SourceIdentifier identifier = RevisionSourceIdentifier.create("test", Revision.of("2016-02-08"));
+        final YangTextSchemaSource source = provider.getSource(identifier).get();
         Assert.assertEquals(identifier, source.getIdentifier());
         verify(service).invokeRpc(
                 SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME),
-                NetconfRemoteSchemaYangSourceProvider
-                        .createGetSchemaRequest(identifier.getName(), Optional.of(identifier.getRevision()))
+                NetconfRemoteSchemaYangSourceProvider.createGetSchemaRequest(identifier.getName(),
+                    Optional.fromJavaUtil(identifier.getRevision().map(Revision::toString)))
         );
     }
 
index 623e61a3376121f8a13be5935a89d5844c7d7cb2..bc94ff2f9ec55f539fdaafb77d26284d8a196ce5 100644 (file)
@@ -7,13 +7,18 @@
  */
 package org.opendaylight.netconf.sal.connect.netconf.schema;
 
-import com.google.common.base.Optional;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
@@ -32,7 +37,7 @@ public class YangLibrarySchemaYangSourceProviderTest {
     @Before
     public void setUp() throws Exception {
         final URL url = getClass().getResource("/schemas/config-test-rpc.yang");
-        workingSid = RevisionSourceIdentifier.create("abc", Optional.<String>absent());
+        workingSid = RevisionSourceIdentifier.create("abc", Optional.empty());
         final Map<SourceIdentifier, URL> sourceIdentifierURLMap = Collections.singletonMap(workingSid, url);
         final RemoteDeviceId id = new RemoteDeviceId("id", new InetSocketAddress("localhost", 22));
         yangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(id, sourceIdentifierURLMap);
@@ -40,23 +45,27 @@ public class YangLibrarySchemaYangSourceProviderTest {
 
     @Test
     public void testGetSource() throws Exception {
-        CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source =
-                yangLibrarySchemaYangSourceProvider.getSource(workingSid);
-        final String x = new String(ByteStreams.toByteArray(source.checkedGet().openStream()));
+        ListenableFuture<? extends YangTextSchemaSource> source = yangLibrarySchemaYangSourceProvider
+                .getSource(workingSid);
+        final String x = new String(ByteStreams.toByteArray(source.get().openStream()));
         Assert.assertThat(x, CoreMatchers.containsString("module config-test-rpc"));
     }
 
-    @Test(expected = SchemaSourceException.class)
-    public void testGetSourceFailure() throws Exception {
+    @Test
+    public void testGetSourceFailure() throws InterruptedException, MalformedURLException {
         final URL url = new URL("http://non-existing-entity.yang");
         final Map<SourceIdentifier, URL> sourceIdentifierURLMap = Collections.singletonMap(workingSid, url);
         final RemoteDeviceId id = new RemoteDeviceId("id", new InetSocketAddress("localhost", 22));
         final YangLibrarySchemaYangSourceProvider failingYangLibrarySchemaYangSourceProvider =
                 new YangLibrarySchemaYangSourceProvider(id, sourceIdentifierURLMap);
 
-        CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source =
-                failingYangLibrarySchemaYangSourceProvider.getSource(workingSid);
-        source.checkedGet();
+        try {
+            failingYangLibrarySchemaYangSourceProvider.getSource(workingSid).get();
+            fail();
+        } catch (ExecutionException e) {
+            final Throwable cause = e.getCause();
+            assertTrue(cause instanceof SchemaSourceException);
+        }
     }
 
     @Test(expected = IllegalArgumentException.class)
index 8f4c320f9750a25f950cf12f33ba5ce643b855d3..0b3f3677c1d1c787959f47818ddf3ab40217455e 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.netconf.sal.connect.netconf.schema.mapping;
 
-import com.google.common.base.Optional;
 import java.io.InputStream;
+import java.util.Optional;
 import javax.xml.transform.dom.DOMSource;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
@@ -24,6 +24,7 @@ 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;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.target.config.target.Candidate;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
@@ -87,7 +88,8 @@ public class BaseRpcSchemalessTransformerTest {
         final ChoiceNode candidate = Builders.choiceBuilder().withNodeIdentifier(
                 new YangInstanceIdentifier.NodeIdentifier(ConfigTarget.QNAME))
                 .withChild(Builders.leafBuilder().withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeIdentifier(Candidate.QNAME)).build())
+                        new YangInstanceIdentifier.NodeIdentifier(Candidate.QNAME))
+                    .withValue(Empty.getInstance()).build())
                 .build();
         final DataContainerChild<?, ?> target = Builders.containerBuilder()
                 .withNodeIdentifier(
@@ -120,7 +122,7 @@ public class BaseRpcSchemalessTransformerTest {
         Assert.assertNotNull(result.getResult());
         final ContainerNode rpcReply = (ContainerNode) result.getResult();
         Assert.assertEquals(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME, rpcReply.getNodeType());
-        final Optional dataOpt = rpcReply.getChild(
+        final Optional<?> dataOpt = rpcReply.getChild(
                 new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_DATA_QNAME));
         Assert.assertTrue(dataOpt.isPresent());
         final AnyXmlNode data = (AnyXmlNode) dataOpt.get();
index a0c90c7293fa5c20c8b136fafa2d03819eaeb20b..a2050628aec2ec4562da1a887a07e080ade29a82 100644 (file)
@@ -148,7 +148,7 @@ public class NetconfMessageTransformerTest {
 
     @Test
     public void tesGetSchemaResponse() throws Exception {
-        final NetconfMessageTransformer netconfMessageTransformer = getTransformer(getSchema(true));
+        final NetconfMessageTransformer transformer = getTransformer(getSchema(true));
         final NetconfMessage response = new NetconfMessage(XmlUtil.readXmlToDocument(
                 "<rpc-reply message-id=\"101\"\n"
                         + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
@@ -160,8 +160,7 @@ public class NetconfMessageTransformerTest {
                         + "</data>\n"
                         + "</rpc-reply>"
         ));
-        final DOMRpcResult compositeNodeRpcResult =
-                netconfMessageTransformer.toRpcResult(response, toPath(GET_SCHEMA_QNAME));
+        final DOMRpcResult compositeNodeRpcResult = transformer.toRpcResult(response, toPath(GET_SCHEMA_QNAME));
         assertTrue(compositeNodeRpcResult.getErrors().isEmpty());
         assertNotNull(compositeNodeRpcResult.getResult());
         final DOMSource schemaContent =
@@ -187,9 +186,9 @@ public class NetconfMessageTransformerTest {
                 + "</data>\n"
                 + "</rpc-reply>"));
 
-        final NetconfMessageTransformer netconfMessageTransformer = getTransformer(getSchema(true));
+        final NetconfMessageTransformer transformer = getTransformer(getSchema(true));
         final DOMRpcResult compositeNodeRpcResult =
-                netconfMessageTransformer.toRpcResult(response, toPath(NETCONF_GET_CONFIG_QNAME));
+                transformer.toRpcResult(response, toPath(NETCONF_GET_CONFIG_QNAME));
         assertTrue(compositeNodeRpcResult.getErrors().isEmpty());
         assertNotNull(compositeNodeRpcResult.getResult());
 
index 84dd65b6b951b0eef2c85fe971ad6d6dba99b192..177aede376866bdb268391dd50ca790305efb0f0 100644 (file)
@@ -92,7 +92,7 @@ public class NetconfBaseOpsTest {
         when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME)))
                 .thenReturn(RpcResultBuilder.success(ok).buildFuture());
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangStreams(getClass().getResourceAsStream("/schemas/test-module.yang"));
+                YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
         final MessageTransformer<NetconfMessage> transformer = new NetconfMessageTransformer(schemaContext, true);
         final DOMRpcService rpc = new NetconfDeviceRpc(schemaContext, listener, transformer);
         final RemoteDeviceId id =
@@ -272,7 +272,7 @@ public class NetconfBaseOpsTest {
 
         private final Document expected;
 
-        private NetconfMessageMatcher(final Document expected) {
+        NetconfMessageMatcher(final Document expected) {
             this.expected = removeAttrs(expected);
         }
 
@@ -312,4 +312,4 @@ public class NetconfBaseOpsTest {
         }
     }
 
-}
\ No newline at end of file
+}
index 72ef9007d1cfc110a98d96df30125d39d2dc7cfd..7dd88b7453258068d0eef2875f181676721c65ac 100644 (file)
@@ -78,7 +78,7 @@ public class NetconfTopologyRPCProviderTest {
         assertEquals(TEST_PWD, loginPw.getLoginPasswordUnencrypted().getPassword());
     }
 
-    private CreateDeviceInput getInput(boolean encrypt) {
+    private static CreateDeviceInput getInput(final boolean encrypt) {
         CreateDeviceInputBuilder builder = new CreateDeviceInputBuilder();
         final Credentials credentials;
         if (encrypt) {
@@ -92,7 +92,7 @@ public class NetconfTopologyRPCProviderTest {
         builder.setCredentials(credentials);
         builder.setHost(new Host(new IpAddress(new Ipv4Address("10.18.16.188"))));
         builder.setPort(new PortNumber(830));
-        builder.setTcpOnly(false);
+        builder.setTcpOnly(Boolean.FALSE);
         builder.setNodeId(NODE_ID.toString());
         return builder.build();
     }
index 534a9520fcf0c5281b5c022835fd02cfc8402099..ede1b39313c0cb8b8e42410613e6917390badee3 100644 (file)
@@ -18,7 +18,7 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 public class NodeContainerProxyTest {
@@ -27,9 +27,9 @@ public class NodeContainerProxyTest {
     private static final QName NODE_1_QNAME = QName.create(QNAME, "node-1");
     private static final QName NODE_2_QNAME = QName.create(QNAME, "node-2");
     @Mock
-    private AugmentationSchema augSchema1;
+    private AugmentationSchemaNode augSchema1;
     @Mock
-    private AugmentationSchema augSchema2;
+    private AugmentationSchemaNode augSchema2;
     @Mock
     private DataSchemaNode schemaNode1;
     @Mock
@@ -42,7 +42,7 @@ public class NodeContainerProxyTest {
         final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
         childNodes.put(NODE_1_QNAME, schemaNode1);
         childNodes.put(NODE_2_QNAME, schemaNode2);
-        final Set<AugmentationSchema> augmentations = new HashSet<>();
+        final Set<AugmentationSchemaNode> augmentations = new HashSet<>();
         augmentations.add(augSchema1);
         augmentations.add(augSchema2);
         proxy = new NodeContainerProxy(QNAME, childNodes, augmentations);
@@ -60,7 +60,7 @@ public class NodeContainerProxyTest {
 
     @Test
     public void testGetAvailableAugmentations() throws Exception {
-        final Set<AugmentationSchema> augmentations = proxy.getAvailableAugmentations();
+        final Set<AugmentationSchemaNode> augmentations = proxy.getAvailableAugmentations();
         Assert.assertEquals(2, augmentations.size());
         Assert.assertTrue(augmentations.contains(augSchema1));
         Assert.assertTrue(augmentations.contains(augSchema2));
@@ -112,11 +112,6 @@ public class NodeContainerProxyTest {
         proxy.isConfiguration();
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testGetConstraints() throws Exception {
-        proxy.getConstraints();
-    }
-
     @Test(expected = UnsupportedOperationException.class)
     public void testGetPath() throws Exception {
         proxy.getPath();
index e2dcfed8f051e9da387634a40f09ba73a8739550..3763058e7b182b2a9965c106264e2b8c01dc6d22 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -40,7 +40,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 4e6c2a327a6192af8bbb10576279bd3cad87b998..6ec885d44cb687029c7ac6f8d5fa7d538318b09d 100644 (file)
@@ -42,10 +42,13 @@ import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 public final class Main {
     private static final Logger LOG = LoggerFactory.getLogger(Main.class);
 
+    private Main() {
+
+    }
+
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static void main(final String[] args) {
         final TesttoolParameters params = TesttoolParameters.parseArgs(args, TesttoolParameters.getParser());
index 071085ddf8c78d532dce8a2656dafb8a5c12c998..fd5c68946953740224500ec75278b7aa2fcf70f0 100644 (file)
@@ -69,7 +69,7 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
 
     private final Set<Capability> caps;
     private final SchemaContext schemaContext;
-    private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
+    private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
 
     MdsalOperationProvider(final SessionIdProvider idProvider,
                            final Set<Capability> caps,
@@ -87,17 +87,14 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
 
     @Override
     public AutoCloseable registerCapabilityListener(
-            CapabilityListener listener) {
+            final CapabilityListener listener) {
         listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-            }
+        return () -> {
         };
     }
 
     @Override
-    public NetconfOperationService createService(String netconfSessionIdForReporting) {
+    public NetconfOperationService createService(final String netconfSessionIdForReporting) {
         return new MdsalOperationService(Long.parseLong(netconfSessionIdForReporting), schemaContext,
             caps, sourceProvider);
     }
@@ -108,7 +105,7 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
         private final Set<Capability> caps;
         private final SchemaService schemaService;
         private final DOMDataBroker dataBroker;
-        private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
+        private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
 
         MdsalOperationService(final long currentSessionId,
                               final SchemaContext schemaContext,
@@ -207,11 +204,11 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
 
             ContainerNode schemasContainer = Builders.containerBuilder().withNodeIdentifier(
                     new YangInstanceIdentifier.NodeIdentifier(Schemas.QNAME)).withChild(schemaList).build();
-            return (ContainerNode) Builders.containerBuilder().withNodeIdentifier(
+            return Builders.containerBuilder().withNodeIdentifier(
                     new YangInstanceIdentifier.NodeIdentifier(NetconfState.QNAME)).withChild(schemasContainer).build();
         }
 
-        private DOMDataBroker createDataStore(SchemaService schemaService, long sessionId) {
+        private static DOMDataBroker createDataStore(final SchemaService schemaService, final long sessionId) {
             LOG.debug("Session {}: Creating data stores for simulated device", sessionId);
             final DOMStore operStore = InMemoryDOMDataStoreFactory
                     .create("DOM-OPER", schemaService);
@@ -219,7 +216,7 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
                     .create("DOM-CFG", schemaService);
 
             ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                    16, 16, "CommitFutures");
+                    16, 16, "CommitFutures", MdsalOperationProvider.class);
 
             final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
             datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
@@ -232,11 +229,11 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory {
             return new SchemaService() {
 
                 @Override
-                public void addModule(Module module) {
+                public void addModule(final Module module) {
                 }
 
                 @Override
-                public void removeModule(Module module) {
+                public void removeModule(final Module module) {
 
                 }
 
index e9ab199009f89dced97a8ac83c10f0e7a7b36aa9..42b162b2def8895f543eecc6422ab05cbe1e4e57 100644 (file)
@@ -8,12 +8,11 @@
 
 package org.opendaylight.netconf.test.tool;
 
-import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Optional;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import io.netty.channel.Channel;
@@ -36,8 +35,9 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import org.apache.sshd.common.util.ThreadUtils;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+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;
@@ -58,12 +58,10 @@ import org.opendaylight.netconf.test.tool.operations.DefaultOperationsCreator;
 import org.opendaylight.netconf.test.tool.operations.OperationsProvider;
 import org.opendaylight.netconf.test.tool.rpchandler.SettableOperationRpcProvider;
 import org.opendaylight.netconf.test.tool.schemacache.SchemaSourceCache;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -73,7 +71,7 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
 import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,7 +90,7 @@ public class NetconfDeviceSimulator implements Closeable {
 
     private boolean sendFakeSchema = false;
 
-    public NetconfDeviceSimulator(Configuration configuration) {
+    public NetconfDeviceSimulator(final Configuration configuration) {
         this.configuration = configuration;
         this.nettyThreadgroup = new NioEventLoopGroup();
         this.hashedWheelTimer = new HashedWheelTimer();
@@ -189,7 +187,7 @@ public class NetconfDeviceSimulator implements Closeable {
         final List<Integer> openDevices = Lists.newArrayList();
 
         // Generate key to temp folder
-        final PEMGeneratorHostKeyProvider keyPairProvider = getPemGeneratorHostKeyProvider();
+        final KeyPairProvider keyPairProvider = getPemGeneratorHostKeyProvider();
 
         for (int i = 0; i < configuration.getDeviceCount(); i++) {
             if (currentPort > 65535) {
@@ -268,7 +266,7 @@ public class NetconfDeviceSimulator implements Closeable {
     }
 
     private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress,
-            final LocalAddress tcpLocalAddress, final PEMGeneratorHostKeyProvider keyPairProvider) throws IOException {
+            final LocalAddress tcpLocalAddress, final KeyPairProvider keyPairProvider) throws IOException {
         return new SshProxyServerConfigurationBuilder()
                 .setBindingAddress(bindingAddress)
                 .setLocalAddress(tcpLocalAddress)
@@ -279,10 +277,10 @@ public class NetconfDeviceSimulator implements Closeable {
                 .createSshProxyServerConfiguration();
     }
 
-    private PEMGeneratorHostKeyProvider getPemGeneratorHostKeyProvider() {
+    private static KeyPairProvider getPemGeneratorHostKeyProvider() {
         try {
             final Path tempFile = Files.createTempFile("tempKeyNetconfTest", "suffix");
-            return new PEMGeneratorHostKeyProvider(tempFile.toAbsolutePath().toString(), "RSA", 4096);
+            return SecurityUtils.createGeneratorHostKeyProvider(tempFile.toAbsolutePath());
         } catch (final IOException e) {
             LOG.error("Unable to generate PEM key", e);
             throw new RuntimeException(e);
@@ -322,16 +320,16 @@ public class NetconfDeviceSimulator implements Closeable {
         }
 
         configuration.getDefaultYangResources().forEach(r -> {
-            SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create(r.getModuleName(), r.getRevision());
+            SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create(r.getModuleName(),
+                Revision.ofNullable(r.getRevision()));
             registerSource(consumer, r.getResourcePath(), sourceIdentifier);
         });
 
         try {
             //necessary for creating mdsal data stores and operations
-            this.schemaContext = consumer.createSchemaContextFactory(
-                SchemaSourceFilter.ALWAYS_ACCEPT)
-                .createSchemaContext(loadedSources).checkedGet();
-        } catch (final SchemaResolutionException e) {
+            this.schemaContext = consumer.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT)
+                .createSchemaContext(loadedSources).get();
+        } catch (final InterruptedException | ExecutionException e) {
             throw new RuntimeException("Cannot parse schema context", e);
         }
 
@@ -346,43 +344,35 @@ public class NetconfDeviceSimulator implements Closeable {
         return capabilities;
     }
 
-    private void addModuleCapability(final SharedSchemaRepository consumer, final Set<Capability> capabilities,
+    private static void addModuleCapability(final SharedSchemaRepository consumer, final Set<Capability> capabilities,
                                      final Module module) {
-        final SourceIdentifier moduleSourceIdentifier = SourceIdentifier.create(module.getName(),
-                (SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.absent() :
-                        Optional.of(module.getQNameModule().getFormattedRevision())));
+        final SourceIdentifier moduleSourceIdentifier = RevisionSourceIdentifier.create(module.getName(),
+            module.getRevision());
         try {
             final String moduleContent = new String(
-                consumer.getSchemaSource(moduleSourceIdentifier, YangTextSchemaSource.class).checkedGet().read());
+                consumer.getSchemaSource(moduleSourceIdentifier, YangTextSchemaSource.class).get().read());
             capabilities.add(new YangModuleCapability(module, moduleContent));
             //IOException would be thrown in creating SchemaContext already
-        } catch (SchemaSourceException | IOException e) {
+        } catch (ExecutionException | InterruptedException | IOException e) {
             throw new RuntimeException("Cannot retrieve schema source for module "
                 + moduleSourceIdentifier.toString() + " from schema repository", e);
         }
     }
 
-    private void registerSource(final SharedSchemaRepository consumer, final String resource,
+    private static void registerSource(final SharedSchemaRepository consumer, final String resource,
                                 final SourceIdentifier sourceId) {
-        consumer.registerSchemaSource(new SchemaSourceProvider<SchemaSourceRepresentation>() {
+        consumer.registerSchemaSource(sourceIdentifier -> Futures.immediateFuture(new YangTextSchemaSource(sourceId) {
             @Override
-            public CheckedFuture<? extends SchemaSourceRepresentation, SchemaSourceException> getSource(
-                    final SourceIdentifier sourceIdentifier) {
-                return Futures.immediateCheckedFuture(new YangTextSchemaSource(sourceId) {
-                    @Override
-                    protected MoreObjects.ToStringHelper addToStringAttributes(
-                            final MoreObjects.ToStringHelper toStringHelper) {
-                        return toStringHelper;
-                    }
+            protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+                return toStringHelper;
+            }
 
-                    @Override
-                    public InputStream openStream() throws IOException {
-                        return getClass().getResourceAsStream(resource);
-                    }
-                });
+            @Override
+            public InputStream openStream() throws IOException {
+                return getClass().getResourceAsStream(resource);
             }
-        }, PotentialSchemaSource.create(
-            sourceId, YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
+        }), PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class,
+            PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
     }
 
     private static InetSocketAddress getAddress(final String ip, final int port) {
@@ -396,7 +386,11 @@ public class NetconfDeviceSimulator implements Closeable {
     @Override
     public void close() {
         for (final SshProxyServer sshWrapper : sshWrappers) {
-            sshWrapper.close();
+            try {
+                sshWrapper.close();
+            } catch (IOException e) {
+                LOG.debug("Wrapper {} failed to close", sshWrapper, e);
+            }
         }
         for (final Channel deviceCh : devicesChannels) {
             deviceCh.close();
index 15fd535de8c3d0eadf876935720884f2dbd6bf0b..6e474c5e9f1841eee245c988f8439a28b426748d 100644 (file)
@@ -11,6 +11,9 @@ package org.opendaylight.netconf.test.tool;
 import java.io.InputStream;
 
 public final class TestToolUtils {
+    private TestToolUtils() {
+
+    }
 
     public static String getMac(long mac) {
         final StringBuilder builder = new StringBuilder(Long.toString(mac, 16));
index 775aa7670b0a55ac6eb222102a346ea79655657f..dde89e478c94064545a7480840103b3a8ff2a8a9 100644 (file)
@@ -349,7 +349,7 @@ public class TesttoolParameters {
                 editContentString = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
             }
         } catch (final IOException e) {
-            throw new IllegalArgumentException("Cannot read content of " + editContent);
+            throw new IllegalArgumentException("Cannot read content of " + editContent, e);
         }
 
         int from;
index 97b19f909ec3b703a97cbce07d29a76edec61311..334556704b3a946aaebc096bca30c7930d9b3c18 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.netconf.test.tool.TestToolUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestPerfClient {
+public final class RestPerfClient {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestPerfClient.class);
 
@@ -63,6 +63,10 @@ public class RestPerfClient {
         }
     }
 
+    private RestPerfClient() {
+
+    }
+
     public static void main(String[] args) throws IOException {
 
         Parameters parameters = parseArgs(args, Parameters.getParser());
@@ -77,7 +81,7 @@ public class RestPerfClient {
         try {
             editContentString = Files.toString(parameters.editContent, StandardCharsets.UTF_8);
         } catch (final IOException e) {
-            throw new IllegalArgumentException("Cannot read content of " + parameters.editContent);
+            throw new IllegalArgumentException("Cannot read content of " + parameters.editContent, e);
         }
 
         final int threadAmount = parameters.threadAmount;
index ab10fca2d04cdd2a116faa96103344ec94c9494c..2b1279b54399fc9c6434720f26b5e3651e1c1ce2 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 
-public class ConfigurableClientDispatcher extends NetconfClientDispatcherImpl {
+public final class ConfigurableClientDispatcher extends NetconfClientDispatcherImpl {
 
     private final Set<String> capabilities;
 
index 7d1fbcb761b63ff42133188e716d29c396b96ac5..90728207b05f584864e5bcc167aa0ed7d04028f4 100644 (file)
@@ -101,6 +101,10 @@ public final class StressClient {
 
     private static Parameters params;
 
+    private StressClient() {
+
+    }
+
     public static void main(final String[] args) {
 
         params = parseArgs(args, Parameters.getParser());
@@ -134,7 +138,7 @@ public final class StressClient {
         try {
             editContentString = Files.toString(params.editContent, StandardCharsets.UTF_8);
         } catch (final IOException e) {
-            throw new IllegalArgumentException("Cannot read content of " + params.editContent);
+            throw new IllegalArgumentException("Cannot read content of " + params.editContent, e);
         }
 
         for (int i = 0; i < threadAmount; i++) {
@@ -152,7 +156,7 @@ public final class StressClient {
         final NioEventLoopGroup nioGroup = new NioEventLoopGroup();
         final Timer timer = new HashedWheelTimer();
 
-        final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(params, nioGroup, timer);
+        final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(nioGroup, timer);
 
         final List<StressClientCallable> callables = new ArrayList<>(threadAmount);
         for (final List<NetconfMessage> messages : allPreparedMessages) {
@@ -224,8 +228,8 @@ public final class StressClient {
         return netconfMessage;
     }
 
-    private static NetconfClientDispatcherImpl configureClientDispatcher(final Parameters params,
-            final NioEventLoopGroup nioGroup, final Timer timer) {
+    private static NetconfClientDispatcherImpl configureClientDispatcher(final NioEventLoopGroup nioGroup,
+            final Timer timer) {
         final NetconfClientDispatcherImpl netconfClientDispatcher;
         if (params.exi) {
             if (params.legacyFraming) {
index 342d9b2ca266c46b44732d15e3b5c19bfdcfae6c..418329a4b1ee1a8d6e7173c37e885893ee78f97e 100644 (file)
@@ -12,8 +12,7 @@ import java.io.File;
 import java.security.PublicKey;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
-
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.apache.sshd.server.session.ServerSession;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.auth.AuthProvider;
@@ -49,17 +48,14 @@ public class Configuration {
                     "/META-INF/yang/ietf-inet-types@2013-07-15.yang")
     );
 
-    public static final AuthProvider DEFAULT_AUTH_PROVIDER = new AuthProvider() {
-        @Override
-        public boolean authenticated(String username, String password) {
-            LOG.info("Auth with username and password: {}", username);
-            return true;
-        }
+    public static final AuthProvider DEFAULT_AUTH_PROVIDER = (username, password) -> {
+        LOG.info("Auth with username and password: {}", username);
+        return true;
     };
 
     public static final PublickeyAuthenticator DEFAULT_PUBLIC_KEY_AUTHENTICATOR = new PublickeyAuthenticator() {
         @Override
-        public boolean authenticate(String username, PublicKey key, ServerSession session) {
+        public boolean authenticate(final String username, final PublicKey key, final ServerSession session) {
             LOG.info("Auth with public key: {}", key);
             return true;
         }
@@ -102,7 +98,7 @@ public class Configuration {
         return publickeyAuthenticator;
     }
 
-    public void setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) {
+    public void setPublickeyAuthenticator(final PublickeyAuthenticator publickeyAuthenticator) {
         this.publickeyAuthenticator = publickeyAuthenticator;
     }
 
@@ -110,7 +106,7 @@ public class Configuration {
         return authProvider;
     }
 
-    public void setAuthProvider(AuthProvider authProvider) {
+    public void setAuthProvider(final AuthProvider authProvider) {
         this.authProvider = authProvider;
     }
 
@@ -118,7 +114,7 @@ public class Configuration {
         return defaultYangResources;
     }
 
-    public void setDefaultYangResources(Set<YangResource> defaultYangResources) {
+    public void setDefaultYangResources(final Set<YangResource> defaultYangResources) {
         this.defaultYangResources = defaultYangResources;
     }
 
@@ -126,7 +122,7 @@ public class Configuration {
         return threadPoolSize;
     }
 
-    public void setThreadPoolSize(int threadPoolSize) {
+    public void setThreadPoolSize(final int threadPoolSize) {
         this.threadPoolSize = threadPoolSize;
     }
 
@@ -134,7 +130,7 @@ public class Configuration {
         return startingPort;
     }
 
-    public void setStartingPort(int startingPort) {
+    public void setStartingPort(final int startingPort) {
         this.startingPort = startingPort;
     }
 
@@ -142,7 +138,7 @@ public class Configuration {
         return deviceCount;
     }
 
-    public void setDeviceCount(int deviceCount) {
+    public void setDeviceCount(final int deviceCount) {
         this.deviceCount = deviceCount;
     }
 
@@ -150,7 +146,7 @@ public class Configuration {
         return generateConfigsTimeout;
     }
 
-    public void setGenerateConfigsTimeout(int generateConfigsTimeout) {
+    public void setGenerateConfigsTimeout(final int generateConfigsTimeout) {
         this.generateConfigsTimeout = generateConfigsTimeout;
     }
 
@@ -158,7 +154,7 @@ public class Configuration {
         return ssh;
     }
 
-    public void setSsh(boolean ssh) {
+    public void setSsh(final boolean ssh) {
         this.ssh = ssh;
     }
 
@@ -166,7 +162,7 @@ public class Configuration {
         return ip;
     }
 
-    public void setIp(String ip) {
+    public void setIp(final String ip) {
         this.ip = ip;
     }
 
@@ -174,7 +170,7 @@ public class Configuration {
         return models;
     }
 
-    public void setModels(Set<String> models) {
+    public void setModels(final Set<String> models) {
         this.models = models;
     }
 
@@ -182,7 +178,7 @@ public class Configuration {
         return capabilities;
     }
 
-    public void setCapabilities(Set<String> capabilities) {
+    public void setCapabilities(final Set<String> capabilities) {
         this.capabilities = capabilities;
     }
 
@@ -190,7 +186,7 @@ public class Configuration {
         return rpcHandler;
     }
 
-    public void setRpcHandler(RpcHandler rpcHandler) {
+    public void setRpcHandler(final RpcHandler rpcHandler) {
         this.rpcHandler = rpcHandler;
     }
 
@@ -198,7 +194,7 @@ public class Configuration {
         return operationsCreator;
     }
 
-    public void setOperationsCreator(OperationsCreator operationsCreator) {
+    public void setOperationsCreator(final OperationsCreator operationsCreator) {
         this.operationsCreator = operationsCreator;
     }
 
@@ -208,7 +204,7 @@ public class Configuration {
     }
 
     @Deprecated
-    public void setMdSal(boolean mdSal) {
+    public void setMdSal(final boolean mdSal) {
         this.mdSal = mdSal;
     }
 
@@ -218,7 +214,7 @@ public class Configuration {
     }
 
     @Deprecated
-    public void setRpcConfigFile(File rpcConfigFile) {
+    public void setRpcConfigFile(final File rpcConfigFile) {
         this.rpcConfigFile = rpcConfigFile;
     }
 
@@ -228,7 +224,7 @@ public class Configuration {
     }
 
     @Deprecated
-    public void setNotificationFile(File notificationFile) {
+    public void setNotificationFile(final File notificationFile) {
         this.notificationFile = notificationFile;
     }
 
@@ -238,7 +234,7 @@ public class Configuration {
     }
 
     @Deprecated
-    public void setInitialConfigXMLFile(File initialConfigXMLFile) {
+    public void setInitialConfigXMLFile(final File initialConfigXMLFile) {
         this.initialConfigXMLFile = initialConfigXMLFile;
     }
 
@@ -253,7 +249,7 @@ public class Configuration {
     }
 
     @Deprecated
-    public void setSchemasDir(File schemasDir) {
+    public void setSchemasDir(final File schemasDir) {
         this.schemasDir = schemasDir;
     }
 }
index 8c1be77c946d20396e54c8e801a036a9343a29f9..d9be6adb2fdd585666ee9bd57ba76c05caca1ccc 100644 (file)
@@ -9,8 +9,7 @@ package org.opendaylight.netconf.test.tool.config;
 
 import java.io.File;
 import java.util.Set;
-
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.opendaylight.netconf.auth.AuthProvider;
 import org.opendaylight.netconf.test.tool.TesttoolParameters;
 import org.opendaylight.netconf.test.tool.operations.OperationsCreator;
@@ -18,124 +17,124 @@ import org.opendaylight.netconf.test.tool.rpchandler.RpcHandler;
 
 public class ConfigurationBuilder {
 
-    private Configuration configuration;
+    private final Configuration configuration;
 
     public ConfigurationBuilder() {
         this.configuration = new Configuration();
     }
 
-    public ConfigurationBuilder setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) {
+    public ConfigurationBuilder setPublickeyAuthenticator(final PublickeyAuthenticator publickeyAuthenticator) {
         this.configuration.setPublickeyAuthenticator(publickeyAuthenticator);
         return this;
     }
 
-    public ConfigurationBuilder setAuthProvider(AuthProvider authProvider) {
+    public ConfigurationBuilder setAuthProvider(final AuthProvider authProvider) {
         this.configuration.setAuthProvider(authProvider);
         return this;
     }
 
-    public ConfigurationBuilder setGetDefaultYangResources(Set<YangResource> defaultYangResources) {
+    public ConfigurationBuilder setGetDefaultYangResources(final Set<YangResource> defaultYangResources) {
         this.configuration.setDefaultYangResources(defaultYangResources);
         return this;
     }
 
-    public ConfigurationBuilder setThreadPoolSize(int threadPoolSize) {
+    public ConfigurationBuilder setThreadPoolSize(final int threadPoolSize) {
         this.configuration.setThreadPoolSize(threadPoolSize);
         return this;
     }
 
-    public ConfigurationBuilder setGenerateConfigsTimeout(int generateConfigsTimeout) {
+    public ConfigurationBuilder setGenerateConfigsTimeout(final int generateConfigsTimeout) {
         this.configuration.setGenerateConfigsTimeout(generateConfigsTimeout);
         return this;
     }
 
-    public ConfigurationBuilder setModels(Set<String> models) {
+    public ConfigurationBuilder setModels(final Set<String> models) {
         this.configuration.setModels(models);
         return this;
     }
 
-    public ConfigurationBuilder setCapabilities(Set<String> capabilities) {
+    public ConfigurationBuilder setCapabilities(final Set<String> capabilities) {
         this.configuration.setCapabilities(capabilities);
         return this;
     }
 
-    public ConfigurationBuilder setStartingPort(int startingPort) {
+    public ConfigurationBuilder setStartingPort(final int startingPort) {
         this.configuration.setStartingPort(startingPort);
         return this;
     }
 
-    public ConfigurationBuilder setDeviceCount(int deviceCount) {
+    public ConfigurationBuilder setDeviceCount(final int deviceCount) {
         this.configuration.setDeviceCount(deviceCount);
         return this;
     }
 
-    public ConfigurationBuilder setSsh(boolean ssh) {
+    public ConfigurationBuilder setSsh(final boolean ssh) {
         this.configuration.setSsh(ssh);
         return this;
     }
 
-    public ConfigurationBuilder setIp(String ip) {
+    public ConfigurationBuilder setIp(final String ip) {
         this.configuration.setIp(ip);
         return this;
     }
 
-    public ConfigurationBuilder setRpcMapping(RpcHandler rpcHandler) {
+    public ConfigurationBuilder setRpcMapping(final RpcHandler rpcHandler) {
         this.configuration.setRpcHandler(rpcHandler);
         return this;
     }
 
     @Deprecated
-    public ConfigurationBuilder setMdSal(boolean mdSal) {
+    public ConfigurationBuilder setMdSal(final boolean mdSal) {
         this.configuration.setMdSal(mdSal);
         return this;
     }
 
     @Deprecated
-    public ConfigurationBuilder setRpcConfigFile(File rpcConfigFile) {
+    public ConfigurationBuilder setRpcConfigFile(final File rpcConfigFile) {
         this.configuration.setRpcConfigFile(rpcConfigFile);
         return this;
     }
 
     @Deprecated
-    public ConfigurationBuilder setInitialConfigXMLFile(File initialConfigXMLFile) {
+    public ConfigurationBuilder setInitialConfigXMLFile(final File initialConfigXMLFile) {
         this.configuration.setInitialConfigXMLFile(initialConfigXMLFile);
         return this;
     }
 
     @Deprecated
-    public ConfigurationBuilder setNotificationFile(File notificationFile) {
+    public ConfigurationBuilder setNotificationFile(final File notificationFile) {
         this.configuration.setNotificationFile(notificationFile);
         return this;
     }
 
-    public ConfigurationBuilder setOperationsCreator(OperationsCreator operationsCreator) {
+    public ConfigurationBuilder setOperationsCreator(final OperationsCreator operationsCreator) {
         this.configuration.setOperationsCreator(operationsCreator);
         return this;
     }
 
-    public ConfigurationBuilder from(Configuration configuration) {
-        this.configuration.setThreadPoolSize(configuration.getThreadPoolSize());
-        this.configuration.setGenerateConfigsTimeout(configuration.getGenerateConfigsTimeout());
-        this.configuration.setModels(configuration.getModels());
-        this.configuration.setCapabilities(configuration.getCapabilities());
-        this.configuration.setStartingPort(configuration.getStartingPort());
-        this.configuration.setDeviceCount(configuration.getDeviceCount());
-        this.configuration.setSsh(configuration.isSsh());
-        this.configuration.setIp(configuration.getIp());
-        this.configuration.setRpcHandler(configuration.getRpcHandler());
-        this.configuration.setOperationsCreator(configuration.getOperationsCreator());
-        this.configuration.setMdSal(configuration.isMdSal());
-        this.configuration.setRpcConfigFile(configuration.getRpcConfigFile());
-        this.configuration.setInitialConfigXMLFile(configuration.getInitialConfigXMLFile());
-        this.configuration.setNotificationFile(configuration.getNotificationFile());
-        this.configuration.setSchemasDir(configuration.getSchemasDir());
-        this.configuration.setDefaultYangResources(configuration.getDefaultYangResources());
-        this.configuration.setAuthProvider(configuration.getAuthProvider());
-        this.configuration.setPublickeyAuthenticator(configuration.getPublickeyAuthenticator());
+    public ConfigurationBuilder from(final Configuration template) {
+        this.configuration.setThreadPoolSize(template.getThreadPoolSize());
+        this.configuration.setGenerateConfigsTimeout(template.getGenerateConfigsTimeout());
+        this.configuration.setModels(template.getModels());
+        this.configuration.setCapabilities(template.getCapabilities());
+        this.configuration.setStartingPort(template.getStartingPort());
+        this.configuration.setDeviceCount(template.getDeviceCount());
+        this.configuration.setSsh(template.isSsh());
+        this.configuration.setIp(template.getIp());
+        this.configuration.setRpcHandler(template.getRpcHandler());
+        this.configuration.setOperationsCreator(template.getOperationsCreator());
+        this.configuration.setMdSal(template.isMdSal());
+        this.configuration.setRpcConfigFile(template.getRpcConfigFile());
+        this.configuration.setInitialConfigXMLFile(template.getInitialConfigXMLFile());
+        this.configuration.setNotificationFile(template.getNotificationFile());
+        this.configuration.setSchemasDir(template.getSchemasDir());
+        this.configuration.setDefaultYangResources(template.getDefaultYangResources());
+        this.configuration.setAuthProvider(template.getAuthProvider());
+        this.configuration.setPublickeyAuthenticator(template.getPublickeyAuthenticator());
         return this;
     }
 
-    public ConfigurationBuilder from(TesttoolParameters testtoolParameters) {
+    public ConfigurationBuilder from(final TesttoolParameters testtoolParameters) {
         this.configuration.setGenerateConfigsTimeout(testtoolParameters.generateConfigsTimeout);
         this.configuration.setStartingPort(testtoolParameters.startingPort);
         this.configuration.setDeviceCount(testtoolParameters.deviceCount);
index 2edab7e0a7cb2a98f280478be9d7554cf3bc3ed1..a1faa4495069910ee3d0b99a9cf3994a03935033 100644 (file)
@@ -76,7 +76,7 @@ class RpcMapping {
         private final XmlElement xmlElement;
         private final int hashCode;
 
-        private Request(final XmlElement element) {
+        Request(final XmlElement element) {
             this.xmlElement = element;
             hashCode = XmlUtil.toString(element)
                     .replaceAll("message-id=.*(>| )", "") //message id is variable, remove it
index d811fe70f435be487e88917e4a859fc22e54388c..d0e19cef972c2df31bd4390e80a69569292be978 100644 (file)
@@ -46,7 +46,7 @@ public class SettableOperationProvider implements NetconfOperationServiceFactory
 
         private final SettableRpc rpc;
 
-        private SettableOperationService(final File rpcConfig) {
+        SettableOperationService(final File rpcConfig) {
             this.rpc = new SettableRpc(rpcConfig);
         }
 
index fddc0be003f9de1acec2c32f874b28ac025cf3d0..49a60da37fd970ea9f62eafda20ad2678a5b30da 100644 (file)
@@ -58,7 +58,7 @@ class SettableRpc implements NetconfOperation {
         }
     }
 
-    private void checkForError(final Document document) throws DocumentedException {
+    private static void checkForError(final Document document) throws DocumentedException {
         final XmlElement rpcReply = XmlElement.fromDomDocument(document);
         if (rpcReply.getOnlyChildElementOptionally("rpc-error").isPresent()) {
             throw DocumentedException.fromXMLDocument(document);
index 21e2b59169ceea5169ecb395f9a8962c826d2d6c..d528df5b5164cbe74a678cdc9ed2da655047d095 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.netconf.test.tool.rpc.SimulatedGetConfig;
 import org.opendaylight.netconf.test.tool.rpc.SimulatedLock;
 import org.opendaylight.netconf.test.tool.rpc.SimulatedUnLock;
 
-public class DefaultOperationsCreator implements OperationsCreator {
+public final class DefaultOperationsCreator implements OperationsCreator {
 
     private final SimulatedOperationService simulatedOperationService;
 
index 9ec5795de21f0b87d6d7d727ed4d03a4a56916f1..682723af1714969c00fb07cfcbeae0313cb14c7c 100644 (file)
@@ -46,19 +46,19 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
     public SimulatedCreateSubscription(final String id, final Optional<File> notificationsFile) {
         super(id);
 
-        Optional<Notifications> notifications;
+        Optional<Notifications> notifs;
 
         if (notificationsFile.isPresent()) {
-            notifications = Optional.of(loadNotifications(notificationsFile.get()));
+            notifs = Optional.of(loadNotifications(notificationsFile.get()));
             scheduledExecutorService = Executors.newScheduledThreadPool(1);
         } else {
-            notifications = Optional.absent();
+            notifs = Optional.absent();
         }
 
-        if (notifications.isPresent()) {
+        if (notifs.isPresent()) {
             Map<Notification, NetconfMessage> preparedMessages = Maps.newHashMapWithExpectedSize(
-                notifications.get().getNotificationList().size());
-            for (final Notification notification : notifications.get().getNotificationList()) {
+                notifs.get().getNotificationList().size());
+            for (final Notification notification : notifs.get().getNotificationList()) {
                 final NetconfMessage parsedNotification = parseNetconfNotification(notification.getContent());
                 preparedMessages.put(notification, parsedNotification);
             }
@@ -69,7 +69,7 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
 
     }
 
-    private Notifications loadNotifications(final File file) {
+    private static Notifications loadNotifications(final File file) {
         try {
             final JAXBContext jaxbContext = JAXBContext.newInstance(Notifications.class);
             final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
@@ -99,12 +99,9 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
 
                 delayAggregator += notification.getKey().getDelayInSeconds();
 
-                scheduledExecutorService.schedule(new Runnable() {
-                    @Override
-                    public void run() {
-                        Preconditions.checkState(session != null, "Session is not set, cannot process notifications");
-                        session.sendMessage(notification.getValue());
-                    }
+                scheduledExecutorService.schedule(() -> {
+                    Preconditions.checkState(session != null, "Session is not set, cannot process notifications");
+                    session.sendMessage(notification.getValue());
                 }, delayAggregator, TimeUnit.SECONDS);
             }
         }
@@ -127,8 +124,8 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
     }
 
     @Override
-    public void setNetconfSession(final NetconfServerSession session) {
-        this.session = session;
+    public void setNetconfSession(final NetconfServerSession newSession) {
+        this.session = newSession;
     }
 
     @XmlRootElement(name = "notifications")
index e6db368b928cde01f861a58410c34bd9f71797a6..f139a9000d50976943fdc56448377ea8c2cecf9e 100644 (file)
@@ -43,7 +43,7 @@ public class SimulatedGetConfig extends AbstractConfigNetconfOperation {
         }
     }
 
-    private DataList loadInitialConfigXMLFile(final File file) {
+    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();
index 66199d984c15ce49dedcdcdce06730e82fb49ad9..ed36c443981629d633811966385ff1b2d2283bb3 100644 (file)
@@ -45,7 +45,7 @@ public class SettableOperationRpcProvider implements NetconfOperationServiceFact
 
         private final SettableRpc rpc;
 
-        private SettableOperationService(RpcHandler rpcHandler) {
+        SettableOperationService(RpcHandler rpcHandler) {
             this.rpc = new SettableRpc(rpcHandler);
         }
 
index 1f2b97df6264f05bc382e5786efeb882169a2479..a85136564ae9b2617a3f481064d3c55b460af4b3 100644 (file)
@@ -27,7 +27,7 @@ class SettableRpc implements NetconfOperation {
 
     private final RpcHandler rpcHandler;
 
-    SettableRpc(RpcHandler rpcHandler) {
+    SettableRpc(final RpcHandler rpcHandler) {
         this.rpcHandler = rpcHandler;
     }
 
@@ -57,7 +57,7 @@ class SettableRpc implements NetconfOperation {
         }
     }
 
-    private void checkForError(final Document document) throws DocumentedException {
+    private static void checkForError(final Document document) throws DocumentedException {
         final XmlElement rpcReply = XmlElement.fromDomDocument(document);
         if (rpcReply.getOnlyChildElementOptionally("rpc-error").isPresent()) {
             throw DocumentedException.fromXMLDocument(document);
index 9ece5a910baa11d5154e31d9fc98ae7c4a8fba2e..51f80848bd2a86463cf333f7eb0e62f12ef1acfa 100644 (file)
@@ -8,21 +8,21 @@
 package org.opendaylight.netconf.test.tool.schemacache;
 
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.opendaylight.netconf.test.tool.TestToolUtils;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -40,9 +40,8 @@ public final class SchemaSourceCache<T extends SchemaSourceRepresentation>
 
     private static final Logger LOG = LoggerFactory.getLogger(SchemaSourceCache.class);
 
-    public static final Pattern CACHED_FILE_PATTERN =
-            Pattern.compile(
-                    ".*/(?<moduleName>[^@]+)" + "(@(?<revision>" + SourceIdentifier.REVISION_PATTERN + "))?.yang");
+    public static final Pattern CACHED_FILE_PATTERN = Pattern.compile(
+                    ".*/(?<moduleName>[^@]+)" + "(@(?<revision>" + Revision.STRING_FORMAT_PATTERN + "))?.yang");
 
     private final Class<T> representation;
     private final Set<String> modelList;
@@ -77,17 +76,15 @@ public final class SchemaSourceCache<T extends SchemaSourceRepresentation>
     }
 
     @Override
-    public synchronized CheckedFuture<? extends T, SchemaSourceException> getSource(
-            final SourceIdentifier sourceIdentifier) {
+    public synchronized ListenableFuture<? extends T> getSource(final SourceIdentifier sourceIdentifier) {
         ModelData modelData = cachedSchemas.get(sourceIdentifier.toYangFilename());
         if (modelData != null) {
             final SchemaSourceRepresentation restored = restoreAsType(modelData.getId(), modelData.getPath());
-            return Futures.immediateCheckedFuture(representation.cast(restored));
-        } else {
-            LOG.debug("Source {} not found in cache as {}", sourceIdentifier);
-            return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found",
-                    sourceIdentifier));
+            return Futures.immediateFuture(representation.cast(restored));
         }
+
+        LOG.debug("Source {} not found in cache as {}", sourceIdentifier);
+        return Futures.immediateFailedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
     }
 
     @Override
@@ -95,7 +92,8 @@ public final class SchemaSourceCache<T extends SchemaSourceRepresentation>
         LOG.trace("Source {} offered to cache", source.getIdentifier());
     }
 
-    private YangTextSchemaSource restoreAsType(final SourceIdentifier sourceIdentifier, final String cachedSource) {
+    private static YangTextSchemaSource restoreAsType(final SourceIdentifier sourceIdentifier,
+            final String cachedSource) {
         return new YangTextSchemaSource(sourceIdentifier) {
 
             @Override
@@ -114,10 +112,9 @@ public final class SchemaSourceCache<T extends SchemaSourceRepresentation>
         final Matcher matcher = CACHED_FILE_PATTERN.matcher(fileName);
         if (matcher.matches()) {
             final String moduleName = matcher.group("moduleName");
-            final String revision = matcher.group("revision");
-            return Optional.of(RevisionSourceIdentifier.create(moduleName, Optional.fromNullable(revision)));
+            final Optional<Revision> revision = Revision.ofNullable(matcher.group("revision"));
+            return Optional.of(RevisionSourceIdentifier.create(moduleName, revision));
         }
-        return Optional.absent();
+        return Optional.empty();
     }
-
 }
index e974af7312899ccefbfe96e88c8155a9ac400365..5f0948b9b0dccfae6e7dc6c1aac563aeceb73a91 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index df88860c1f7e757ce548c2f0bb171b84a4c661e2..ba7e22a025bc26bcb5ef251821293bd85f9fdecd 100644 (file)
@@ -5,7 +5,6 @@
  * 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.yanglib.impl;
 
 import com.google.common.base.Preconditions;
@@ -33,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.librar
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -47,7 +47,6 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Listens on new schema sources registered event. For each new source
  * registered generates URL representing its schema source and write this URL
@@ -186,14 +185,12 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
     }
 
     private static String revString(final SourceIdentifier id) {
-        final String rev = id.getRevision();
-        return rev == null || SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(rev) ? "" : rev;
+        return id.getRevision().map(Revision::toString).orElse("");
     }
 
     private static OptionalRevision getRevisionForModule(final SourceIdentifier sourceIdentifier) {
-        final String rev = sourceIdentifier.getRevision();
-        return rev == null || SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(rev) ? NO_REVISION
-                : new OptionalRevision(new RevisionIdentifier(rev));
+        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) {
index 5f66daea8212fdddc63ddb3284957e4f03274f3f..e75776f84b533c6f7baefa94ab5d0b198ffce754 100644 (file)
@@ -8,15 +8,15 @@
 
 package org.opendaylight.yanglib.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.yanglib.api.YangLibService;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.slf4j.Logger;
@@ -43,17 +43,17 @@ public class YangLibServiceImpl implements YangLibService {
     public String getSchema(final String name, final String revision) {
         Preconditions.checkNotNull(schemaRepository, "Schema repository is not initialized");
         LOG.debug("Attempting load for schema source {}:{}", name, revision);
-        final SourceIdentifier sourceId =
-                RevisionSourceIdentifier.create(name, Optional.fromNullable(revision.equals("") ? null : revision));
+        final SourceIdentifier sourceId = RevisionSourceIdentifier.create(name,
+            revision.isEmpty() ? null : Revision.of(revision));
 
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> sourceFuture =
-                schemaRepository.getSchemaSource(sourceId, YangTextSchemaSource.class);
+        final ListenableFuture<YangTextSchemaSource> sourceFuture = schemaRepository.getSchemaSource(sourceId,
+            YangTextSchemaSource.class);
 
         try {
-            final YangTextSchemaSource source = sourceFuture.checkedGet();
+            final YangTextSchemaSource source = sourceFuture.get();
             return new String(ByteStreams.toByteArray(source.openStream()));
-        } catch (SchemaSourceException | IOException e) {
-            throw new IllegalStateException("Unable to get schema" + sourceId, e);
+        } catch (InterruptedException | ExecutionException | IOException e) {
+            throw new IllegalStateException("Unable to get schema " + sourceId, e);
         }
     }
 }
index ab0cb2359c90576b5d8ea1c15862fb54ccb8db9a..5372a072605f4e243d216a438fa0b07eff6d2e8c 100644 (file)
@@ -45,11 +45,12 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfigBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.api.YinSchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
-import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
 
 public class YangLibProviderTest {
     private static final File CACHE_DIR = new File("target/yanglib");
@@ -106,7 +107,7 @@ public class YangLibProviderTest {
 
         list.add(
                 PotentialSchemaSource.create(
-                        RevisionSourceIdentifier.create("with-revision", "2016-04-28"),
+                        RevisionSourceIdentifier.create("with-revision", Revision.of("2016-04-28")),
                         YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
 
         when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
@@ -224,7 +225,7 @@ public class YangLibProviderTest {
 
         yangUnregistererSource =
                 PotentialSchemaSource.create(
-                        RevisionSourceIdentifier.create("unregistered-yang-with-revision", "2016-04-28"),
+                        RevisionSourceIdentifier.create("unregistered-yang-with-revision", Revision.of("2016-04-28")),
                         YangTextSchemaSource.class, PotentialSchemaSource.Costs.LOCAL_IO.getValue());
 
         yangLibProvider.schemaSourceUnregistered(yangUnregistererSource);
index ab1b55210ef24aba15538c347aad24f54296d199..4c9338e1e7b8bc2ef77de8bfa5de71ac5488f991 100644 (file)
@@ -14,13 +14,14 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
-import com.google.common.base.MoreObjects;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -38,11 +39,11 @@ public class YangLibServiceImplTest {
         final YangLibServiceImpl yangLibService = new YangLibServiceImpl();
         yangLibService.setSchemaRepository(schemaRepository);
 
-        final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("name", "2016-01-01");
+        final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("name", Revision.of("2016-01-01"));
 
         final YangTextSchemaSource yangTextSchemaSource = new YangTextSchemaSource(sourceIdentifier) {
             @Override
-            protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper) {
+            protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
                 return null;
             }
 
@@ -52,8 +53,7 @@ public class YangLibServiceImplTest {
             }
         };
 
-        final CheckedFuture<YangTextSchemaSource, SchemaSourceException> sourceFuture =
-                Futures.immediateCheckedFuture(yangTextSchemaSource);
+        final ListenableFuture<YangTextSchemaSource> sourceFuture = Futures.immediateFuture(yangTextSchemaSource);
         doReturn(sourceFuture).when(schemaRepository).getSchemaSource(any(SourceIdentifier.class),
                 eq(YangTextSchemaSource.class));
 
diff --git a/pom.xml b/pom.xml
index 20fff3c8d81e65179639a70d0bbf81c05cbbadb1..03d397b083098c48cd71713dde197a2a11a20459 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 69cfe192c4015b7f4ae6c4dfac8a19d174741cbc..fa4245495c0c236cd610d4b06e4702d34b53b483 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -48,7 +48,7 @@
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>mockito-configuration</artifactId>
-      <version>1.2.0</version>
+      <version>2.0.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
index 20e54376d3a974532b44e642f6e7fc07560503d7..521233e10ae08401f25e354cc605c37e994009f9 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
index 15f4182f5461e67d22bc4eb90972787cd654ceff..ef40382952542d20a241ec9f59f4e82998092c90 100644 (file)
@@ -15,7 +15,7 @@
     <parent>
       <groupId>org.opendaylight.odlparent</groupId>
       <artifactId>odlparent-lite</artifactId>
-      <version>2.0.5</version>
+      <version>3.0.2</version>
       <relativePath/>
     </parent>
 
index 38a62117498c0d70ab4f13f38b92f9bcc0151b70..18519d6e9873a0e1964b028bbaa7d1e6d30d9ddc 100644 (file)
@@ -156,7 +156,7 @@ public class RestconfDocumentedException extends WebApplicationException {
         this.status = status;
     }
 
-    private RestconfDocumentedException(final Throwable cause, final RestconfError error) {
+    public RestconfDocumentedException(final Throwable cause, final RestconfError error) {
         super(cause);
         Preconditions.checkNotNull(error, "RestconfError can't be null");
         errors = ImmutableList.of(error);
index ddc816d59e9db5e5d6623e618d7664dd67aafe20..31be076851f45cd4ae3af734cce28a2cf177e93a 100644 (file)
@@ -9,13 +9,11 @@
 package org.opendaylight.restconf.common.util;
 
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
 /**
@@ -47,7 +45,7 @@ public class RestconfSchemaUtilTest {
     private static SchemaNode mockSchemaNode(final String origKey) {
         final SchemaNode mockSchNode = Mockito.mock(SchemaNode.class);
         Mockito.when(mockSchNode.getQName())
-                .thenReturn(QName.create("ns", SimpleDateFormatUtil.getRevisionFormat().format(new Date()), origKey));
+                .thenReturn(QName.create("ns", "2016-10-10", origKey));
         return mockSchNode;
     }
 }
index 825983dbd0ce33d102338e0639df1badf70766a3..5a11502f6cd80a979c79245db1e63c485df23589 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 4826405496ce17653e41e02f50b070e4adc177fb..941f3a9d2fee1826b79a7287a3e63c0a48902e2a 100644 (file)
@@ -11,6 +11,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.concurrent.ExecutionException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
@@ -19,7 +20,6 @@ import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 import org.opendaylight.restconf.common.schema.SchemaExportContext;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 
 @Provider
@@ -44,11 +44,11 @@ public class SchemaExportContentYangBodyWriter implements MessageBodyWriter<Sche
             final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
             WebApplicationException {
         final RevisionSourceIdentifier sourceId = RevisionSourceIdentifier.create(context.getModule().getName(),
-                context.getModule().getQNameModule().getFormattedRevision());
+                context.getModule().getQNameModule().getRevision());
         final YangTextSchemaSource yangTextSchemaSource;
         try {
-            yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).checkedGet();
-        } catch (SchemaSourceException e) {
+            yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).get();
+        } catch (InterruptedException | ExecutionException e) {
             throw new WebApplicationException("Unable to retrieve source from SourceProvider.", e);
         }
         yangTextSchemaSource.copyTo(entityStream);
index 7282d03b1a7b8b27ed48fb499ddacfbd077c9db5..45a677df1c2f1eb337f7912f5f5d7fc7db88bfca 100644 (file)
@@ -9,8 +9,7 @@ package org.opendaylight.netconf.md.sal.rest.schema;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
-import java.text.ParseException;
-import java.util.Date;
+import java.time.format.DateTimeParseException;
 import java.util.Iterator;
 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
@@ -20,7 +19,7 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.schema.SchemaExportContext;
 import org.opendaylight.restconf.common.validation.RestconfValidationUtils;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -76,13 +75,11 @@ public class SchemaRetrievalServiceImpl implements SchemaRetrievalService {
              final String moduleName, final String revisionStr,
              final DOMYangTextSourceProvider yangTextSourceProvider) {
         try {
-            final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse(revisionStr);
-            final Module module = schemaContext.findModuleByName(moduleName, revision);
-
+            final Module module = schemaContext.findModule(moduleName, Revision.of(revisionStr)).orElse(null);
             return new SchemaExportContext(
                     schemaContext, RestconfValidationUtils.checkNotNullDocumented(module, moduleName),
                     yangTextSourceProvider);
-        } catch (final ParseException e) {
+        } catch (final DateTimeParseException e) {
             throw new RestconfDocumentedException("Supplied revision is not in expected date format YYYY-mm-dd", e);
         }
     }
index 7b088f69e7b105cf532560d28d3265f8146363e9..9374f13e493af38c7dd9ad158cd7867c2b241bd3 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.netconf.sal.rest.impl;
 
 import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterables;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.netconf.sal.rest.api.RestconfNormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.common.QName;
index cfab0111a8462a33d6489e2a15ca85eb5eee2c20..38e3c130001948d6c1db9b0fc738cf4d9de68ea3 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit
 /**
  * This class just delegates all of the functionality to Yangtools normalized node writer.
  */
-public class RestconfDelegatingNormalizedNodeWriter implements RestconfNormalizedNodeWriter {
+public final class RestconfDelegatingNormalizedNodeWriter implements RestconfNormalizedNodeWriter {
     private NormalizedNodeWriter delegNNWriter;
 
     private RestconfDelegatingNormalizedNodeWriter(NormalizedNodeStreamWriter streamWriter, final boolean
index f4833c07c6a0bd67ea9f2b3f1533f5aa50c072e6..ef0c8a3eb588a303fa017709cc6f131774a0ddf9 100644 (file)
@@ -44,9 +44,9 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
     @Override
     protected Module moduleForPrefix(@Nonnull final String prefix) {
         if (prefix.isEmpty() && !this.defaultPrefix.isEmpty()) {
-            return this.context.findModuleByName(this.defaultPrefix, null);
+            return this.context.findModules(this.defaultPrefix).stream().findFirst().orElse(null);
         } else {
-            return this.context.findModuleByName(prefix, null);
+            return this.context.findModules(prefix).stream().findFirst().orElse(null);
         }
     }
 
@@ -59,7 +59,6 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
     @Nullable
     @Override
     protected String prefixForNamespace(@Nonnull final URI namespace) {
-        final Module module = this.context.findModuleByNamespaceAndRevision(namespace, null);
-        return module == null ? null : module.getName();
+        return this.context.findModules(namespace).stream().findFirst().map(Module::getName).orElse(null);
     }
 }
\ No newline at end of file
index 4c2eae4992aaabed1f6ff2e239b2d3f7f2038d42..12d933f4b1faa01cb4e425fec907c8b32a283d82 100644 (file)
@@ -47,9 +47,9 @@ import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -134,8 +134,8 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
             }
             while (!foundSchemaNodes.isEmpty()) {
                 final Object child = foundSchemaNodes.pop();
-                if (child instanceof AugmentationSchema) {
-                    final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child;
+                if (child instanceof AugmentationSchemaNode) {
+                    final AugmentationSchemaNode augmentSchemaNode = (AugmentationSchemaNode) child;
                     iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode));
                 } else if (child instanceof DataSchemaNode) {
                     schemaNode = (DataSchemaNode) child;
@@ -205,7 +205,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
 
                 // find augmentation
                 if (child.isAugmenting()) {
-                    final AugmentationSchema augment = findCorrespondingAugment(schemaNode, child);
+                    final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, child);
                     if (augment != null) {
                         result.push(augment);
                     }
@@ -217,12 +217,12 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
         }
 
         for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
-            for (final ChoiceCaseNode caseNode : choiceNode.getCases()) {
+            for (final CaseSchemaNode caseNode : choiceNode.getCases().values()) {
                 final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
                 if (!resultFromRecursion.isEmpty()) {
                     resultFromRecursion.push(choiceNode);
                     if (choiceNode.isAugmenting()) {
-                        final AugmentationSchema augment = findCorrespondingAugment(schemaNode, choiceNode);
+                        final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, choiceNode);
                         if (augment != null) {
                             resultFromRecursion.push(augment);
                         }
@@ -234,10 +234,11 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
         return result;
     }
 
-    private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent,
+    private static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent,
                                                                final DataSchemaNode child) {
-        if ((parent instanceof AugmentationTarget) && !(parent instanceof ChoiceSchemaNode)) {
-            for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
+        if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) {
+            for (final AugmentationSchemaNode augmentation :
+                    ((AugmentationTarget) parent).getAvailableAugmentations()) {
                 final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName());
                 if (childInAugmentation != null) {
                     return augmentation;
index c81c770e8c5f63014800980c3ee2a072187cf3af..fdc2896fb0bac80f6dc7e18b55a503c04851066a 100644 (file)
@@ -42,6 +42,7 @@ import org.opendaylight.restconf.common.patch.PatchEntity;
 import org.opendaylight.restconf.common.util.RestUtil;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -106,7 +107,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
             LOG.debug("Error parsing xml input", e);
 
             throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
-                    ErrorTag.MALFORMED_MESSAGE);
+                    ErrorTag.MALFORMED_MESSAGE, e);
         }
     }
 
@@ -132,8 +133,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
                     ? schemaNode.getQName().getNamespace().toString() : firstValueElement.getNamespaceURI();
 
             // find module according to namespace
-            final Module module = pathContext.getSchemaContext().findModuleByNamespace(
-                    URI.create(namespace)).iterator().next();
+            final Module module = pathContext.getSchemaContext().findModules(URI.create(namespace)).iterator().next();
 
             // initialize codec + set default prefix derived from module name
             final StringModuleInstanceIdentifierCodec codec = new StringModuleInstanceIdentifierCodec(
@@ -149,7 +149,8 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
             } else {
                 targetII = codec.deserialize(codec.serialize(pathContext.getInstanceIdentifier())
                         .concat(prepareNonCondXpath(schemaNode, target.replaceFirst("/", ""), firstValueElement,
-                                namespace, module.getQNameModule().getFormattedRevision())));
+                                namespace,
+                                module.getQNameModule().getRevision().map(Revision::toString).orElse(null))));
 
                 targetNode = SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(),
                         codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath().getParent());
index 3b460fdfa1f521427a62089352111a4a466498a9..1e3379cabc64edaee576662bdc5c2ec545379e66 100644 (file)
@@ -97,14 +97,16 @@ public class BrokerFacade {
     private DOMDataBroker domDataBroker;
     private DOMNotificationService domNotification;
 
-    private BrokerFacade() {}
+    BrokerFacade() {
+
+    }
 
     public void setRpcService(final DOMRpcService router) {
         this.rpcService = router;
     }
 
-    public void setDomNotificationService(final DOMNotificationService domNotification) {
-        this.domNotification = domNotification;
+    public void setDomNotificationService(final DOMNotificationService service) {
+        this.domNotification = service;
     }
 
     public static BrokerFacade getInstance() {
@@ -563,7 +565,7 @@ public class BrokerFacade {
                     throw new RestconfDocumentedException(
                             error.getMessage(),
                             ErrorType.TRANSPORT,
-                            ErrorTag.RESOURCE_DENIED_TRANSPORT);
+                            ErrorTag.RESOURCE_DENIED_TRANSPORT, e);
                 }
             }
             throw new RestconfDocumentedException("Error reading data.", e, e.getErrorList());
@@ -620,8 +622,8 @@ public class BrokerFacade {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (keys.contains(child.getNodeType())) {
@@ -675,8 +677,8 @@ public class BrokerFacade {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (trim) {
index a99495cc052b5db7a059e20e7867c970c8651db5..0707231f7b350e0718683a33ebaaf6e3c6b3c6af 100644 (file)
@@ -23,8 +23,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -36,6 +36,7 @@ import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
+import org.opendaylight.netconf.sal.rest.api.Draft02;
 import org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
@@ -44,6 +45,7 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.util.RestUtil;
 import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
@@ -51,7 +53,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -116,7 +118,8 @@ public class ControllerContext implements SchemaContextListener {
         this.yangTextSourceProvider = yangTextSourceProvider;
     }
 
-    private ControllerContext() {
+    ControllerContext() {
+
     }
 
     public static ControllerContext getInstance() {
@@ -168,15 +171,15 @@ public class ControllerContext implements SchemaContextListener {
         }
 
         final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder();
-        final Module latestModule = this.globalSchema.findModuleByName(startModule, null);
+        final Set<Module> latestModule = this.globalSchema.findModules(startModule);
 
-        if (latestModule == null) {
+        if (latestModule.isEmpty()) {
             throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.",
                     ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
         }
 
         final InstanceIdentifierContext<?> iiWithSchemaNode =
-                collectPathArguments(builder, pathArgs, latestModule, null, toMountPointIdentifier);
+                collectPathArguments(builder, pathArgs, latestModule.iterator().next(), null, toMountPointIdentifier);
 
         if (iiWithSchemaNode == null) {
             throw new RestconfDocumentedException("URI has bad format", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
@@ -209,55 +212,52 @@ public class ControllerContext implements SchemaContextListener {
 
     public Module findModuleByName(final String moduleName) {
         checkPreconditions();
-        Preconditions.checkArgument((moduleName != null) && !moduleName.isEmpty());
-        return this.globalSchema.findModuleByName(moduleName, null);
+        Preconditions.checkArgument(moduleName != null && !moduleName.isEmpty());
+        return this.globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
     public Module findModuleByName(final DOMMountPoint mountPoint, final String moduleName) {
-        Preconditions.checkArgument((moduleName != null) && (mountPoint != null));
+        Preconditions.checkArgument(moduleName != null && mountPoint != null);
 
         final SchemaContext mountPointSchema = mountPoint.getSchemaContext();
         if (mountPointSchema == null) {
             return null;
         }
 
-        return mountPointSchema.findModuleByName(moduleName, null);
+        return mountPointSchema.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
     public Module findModuleByNamespace(final URI namespace) {
         checkPreconditions();
         Preconditions.checkArgument(namespace != null);
-        return this.globalSchema.findModuleByNamespaceAndRevision(namespace, null);
+        return this.globalSchema.findModules(namespace).stream().findFirst().orElse(null);
     }
 
     public Module findModuleByNamespace(final DOMMountPoint mountPoint, final URI namespace) {
-        Preconditions.checkArgument((namespace != null) && (mountPoint != null));
+        Preconditions.checkArgument(namespace != null && mountPoint != null);
 
         final SchemaContext mountPointSchema = mountPoint.getSchemaContext();
         if (mountPointSchema == null) {
             return null;
         }
 
-        return mountPointSchema.findModuleByNamespaceAndRevision(namespace, null);
+        return mountPointSchema.findModules(namespace).stream().findFirst().orElse(null);
     }
 
-    public Module findModuleByNameAndRevision(final QName module) {
+    public Module findModuleByNameAndRevision(final String name, final Revision revision) {
         checkPreconditions();
-        Preconditions
-                .checkArgument((module != null) && (module.getLocalName() != null) && (module.getRevision() != null));
+        Preconditions.checkArgument(name != null && revision != null);
 
-        return this.globalSchema.findModuleByName(module.getLocalName(), module.getRevision());
+        return this.globalSchema.findModule(name, revision).orElse(null);
     }
 
-    public Module findModuleByNameAndRevision(final DOMMountPoint mountPoint, final QName module) {
+    public Module findModuleByNameAndRevision(final DOMMountPoint mountPoint, final String name,
+            final Revision revision) {
         checkPreconditions();
-        Preconditions
-                .checkArgument((module != null) && (module.getLocalName() != null) && (module.getRevision() != null)
-                && (mountPoint != null));
+        Preconditions.checkArgument(name != null && revision != null && mountPoint != null);
 
         final SchemaContext schemaContext = mountPoint.getSchemaContext();
-        return schemaContext == null ? null : schemaContext.findModuleByName(module.getLocalName(),
-                module.getRevision());
+        return schemaContext == null ? null : schemaContext.findModule(name, revision).orElse(null);
     }
 
     public DataNodeContainer getDataNodeContainerFor(final YangInstanceIdentifier path) {
@@ -266,13 +266,12 @@ public class ControllerContext implements SchemaContextListener {
         final Iterable<PathArgument> elements = path.getPathArguments();
         final PathArgument head = elements.iterator().next();
         final QName startQName = head.getNodeType();
-        final Module initialModule = this.globalSchema.findModuleByNamespaceAndRevision(startQName.getNamespace(),
-                startQName.getRevision());
+        final Module initialModule = this.globalSchema.findModule(startQName.getModule()).orElse(null);
         DataNodeContainer node = initialModule;
         for (final PathArgument element : elements) {
             final QName _nodeType = element.getNodeType();
             final DataSchemaNode potentialNode = childByQName(node, _nodeType);
-            if ((potentialNode == null) || !isListOrContainer(potentialNode)) {
+            if (potentialNode == null || !isListOrContainer(potentialNode)) {
                 return null;
             }
             node = (DataNodeContainer) potentialNode;
@@ -294,14 +293,13 @@ public class ControllerContext implements SchemaContextListener {
         } else {
             schemaContext = this.globalSchema;
         }
-        final Module initialModule = schemaContext.findModuleByNamespaceAndRevision(startQName.getNamespace(),
-                startQName.getRevision());
+        final Module initialModule = schemaContext.findModule(startQName.getModule()).orElse(null);
         DataNodeContainer node = initialModule;
         for (final PathArgument element : elements) {
             if (!(element instanceof AugmentationIdentifier)) {
                 final QName _nodeType = element.getNodeType();
                 final DataSchemaNode potentialNode = childByQName(node, _nodeType);
-                if (!((element instanceof NodeIdentifier) && (potentialNode instanceof ListSchemaNode))
+                if (!(element instanceof NodeIdentifier && potentialNode instanceof ListSchemaNode)
                         && !(potentialNode instanceof ChoiceSchemaNode)) {
                     builder.append(convertToRestconfIdentifier(element, potentialNode, mount));
                     if (potentialNode instanceof DataNodeContainer) {
@@ -349,7 +347,7 @@ public class ControllerContext implements SchemaContextListener {
     }
 
     private static CharSequence toRestconfIdentifier(final SchemaContext context, final QName qname) {
-        final Module schema = context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision());
+        final Module schema = context.findModule(qname.getModule()).orElse(null);
         return schema == null ? null : schema.getName() + ':' + qname.getLocalName();
     }
 
@@ -380,7 +378,7 @@ public class ControllerContext implements SchemaContextListener {
     }
 
     public Module getRestconfModule() {
-        return findModuleByNameAndRevision(RestConfModule.IETF_RESTCONF_QNAME);
+        return findModuleByNameAndRevision(Draft02.RestConfModule.NAME, Revision.of(Draft02.RestConfModule.REVISION));
     }
 
     public DataSchemaNode getRestconfModuleErrorsSchemaNode() {
@@ -423,33 +421,33 @@ public class ControllerContext implements SchemaContextListener {
 
         if (RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
             final List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         } else if (RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
             final List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         } else if (RestConfModule.STREAM_LIST_SCHEMA_NODE.equals(schemaNodeName)) {
             List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
             final DataSchemaNode modules = Iterables.getFirst(instances, null);
-            instances = findInstanceDataChildrenByName(((DataNodeContainer) modules),
+            instances = findInstanceDataChildrenByName((DataNodeContainer) modules,
                     RestConfModule.STREAM_LIST_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         } else if (RestConfModule.MODULES_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
             final List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         } else if (RestConfModule.MODULE_LIST_SCHEMA_NODE.equals(schemaNodeName)) {
             List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
             final DataSchemaNode modules = Iterables.getFirst(instances, null);
-            instances = findInstanceDataChildrenByName(((DataNodeContainer) modules),
+            instances = findInstanceDataChildrenByName((DataNodeContainer) modules,
                     RestConfModule.MODULE_LIST_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         } else if (RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
             final List<DataSchemaNode> instances = findInstanceDataChildrenByName(
-                    ((DataNodeContainer) restconfContainer), RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
+                    (DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
             return Iterables.getFirst(instances, null);
         }
 
@@ -457,7 +455,7 @@ public class ControllerContext implements SchemaContextListener {
     }
 
     private static DataSchemaNode childByQName(final ChoiceSchemaNode container, final QName name) {
-        for (final ChoiceCaseNode caze : container.getCases()) {
+        for (final CaseSchemaNode caze : container.getCases().values()) {
             final DataSchemaNode ret = childByQName(caze, name);
             if (ret != null) {
                 return ret;
@@ -467,7 +465,7 @@ public class ControllerContext implements SchemaContextListener {
         return null;
     }
 
-    private static DataSchemaNode childByQName(final ChoiceCaseNode container, final QName name) {
+    private static DataSchemaNode childByQName(final CaseSchemaNode container, final QName name) {
         return container.getDataChildByName(name);
     }
 
@@ -489,8 +487,8 @@ public class ControllerContext implements SchemaContextListener {
 
 
     private static DataSchemaNode childByQName(final Object container, final QName name) {
-        if (container instanceof ChoiceCaseNode) {
-            return childByQName((ChoiceCaseNode) container, name);
+        if (container instanceof CaseSchemaNode) {
+            return childByQName((CaseSchemaNode) container, name);
         } else if (container instanceof ChoiceSchemaNode) {
             return childByQName((ChoiceSchemaNode) container, name);
         } else if (container instanceof ContainerSchemaNode) {
@@ -511,8 +509,8 @@ public class ControllerContext implements SchemaContextListener {
         final DataSchemaNode ret = container.getDataChildByName(name);
         if (ret == null) {
             for (final DataSchemaNode node : container.getChildNodes()) {
-                if ((node instanceof ChoiceSchemaNode)) {
-                    final ChoiceSchemaNode choiceNode = ((ChoiceSchemaNode) node);
+                if (node instanceof ChoiceSchemaNode) {
+                    final ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) node;
                     final DataSchemaNode childByQName = childByQName(choiceNode, name);
                     if (childByQName != null) {
                         return childByQName;
@@ -540,7 +538,7 @@ public class ControllerContext implements SchemaContextListener {
         }
 
         if (strings.isEmpty()) {
-            return createContext(builder.build(), ((DataSchemaNode) parentNode),
+            return createContext(builder.build(), (DataSchemaNode) parentNode,
                 mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : this.globalSchema);
         }
 
@@ -577,7 +575,7 @@ public class ControllerContext implements SchemaContextListener {
                             ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT);
                 }
 
-                if (returnJustMountPoint || (strings.size() == 1)) {
+                if (returnJustMountPoint || strings.size() == 1) {
                     final YangInstanceIdentifier instance = YangInstanceIdentifier.builder().build();
                     return new InstanceIdentifierContext<>(instance, mountPointSchema, mount,mountPointSchema);
                 }
@@ -589,22 +587,21 @@ public class ControllerContext implements SchemaContextListener {
                             ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
                 }
 
-                final Module moduleBehindMountPoint =
-                        mountPointSchema.findModuleByName(moduleNameBehindMountPoint, null);
-                if (moduleBehindMountPoint == null) {
+                final Iterator<Module> it = mountPointSchema.findModules(moduleNameBehindMountPoint).iterator();
+                if (!it.hasNext()) {
                     throw new RestconfDocumentedException("\"" + moduleNameBehindMountPoint
                             + "\" module does not exist in mount point.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
                 }
 
                 final List<String> subList = strings.subList(1, strings.size());
-                return collectPathArguments(YangInstanceIdentifier.builder(), subList, moduleBehindMountPoint, mount,
+                return collectPathArguments(YangInstanceIdentifier.builder(), subList, it.next(), mount,
                         returnJustMountPoint);
             }
 
             Module module = null;
             if (mountPoint == null) {
                 checkPreconditions();
-                module = this.globalSchema.findModuleByName(moduleName, null);
+                module = this.globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
                 if (module == null) {
                     throw new RestconfDocumentedException("\"" + moduleName + "\" module does not exist.",
                             ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
@@ -612,7 +609,7 @@ public class ControllerContext implements SchemaContextListener {
             } else {
                 final SchemaContext schemaContext = mountPoint.getSchemaContext();
                 if (schemaContext != null) {
-                    module = schemaContext.findModuleByName(moduleName, null);
+                    module = schemaContext.findModules(moduleName).stream().findFirst().orElse(null);
                 } else {
                     module = null;
                 }
@@ -624,7 +621,7 @@ public class ControllerContext implements SchemaContextListener {
 
             targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace());
 
-            if ((targetNode == null) && (parentNode instanceof Module)) {
+            if (targetNode == null && parentNode instanceof Module) {
                 final RpcDefinition rpc;
                 if (mountPoint == null) {
                     rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision());
@@ -676,10 +673,10 @@ public class ControllerContext implements SchemaContextListener {
         }
 
         int consumed = 1;
-        if ((targetNode instanceof ListSchemaNode)) {
-            final ListSchemaNode listNode = ((ListSchemaNode) targetNode);
+        if (targetNode instanceof ListSchemaNode) {
+            final ListSchemaNode listNode = (ListSchemaNode) targetNode;
             final int keysSize = listNode.getKeyDefinition().size();
-            if ((strings.size() - consumed) < keysSize) {
+            if (strings.size() - consumed < keysSize) {
                 throw new RestconfDocumentedException("Missing key for list \"" + listNode.getQName().getLocalName()
                         + "\".", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING);
             }
@@ -707,9 +704,9 @@ public class ControllerContext implements SchemaContextListener {
             builder.node(targetNode.getQName());
         }
 
-        if ((targetNode instanceof DataNodeContainer)) {
+        if (targetNode instanceof DataNodeContainer) {
             final List<String> remaining = strings.subList(consumed, strings.size());
-            return collectPathArguments(builder, remaining, ((DataNodeContainer) targetNode), mountPoint,
+            return collectPathArguments(builder, remaining, (DataNodeContainer) targetNode, mountPoint,
                     returnJustMountPoint);
         }
 
@@ -758,22 +755,23 @@ public class ControllerContext implements SchemaContextListener {
 
         final Iterable<ChoiceSchemaNode> choiceNodes = Iterables.filter(container.getChildNodes(),
             ChoiceSchemaNode.class);
-        final Iterable<Set<ChoiceCaseNode>> map = Iterables.transform(choiceNodes, ChoiceSchemaNode::getCases);
-        for (final ChoiceCaseNode caze : Iterables.concat(map)) {
+        final Iterable<Collection<CaseSchemaNode>> map = Iterables.transform(choiceNodes,
+            choice -> choice.getCases().values());
+        for (final CaseSchemaNode caze : Iterables.concat(map)) {
             collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name);
         }
     }
 
     public static boolean isInstantiatedDataSchema(final DataSchemaNode node) {
-        return (node instanceof LeafSchemaNode) || (node instanceof LeafListSchemaNode)
-                || (node instanceof ContainerSchemaNode) || (node instanceof ListSchemaNode)
-                || (node instanceof AnyXmlSchemaNode);
+        return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode
+                || node instanceof ContainerSchemaNode || node instanceof ListSchemaNode
+                || node instanceof AnyXmlSchemaNode;
     }
 
     private void addKeyValue(final HashMap<QName, Object> map, final DataSchemaNode node, final String uriValue,
             final DOMMountPoint mountPoint) {
         Preconditions.checkNotNull(uriValue);
-        Preconditions.checkArgument((node instanceof LeafSchemaNode));
+        Preconditions.checkArgument(node instanceof LeafSchemaNode);
 
         final String urlDecoded = urlPathArgDecode(uriValue);
         TypeDefinition<?> typedef = ((LeafSchemaNode) node).getType();
@@ -786,10 +784,10 @@ public class ControllerContext implements SchemaContextListener {
         Object decoded = codec.deserialize(urlDecoded);
         String additionalInfo = "";
         if (decoded == null) {
-            if ((typedef instanceof IdentityrefTypeDefinition)) {
+            if (typedef instanceof IdentityrefTypeDefinition) {
                 final SchemaContext schemaContext =
                         mountPoint == null ? this.globalSchema : mountPoint.getSchemaContext();
-                decoded = toQName(schemaContext, urlDecoded, null);
+                decoded = toQName(schemaContext, urlDecoded);
                 additionalInfo =
                         "For key which is of type identityref it should be in format module_name:identity_name.";
             }
@@ -831,23 +829,37 @@ public class ControllerContext implements SchemaContextListener {
         return str.substring(idx + 1);
     }
 
-    private QName toQName(final SchemaContext schemaContext, final String name, final Date revisionDate) {
+    private QName toQName(final SchemaContext schemaContext, final String name,
+            final java.util.Optional<Revision> revisionDate) {
         checkPreconditions();
         final String module = toModuleName(name);
         final String node = toNodeName(name);
-        final Module m = schemaContext.findModuleByName(module, revisionDate);
+        final Module m = schemaContext.findModule(module, revisionDate).orElse(null);
         return m == null ? null : QName.create(m.getQNameModule(), node);
     }
 
+    private QName toQName(final SchemaContext schemaContext, final String name) {
+        checkPreconditions();
+        final String module = toModuleName(name);
+        final String node = toNodeName(name);
+        final Set<Module> modules = schemaContext.findModules(module);
+        return modules.isEmpty() ? null : QName.create(modules.iterator().next().getQNameModule(), node);
+    }
+
     private static boolean isListOrContainer(final DataSchemaNode node) {
-        return (node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode);
+        return node instanceof ListSchemaNode || node instanceof ContainerSchemaNode;
     }
 
-    public RpcDefinition getRpcDefinition(final String name, final Date revisionDate) {
+    public RpcDefinition getRpcDefinition(final String name, final java.util.Optional<Revision> revisionDate) {
         final QName validName = toQName(this.globalSchema, name, revisionDate);
         return validName == null ? null : this.qnameToRpc.get().get(validName);
     }
 
+    public RpcDefinition getRpcDefinition(final String name) {
+        final QName validName = toQName(this.globalSchema, name);
+        return validName == null ? null : this.qnameToRpc.get().get(validName);
+    }
+
     private static RpcDefinition getRpcDefinition(final Module module, final String rpcName) {
         final QName rpcQName = QName.create(module.getQNameModule(), rpcName);
         for (final RpcDefinition rpcDefinition : module.getRpcs()) {
@@ -884,7 +896,7 @@ public class ControllerContext implements SchemaContextListener {
             return decodedPathArgs;
         } catch (final UnsupportedEncodingException e) {
             throw new RestconfDocumentedException("Invalid URL path '" + strings + "': " + e.getMessage(),
-                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, e);
         }
     }
 
@@ -894,7 +906,7 @@ public class ControllerContext implements SchemaContextListener {
                 return URLDecoder.decode(pathArg, URI_ENCODING_CHARSET.name());
             } catch (final UnsupportedEncodingException e) {
                 throw new RestconfDocumentedException("Invalid URL path arg '" + pathArg + "': " + e.getMessage(),
-                        ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+                        ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, e);
             }
         }
 
@@ -905,10 +917,10 @@ public class ControllerContext implements SchemaContextListener {
             final DOMMountPoint mount) {
         if (argument instanceof NodeIdentifier) {
             return convertToRestconfIdentifier((NodeIdentifier) argument, mount);
-        } else if ((argument instanceof NodeIdentifierWithPredicates) && (node instanceof ListSchemaNode)) {
+        } else if (argument instanceof NodeIdentifierWithPredicates && node instanceof ListSchemaNode) {
             return convertToRestconfIdentifierWithPredicates((NodeIdentifierWithPredicates) argument,
                 (ListSchemaNode) node, mount);
-        } else if ((argument != null) && (node != null)) {
+        } else if (argument != null && node != null) {
             throw new IllegalArgumentException("Conversion of generic path argument is not supported");
         } else {
             throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.asList(argument, node));
index b1bbeb79024e41683802c32be81baad755b3e984..7a7b13605082d76052aa985f4df116467c472453 100644 (file)
@@ -11,15 +11,19 @@ import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -57,10 +61,10 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
         for (final DataSchemaNode node : this.children) {
             if (node.getQName().equals(name)) {
-                return node;
+                return Optional.of(node);
             }
         }
         throw new RestconfDocumentedException(name + " is not in child of " + PATH.getLastComponent());
@@ -72,7 +76,7 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public Set<AugmentationSchema> getAvailableAugmentations() {
+    public Set<AugmentationSchemaNode> getAvailableAugmentations() {
         return new HashSet<>();
     }
 
@@ -91,11 +95,6 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
         return false;
     }
 
-    @Override
-    public ConstraintDefinition getConstraints() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
     @Override
     public QName getQName() {
         return PATH.getLastComponent();
@@ -112,12 +111,12 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
@@ -130,4 +129,24 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     public boolean isPresenceContainer() {
         throw new UnsupportedOperationException("Not supported.");
     }
+
+    @Override
+    public Optional<RevisionAwareXPath> getWhenCondition() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Set<ActionDefinition> getActions() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Collection<MustDefinition> getMustConstraints() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
 }
index 10002206608093ff1cf8e9800a6cb01dd0303e8c..d5d43e7af0442f39cf9496da1d516864a98524d0 100644 (file)
@@ -13,12 +13,15 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangVersion;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
@@ -27,6 +30,7 @@ import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -60,21 +64,11 @@ final class FakeImportedModule extends ForwardingObject implements Module {
         return ImmutableSet.of();
     }
 
-    @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
-        return null;
-    }
-
     @Override
     public Set<UsesNode> getUses() {
         return ImmutableSet.of();
     }
 
-    @Override
-    public String getModuleSourcePath() {
-        return null;
-    }
-
     @Override
     public QNameModule getQNameModule() {
         return delegate.getQNameModule();
@@ -91,7 +85,7 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return delegate.getRevision();
     }
 
@@ -101,27 +95,27 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public String getYangVersion() {
+    public YangVersion getYangVersion() {
         return delegate.getYangVersion();
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return delegate.getDescription();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return delegate.getReference();
     }
 
     @Override
-    public String getOrganization() {
+    public Optional<String> getOrganization() {
         return delegate.getOrganization();
     }
 
     @Override
-    public String getContact() {
+    public Optional<String> getContact() {
         return delegate.getContact();
     }
 
@@ -141,7 +135,7 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public Set<AugmentationSchema> getAugmentations() {
+    public Set<AugmentationSchemaNode> getAugmentations() {
         return ImmutableSet.of();
     }
 
@@ -171,7 +165,17 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public String getSource() {
-        return null;
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
+        return Optional.empty();
+    }
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        return delegate.getNotifications();
+    }
+
+    @Override
+    public Optional<SemVer> getSemanticVersion() {
+        return delegate.getSemanticVersion();
     }
 }
index dbcbf38113b2f8c9f5208def57d00a38b55a2ddc..65aebbea337652c1dadd2fb82bbee52c13525634 100644 (file)
@@ -7,10 +7,13 @@
  */
 package org.opendaylight.netconf.sal.restconf.impl;
 
+import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -51,11 +54,6 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
         return false;
     }
 
-    @Override
-    public ConstraintDefinition getConstraints() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
     @Override
     public QName getQName() {
         return path.getLastComponent();
@@ -72,12 +70,12 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
@@ -92,13 +90,17 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
     }
 
     @Override
-    public String getDefault() {
+    public Optional<RevisionAwareXPath> getWhenCondition() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
     @Override
-    public String getUnits() {
+    public boolean isMandatory() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
+    @Override
+    public Collection<MustDefinition> getMustConstraints() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
 }
index 8d781e88c537541577e1b85a08d974ddccc7b5a7..aae1e039c1dd261bca087f5d5cdee2743f86852a 100644 (file)
@@ -8,12 +8,14 @@
 package org.opendaylight.netconf.sal.restconf.impl;
 
 import com.google.common.base.Preconditions;
-import java.util.Date;
+import java.util.Optional;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
 /**
- * Fake {@link ModuleImport} implementation used to attach corrent prefix mapping to fake RPCs.
+ * Fake {@link ModuleImport} implementation used to attach current prefix mapping to fake RPCs.
  *
  * @author Robert Varga
  */
@@ -30,7 +32,7 @@ final class FakeModuleImport implements ModuleImport {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return module.getRevision();
     }
 
@@ -38,4 +40,19 @@ final class FakeModuleImport implements ModuleImport {
     public String getPrefix() {
         return module.getName();
     }
+
+    @Override
+    public Optional<String> getDescription() {
+        return module.getDescription();
+    }
+
+    @Override
+    public Optional<String> getReference() {
+        return module.getReference();
+    }
+
+    @Override
+    public Optional<SemVer> getSemanticVersion() {
+        return module.getSemanticVersion();
+    }
 }
index f1e6b8ab4fb8e3dfcbc0ee0e8989074f8c45a50b..fcd4d653369e19ba677b557966354368dec61a5e 100644 (file)
@@ -11,16 +11,17 @@ import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangVersion;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
@@ -43,17 +44,8 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
  */
 final class FakeRestconfModule implements Module {
 
-    static final QNameModule QNAME;
-
-    static {
-        Date date;
-        try {
-            date = SimpleDateFormatUtil.getRevisionFormat().parse("2016-06-28");
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-        QNAME = QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"), date).intern();
-    }
+    static final QNameModule QNAME = QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"),
+        Revision.of("2016-06-28")).intern();
 
     private final Collection<DataSchemaNode> children;
     private final ImmutableSet<ModuleImport> imports;
@@ -85,10 +77,10 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
         for (final DataSchemaNode node : this.children) {
             if (node.getQName().equals(name)) {
-                return node;
+                return Optional.of(node);
             }
         }
         throw new RestconfDocumentedException(name + " is not in child of " + FakeRestconfModule.QNAME);
@@ -99,11 +91,6 @@ final class FakeRestconfModule implements Module {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
-    @Override
-    public String getModuleSourcePath() {
-        throw new UnsupportedOperationException("Not supported operations.");
-    }
-
     @Override
     public QNameModule getQNameModule() {
         return QNAME;
@@ -120,7 +107,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return QNAME.getRevision();
     }
 
@@ -130,27 +117,27 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public String getYangVersion() {
+    public YangVersion getYangVersion() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getOrganization() {
+    public Optional<String> getOrganization() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getContact() {
+    public Optional<String> getContact() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
@@ -175,7 +162,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public Set<AugmentationSchema> getAugmentations() {
+    public Set<AugmentationSchemaNode> getAugmentations() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
@@ -205,8 +192,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public String getSource() {
+    public Optional<SemVer> getSemanticVersion() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
-
 }
index 783700bcba5f47bd6ba534a6843dae4e1a30f837..7e878591a1fa791fe821f9864d43c0df4eb70188 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.restconf.common.context.WriterParameters;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 
-public class QueryParametersParser {
+public final class QueryParametersParser {
 
     private enum UriParameters {
         PRETTY_PRINT("prettyPrint"),
@@ -31,6 +31,10 @@ public class QueryParametersParser {
         }
     }
 
+    private QueryParametersParser() {
+
+    }
+
     public static WriterParameters parseWriterParameters(final UriInfo info) {
         return parseParams(info, false);
     }
@@ -58,7 +62,7 @@ public class QueryParametersParser {
                 }
                 wpBuilder.setDepth(depth);
             } catch (final NumberFormatException e) {
-                throw new RestconfDocumentedException(new RestconfError(
+                throw new RestconfDocumentedException(e, new RestconfError(
                         RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
                         "Invalid depth parameter: " + e.getMessage(), null,
                         "The depth parameter must be an integer > 1 or \"unbounded\""));
index c35a9b07d47149bb41a82f2921782add7416c2b7..eba00424143789da66403b00f9ad301195e53e7d 100644 (file)
@@ -41,14 +41,14 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestCodec {
+public final class RestCodec {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestCodec.class);
 
     private RestCodec() {
     }
 
-    public static final Codec<Object, Object> from(final TypeDefinition<?> typeDefinition,
+    public static Codec<Object, Object> from(final TypeDefinition<?> typeDefinition,
             final DOMMountPoint mountPoint) {
         return new ObjectCodec(typeDefinition, mountPoint);
     }
index 090e861eef50587d3204f373a3e1b130fed985f8..715d66c9552ceb43b6aa0b4c5e61c5bff89f5735 100644 (file)
@@ -18,18 +18,17 @@ import com.google.common.base.Strings;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.net.URI;
-import java.text.ParseException;
 import java.time.Instant;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoField;
 import java.time.temporal.TemporalAccessor;
+import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -76,7 +75,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -117,7 +116,7 @@ import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestconfImpl implements RestconfService {
+public final class RestconfImpl implements RestconfService {
 
     private static final RestconfImpl INSTANCE = new RestconfImpl();
 
@@ -148,19 +147,11 @@ public class RestconfImpl implements RestconfService {
 
     private static final String NETCONF_BASE_PAYLOAD_NAME = "data";
 
-    private static final QName NETCONF_BASE_QNAME = QName.create(QNameModule.create(URI.create(NETCONF_BASE), null),
+    private static final QName NETCONF_BASE_QNAME = QName.create(QNameModule.create(URI.create(NETCONF_BASE)),
         NETCONF_BASE_PAYLOAD_NAME).intern();
 
-    private static final QNameModule SAL_REMOTE_AUGMENT;
-
-    static {
-        try {
-            SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT,
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-07-08"));
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
+    private static final QNameModule SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT,
+        Revision.of("2014-07-08"));
 
     private static final AugmentationIdentifier SAL_REMOTE_AUG_IDENTIFIER =
             new AugmentationIdentifier(ImmutableSet.of(
@@ -259,7 +250,7 @@ public class RestconfImpl implements RestconfService {
     @Override
     public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) {
         Preconditions.checkNotNull(identifier);
-        final QName moduleNameAndRevision = getModuleNameAndRevision(identifier);
+        final Entry<String, Revision> nameRev = getModuleNameAndRevision(identifier);
         Module module = null;
         DOMMountPoint mountPoint = null;
         final SchemaContext schemaContext;
@@ -267,16 +258,17 @@ public class RestconfImpl implements RestconfService {
             final InstanceIdentifierContext<?> mountPointIdentifier =
                     this.controllerContext.toMountPointIdentifier(identifier);
             mountPoint = mountPointIdentifier.getMountPoint();
-            module = this.controllerContext.findModuleByNameAndRevision(mountPoint, moduleNameAndRevision);
+            module = this.controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(),
+                nameRev.getValue());
             schemaContext = mountPoint.getSchemaContext();
         } else {
-            module = this.controllerContext.findModuleByNameAndRevision(moduleNameAndRevision);
+            module = this.controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue());
             schemaContext = this.controllerContext.getGlobalSchema();
         }
 
         if (module == null) {
-            final String errMsg = "Module with name '" + moduleNameAndRevision.getLocalName() + "' and revision '"
-                    + moduleNameAndRevision.getRevision() + "' was not found.";
+            final String errMsg = "Module with name '" + nameRev.getKey() + "' and revision '"
+                    + nameRev.getValue() + "' was not found.";
             LOG.debug(errMsg);
             throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
         }
@@ -407,7 +399,7 @@ public class RestconfImpl implements RestconfService {
         return restconfModule;
     }
 
-    private static QName getModuleNameAndRevision(final String identifier) {
+    private static Entry<String, Revision> getModuleNameAndRevision(final String identifier) {
         final int mountIndex = identifier.indexOf(ControllerContext.MOUNT);
         String moduleNameAndRevision = "";
         if (mountIndex >= 0) {
@@ -416,9 +408,8 @@ public class RestconfImpl implements RestconfService {
             moduleNameAndRevision = identifier;
         }
 
-        final Splitter splitter = Splitter.on("/").omitEmptyStrings();
-        final Iterable<String> split = splitter.split(moduleNameAndRevision);
-        final List<String> pathArgs = Lists.<String>newArrayList(split);
+        final Splitter splitter = Splitter.on('/').omitEmptyStrings();
+        final List<String> pathArgs = splitter.splitToList(moduleNameAndRevision);
         if (pathArgs.size() < 2) {
             LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier);
             throw new RestconfDocumentedException(
@@ -427,13 +418,11 @@ public class RestconfImpl implements RestconfService {
         }
 
         try {
-            final String moduleName = pathArgs.get(0);
-            final String revision = pathArgs.get(1);
-            return QName.create(null, SimpleDateFormatUtil.getRevisionFormat().parse(revision), moduleName);
-        } catch (final ParseException e) {
+            return new SimpleImmutableEntry<>(pathArgs.get(0), Revision.of(pathArgs.get(1)));
+        } catch (final DateTimeParseException e) {
             LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier);
             throw new RestconfDocumentedException("URI has bad format. It should be \'moduleName/yyyy-MM-dd\'",
-                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, e);
         }
     }
 
@@ -524,7 +513,7 @@ public class RestconfImpl implements RestconfService {
 
         RpcDefinition rpc = null;
         if (mountPoint == null) {
-            rpc = this.controllerContext.getRpcDefinition(identifierDecoded, null);
+            rpc = this.controllerContext.getRpcDefinition(identifierDecoded);
         } else {
             rpc = findRpc(mountPoint.getSchemaContext(), identifierDecoded);
         }
@@ -557,6 +546,7 @@ public class RestconfImpl implements RestconfService {
                 result.getResult(), QueryParametersParser.parseWriterParameters(uriInfo));
     }
 
+    @SuppressWarnings("checkstyle:avoidHidingCauseException")
     private static DOMRpcResult checkRpcResponse(final CheckedFuture<DOMRpcResult, DOMRpcException> response) {
         if (response == null) {
             return null;
@@ -571,7 +561,7 @@ public class RestconfImpl implements RestconfService {
         } catch (final InterruptedException e) {
             final String errMsg = "The operation was interrupted while executing and did not complete.";
             LOG.debug("Rpc Interrupt - " + errMsg, e);
-            throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION);
+            throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
         } catch (final ExecutionException e) {
             LOG.debug("Execution RpcError: ", e);
             Throwable cause = e.getCause();
@@ -614,8 +604,9 @@ public class RestconfImpl implements RestconfService {
             invokeSalRemoteRpcSubscribeRPC(final NormalizedNodeContext payload) {
         final ContainerNode value = (ContainerNode) payload.getData();
         final QName rpcQName = payload.getInstanceIdentifierContext().getSchemaNode().getQName();
-        final Optional<DataContainerChild<? extends PathArgument, ?>> path = value.getChild(new NodeIdentifier(
-                QName.create(payload.getInstanceIdentifierContext().getSchemaNode().getQName(), "path")));
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> path = value.getChild(
+            new NodeIdentifier(QName.create(payload.getInstanceIdentifierContext().getSchemaNode().getQName(),
+                "path")));
         final Object pathValue = path.isPresent() ? path.get().getValue() : null;
 
         if (!(pathValue instanceof YangInstanceIdentifier)) {
@@ -1071,8 +1062,8 @@ public class RestconfImpl implements RestconfService {
             final Optional<Throwable> searchedException = Iterables.tryFind(Throwables.getCausalChain(e),
                     Predicates.instanceOf(ModifiedNodeDoesNotExistException.class));
             if (searchedException.isPresent()) {
-                throw new RestconfDocumentedException("Data specified for delete doesn't exist.", ErrorType.APPLICATION,
-                        ErrorTag.DATA_MISSING);
+                throw new RestconfDocumentedException("Data specified for delete doesn't exist.",
+                        ErrorType.APPLICATION, ErrorTag.DATA_MISSING, e);
             }
 
             final String errMsg = "Error while deleting data";
@@ -1197,7 +1188,7 @@ public class RestconfImpl implements RestconfService {
         final QName qnameBase = QName.create("subscribe:to:notification", "2016-10-28", "notifi");
         final SchemaContext schemaCtx = ControllerContext.getInstance().getGlobalSchema();
         final DataSchemaNode location = ((ContainerSchemaNode) schemaCtx
-                .findModuleByNamespaceAndRevision(qnameBase.getNamespace(), qnameBase.getRevision())
+                .findModule(qnameBase.getModule()).orElse(null)
                 .getDataChildByName(qnameBase)).getDataChildByName(QName.create(qnameBase, "location"));
         final List<PathArgument> path = new ArrayList<>();
         path.add(NodeIdentifier.create(qnameBase));
@@ -1318,7 +1309,7 @@ public class RestconfImpl implements RestconfService {
             return this.broker.patchConfigurationDataWithinTransaction(context);
         } catch (final Exception e) {
             LOG.debug("Patch transaction failed", e);
-            throw new RestconfDocumentedException(e.getMessage());
+            throw new RestconfDocumentedException(e.getMessage(), e);
         }
     }
 
@@ -1333,7 +1324,7 @@ public class RestconfImpl implements RestconfService {
             return this.broker.patchConfigurationDataWithinTransaction(context);
         } catch (final Exception e) {
             LOG.debug("Patch transaction failed", e);
-            throw new RestconfDocumentedException(e.getMessage());
+            throw new RestconfDocumentedException(e.getMessage(), e);
         }
     }
 
@@ -1347,7 +1338,7 @@ public class RestconfImpl implements RestconfService {
      */
     private static <T> T parseEnumTypeParameter(final ContainerNode value, final Class<T> classDescriptor,
             final String paramName) {
-        final Optional<DataContainerChild<? extends PathArgument, ?>> optAugNode = value.getChild(
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> optAugNode = value.getChild(
             SAL_REMOTE_AUG_IDENTIFIER);
         if (!optAugNode.isPresent()) {
             return null;
@@ -1356,8 +1347,8 @@ public class RestconfImpl implements RestconfService {
         if (!(augNode instanceof AugmentationNode)) {
             return null;
         }
-        final Optional<DataContainerChild<? extends PathArgument, ?>> enumNode = ((AugmentationNode) augNode).getChild(
-            new NodeIdentifier(QName.create(SAL_REMOTE_AUGMENT, paramName)));
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> enumNode = ((AugmentationNode) augNode)
+            .getChild(new NodeIdentifier(QName.create(SAL_REMOTE_AUGMENT, paramName)));
         if (!enumNode.isPresent()) {
             return null;
         }
@@ -1441,9 +1432,11 @@ public class RestconfImpl implements RestconfService {
                 ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "revision");
         final DataSchemaNode revisionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null);
         Preconditions.checkState(revisionSchemaNode instanceof LeafSchemaNode);
-        final String revision = module.getQNameModule().getFormattedRevision();
-        moduleNodeValues
-                .withChild(Builders.leafBuilder((LeafSchemaNode) revisionSchemaNode).withValue(revision).build());
+        final java.util.Optional<Revision> revision = module.getQNameModule().getRevision();
+        if (revision.isPresent()) {
+            moduleNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) revisionSchemaNode)
+                .withValue(revision.get().toString()).build());
+        }
 
         instanceDataChildrenByName =
                 ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "namespace");
index dffcf875073de2e19840218ae72f95fecec6b629..a6c2a8d7c4f886c33c96e449a1dc11a7ea2ed2e1 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 
-public class StatisticsRestconfServiceWrapper implements RestconfService {
+public final class StatisticsRestconfServiceWrapper implements RestconfService {
 
     AtomicLong operationalGet = new AtomicLong();
     AtomicLong configGet = new AtomicLong();
@@ -292,4 +292,4 @@ public class StatisticsRestconfServiceWrapper implements RestconfService {
     public BigInteger getFailureDelete() {
         return BigInteger.valueOf(this.failureDelete.get());
     }
-}
\ No newline at end of file
+}
index 411183b64896a0580644f6f0d152fd6806662f24..618bf4de91ac475bf676456655a54b39a23ae1d2 100644 (file)
@@ -71,6 +71,7 @@ abstract class AbstractQueryParams extends AbstractNotificationsData {
      * @param leafNodesOnly
      *            if true, notifications will contain changes to leaf nodes only
      */
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setQueryParams(final Instant start, final Optional<Instant> stop, final Optional<String> filter,
                                final boolean leafNodesOnly) {
         this.start = Preconditions.checkNotNull(start);
index 6355769336a213b8d4b927fd9112f38d2ce091a8..2775cce13429085f1000fe0f0ebf2883473e85a5 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.streams.listeners;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.util.Collection;
@@ -52,7 +51,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
     private final String streamName;
     private final NotificationOutputType outputType;
 
-    private Collection<DataTreeCandidate> dataTreeCandidates;
+    private Collection<DataTreeCandidate> candidates;
 
     /**
      * Creates new {@link ListenerAdapter} listener specified by path and stream
@@ -70,13 +69,13 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
         register(this);
         this.outputType = Preconditions.checkNotNull(outputType);
         this.path = Preconditions.checkNotNull(path);
-        Preconditions.checkArgument((streamName != null) && !streamName.isEmpty());
+        Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
         this.streamName = streamName;
     }
 
     @Override
-    public void onDataTreeChanged(@Nonnull Collection<DataTreeCandidate> dataTreeCandidates) {
-        this.dataTreeCandidates = dataTreeCandidates;
+    public void onDataTreeChanged(@Nonnull final Collection<DataTreeCandidate> dataTreeCandidates) {
+        this.candidates = dataTreeCandidates;
         final String xml = prepareXml();
         if (checkQueryParams(xml, this)) {
             prepareAndPostData(xml);
@@ -141,7 +140,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
                 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "data-changed-notification");
 
         addValuesToDataChangedNotificationEventElement(doc, dataChangedNotificationEventElement,
-                                                            this.dataTreeCandidates, schemaContext, dataContextTree);
+                                                            this.candidates, schemaContext, dataContextTree);
         notificationElement.appendChild(dataChangedNotificationEventElement);
         return transformDoc(doc);
     }
@@ -173,11 +172,11 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
     }
 
     private void addNodeToDataChangeNotificationEventElement(final Document doc,
-                             final Element dataChangedNotificationEventElement, DataTreeCandidateNode candidateNode,
-                             YangInstanceIdentifier parentYiid, SchemaContext schemaContext,
-                             DataSchemaContextTree dataSchemaContextTree) {
+            final Element dataChangedNotificationEventElement, final DataTreeCandidateNode candidateNode,
+            final YangInstanceIdentifier parentYiid, final SchemaContext schemaContext,
+            final DataSchemaContextTree dataSchemaContextTree) {
 
-        Optional<NormalizedNode<?,?>> optionalNormalizedNode = Optional.absent();
+        java.util.Optional<NormalizedNode<?,?>> optionalNormalizedNode = java.util.Optional.empty();
         switch (candidateNode.getModificationType()) {
             case APPEARED:
             case SUBTREE_MODIFIED:
@@ -244,7 +243,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
      *            {@link Operation}
      * @return {@link Node} node represented by changed event element.
      */
-    private Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier path,
+    private static Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier path,
             final Operation operation) {
         final Element dataChangeEventElement = doc.createElement("data-change-event");
         final Element pathElement = doc.createElement("path");
@@ -259,11 +258,11 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
     }
 
     private Node createCreatedChangedDataChangeEventElement(final Document doc,
-            YangInstanceIdentifier path, NormalizedNode normalized, final Operation operation,
+            final YangInstanceIdentifier eventPath, final NormalizedNode normalized, final Operation operation,
             final SchemaContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) {
         final Element dataChangeEventElement = doc.createElement("data-change-event");
         final Element pathElement = doc.createElement("path");
-        addPathAsValueToElement(path, pathElement);
+        addPathAsValueToElement(eventPath, pathElement);
         dataChangeEventElement.appendChild(pathElement);
 
         final Element operationElement = doc.createElement("operation");
@@ -272,10 +271,10 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
 
         try {
             SchemaPath nodePath;
-            if ((normalized instanceof MapEntryNode) || (normalized instanceof UnkeyedListEntryNode)) {
-                nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath();
+            if (normalized instanceof MapEntryNode || normalized instanceof UnkeyedListEntryNode) {
+                nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath();
             } else {
-                nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath().getParent();
+                nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath().getParent();
             }
             final DOMResult domResult = writeNormalizedNode(normalized, schemaContext, nodePath);
             final Node result = doc.importNode(domResult.getNode().getFirstChild(), true);
@@ -300,7 +299,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
      *            {@link Element}
      */
     @SuppressWarnings("rawtypes")
-    private void addPathAsValueToElement(final YangInstanceIdentifier path, final Element element) {
+    private static void addPathAsValueToElement(final YangInstanceIdentifier path, final Element element) {
         final YangInstanceIdentifier normalizedPath = ControllerContext.getInstance().toXpathRepresentation(path);
         final StringBuilder textContent = new StringBuilder();
 
@@ -343,8 +342,8 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster
      */
     private static void writeIdentifierWithNamespacePrefix(final Element element, final StringBuilder textContent,
             final QName qualifiedName) {
-        final Module module = ControllerContext.getInstance().getGlobalSchema()
-                .findModuleByNamespaceAndRevision(qualifiedName.getNamespace(), qualifiedName.getRevision());
+        final Module module = ControllerContext.getInstance().getGlobalSchema().findModule(qualifiedName.getModule())
+                .get();
 
         textContent.append(module.getName());
         textContent.append(":");
index 54e25a7c189b27863f042d3123940795e57fe56a..9775e344f6018361eb4b7d07bbafe5117136edeb 100644 (file)
@@ -84,6 +84,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void onNotification(final DOMNotification notification) {
         this.schemaContext = ControllerContext.getInstance().getGlobalSchema();
         this.notification = notification;
@@ -173,18 +174,13 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
 
         final Element notificationEventElement = doc.createElementNS(
                 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "create-notification-stream");
-        addValuesToNotificationEventElement(doc, notificationEventElement, this.notification, this.schemaContext);
+        addValuesToNotificationEventElement(doc, notificationEventElement);
         notificationElement.appendChild(notificationEventElement);
 
         return transformDoc(doc);
     }
 
-    private void addValuesToNotificationEventElement(final Document doc, final Element element,
-            final DOMNotification notification, final SchemaContext schemaContext) {
-        if (notification == null) {
-            return;
-        }
-
+    private void addValuesToNotificationEventElement(final Document doc, final Element element) {
         final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> body =
                 notification.getBody();
         try {
index 8d7af400df6ad57ac7c4bc25a4b4e28fa97a85f0..c08a2463c32fb3a5f1f2df03c554faa1f5ff71ca 100644 (file)
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
  * {@link Notificator} is responsible to create, remove and find
  * {@link ListenerAdapter} listener.
  */
-public class Notificator {
+public final class Notificator {
 
     private static Map<String, ListenerAdapter> dataChangeListener = new ConcurrentHashMap<>();
     private static Map<String, List<NotificationListenerAdapter>> notificationListenersByStreamName =
index 1fdfd4d63dae6c2dd5591720735c26437bf62c65..b8093dcb7a38077f6da9a2646ab5e493f4434f3a 100644 (file)
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
  * {@link WebSocketServer} is the singleton responsible for starting and stopping the
  * web socket server.
  */
-public class WebSocketServer implements Runnable {
+public final class WebSocketServer implements Runnable {
 
     private static final Logger LOG = LoggerFactory.getLogger(WebSocketServer.class);
 
index 1b76e4b98cd00f4a8d437f9d980b473c55f10686..39b881ac657bd9cc9a0cf8aa978522f4592cc810 100644 (file)
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
-public class TestRestconfUtils {
+public final class TestRestconfUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestRestconfUtils.class);
 
@@ -55,14 +55,14 @@ public class TestRestconfUtils {
     public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) {
         try {
             Preconditions.checkArgument(yangPath != null, "Path can not be null.");
-            Preconditions.checkArgument((!yangPath.isEmpty()), "Path can not be empty.");
+            Preconditions.checkArgument(!yangPath.isEmpty(), "Path can not be empty.");
             if (schemaContext == null) {
-                return YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(yangPath));
+                return YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(yangPath));
             } else {
                 throw new UnsupportedOperationException("Unable to add new yang sources to existing schema context.");
             }
         } catch (final Exception e) {
-            LOG.error("Yang files at path: " + yangPath + " weren't loaded.");
+            LOG.error("Yang files at path: " + yangPath + " weren't loaded.", e);
         }
         return schemaContext;
     }
index 8d8c2aa96efac791bd1eee64e96b9841aa9f28d2..4e0801c2c80558620f4ae32d8ce38a3a6f62ccfe 100644 (file)
@@ -24,7 +24,7 @@ public class InstanceIdentifierTypeLeafTest {
     @Test
     public void stringToInstanceIdentifierTest() throws Exception {
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/instanceidentifier"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/instanceidentifier"));
         ControllerContext.getInstance().setGlobalSchema(schemaContext);
         final InstanceIdentifierContext<?> instanceIdentifier =
                 ControllerContext.getInstance().toInstanceIdentifier(
index e9c772018ee4c9923d3639440b7538cd3e5eade1..7d5b015c1690f8ae323c27ce81101868561630ae 100644 (file)
@@ -12,13 +12,12 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
+import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -27,7 +26,7 @@ import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -39,23 +38,13 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-
 public class TestJsonBodyReader extends AbstractBodyReaderTest {
 
     private final JsonNormalizedNodeBodyReader jsonBodyReader;
     private static SchemaContext schemaContext;
 
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
-
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public TestJsonBodyReader() throws NoSuchFieldException, SecurityException {
         this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
@@ -71,7 +60,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
             throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         CONTROLLER_CONTEXT.setSchemas(schemaContext);
     }
 
@@ -127,7 +116,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
     public void moduleSubContainerAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode =
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
         final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
                 Sets.newHashSet(contAugmentQName));
@@ -148,7 +137,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
     public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode =
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
index 9190a49cad3eaba546ab8165a0ec1833d3e454a9..328e6182c135240c2e908e6fcc234a7eeee32f7d 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.base.Optional;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
@@ -31,7 +30,7 @@ import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -47,16 +46,8 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
     private final JsonNormalizedNodeBodyReader jsonBodyReader;
     private static SchemaContext schemaContext;
 
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public TestJsonBodyReaderMountPoint() throws NoSuchFieldException,
             SecurityException {
@@ -72,7 +63,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
     public static void initialization() throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
 
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
@@ -139,14 +130,14 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName
                 .create(inputNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode
                 .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNode.isPresent());
         assertTrue(contDataNode.get() instanceof ContainerNode);
         final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
                 .create(inputNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = ((ContainerNode) contDataNode
-                .get()).getChild(yangleaf.getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode =
+                ((ContainerNode) contDataNode.get()).getChild(yangleaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
         assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
                 .toString()));
@@ -169,7 +160,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
                 .getSchemaContext().getDataChildByName(
                         dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
-        if ((qualifiedName != null) && (dataSchemaNode instanceof DataNodeContainer)) {
+        if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) {
             final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
                     .getDataChildByName(qualifiedName);
             dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
index c145c5b895b0c89f2865da887a1894f5252ff63c..8f7b008ec66fd75787cad7d169daf9ef83a923cd 100644 (file)
@@ -45,7 +45,7 @@ public class TestJsonBodyWriter extends AbstractBodyReaderTest {
     public static void initialization() throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         CONTROLLER_CONTEXT.setSchemas(schemaContext);
     }
 
index 7b6bda935237e93fe9aa97613ebcece76460ed11..a34308160e2a6470d9ca02518da12e01dfeac9af 100644 (file)
@@ -13,12 +13,10 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
@@ -31,7 +29,7 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -48,16 +46,8 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
 
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public TestXmlBodyReader() throws Exception {
         this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
@@ -73,7 +63,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         CONTROLLER_CONTEXT.setSchemas(schemaContext);
     }
 
@@ -163,7 +153,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
     public void moduleSubContainerAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode =
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
         final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
                 Sets.newHashSet(contAugmentQName));
@@ -183,7 +173,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
     public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode =
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
@@ -215,14 +205,14 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode.getChild(yangCont
-                .getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode
+                .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNodePotential.isPresent());
         final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get();
         final YangInstanceIdentifier yangLeaf =
                 YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(yangLeaf
-                .getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
+            yangLeaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
         assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
     }
index 9ab3a2ce5f8eb60a7fda253515b9b5912280bb9f..214ee79cc0cb808086ee619117434fb673be9fb9 100644 (file)
@@ -19,7 +19,6 @@ import com.google.common.base.Optional;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
@@ -35,7 +34,7 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -50,16 +49,8 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
 
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public TestXmlBodyReaderMountPoint() throws Exception {
         this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
@@ -74,7 +65,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
     public static void initialization() throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
 
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
@@ -140,14 +131,14 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode.getChild(yangCont
-                .getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode
+                .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNodePotential.isPresent());
         final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get();
         final YangInstanceIdentifier yangLeaf =
                 YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(yangLeaf
-                .getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
+            yangLeaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
         assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
     }
@@ -169,7 +160,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
                 .getSchemaContext().getDataChildByName(
                         dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
-        if ((qualifiedName != null) && (dataSchemaNode instanceof DataNodeContainer)) {
+        if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) {
             final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
                     .getDataChildByName(qualifiedName);
             dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
index a1b8777b0cc839139575169e485e8ee3500007da..ca594a36901b3b74d11d91cb2f13c5a154c610ce 100644 (file)
@@ -41,7 +41,7 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest {
     public static void initialization() throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         CONTROLLER_CONTEXT.setSchemas(schemaContext);
     }
 
index 22aacbda1f63c10b30c3469a2bce04055f31d879..f82fc170fa661834d89c897ad72e43612b33b5a6 100644 (file)
@@ -22,7 +22,6 @@ import java.io.StringReader;
 import java.util.Map;
 import org.junit.BeforeClass;
 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader {
 
@@ -178,7 +177,7 @@ public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader
     }
 
     @BeforeClass
-    public static void initialize() throws FileNotFoundException, ReactorException {
+    public static void initialize() throws FileNotFoundException {
         dataLoad("/cnsn-to-json/simple-data-types");
     }
 
index 20eba2be0d287e201cb81975b6cec82c7274f5b1..c18c13a2328a2ef4d5a4f0ee0290aff6062db1bf 100644 (file)
@@ -51,7 +51,6 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class RestPutListDataTest {
 
@@ -68,7 +67,7 @@ public class RestPutListDataTest {
     }
 
     @Before
-    public void initialize() throws FileNotFoundException, ReactorException {
+    public void initialize() throws FileNotFoundException {
         final ControllerContext controllerContext = ControllerContext.getInstance();
         schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
         controllerContext.setSchemas(schemaContextTestModule);
index ff7cd5703d8bfe7d6bc1ecad39e4b6137869a473..7f1de7f3f1f88436d7fbca7dce4fb001cc6e5a27 100644 (file)
@@ -101,7 +101,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
         final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
                 .getData());
         assertTrue(dataTree.contains("lf"));
-        assertTrue(dataTree.contains("null"));
+        assertTrue(dataTree.contains("empty"));
     }
 
     @Test
@@ -126,7 +126,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
         }
         assertNotNull(exception);
         assertEquals(
-                "Error parsing input: Schema node with name cont wasn't found under "
+                "Error parsing input: Schema node with name cont was not found under "
                         + "(urn:ietf:params:xml:ns:netconf:base:1.0)data.",
                 exception.getErrors().get(0).getErrorMessage());
 
@@ -142,7 +142,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
         }
         assertNotNull(exception);
         assertEquals(
-                "Error parsing input: Schema node with name lst1 wasn't found under "
+                "Error parsing input: Schema node with name lst1 was not found under "
                         + "(urn:ietf:params:xml:ns:netconf:base:1.0)data.",
                 exception.getErrors().get(0).getErrorMessage());
 
@@ -158,7 +158,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
         }
         assertNotNull(exception);
         assertEquals(
-                "Error parsing input: Schema node with name lf wasn't found under "
+                "Error parsing input: Schema node with name lf was not found under "
                         + "(urn:ietf:params:xml:ns:netconf:base:1.0)data.",
                 exception.getErrors().get(0).getErrorMessage());
         assertEquals(3, countExceptions);
index 501c6eff5a19fe28902217bc88c887b9f69d7ee8..f1e5786b47af19ec16654666acbea5ef5decd873 100644 (file)
@@ -153,7 +153,6 @@ public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest {
     public void nnAsYangInstanceIdentifierAugment() throws Exception {
 
         final NormalizedNodeContext normalizedNodeContext = preparNNC();
-        final NormalizedNodeXmlBodyWriter xmlBodyWriter = new NormalizedNodeXmlBodyWriter();
         final OutputStream output = new ByteArrayOutputStream();
 
         xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null,
index 03a6279965363acf90b4daa4620960a72abe9a03..da5f91e25c7848d6b3dc5f365eeb4b5e018611a6 100644 (file)
@@ -225,7 +225,7 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
     public void nnAsYangEmptyToXmlTest() throws Exception {
         final String elName = "lfEmpty";
         final NormalizedNodeContext normalizedNodeContext = prepareNNC(
-                TypeDefinitionAwareCodec.from(BaseTypes.emptyType()).deserialize(null), elName);
+                TypeDefinitionAwareCodec.from(BaseTypes.emptyType()).deserialize(""), elName);
         nnToXml(normalizedNodeContext, "<" + elName + "></" + elName + ">");
     }
 
@@ -288,8 +288,8 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
     }
 
     private static NormalizedNodeContext prepareNNC(final Object object, final String name) {
-        final QName cont = QName.create("basic:module", "2013-12-2", "cont");
-        final QName lf = QName.create("basic:module", "2013-12-2", name);
+        final QName cont = QName.create("basic:module", "2013-12-02", "cont");
+        final QName lf = QName.create("basic:module", "2013-12-02", name);
 
         final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
 
@@ -319,9 +319,9 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
     }
 
     private static NormalizedNodeContext prepareLeafrefData() {
-        final QName cont = QName.create("basic:module", "2013-12-2", "cont");
-        final QName lfBoolean = QName.create("basic:module", "2013-12-2", "lfBoolean");
-        final QName lfLfref = QName.create("basic:module", "2013-12-2", "lfLfref");
+        final QName cont = QName.create("basic:module", "2013-12-02", "cont");
+        final QName lfBoolean = QName.create("basic:module", "2013-12-02", "lfBoolean");
+        final QName lfLfref = QName.create("basic:module", "2013-12-02", "lfLfref");
 
         final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
 
@@ -347,8 +347,8 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
     }
 
     private static NormalizedNodeContext prepareLeafrefNegativeData() {
-        final QName cont = QName.create("basic:module", "2013-12-2", "cont");
-        final QName lfLfref = QName.create("basic:module", "2013-12-2", "lfLfrefNegative");
+        final QName cont = QName.create("basic:module", "2013-12-02", "cont");
+        final QName lfLfref = QName.create("basic:module", "2013-12-02", "lfLfrefNegative");
 
         final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> contData = Builders
@@ -365,9 +365,9 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
     }
 
     private static NormalizedNodeContext prepareIdrefData(final String prefix, final boolean valueAsQName) {
-        final QName cont = QName.create("basic:module", "2013-12-2", "cont");
-        final QName cont1 = QName.create("basic:module", "2013-12-2", "cont1");
-        final QName lf11 = QName.create("basic:module", "2013-12-2", "lf11");
+        final QName cont = QName.create("basic:module", "2013-12-02", "cont");
+        final QName cont1 = QName.create("basic:module", "2013-12-02", "cont1");
+        final QName lf11 = QName.create("basic:module", "2013-12-02", "lf11");
 
         final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
 
@@ -381,7 +381,7 @@ public class NnToXmlTest extends AbstractBodyReaderTest {
 
         Object value = null;
         if (valueAsQName) {
-            value = QName.create("referenced:module", "2013-12-2", "iden");
+            value = QName.create("referenced:module", "2013-12-02", "iden");
         } else {
             value = "no qname value";
         }
index 0791b8ab1201c35355d3865404d90c56a0425d8c..08539d0a5b63f3761791f26a950277eb3acee87e 100644 (file)
@@ -73,13 +73,13 @@ public class NnToXmlWithDataFromSeveralModulesTest extends
         assertTrue(outputString.contains(
                 "<cont_m2 xmlns=" + '"' + "module:two" + '"' + '>'));
         assertTrue(outputString.contains("<lf1_m2>lf1 m2 value</lf1_m2>"));
-        assertTrue(outputString.contains("<contB_m2></contB_m2>"));
+        assertTrue(outputString.contains("<contB_m2/>"));
         assertTrue(outputString.contains("</cont_m2>"));
 
         // cont m1
         assertTrue(outputString.contains(
                 "<cont_m1 xmlns=" + '"' + "module:one" + '"' + '>'));
-        assertTrue(outputString.contains("<contB_m1></contB_m1>"));
+        assertTrue(outputString.contains("<contB_m1/>"));
         assertTrue(outputString.contains("<lf1_m1>lf1 m1 value</lf1_m1>"));
         assertTrue(outputString.contains("</cont_m1>"));
 
index deb443ad0c719830df4ac68750bf6a4a93b11c23..db96f0cb2b1fc4b612d2f082f652985f2d8fd6e0 100644 (file)
@@ -18,9 +18,9 @@ import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug3595Test {
 
@@ -32,7 +32,7 @@ public class Bug3595Test {
     private static ControllerContext controllerContext = ControllerContext.getInstance();
 
     @BeforeClass
-    public static void initialize() throws FileNotFoundException, ReactorException {
+    public static void initialize() throws FileNotFoundException {
         final SchemaContext schemaContext = TestUtils.loadSchemaContext("/leafref/yang");
         Module module = TestUtils.findModule(schemaContext.getModules(), "leafref-module");
         assertNotNull(module);
@@ -45,7 +45,7 @@ public class Bug3595Test {
     @Test
     public void testLeafrefListKeyDeserializtion() {
         final YangInstanceIdentifier node1IIexpected = YangInstanceIdentifier.of(CONT_QNAME)
-                .node(LST_WITH_LFREF_KEY_QNAME).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                .node(LST_WITH_LFREF_KEY_QNAME).node(new NodeIdentifierWithPredicates(
                         LST_WITH_LFREF_KEY_QNAME, LFREF_KEY_QNAME, "node1"));
         final InstanceIdentifierContext<?> iiContext =
                 controllerContext.toInstanceIdentifier("leafref-module:cont/lst-with-lfref-key/node1");
index 8edda9dab9f26c07b2af8d9376e8bb0325ae31d6..ad2ce0dc7b65d2ff10a8295d3a7d0cc695fdbf40 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -46,7 +45,7 @@ public class Bug8072Test {
     @BeforeClass
     public static void init() throws FileNotFoundException, ReactorException {
         final SchemaContext globalContext = TestUtils.loadSchemaContext("/full-versions/yangs");
-        assertNull(globalContext.findModuleByName(EXTERNAL_MODULE_NAME, null));
+        assertEquals(0, globalContext.findModules(EXTERNAL_MODULE_NAME).size());
         final Set<Module> allModules = globalContext.getModules();
         assertNotNull(allModules);
         CONTROLLER_CONTEXT.setSchemas(globalContext);
index dd0ea449a1d0d6722623c9016f27382e109303e3..dc049410dadee33c29340007ebbfc8df4fcde198 100644 (file)
@@ -124,27 +124,28 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
 
     private static YangInstanceIdentifier createInstanceIdentifier() throws URISyntaxException {
         final List<PathArgument> pathArguments = new ArrayList<>();
-        pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont")));
-        pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1")));
+        pathArguments.add(new NodeIdentifier(QName.create(new URI("instance:identifier:module"), "cont")));
+        pathArguments.add(new NodeIdentifier(QName.create(new URI("instance:identifier:module"), "cont1")));
 
-        final QName qName = new QName(new URI("augment:module"), "lst11");
+        final QName qName = QName.create(new URI("augment:module"), "lst11");
         final Map<QName, Object> keyValues = new HashMap<>();
-        keyValues.put(new QName(new URI("augment:module"), "keyvalue111"), "value1");
-        keyValues.put(new QName(new URI("augment:module"), "keyvalue112"), "value2");
+        keyValues.put(QName.create(new URI("augment:module"), "keyvalue111"), "value1");
+        keyValues.put(QName.create(new URI("augment:module"), "keyvalue112"), "value2");
         final NodeIdentifierWithPredicates nodeIdentifierWithPredicates =
                 new NodeIdentifierWithPredicates(qName, keyValues);
         pathArguments.add(nodeIdentifierWithPredicates);
 
-        pathArguments.add(new NodeIdentifier(new QName(new URI("augment:augment:module"), "lf112")));
+        pathArguments.add(new NodeIdentifier(QName.create(new URI("augment:augment:module"), "lf112")));
 
         return YangInstanceIdentifier.create(pathArguments);
     }
 
     private static YangInstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException {
         final List<PathArgument> pathArguments = new ArrayList<>();
-        pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont")));
-        pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1")));
-        pathArguments.add(new NodeWithValue<>(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1"));
+        pathArguments.add(new NodeIdentifier(QName.create(new URI("instance:identifier:module"), "cont")));
+        pathArguments.add(new NodeIdentifier(QName.create(new URI("instance:identifier:module"), "cont1")));
+        pathArguments.add(new NodeWithValue<>(QName.create(new URI("augment:module:leaf:list"), "lflst11"),
+                "lflst11_1"));
 
         return YangInstanceIdentifier.create(pathArguments);
     }
index 93c23c2b05d8206ff6c6d56d38f9ee61afff3572..649ec8fc87d99b00726603afbd65c7a1111da752 100644 (file)
@@ -303,16 +303,16 @@ public class CutDataToCorrectDepthTest extends JerseyTest {
     }
 
     private static NodeIdentifier toIdentifier(final String localName) {
-        return new NodeIdentifier(QName.create("urn:nested:module", "2014-06-3", localName));
+        return new NodeIdentifier(QName.create("urn:nested:module", "2014-06-03", localName));
     }
 
     private static NodeIdentifierWithPredicates toIdentifier(final String localName, final Map<QName, Object> keys) {
-        return new NodeIdentifierWithPredicates(QName.create("urn:nested:module", "2014-06-3", localName),
+        return new NodeIdentifierWithPredicates(QName.create("urn:nested:module", "2014-06-03", localName),
                 keys);
     }
 
     private static NodeWithValue<?> toIdentifier(final String localName, final Object value) {
-        return new NodeWithValue<>(QName.create("urn:nested:module", "2014-06-3", localName), value);
+        return new NodeWithValue<>(QName.create("urn:nested:module", "2014-06-03", localName), value);
     }
 
     private static UnkeyedListEntryNode nodeDataDepth3Operational() {
index 8ae8d0bdac927415b7ebd514cf8c356a45a6b52e..9a1d2074ae41418f52810472b1783d83a185e639 100644 (file)
@@ -67,23 +67,23 @@ public class DummyFuture<T> implements Future<RpcResult<T>> {
         private boolean isDone;
         private RpcResult<T> result;
 
-        public Builder<T> cancel(final boolean cancel) {
-            this.cancel = cancel;
+        public Builder<T> cancel(final boolean newCancel) {
+            this.cancel = newCancel;
             return this;
         }
 
-        public Builder<T> isCancelled(final boolean isCancelled) {
-            this.isCancelled = isCancelled;
+        public Builder<T> isCancelled(final boolean cancelled) {
+            this.isCancelled = cancelled;
             return this;
         }
 
-        public Builder<T> isDone(final boolean isDone) {
-            this.isDone = isDone;
+        public Builder<T> isDone(final boolean done) {
+            this.isDone = done;
             return this;
         }
 
-        public Builder<T> rpcResult(final RpcResult<T> result) {
-            this.result = result;
+        public Builder<T> rpcResult(final RpcResult<T> newResult) {
+            this.result = newResult;
             return this;
         }
 
index 3c545c06e95054f70dd4ab21c42912179f37990d..f03330e3c3c5aad87290d2d9f1438bb9ad51a6f6 100644 (file)
@@ -49,18 +49,18 @@ public class DummyRpcResult<T> implements RpcResult<T> {
         private T result;
         private Collection<RpcError> errors;
 
-        public Builder<T> isSuccessful(final boolean isSuccessful) {
-            this.isSuccessful = isSuccessful;
+        public Builder<T> isSuccessful(final boolean successful) {
+            this.isSuccessful = successful;
             return this;
         }
 
-        public Builder<T> result(final T result) {
-            this.result = result;
+        public Builder<T> result(final T newResult) {
+            this.result = newResult;
             return this;
         }
 
-        public Builder<T> errors(final Collection<RpcError> errors) {
-            this.errors = errors;
+        public Builder<T> errors(final Collection<RpcError> newErrors) {
+            this.errors = newErrors;
             return this;
         }
 
index 008fda4e0960b9e2ecd3b3c5518887dd03dba452..1a7de78c5bc97254503b4607383720ffe91b2a5e 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -29,15 +30,13 @@ public class DummyType implements TypeDefinition<DummyType> {
     }
 
     @Override
-    public String getDescription() {
-        // TODO Auto-generated method stub
-        return null;
+    public Optional<String> getDescription() {
+        return Optional.empty();
     }
 
     @Override
-    public String getReference() {
-        // TODO Auto-generated method stub
-        return null;
+    public Optional<String> getReference() {
+        return Optional.empty();
     }
 
     @Override
@@ -59,15 +58,12 @@ public class DummyType implements TypeDefinition<DummyType> {
     }
 
     @Override
-    public String getUnits() {
-        // TODO Auto-generated method stub
-        return null;
+    public Optional<String> getUnits() {
+        return Optional.empty();
     }
 
     @Override
-    public Object getDefaultValue() {
-        // TODO Auto-generated method stub
-        return null;
+    public Optional<? extends Object> getDefaultValue() {
+        return Optional.empty();
     }
-
 }
index 63666c78a90231aac2f193342aeda00066a47511..434304da2193c08464e2fd71830fa841e28afa2b 100644 (file)
@@ -132,7 +132,7 @@ public class ExpressionParserTest {
             }
         }
         final YangInstanceIdentifier path = Mockito.mock(YangInstanceIdentifier.class);
-        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-14-12", "localName"));
+        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-12-14", "localName"));
         Mockito.when(path.getLastPathArgument()).thenReturn(pathValue);
         final ListenerAdapter listener = Notificator.createListener(path, "streamName", NotificationOutputType.JSON);
         listener.setQueryParams(Instant.now(), Optional.empty(), Optional.ofNullable(filter), false);
index a1c497636b08443c499611d8d1af1142e33e1964..bebb7f4e5f233fc9f0906c8772c16ab7c52433e9 100644 (file)
@@ -128,7 +128,7 @@ public class InvokeRpcMethodTest {
 
     private static NormalizedNodeContext prepareDomPayload() {
         final SchemaContext schema = controllerContext.getGlobalSchema();
-        final Module rpcModule = schema.findModuleByName("invoke-rpc-module", null);
+        final Module rpcModule = schema.findModules("invoke-rpc-module").iterator().next();
         assertNotNull(rpcModule);
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), "rpc-test");
         final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input");
@@ -290,7 +290,7 @@ public class InvokeRpcMethodTest {
                 QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)make-toast"));
 
         final SchemaContext schemaContext = controllerContext.getGlobalSchema();
-        final Module rpcModule = schemaContext.findModuleByName("toaster", null);
+        final Module rpcModule = schemaContext.findModules("toaster").iterator().next();
         assertNotNull(rpcModule);
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), "make-toast");
         final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input");
@@ -341,7 +341,7 @@ public class InvokeRpcMethodTest {
     @Test
     public void testInvokeRpcWithNoPayloadWithOutput_Success() {
         final SchemaContext schema = controllerContext.getGlobalSchema();
-        final Module rpcModule = schema.findModuleByName("toaster", null);
+        final Module rpcModule = schema.findModules("toaster").iterator().next();
         assertNotNull(rpcModule);
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), "testOutput");
         final QName rpcOutputQName = QName.create(rpcModule.getQNameModule(),"output");
index 31807c84e8a8c3828706c6839e10989c75c24441..5037c4bbf09f96cfbb88a7d4c5988d2cfd4951fc 100644 (file)
@@ -233,14 +233,15 @@ public class JSONRestconfServiceImplTest {
         final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         assertEquals("ContainerNode node type", INTERFACES_QNAME, actualNode.getNodeType());
 
-        final Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(new NodeIdentifier(INTERFACE_QNAME));
+        final java.util.Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(
+            new NodeIdentifier(INTERFACE_QNAME));
         assertEquals(INTERFACE_QNAME.toString() + " present", true, mapChild.isPresent());
         assertTrue("Expected MapNode. Actual " + mapChild.get().getClass(), mapChild.get() instanceof MapNode);
         final MapNode mapNode = (MapNode)mapChild.get();
 
         final NodeIdentifierWithPredicates entryNodeID = new NodeIdentifierWithPredicates(
                 INTERFACE_QNAME, NAME_QNAME, "eth0");
-        final Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
+        final java.util.Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
         assertEquals(entryNodeID.toString() + " present", true, entryChild.isPresent());
         final MapEntryNode entryNode = entryChild.get();
         verifyLeafNode(entryNode, NAME_QNAME, "eth0");
@@ -278,7 +279,7 @@ public class JSONRestconfServiceImplTest {
     }
 
     @Test(expected = TransactionCommitFailedException.class)
-    @SuppressWarnings("checkstyle:IllegalThrows")
+    @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
     public void testPostFailure() throws Throwable {
         doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock"))).when(brokerFacade)
                 .commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),
@@ -540,7 +541,7 @@ public class JSONRestconfServiceImplTest {
     }
 
     void verifyLeafNode(final DataContainerNode<?> parent, final QName leafType, final Object leafValue) {
-        final Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
+        final java.util.Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
         assertEquals(leafType.toString() + " present", true, leafChild.isPresent());
         assertEquals(leafType.toString() + " value", leafValue, leafChild.get().getValue());
     }
index 7050f72211a413a29b127cece30d5efd37c552b7..051ca9e7da976616a10418fda25dd7327a15a565 100644 (file)
@@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
 import java.net.URI;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -56,7 +55,7 @@ import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -224,9 +223,7 @@ public class RestGetOperationTest extends JerseyTest {
     }
 
     private static QName newTestModuleQName(final String localPart) throws Exception {
-        final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-09");
-        final URI uri = URI.create("test:module");
-        return QName.create(uri, revision, localPart);
+        return QName.create(URI.create("test:module"), Revision.of("2014-01-09"), localPart);
     }
 
     @Test
@@ -325,7 +322,7 @@ public class RestGetOperationTest extends JerseyTest {
 
         assertEquals("module2", qname.getLocalName());
         assertEquals("module:2", qname.getNamespace().toString());
-        assertEquals("2014-01-02", qname.getFormattedRevision());
+        assertEquals("2014-01-02", qname.getRevision().get().toString());
 
         response = target(uri).request("application/yang.api+json").get();
         assertEquals(200, response.getStatus());
@@ -513,7 +510,7 @@ public class RestGetOperationTest extends JerseyTest {
         final QName module = assertedModuleXmlToModuleQName(responseXml.getDocumentElement());
 
         assertEquals("module1-behind-mount-point", module.getLocalName());
-        assertEquals("2014-02-03", module.getFormattedRevision());
+        assertEquals("2014-02-03", module.getRevision().get().toString());
         assertEquals("module:1:behind:mount:point", module.getNamespace().toString());
 
 
@@ -743,7 +740,7 @@ public class RestGetOperationTest extends JerseyTest {
             final QName qNameDepth1Cont = QName.create("urn:nested:module", "2014-06-3", "depth1-cont");
             final YangInstanceIdentifier ii = YangInstanceIdentifier.builder().node(qNameDepth1Cont).build();
             final NormalizedNode value =
-                    (Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(qNameDepth1Cont)).build());
+                    Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(qNameDepth1Cont)).build();
             when(brokerFacade.readConfigurationData(eq(ii))).thenReturn(value);
             restconfImpl.readConfigurationData("nested-module:depth1-cont", uriInfo);
             fail("Expected RestconfDocumentedException");
@@ -790,7 +787,7 @@ public class RestGetOperationTest extends JerseyTest {
                     "Unexpected child element for parent \"" + element.getLocalName() + "\": "
                             + actualElement.getLocalName(), expChild);
 
-            if ((expChild.data == null) || (expChild.data instanceof List)) {
+            if (expChild.data == null || expChild.data instanceof List) {
                 verifyContainerElement(actualElement, expChild);
             } else {
                 assertEquals("Text content for element: " + actualElement.getLocalName(), expChild.data,
index 7bf4782790506631de6652a2ef67126071d9ba74..bdc967974450ea85e8d92c2eb2e8e7bb757f9a7d 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.sal.restconf.impl.test;
 
-public class RestOperationUtils {
+public final class RestOperationUtils {
 
     public static final String JSON = "+json";
     public static final String XML = "+xml";
index bbac0c5cf675dbea0ba317762349dfbe5a0fc1f0..945eb6b211c607855676d55db30db8e92df27d30 100644 (file)
@@ -59,10 +59,10 @@ public class RestconfImplNotificationSubscribingTest {
         this.broker.setDomDataBroker(this.domDataBroker);
         RestconfImpl.getInstance().setBroker(this.broker);
         ControllerContext.getInstance()
-                .setGlobalSchema(YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/notifications")));
+                .setGlobalSchema(YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications")));
 
         final YangInstanceIdentifier path = Mockito.mock(YangInstanceIdentifier.class);
-        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-14-12", "localName"));
+        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-12-14", "localName"));
         Mockito.when(path.getLastPathArgument()).thenReturn(pathValue);
         Notificator.createListener(path, this.identifier, NotificationOutputType.XML);
     }
@@ -196,7 +196,7 @@ public class RestconfImplNotificationSubscribingTest {
     @Test
     public void onNotifiTest() throws Exception {
         final YangInstanceIdentifier path = Mockito.mock(YangInstanceIdentifier.class);
-        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-14-12", "localName"));
+        final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-12-14", "localName"));
         Mockito.when(path.getLastPathArgument()).thenReturn(pathValue);
         final ListenerAdapter listener = Notificator.createListener(path, this.identifier, NotificationOutputType.XML);
 
index f55a97ad7bb88ef07ee445f87af5217d6281d1e9..433684041f49d37173444d16b30c95d68e5f2231 100644 (file)
@@ -102,7 +102,7 @@ public class RestconfImplTest {
 
     private void binaryKeyTest(final List<Byte> al, final List<Byte> al2) {
 
-        final QName keyDef = QName.create("test:key:binary", "2017-14-08", "b1");
+        final QName keyDef = QName.create("test:key:binary", "2017-08-14", "b1");
 
         final Map<QName, Object> uriKeyValues = new HashMap<>();
         uriKeyValues.put(keyDef, al.toArray());
index ffd4ae3632325cfe4ba2f8135622ee928f1a57a6..481898d4b1a4e06fa300fb57ceba26ae4cbb3c67 100644 (file)
@@ -21,7 +21,6 @@ import java.io.OutputStreamWriter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
-import java.sql.Date;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -38,6 +37,7 @@ import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -48,7 +48,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMa
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,8 +58,11 @@ public final class TestUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
 
-    public static SchemaContext loadSchemaContext(final String... yangPath)
-            throws FileNotFoundException, ReactorException {
+    private TestUtils() {
+
+    }
+
+    public static SchemaContext loadSchemaContext(final String... yangPath) throws FileNotFoundException {
         final List<File> files = new ArrayList<>();
         for (final String path : yangPath) {
             final String pathToFile = TestUtils.class.getResource(path).getPath();
@@ -78,7 +80,7 @@ public final class TestUtils {
             }
         }
 
-        return YangParserTestUtils.parseYangSources(files);
+        return YangParserTestUtils.parseYangFiles(files);
     }
 
     public static Module findModule(final Set<Module> modules, final String moduleName) {
@@ -159,12 +161,7 @@ public final class TestUtils {
 
     public static QName buildQName(final String name, final String uri, final String date, final String prefix) {
         try {
-            final URI u = new URI(uri);
-            Date dt = null;
-            if (date != null) {
-                dt = Date.valueOf(date);
-            }
-            return QName.create(u, dt, name);
+            return QName.create(new URI(uri), Revision.ofNullable(date), name);
         } catch (final URISyntaxException e) {
             return null;
         }
index e0596f69884fd508b09edd52cf4d0ad6d92d2dec..10d7f75d17102ba1c21e2b52fa219eb0291527eb 100644 (file)
@@ -12,12 +12,9 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
 
 import com.google.common.base.Preconditions;
 import java.io.FileNotFoundException;
-import java.text.ParseException;
-import java.util.Date;
 import java.util.Set;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriBuilder;
@@ -36,6 +33,7 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
@@ -46,7 +44,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -87,7 +85,7 @@ public class URIParametersParsing {
             final LogicalDatastoreType datastoreExpected, final DataChangeScope scopeExpected) {
 
         final InstanceIdentifierBuilder iiBuilder = YangInstanceIdentifier.builder();
-        iiBuilder.node(QName.create("dummyStreamName"));
+        iiBuilder.node(QName.create("", "dummyStreamName"));
 
         final String datastoreValue = datastore == null ? "CONFIGURATION" : datastore;
         final String scopeValue = scope == null ? "BASE" : scope + "";
@@ -105,8 +103,8 @@ public class URIParametersParsing {
         final UriBuilder uriBuilder = UriBuilder.fromUri("www.whatever.com");
         when(mockedUriInfo.getAbsolutePathBuilder()).thenReturn(uriBuilder);
 
-        this.restconf.invokeRpc("sal-remote:create-data-change-event-subscription", prepareDomRpcNode(datastore, scope),
-                mockedUriInfo);
+        this.restconf.invokeRpc("sal-remote:create-data-change-event-subscription",
+            prepareDomRpcNode(datastoreValue, scopeValue), mockedUriInfo);
 
         final ListenerAdapter listener =
                 Notificator.getListenerFor("data-change-event-subscription/opendaylight-inventory:nodes/datastore="
@@ -116,13 +114,7 @@ public class URIParametersParsing {
 
     private NormalizedNodeContext prepareDomRpcNode(final String datastore, final String scope) {
         final SchemaContext schema = this.controllerContext.getGlobalSchema();
-        final Date revDate;
-        try {
-            revDate = getRevisionFormat().parse("2014-01-14");
-        } catch (final ParseException e) {
-            throw new IllegalStateException(e);
-        }
-        final Module rpcSalRemoteModule = schema.findModuleByName("sal-remote", revDate);
+        final Module rpcSalRemoteModule = schema.findModule("sal-remote", Revision.of("2014-01-14")).get();
         final Set<RpcDefinition> setRpcs = rpcSalRemoteModule.getRpcs();
         final QName rpcQName =
                 QName.create(rpcSalRemoteModule.getQNameModule(), "create-data-change-event-subscription");
@@ -145,36 +137,37 @@ public class URIParametersParsing {
                 QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "path");
         final DataSchemaNode pathSchemaNode = rpcInputSchemaNode.getDataChildByName(pathQName);
         assertTrue(pathSchemaNode instanceof LeafSchemaNode);
-        final LeafNode<Object> pathNode = (Builders.leafBuilder((LeafSchemaNode) pathSchemaNode)
+        final LeafNode<Object> pathNode = Builders.leafBuilder((LeafSchemaNode) pathSchemaNode)
                 .withValue(YangInstanceIdentifier.builder()
-                        .node(QName.create("urn:opendaylight:inventory", "2013-08-19", "nodes")).build())).build();
+                        .node(QName.create("urn:opendaylight:inventory", "2013-08-19", "nodes")).build()).build();
         container.withChild(pathNode);
 
-        final AugmentationSchema augmentationSchema = rpcInputSchemaNode.getAvailableAugmentations().iterator().next();
+        final AugmentationSchemaNode augmentationSchema = rpcInputSchemaNode.getAvailableAugmentations().iterator()
+                .next();
         Preconditions.checkNotNull(augmentationSchema);
         final DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> augmentationBuilder =
                 Builders.augmentationBuilder(augmentationSchema);
 
-        final QName dataStoreQName = QName.create("urn:sal:restconf:event:subscription", "2014-7-8", "datastore");
+        final QName dataStoreQName = QName.create("urn:sal:restconf:event:subscription", "2014-07-08", "datastore");
         final DataSchemaNode dsSchemaNode = augmentationSchema.getDataChildByName(dataStoreQName);
         assertTrue(dsSchemaNode instanceof LeafSchemaNode);
-        final LeafNode<Object> dsNode = (Builders.leafBuilder((LeafSchemaNode) dsSchemaNode)
-                .withValue(datastore)).build();
+        final LeafNode<Object> dsNode = Builders.leafBuilder((LeafSchemaNode) dsSchemaNode)
+                .withValue(datastore).build();
         augmentationBuilder.withChild(dsNode);
 
-        final QName scopeQName = QName.create("urn:sal:restconf:event:subscription", "2014-7-8", "scope");
+        final QName scopeQName = QName.create("urn:sal:restconf:event:subscription", "2014-07-08", "scope");
         final DataSchemaNode scopeSchemaNode = augmentationSchema.getDataChildByName(scopeQName);
         assertTrue(scopeSchemaNode instanceof LeafSchemaNode);
-        final LeafNode<Object> scopeNode = (Builders.leafBuilder((LeafSchemaNode) scopeSchemaNode)
-                .withValue(scope)).build();
+        final LeafNode<Object> scopeNode = Builders.leafBuilder((LeafSchemaNode) scopeSchemaNode)
+                .withValue(scope).build();
         augmentationBuilder.withChild(scopeNode);
 
         final QName outputQName =
-                QName.create("urn:sal:restconf:event:subscription", "2014-7-8", "notification-output-type");
+                QName.create("urn:sal:restconf:event:subscription", "2014-07-08", "notification-output-type");
         final DataSchemaNode outputSchemaNode = augmentationSchema.getDataChildByName(outputQName);
         assertTrue(outputSchemaNode instanceof LeafSchemaNode);
         final LeafNode<Object> outputNode =
-                (Builders.leafBuilder((LeafSchemaNode) outputSchemaNode).withValue("XML")).build();
+                Builders.leafBuilder((LeafSchemaNode) outputSchemaNode).withValue("XML").build();
         augmentationBuilder.withChild(outputNode);
 
         container.withChild(augmentationBuilder.build());
@@ -183,7 +176,7 @@ public class URIParametersParsing {
         when(rpcDef.getPath()).thenReturn(SchemaPath.create(true, rpcQName));
         when(rpcDef.getQName()).thenReturn(rpcQName);
 
-        return new NormalizedNodeContext(new InstanceIdentifierContext<RpcDefinition>(null, rpcDef, null, schema),
+        return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcDef, null, schema),
                 container.build());
     }
 }
index 6688ade142eaadf7dc7adbf07e6a1cfe4b75faef..b1562b1433c9eca6a5af56d303e0f929897c9483 100644 (file)
@@ -14,7 +14,6 @@ import java.io.FileNotFoundException;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public abstract class YangAndXmlAndDataSchemaLoader {
 
@@ -24,12 +23,12 @@ public abstract class YangAndXmlAndDataSchemaLoader {
     protected static String searchedDataSchemaName;
     protected static String schemaNodePath;
 
-    protected static void dataLoad(final String yangPath) throws FileNotFoundException, ReactorException {
+    protected static void dataLoad(final String yangPath) throws FileNotFoundException {
         dataLoad(yangPath, 1, null, null);
     }
 
     protected static void dataLoad(final String yangPath, final int modulesNumber, final String moduleName,
-            final String dataSchemaName) throws FileNotFoundException, ReactorException {
+            final String dataSchemaName) throws FileNotFoundException {
         modules = TestUtils.loadSchemaContext(yangPath).getModules();
         assertEquals(modulesNumber, modules.size());
         final Module module = TestUtils.resolveModule(moduleName, modules);
index d8893fe047ee62390cb327ae3883d25161e6c5a4..d8ed4902cbc5277b5084bcf462cf5d44f0da06d2 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.netconf.sal.rest.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
index 0c7ab15b533e4e9d5a03b6a9da696ea331d0826b..fca1543b0557d26d64ac65c8a956adb68febd528 100644 (file)
@@ -33,7 +33,7 @@ public class InstanceIdentifierCodecImplTest {
     @Before
     public void setUp() throws Exception {
         this.schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
         this.instanceIdentifierDTO = new InstanceIdentifierCodecImpl(null);
         ControllerContext.getInstance().setGlobalSchema(this.schemaContext);
 
index 41bc13146ff92471a51f744f3d1a46a4bb35d897..df9cf7fca00907f44d63ae11c4236b41a98ea3c8 100644 (file)
@@ -17,7 +17,6 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Optional;
-
 import org.json.JSONObject;
 import org.junit.Before;
 import org.junit.Test;
@@ -62,7 +61,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
     public void setUp() throws Exception {
         dataBroker = getDataBroker();
         domDataBroker = getDomBroker();
-        SchemaContext sc = YangParserTestUtils.parseYangSource(
+        SchemaContext sc = YangParserTestUtils.parseYangResource(
                 "/instanceidentifier/yang/instance-identifier-patch-module.yang");
         ControllerContext.getInstance().setGlobalSchema(sc);
     }
@@ -71,8 +70,9 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
 
         private String lastNotification = null;
 
-        ListenerAdapterTester(YangInstanceIdentifier path, String streamName,
-                              NotificationOutputTypeGrouping.NotificationOutputType outputType, boolean leafNodesOnly) {
+        ListenerAdapterTester(final YangInstanceIdentifier path, final String streamName,
+                              final NotificationOutputTypeGrouping.NotificationOutputType outputType,
+                              final boolean leafNodesOnly) {
             super(path, streamName, outputType);
             setQueryParams(EPOCH, Optional.empty(), Optional.empty(), leafNodesOnly);
         }
@@ -82,7 +82,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
             this.lastNotification = event.getData();
         }
 
-        public void assertGot(String json) throws Exception {
+        public void assertGot(final String json) throws Exception {
             long start = System.currentTimeMillis();
             while (true) {
                 if (lastNotification != null) {
@@ -91,7 +91,8 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
                 if (System.currentTimeMillis() - start > 1000) {
                     throw new Exception("TIMED OUT waiting for notification with " + json);
                 }
-                Thread.currentThread().sleep(200);
+                Thread.currentThread();
+                Thread.sleep(200);
             }
             LOG.debug("Comparing {} {}", json, lastNotification);
             JSONAssert.assertEquals(json, withFakeDate(lastNotification), false);
@@ -99,7 +100,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         }
     }
 
-    static String withFakeDate(String in) {
+    static String withFakeDate(final String in) {
         JSONObject doc = new JSONObject(in);
         JSONObject notification = doc.getJSONObject("notification");
         if (notification == null) {
@@ -109,7 +110,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         return doc.toString();
     }
 
-    private String getNotifJson(String path) throws IOException, URISyntaxException {
+    private String getNotifJson(final String path) throws IOException, URISyntaxException {
         URL url = getClass().getResource(path);
         byte[] bytes = Files.readAllBytes(Paths.get(url.toURI()));
         return withFakeDate(new String(bytes, StandardCharsets.UTF_8));
index 920d7e02491f0b16365bdfaa2181fe6f9e154ec1..1edfecb32790d22ac45c8dd1b2cacae1af67c6cb 100644 (file)
@@ -12,16 +12,15 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
@@ -32,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev14070
 import org.opendaylight.yangtools.util.SingletonSet;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -47,16 +46,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class NotificationListenerTest {
-    private static final QNameModule MODULE;
-
-    static {
-        try {
-            MODULE = QNameModule.create(URI.create("notifi:mod"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2016-11-23"));
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
+    private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23"));
 
     private SchemaContext schmeaCtx;
 
index f88f17b5872b360298f4609c5fc0af9680783739..cdc8c69c4b05b51499327a41f12103d1863a4137 100644 (file)
@@ -9,7 +9,7 @@ module sal-remote-augment {
     description
         "Added input parameters to rpc create-data-change-event-subscription";
 
-    revision "2014-7-8" {
+    revision "2014-07-08" {
     }
 
     augment "/salrmt:create-data-change-event-subscription/salrmt:input" {
@@ -36,4 +36,4 @@ module sal-remote-augment {
         }
     }
 
-}
\ No newline at end of file
+}
index ad4883c064a6816f5fda4afe156c194ffbb1b8f9..e74481868f5034a5a7bfdb503fcadf02139727ac 100644 (file)
@@ -3,7 +3,7 @@ module invoke-rpc-module {
 
   prefix "inrpcmod";
          
-  revision 2013-12-3 {
+  revision 2013-12-03 {
   
   }
 
@@ -27,4 +27,4 @@ module invoke-rpc-module {
   rpc rpc-noop {
   }
 
-}
\ No newline at end of file
+}
index 30890bf9c3089078c057a7fae249ebf2747e7274..09a34c5f061b2499b1cdc6f18708fdf3392825b8 100644 (file)
@@ -2,9 +2,9 @@ module identity-module {
   namespace "identity:module";  
 
   prefix "idemod";
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        identity iden {         
        }
-}
\ No newline at end of file
+}
index b90b533ce5dd8c2844d01ae33a2ef81184c72c84..80ec3965fb71dd43141f9b32470fa47e7f3ea09e 100644 (file)
@@ -2,15 +2,15 @@ module identityref-module {
   namespace "identityref:module";  
 
   prefix "iderefmod";
-  
-  import identity-module {prefix idemo; revision-date 2013-12-2;}
-   
-  revision 2013-12-2 {    
+
+  import identity-module {prefix idemo; revision-date 2013-12-02; }
+
+  revision 2013-12-02 {    
   }
-  
+
   identity iden_local {
   }
-  
+
        container cont {
           container cont1 {
                leaf lf11 {
@@ -36,4 +36,4 @@ module identityref-module {
                }
        }
          
-}
\ No newline at end of file
+}
index aa2795afebbe0cf0c8a739a382dfd2d4c5c26eef..794859b0c2566480d9cf80b1cc15379392b634c7 100644 (file)
@@ -1,7 +1,7 @@
 module nested-module {
     namespace "urn:nested:module";
     prefix "nested";
-    revision "2014-06-3";
+    revision "2014-06-03";
 
     container depth1-cont {
         list depth2-cont1 {
index 30890bf9c3089078c057a7fae249ebf2747e7274..09a34c5f061b2499b1cdc6f18708fdf3392825b8 100644 (file)
@@ -2,9 +2,9 @@ module identity-module {
   namespace "identity:module";  
 
   prefix "idemod";
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        identity iden {         
        }
-}
\ No newline at end of file
+}
index 20f91b2bdd57ccd0d0bc5cc7f8d10597176dc69c..c5c8f622a988f2fdf338b21b084f30d340486adf 100644 (file)
@@ -3,9 +3,9 @@ module identityref-module {
 
   prefix "iderefmod";
   
-  import identity-module {prefix idemo; revision-date 2013-12-2;}
+  import identity-module {prefix idemo; revision-date 2013-12-02; }
    
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        container cont {
@@ -18,4 +18,4 @@ module identityref-module {
                }
        }
          
-}
\ No newline at end of file
+}
index 528eb5e4201d13d59dc6eaa5252d8b7b93427da9..b54027e0bc9ee7de4a655bfcb74c26824f6594ab 100644 (file)
@@ -3,9 +3,9 @@ module cont-augment-module {
 
   prefix "cntaugmod";
 
-  import main-module {prefix mamo; revision-date 2013-12-2;}
+  import main-module {prefix mamo; revision-date 2013-12-02;}
 
-  revision 2013-12-2 {
+  revision 2013-12-02 {
 
   }
 
@@ -36,4 +36,4 @@ module cont-augment-module {
        }
   }
   
-}
\ No newline at end of file
+}
index 1641aaae6e40a4ace09847620b2d1679ddcc55e1..0d90d2b4eb9a0415bd50c356a0f8c6d7f02112e1 100644 (file)
@@ -2,7 +2,7 @@ module main-module {
     namespace "main:module";
 
     prefix "mainmod";
-    revision 2013-12-2 {
+    revision 2013-12-02 {
     }
 
     container cont {
index 1b861f5765d54faf6f0326b40a131104d0ec0caf..5829e0481c48cefec3bcabe28ddacc677ab86102 100644 (file)
@@ -3,9 +3,9 @@ module aug-referenced-elements-module {
 
   prefix "augrefelmo";
   
-  import referenced-elements-module {prefix refelmo; revision-date 2013-12-3;}
+  import referenced-elements-module {prefix refelmo; revision-date 2013-12-03;}
    
-  revision 2013-12-3 {    
+  revision 2013-12-03 {    
   }
   
   augment "/refelmo:cont" {
@@ -15,4 +15,4 @@ module aug-referenced-elements-module {
   }
   
          
-}
\ No newline at end of file
+}
index fd6e0fb27a8c772815a41829ed2adaea0e73fc24..a844ac683ceb637ab41ea8f892b3b240f20f8963 100644 (file)
@@ -3,7 +3,7 @@ module referenced-elements-module {
 
   prefix "refelmo";
    
-  revision 2013-12-3 {    
+  revision 2013-12-03 {    
   }
   
        container cont {
@@ -17,4 +17,4 @@ module referenced-elements-module {
                
        }
          
-}
\ No newline at end of file
+}
index 61ce8228b7fd53cce5557571e431254d3059ca93..41a9001113c811ab3a7b0219037f0573af01d102 100644 (file)
@@ -3,7 +3,7 @@ module instance-identifier-module {
 
   prefix "inidmod";
    
-  revision 2013-12-3 {    
+  revision 2013-12-03 {    
   }
   
        container cont {
@@ -13,4 +13,4 @@ module instance-identifier-module {
                }
        }
          
-}
\ No newline at end of file
+}
index 992c9af00ca9ff2d600c49566795625a01c45d57..efbac4dae4141584e8cbad6393563d6cccddc4eb 100644 (file)
@@ -3,9 +3,9 @@ module basic-module {
 
     prefix "basmod";
 
-    import referenced-module {prefix refmo; revision-date 2013-12-2;}
+    import referenced-module {prefix refmo; revision-date 2013-12-02;}
 
-    revision 2013-12-2 {
+    revision 2013-12-02 {
     }
 
     container cont {
index 9821b1e169a21dbfc386730f46ee04a22862d284..e78266fbb2e491669a46dac39ce4aeeb93abe860 100644 (file)
@@ -2,9 +2,9 @@ module referenced-module {
   namespace "referenced:module";  
 
   prefix "refmod";
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        identity iden {         
        }
-}
\ No newline at end of file
+}
index 30890bf9c3089078c057a7fae249ebf2747e7274..09a34c5f061b2499b1cdc6f18708fdf3392825b8 100644 (file)
@@ -2,9 +2,9 @@ module identity-module {
   namespace "identity:module";  
 
   prefix "idemod";
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        identity iden {         
        }
-}
\ No newline at end of file
+}
index a43d43990debd3f1da552eaca2b89fd533b17bd7..e0ef1bbe3489310452a6c55f9899ead57e897a6b 100644 (file)
@@ -3,9 +3,9 @@ module identityref-module {
 
   prefix "iderefmod";
   
-  import identity-module {prefix idemo; revision-date 2013-12-2;}
+  import identity-module {prefix idemo; revision-date 2013-12-02;}
    
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        container cont {
@@ -18,4 +18,4 @@ module identityref-module {
                }
        }
          
-}
\ No newline at end of file
+}
index 30890bf9c3089078c057a7fae249ebf2747e7274..09a34c5f061b2499b1cdc6f18708fdf3392825b8 100644 (file)
@@ -2,9 +2,9 @@ module identity-module {
   namespace "identity:module";  
 
   prefix "idemod";
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        identity iden {         
        }
-}
\ No newline at end of file
+}
index 719ac1222611782aa27ac44bf7ca0507f9a06753..8fd900277c77561fb9360a83e25355a780636299 100644 (file)
@@ -3,10 +3,10 @@ module identityref-module {
 
   prefix "iderefmod";
   
-  import identity-module {prefix idemo; revision-date 2013-12-2;}
+  import identity-module {prefix idemo; revision-date 2013-12-02;}
   import general-module {prefix gmo; revision-date 2013-12-12;}
    
-  revision 2013-12-2 {    
+  revision 2013-12-02 {    
   }
   
        augment "/gmo:cont/gmo:cont1" {
@@ -17,4 +17,4 @@ module identityref-module {
                }
        }
          
-}
\ No newline at end of file
+}
index 8c6d2ca944e2183fd1e66885dfbeba1bb39c1a59..8de2d24da9a5469e3d436129a4916f47539f2646 100644 (file)
@@ -8,11 +8,9 @@
 package org.opendaylight.restconf.nb.rfc8040;
 
 import java.net.URI;
-import java.text.ParseException;
-import java.util.Date;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 /**
  * Base Draft for Restconf project.
@@ -57,25 +55,14 @@ public final class Rfc8040 {
             throw new UnsupportedOperationException("Util class");
         }
 
-        public static final String REVISION = "2017-01-26";
+        public static final Revision REVISION = Revision.of("2017-01-26");
         public static final String NAME = "ietf-restconf";
         public static final String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf";
+        public static final URI URI_MODULE = URI.create(NAMESPACE);
 
-        public static final QName IETF_RESTCONF_QNAME = QName.create(Rfc8040.RestconfModule.NAMESPACE,
+        public static final QName IETF_RESTCONF_QNAME = QName.create(URI_MODULE,
                 Rfc8040.RestconfModule.REVISION, Rfc8040.RestconfModule.NAME).intern();
 
-        public static final Date DATE;
-
-        static {
-            try {
-                DATE = SimpleDateFormatUtil.getRevisionFormat().parse(REVISION);
-            } catch (final ParseException e) {
-                throw new ExceptionInInitializerError(e);
-            }
-        }
-
-        public static final URI URI_MODULE = URI.create(NAMESPACE);
-
         // RESTCONF
         public static final String RESTCONF_GROUPING_SCHEMA_NODE = "restconf";
         public static final String RESTCONF_CONTAINER_SCHEMA_NODE = "restconf";
@@ -117,21 +104,10 @@ public final class Rfc8040 {
 
         public static final String NAME = "ietf-yang-library";
         public static final String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-yang-library";
-        public static final String REVISION = "2016-06-21";
-
-        public static final Date DATE;
-
-        static {
-            try {
-                DATE = SimpleDateFormatUtil.getRevisionFormat().parse(REVISION);
-            } catch (final ParseException e) {
-                throw new ExceptionInInitializerError(e);
-            }
-        }
-
         public static final URI URI_MODULE = URI.create(NAMESPACE);
+        public static final Revision REVISION =  Revision.of("2016-06-21");
 
-        public static final QNameModule MODULE_QNAME = QNameModule.create(URI_MODULE, DATE).intern();
+        public static final QNameModule MODULE_QNAME = QNameModule.create(URI_MODULE, REVISION).intern();
 
         public static final String MODULE_SET_ID_LEAF = "module-set-id";
         public static final QName MODULE_SET_ID_LEAF_QNAME = QName.create(MODULE_QNAME, MODULE_SET_ID_LEAF).intern();
@@ -192,24 +168,14 @@ public final class Rfc8040 {
 
         public static final String NAME = "ietf-restconf-monitoring";
         public static final String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
-        public static final String REVISION = "2017-01-26";
+        public static final Revision REVISION = Revision.of("2017-01-26");
         public static final String PATH_TO_STREAM_WITHOUT_KEY =
                 "ietf-restconf-monitoring:restconf-state/streams/stream=";
         public static final String PATH_TO_STREAMS = "ietf-restconf-monitoring:restconf-state/streams";
 
-        public static final Date DATE;
-
-        static {
-            try {
-                DATE = SimpleDateFormatUtil.getRevisionFormat().parse(REVISION);
-            } catch (final ParseException e) {
-                throw new ExceptionInInitializerError(e);
-            }
-        }
-
         public static final URI URI_MODULE = URI.create(NAMESPACE);
 
-        public static final QNameModule MODULE_QNAME = QNameModule.create(URI_MODULE, DATE).intern();
+        public static final QNameModule MODULE_QNAME = QNameModule.create(URI_MODULE, REVISION).intern();
 
         public static final String CONT_RESTCONF_STATE_NAME = "restconf-state";
         public static final QName CONT_RESTCONF_STATE_QNAME = QName.create(MODULE_QNAME, CONT_RESTCONF_STATE_NAME)
index a4239e8bb9083bf36e11b8655e02bf8102d4ad14..947002c9f014af93fdc631c6958480d6ced6fbff 100644 (file)
@@ -11,10 +11,10 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterables;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.restconf.common.util.IdentityValuesDTO;
 import org.opendaylight.restconf.common.util.IdentityValuesDTO.IdentityValue;
@@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.data.api.codec.InstanceIdentifierCodec;
 import org.opendaylight.yangtools.yang.data.api.codec.LeafrefCodec;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -49,14 +49,14 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RestCodec {
+public final class RestCodec {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestCodec.class);
 
     private RestCodec() {
     }
 
-    public static final Codec<Object, Object> from(final TypeDefinition<?> typeDefinition,
+    public static Codec<Object, Object> from(final TypeDefinition<?> typeDefinition,
             final DOMMountPoint mountPoint, final SchemaContext schemaContext) {
         return new ObjectCodec(typeDefinition, mountPoint, schemaContext);
     }
@@ -345,9 +345,9 @@ public class RestCodec {
         final URI validNamespace = resolveValidNamespace(namespace, mountPoint, schemaContext);
         Module module = null;
         if (mountPoint != null) {
-            module = mountPoint.getSchemaContext().findModuleByNamespace(validNamespace).iterator().next();
+            module = mountPoint.getSchemaContext().findModules(validNamespace).iterator().next();
         } else {
-            module = schemaContext.findModuleByNamespace(validNamespace).iterator().next();
+            module = schemaContext.findModules(validNamespace).iterator().next();
         }
         if (module == null) {
             LOG.info("Module for namespace " + validNamespace + " wasn't found.");
@@ -415,15 +415,16 @@ public class RestCodec {
 
         final Iterable<ChoiceSchemaNode> choiceNodes =
                 Iterables.filter(container.getChildNodes(), ChoiceSchemaNode.class);
-        final Iterable<Set<ChoiceCaseNode>> map = Iterables.transform(choiceNodes, ChoiceSchemaNode::getCases);
-        for (final ChoiceCaseNode caze : Iterables.concat(map)) {
+        final Iterable<Collection<CaseSchemaNode>> map = Iterables.transform(choiceNodes,
+            choice -> choice.getCases().values());
+        for (final CaseSchemaNode caze : Iterables.concat(map)) {
             collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name);
         }
     }
 
     private static boolean isInstantiatedDataSchema(final DataSchemaNode node) {
-        return (node instanceof LeafSchemaNode) || (node instanceof LeafListSchemaNode)
-                || (node instanceof ContainerSchemaNode) || (node instanceof ListSchemaNode)
-                || (node instanceof AnyXmlSchemaNode);
+        return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode
+                || node instanceof ContainerSchemaNode || node instanceof ListSchemaNode
+                || node instanceof AnyXmlSchemaNode;
     }
 }
index 69d26a5a67b99739e6d8101c75ed07ca7ce24392..3dc7778782fb1e8a20ca70fc9157d3b2627b687e 100644 (file)
@@ -37,11 +37,8 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
 
     @Override
     protected Module moduleForPrefix(@Nonnull final String prefix) {
-        if (prefix.isEmpty() && !this.defaultPrefix.isEmpty()) {
-            return this.context.findModuleByName(this.defaultPrefix, null);
-        } else {
-            return this.context.findModuleByName(prefix, null);
-        }
+        final String moduleName = prefix.isEmpty() && !defaultPrefix.isEmpty() ? defaultPrefix : prefix;
+        return context.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
     @Nonnull
@@ -53,7 +50,6 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr
     @Nullable
     @Override
     protected String prefixForNamespace(@Nonnull final URI namespace) {
-        final Module module = this.context.findModuleByNamespaceAndRevision(namespace, null);
-        return module == null ? null : module.getName();
+        return this.context.findModules(namespace).stream().findFirst().map(Module::getName).orElse(null);
     }
-}
\ No newline at end of file
+}
index 6ba7018cb5d6e6d7a957a0ea3ee97e9855efb49c..e50b0152a51ba59cfb3ad7c53fe68d4ee89cabb4 100644 (file)
@@ -54,6 +54,7 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void onGlobalContextUpdated(final SchemaContext context) {
         Preconditions.checkNotNull(context);
         this.context = null;
@@ -63,14 +64,14 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
 
         this.moduleSetId++;
         final Module ietfYangLibraryModule =
-                context.findModuleByNamespaceAndRevision(IetfYangLibrary.URI_MODULE, IetfYangLibrary.DATE);
+                context.findModule(IetfYangLibrary.MODULE_QNAME).orElse(null);
         NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
                 RestconfMappingNodeUtil.mapModulesByIetfYangLibraryYang(context.getModules(), ietfYangLibraryModule,
                         context, String.valueOf(this.moduleSetId));
         putData(normNode);
 
         final Module monitoringModule =
-                this.context.findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+                this.context.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
         normNode = RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
         putData(normNode);
     }
index c949b15bcf15d1714b19b9ada529b274650d4185..573dc36e0144d2cf8bc2dbb80e89b5372934cea8 100644 (file)
@@ -31,6 +31,7 @@ public class TransactionChainHandler implements Handler<DOMTransactionChain> {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void update(final DOMTransactionChain transactionChain) {
         Preconditions.checkNotNull(transactionChain);
         this.transactionChain = transactionChain;
index 55c404a1f7c3135a8d6bb7d8a5a4e529b2008ebe..9da9bc85e61ec79b599ba9a8e89a072d3380d5ad 100644 (file)
@@ -11,13 +11,13 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
 import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterables;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.common.QName;
index dc5a1f243877baa0de6cb2acf48be0140fc8fc1e..54ea4fe3680acc2214e053e6ff62227435b19a89 100644 (file)
@@ -42,9 +42,9 @@ import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -106,8 +106,8 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade
             }
             while (!foundSchemaNodes.isEmpty()) {
                 final Object child = foundSchemaNodes.pop();
-                if (child instanceof AugmentationSchema) {
-                    final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child;
+                if (child instanceof AugmentationSchemaNode) {
+                    final AugmentationSchemaNode augmentSchemaNode = (AugmentationSchemaNode) child;
                     iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode));
                 } else if (child instanceof DataSchemaNode) {
                     schemaNode = (DataSchemaNode) child;
@@ -177,7 +177,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade
 
                 // find augmentation
                 if (child.isAugmenting()) {
-                    final AugmentationSchema augment = findCorrespondingAugment(schemaNode, child);
+                    final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, child);
                     if (augment != null) {
                         result.push(augment);
                     }
@@ -189,12 +189,12 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade
         }
 
         for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
-            for (final ChoiceCaseNode caseNode : choiceNode.getCases()) {
+            for (final CaseSchemaNode caseNode : choiceNode.getCases().values()) {
                 final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
                 if (!resultFromRecursion.isEmpty()) {
                     resultFromRecursion.push(choiceNode);
                     if (choiceNode.isAugmenting()) {
-                        final AugmentationSchema augment = findCorrespondingAugment(schemaNode, choiceNode);
+                        final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, choiceNode);
                         if (augment != null) {
                             resultFromRecursion.push(augment);
                         }
@@ -206,10 +206,11 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade
         return result;
     }
 
-    private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent,
+    private static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent,
                                                                final DataSchemaNode child) {
         if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) {
-            for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
+            for (final AugmentationSchemaNode augmentation
+                    : ((AugmentationTarget) parent).getAvailableAugmentations()) {
                 final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName());
                 if (childInAugmentation != null) {
                     return augmentation;
index 62cef20f5f047f5c51caa58f0a48e2df4c0903b3..2db6167dc0e7d92ec1d6691dffc00906baff15d1 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifie
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -77,7 +78,7 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader {
             LOG.debug("Error parsing xml input", e);
 
             throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
-                    ErrorTag.MALFORMED_MESSAGE);
+                    ErrorTag.MALFORMED_MESSAGE, e);
         }
     }
 
@@ -102,8 +103,7 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader {
                     ? schemaNode.getQName().getNamespace().toString() : firstValueElement.getNamespaceURI();
 
             // find module according to namespace
-            final Module module = pathContext.getSchemaContext().findModuleByNamespace(
-                    URI.create(namespace)).iterator().next();
+            final Module module = pathContext.getSchemaContext().findModules(URI.create(namespace)).iterator().next();
 
             // initialize codec + set default prefix derived from module name
             final StringModuleInstanceIdentifierCodec codec = new StringModuleInstanceIdentifierCodec(
@@ -119,7 +119,8 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader {
             } else {
                 targetII = codec.deserialize(codec.serialize(pathContext.getInstanceIdentifier())
                         .concat(prepareNonCondXpath(schemaNode, target.replaceFirst("/", ""), firstValueElement,
-                                namespace, module.getQNameModule().getFormattedRevision())));
+                                namespace,
+                                module.getQNameModule().getRevision().map(Revision::toString).orElse(null))));
 
                 targetNode = SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(),
                         codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath().getParent());
index 395f2362f49fe949e4b79279fd593a836995dca3..1266a580bb278563d57878dc64fcf0470ab999d9 100644 (file)
@@ -11,6 +11,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.concurrent.ExecutionException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
@@ -20,7 +21,6 @@ import javax.ws.rs.ext.Provider;
 import org.opendaylight.restconf.common.schema.SchemaExportContext;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 
 @Provider
@@ -45,11 +45,11 @@ public class SchemaExportContentYangBodyWriter implements MessageBodyWriter<Sche
             final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
             WebApplicationException {
         final RevisionSourceIdentifier sourceId = RevisionSourceIdentifier.create(context.getModule().getName(),
-                context.getModule().getQNameModule().getFormattedRevision());
+                context.getModule().getQNameModule().getRevision());
         final YangTextSchemaSource yangTextSchemaSource;
         try {
-            yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).checkedGet();
-        } catch (SchemaSourceException e) {
+            yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).get();
+        } catch (InterruptedException | ExecutionException e) {
             throw new WebApplicationException("Unable to retrieve source from SourceProvider.", e);
         }
         yangTextSchemaSource.copyTo(entityStream);
index 64623c6e7bc5c0e9a1fcef54a4cf091d0a81890d..40fdd71e9c272b7bb5d6a9489f90ac21d829bec8 100644 (file)
@@ -10,10 +10,12 @@ package org.opendaylight.restconf.nb.rfc8040.references;
 import java.lang.ref.SoftReference;
 import java.net.URI;
 import java.util.Date;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -35,7 +37,7 @@ public final class SchemaContextRef {
      *             actual {@link SchemaContext}
      */
     public SchemaContextRef(final SchemaContext schemaContext) {
-        this.schemaContextRef = new SoftReference<SchemaContext>(schemaContext);
+        this.schemaContextRef = new SoftReference<>(schemaContext);
     }
 
     /**
@@ -92,11 +94,10 @@ public final class SchemaContextRef {
      *             revision of module
      * @return {@link Module}
      */
-    public Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision) {
-        return this.get().findModuleByNamespaceAndRevision(namespace, revision);
+    public Module findModuleByNamespaceAndRevision(final URI namespace, final Optional<Revision> revision) {
+        return this.get().findModule(namespace, revision).orElse(null);
     }
 
-
     /**
      * Find {@link Module} in {@link SchemaContext} of {@link DOMMountPoint} by
      * {@link QName} of {@link Module}.
@@ -110,7 +111,7 @@ public final class SchemaContextRef {
     public Module findModuleInMountPointByQName(final DOMMountPoint mountPoint, final QName moduleQname) {
         final SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext();
         return schemaContext == null ? null
-                : schemaContext.findModuleByName(moduleQname.getLocalName(), moduleQname.getRevision());
+                : schemaContext.findModule(moduleQname.getLocalName(), moduleQname.getRevision()).orElse(null);
     }
 
     /**
@@ -134,7 +135,7 @@ public final class SchemaContextRef {
      *             revision of module
      * @return {@link Module}
      */
-    public Module findModuleByNameAndRevision(final String localName, final Date revision) {
-        return this.get().findModuleByName(localName, revision);
+    public Module findModuleByNameAndRevision(final String localName, final Optional<Revision> revision) {
+        return this.get().findModule(localName, revision).orElse(null);
     }
 }
index 0e8971ff4cac835b7619d96b3c104b87a59b0197..a8f6b91bb90cb38f92ed95b219378c7d34ced6e4 100644 (file)
@@ -48,6 +48,8 @@ import org.opendaylight.restconf.nb.rfc8040.rests.utils.ReadDataTransactionUtil;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfDataServiceConstant;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.slf4j.Logger;
@@ -161,12 +163,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
                     RestconfError.ErrorTag.DATA_MISSING);
         }
 
-        if ((parameters.getContent().equals(RestconfDataServiceConstant.ReadData.ALL))
+        if (parameters.getContent().equals(RestconfDataServiceConstant.ReadData.ALL)
                     || parameters.getContent().equals(RestconfDataServiceConstant.ReadData.CONFIG)) {
+            final QName type = node.getNodeType();
             return Response.status(200)
                     .entity(new NormalizedNodeContext(instanceIdentifier, node, parameters))
-                    .header("ETag", '"' + node.getNodeType().getModule().getFormattedRevision()
-                        + node.getNodeType().getLocalName() + '"')
+                    .header("ETag", '"' + type.getModule().getRevision().map(Revision::toString).orElse(null)
+                        + type.getLocalName() + '"')
                     .header("Last-Modified", FORMATTER.format(LocalDateTime.now(Clock.systemUTC())))
                     .build();
         }
index fb7ef5c48b9fa011a579dea92d45d72806db5254..b678623fdd3ab7037cf3cceb69460ea375199b8a 100644 (file)
@@ -64,11 +64,11 @@ public final class TransactionVarsWrapper {
     /**
      * Set {@link LogicalDatastoreType} of data for transaction.
      *
-     * @param configuration
+     * @param datastoreType
      *             {@link LogicalDatastoreType}
      */
-    public void setLogicalDatastoreType(final LogicalDatastoreType configuration) {
-        this.configuration = configuration;
+    public void setLogicalDatastoreType(final LogicalDatastoreType datastoreType) {
+        this.configuration = datastoreType;
 
     }
 
index 3986598cffaa8c76e064f66b1c4018eda320ffde..dff93ea258a56879d7d4c9566aa8cfff915a03bf 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.rests.utils;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
index 919446f74b89992b315e35dc06174e5196d5dcdd..853face35e49644123d71eaf3b46ee706d2b66df 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 
-class ParametersUtil {
+final class ParametersUtil {
 
     private ParametersUtil() {
         throw new UnsupportedOperationException("Util class.");
index fe772b2d8f675b42e26db94160b12fcdbfe453fc..1d6d96083b59f967b8cd20202a525710f2c11abd 100644 (file)
@@ -53,6 +53,10 @@ import org.opendaylight.yangtools.yang.model.api.SchemaNode;
  */
 public final class PutDataTransactionUtil {
 
+    private PutDataTransactionUtil() {
+
+    }
+
     /**
      * Valid input data with {@link SchemaNode}.
      *
index 2aa4f0603b815b74c8e59190cffa11398fb466fe..fc55fa764909993f87ad47d49254d721f9e56df7 100644 (file)
@@ -171,9 +171,9 @@ public final class ReadDataTransactionUtil {
         if (!depth.get(0).equals(RestconfDataServiceConstant.ReadData.UNBOUNDED)) {
             final Integer value = Ints.tryParse(depth.get(0));
 
-            if ((value == null)
-                    || (!((value >= RestconfDataServiceConstant.ReadData.MIN_DEPTH)
-                        && (value <= RestconfDataServiceConstant.ReadData.MAX_DEPTH)))) {
+            if (value == null
+                    || !(value >= RestconfDataServiceConstant.ReadData.MIN_DEPTH
+                        && value <= RestconfDataServiceConstant.ReadData.MAX_DEPTH)) {
                 throw new RestconfDocumentedException(
                         new RestconfError(RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
                                 "Invalid depth parameter: " + depth, null,
@@ -347,8 +347,8 @@ public final class ReadDataTransactionUtil {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (keys.contains(child.getNodeType())) {
@@ -356,12 +356,12 @@ public final class ReadDataTransactionUtil {
                     builder.withChild(leafBuilder.build());
                 } else {
                     if (trim) {
-                        if ((defaultVal == null) || !defaultVal.equals(nodeVal)) {
+                        if (defaultVal == null || !defaultVal.equals(nodeVal)) {
                             leafBuilder.withValue(((LeafNode) child).getValue());
                             builder.withChild(leafBuilder.build());
                         }
                     } else {
-                        if ((defaultVal != null) && defaultVal.equals(nodeVal)) {
+                        if (defaultVal != null && defaultVal.equals(nodeVal)) {
                             leafBuilder.withValue(((LeafNode) child).getValue());
                             builder.withChild(leafBuilder.build());
                         }
@@ -402,17 +402,17 @@ public final class ReadDataTransactionUtil {
                         ((ListSchemaNode) childSchema).getKeyDefinition());
                 builder.withChild(childBuilder.build());
             } else if (child instanceof LeafNode) {
-                final String defaultVal = ((LeafSchemaNode) childSchema).getDefault();
-                final String nodeVal = ((LeafNode<String>) child).getValue();
+                final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
+                final Object nodeVal = ((LeafNode<?>) child).getValue();
                 final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
                         Builders.leafBuilder((LeafSchemaNode) childSchema);
                 if (trim) {
-                    if ((defaultVal == null) || !defaultVal.equals(nodeVal)) {
+                    if (defaultVal == null || !defaultVal.equals(nodeVal)) {
                         leafBuilder.withValue(((LeafNode) child).getValue());
                         builder.withChild(leafBuilder.build());
                     }
                 } else {
-                    if ((defaultVal != null) && defaultVal.equals(nodeVal)) {
+                    if (defaultVal != null && defaultVal.equals(nodeVal)) {
                         leafBuilder.withValue(((LeafNode) child).getValue());
                         builder.withChild(leafBuilder.build());
                     }
@@ -473,7 +473,7 @@ public final class ReadDataTransactionUtil {
         }
 
         // if no data exists
-        if ((stateDataNode == null) && (configDataNode == null)) {
+        if (stateDataNode == null && configDataNode == null) {
             return null;
         }
 
index c0acdcb0ca95a13472dc5f5bd52c21a1b88f8b05..8077b5cc002e8cfb44ce53ce29ce9bce4ecfad56 100644 (file)
@@ -8,10 +8,6 @@
 package org.opendaylight.restconf.nb.rfc8040.rests.utils;
 
 import java.net.URI;
-import java.net.URISyntaxException;
-import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 
@@ -21,18 +17,8 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
  */
 public final class RestconfDataServiceConstant {
 
-    public static final QName NETCONF_BASE_QNAME;
-
-    static {
-        try {
-            NETCONF_BASE_QNAME = QName.create(
-                    QNameModule.create(new URI(PutData.NETCONF_BASE), null), PutData.NETCONF_BASE_PAYLOAD_NAME);
-        } catch (final URISyntaxException e) {
-            final String errMsg = "It wasn't possible to create instance of URI class with " + PutData.NETCONF_BASE
-                    + " URI";
-            throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
-        }
-    }
+    public static final QName NETCONF_BASE_QNAME  = QName.create(QNameModule.create(URI.create(PutData.NETCONF_BASE)),
+        PutData.NETCONF_BASE_PAYLOAD_NAME);
 
     private RestconfDataServiceConstant() {
         throw new UnsupportedOperationException("Util class.");
index c76c79d33f71e103e03db29fd02ed6a10f42421a..b5d44cd5ac344e481aea1ca187b91dc8e7a4ddab 100644 (file)
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
  * Util class for rpc.
  *
  */
-public class RestconfInvokeOperationsUtil {
+public final class RestconfInvokeOperationsUtil {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestconfInvokeOperationsUtil.class);
 
@@ -102,7 +102,7 @@ public class RestconfInvokeOperationsUtil {
         } catch (final CancellationException e) {
             final String errMsg = "The operation was cancelled while executing.";
             LOG.debug("Cancel RpcExecution: " + errMsg, e);
-            throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION);
+            throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
         }
     }
 
index c68cb49c8bfd8219cbb3758e9ead4813dada5603..7f17200664e6ad6f067e6449dede2a09d6892a06 100644 (file)
@@ -9,50 +9,28 @@ package org.opendaylight.restconf.nb.rfc8040.rests.utils;
 
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
-import java.text.ParseException;
-import java.util.Date;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Constants for streams.
  *
  */
 public final class RestconfStreamsConstants {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RestconfStreamsConstants.class);
-
     public static final String SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote";
 
     public static final String DATASTORE_PARAM_NAME = "datastore";
 
     private static final URI NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT = URI.create("urn:sal:restconf:event:subscription");
 
-    public static final QNameModule SAL_REMOTE_AUGMENT;
-
-    static {
-        final Date eventSubscriptionAugRevision;
-        try {
-            eventSubscriptionAugRevision = SimpleDateFormatUtil.getRevisionFormat().parse("2014-07-08");
-        } catch (final ParseException e) {
-            final String errMsg = "It wasn't possible to convert revision date of sal-remote-augment to date";
-            LOG.debug(errMsg);
-            throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
-        }
-        SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT, eventSubscriptionAugRevision)
-                .intern();
-    }
+    public static final QNameModule SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT,
+        Revision.of("2014-07-08")).intern();
 
     public static final AugmentationIdentifier SAL_REMOTE_AUG_IDENTIFIER = new AugmentationIdentifier(
         ImmutableSet.of(QName.create(SAL_REMOTE_AUGMENT, "scope"), QName.create(SAL_REMOTE_AUGMENT, "datastore"),
index b7430c674a58b42acc6de0223b4fd97d74c3144f..f6b685ac0689bf86f2031d548c9c47826ab67d80 100644 (file)
@@ -113,7 +113,7 @@ public final class SubscribeToStreamUtil {
         } else {
             listeners = pickSpecificListenerByOutput(listeners, NotificationOutputType.XML.getName());
         }
-        if ((listeners == null) || listeners.isEmpty()) {
+        if (listeners == null || listeners.isEmpty()) {
             throw new RestconfDocumentedException("Stream was not found.", ErrorType.PROTOCOL,
                     ErrorTag.UNKNOWN_ELEMENT);
         }
@@ -163,7 +163,7 @@ public final class SubscribeToStreamUtil {
     public static InstanceIdentifierContext<?> prepareIIDSubsStreamOutput(final SchemaContextHandler schemaHandler) {
         final QName qnameBase = QName.create("subscribe:to:notification", "2016-10-28", "notifi");
         final DataSchemaNode location = ((ContainerSchemaNode) schemaHandler.get()
-                .findModuleByNamespaceAndRevision(qnameBase.getNamespace(), qnameBase.getRevision())
+                .findModule(qnameBase.getModule()).get()
                 .getDataChildByName(qnameBase)).getDataChildByName(QName.create(qnameBase, "location"));
         final List<PathArgument> path = new ArrayList<>();
         path.add(NodeIdentifier.create(qnameBase));
@@ -238,9 +238,7 @@ public final class SubscribeToStreamUtil {
     }
 
     public static Module getMonitoringModule(final SchemaContext schemaContext) {
-        final Module monitoringModule =
-                schemaContext.findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
-        return monitoringModule;
+        return schemaContext.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
     }
 
     /**
@@ -389,7 +387,7 @@ public final class SubscribeToStreamUtil {
      * @return enum
      */
     private static <T> T parseURIEnum(final Class<T> clazz, final String value) {
-        if ((value == null) || value.equals("")) {
+        if (value == null || value.equals("")) {
             return null;
         }
         return ResolveEnumUtil.resolveEnum(clazz, value);
index 8604f575685a53549ab2400d8d4946432b67041d..db1641618a11129b7c26aa2c0b2c619df1a9010a 100644 (file)
@@ -11,15 +11,19 @@ import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -57,10 +61,10 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
         for (final DataSchemaNode node : this.children) {
             if (node.getQName().equals(name)) {
-                return node;
+                return Optional.of(node);
             }
         }
         throw new RestconfDocumentedException(name + " is not in child of " + PATH.getLastComponent());
@@ -72,7 +76,7 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public Set<AugmentationSchema> getAvailableAugmentations() {
+    public Set<AugmentationSchemaNode> getAvailableAugmentations() {
         return new HashSet<>();
     }
 
@@ -91,11 +95,6 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
         return false;
     }
 
-    @Override
-    public ConstraintDefinition getConstraints() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
     @Override
     public QName getQName() {
         return PATH.getLastComponent();
@@ -112,12 +111,12 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
@@ -130,4 +129,24 @@ class FakeContainerSchemaNode implements ContainerSchemaNode {
     public boolean isPresenceContainer() {
         throw new UnsupportedOperationException("Not supported.");
     }
+
+    @Override
+    public Optional<RevisionAwareXPath> getWhenCondition() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Set<ActionDefinition> getActions() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public Collection<MustDefinition> getMustConstraints() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
 }
index 5bcab1ac523d8594edca3321bc497c4ff665b22f..3d7feae3fd3e104954223de720ebe310fb6920d8 100644 (file)
@@ -13,12 +13,15 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangVersion;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
@@ -27,6 +30,7 @@ import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -61,8 +65,8 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
-        return null;
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
+        return Optional.empty();
     }
 
     @Override
@@ -70,11 +74,6 @@ final class FakeImportedModule extends ForwardingObject implements Module {
         return ImmutableSet.of();
     }
 
-    @Override
-    public String getModuleSourcePath() {
-        return null;
-    }
-
     @Override
     public QNameModule getQNameModule() {
         return delegate.getQNameModule();
@@ -91,7 +90,7 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return delegate.getRevision();
     }
 
@@ -101,27 +100,27 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public String getYangVersion() {
+    public YangVersion getYangVersion() {
         return delegate.getYangVersion();
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return delegate.getDescription();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return delegate.getReference();
     }
 
     @Override
-    public String getOrganization() {
+    public Optional<String> getOrganization() {
         return delegate.getOrganization();
     }
 
     @Override
-    public String getContact() {
+    public Optional<String> getContact() {
         return delegate.getContact();
     }
 
@@ -141,7 +140,7 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public Set<AugmentationSchema> getAugmentations() {
+    public Set<AugmentationSchemaNode> getAugmentations() {
         return ImmutableSet.of();
     }
 
@@ -171,7 +170,12 @@ final class FakeImportedModule extends ForwardingObject implements Module {
     }
 
     @Override
-    public String getSource() {
-        return null;
+    public Set<NotificationDefinition> getNotifications() {
+        return ImmutableSet.of();
+    }
+
+    @Override
+    public Optional<SemVer> getSemanticVersion() {
+        return Optional.empty();
     }
 }
index 053fd334cd0fdce40f021eed0a6c71d4aa8e6b63..e758342ac45d6c3cbe1fe573c847fc1861f30c3c 100644 (file)
@@ -7,10 +7,14 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
 
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -51,11 +55,6 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
         return false;
     }
 
-    @Override
-    public ConstraintDefinition getConstraints() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
     @Override
     public QName getQName() {
         return path.getLastComponent();
@@ -72,12 +71,12 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
@@ -92,13 +91,17 @@ final class FakeLeafSchemaNode implements LeafSchemaNode {
     }
 
     @Override
-    public String getDefault() {
-        throw new UnsupportedOperationException("Not supported.");
+    public Optional<RevisionAwareXPath> getWhenCondition() {
+        return Optional.empty();
     }
 
     @Override
-    public String getUnits() {
+    public boolean isMandatory() {
         throw new UnsupportedOperationException("Not supported.");
     }
 
+    @Override
+    public Collection<MustDefinition> getMustConstraints() {
+        return ImmutableList.of();
+    }
 }
index 8ce1b391c80fb9cf6b15dbc9c9401dda86d4551d..eff7662440ded76304de46d942d53db63069a086 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
 
 import com.google.common.base.Preconditions;
-import java.util.Date;
+import java.util.Optional;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
@@ -30,7 +32,7 @@ final class FakeModuleImport implements ModuleImport {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return module.getRevision();
     }
 
@@ -38,4 +40,19 @@ final class FakeModuleImport implements ModuleImport {
     public String getPrefix() {
         return module.getName();
     }
+
+    @Override
+    public Optional<String> getDescription() {
+        return module.getDescription();
+    }
+
+    @Override
+    public Optional<String> getReference() {
+        return module.getReference();
+    }
+
+    @Override
+    public Optional<SemVer> getSemanticVersion() {
+        return module.getSemanticVersion();
+    }
 }
index 73ed2757674a901204805815f1df450c423b6b1c..8dcc91c214ed52e1ee36aebc1074db150a276b68 100644 (file)
@@ -11,17 +11,17 @@ import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
@@ -44,17 +44,8 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
  */
 final class FakeRestconfModule implements Module {
 
-    static final QNameModule QNAME;
-
-    static {
-        Date date;
-        try {
-            date = SimpleDateFormatUtil.getRevisionFormat().parse("2016-06-28");
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-        QNAME = QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"), date).intern();
-    }
+    static final QNameModule QNAME = QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"),
+        Revision.of("2016-06-28")).intern();
 
     private final Collection<DataSchemaNode> children;
     private final ImmutableSet<ModuleImport> imports;
@@ -86,10 +77,10 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public DataSchemaNode getDataChildByName(final QName name) {
+    public Optional<DataSchemaNode> findDataChildByName(final QName name) {
         for (final DataSchemaNode node : this.children) {
             if (node.getQName().equals(name)) {
-                return node;
+                return Optional.of(node);
             }
         }
         throw new RestconfDocumentedException(name + " is not in child of " + FakeRestconfModule.QNAME);
@@ -100,11 +91,6 @@ final class FakeRestconfModule implements Module {
         throw new UnsupportedOperationException("Not supported operations.");
     }
 
-    @Override
-    public String getModuleSourcePath() {
-        throw new UnsupportedOperationException("Not supported operations.");
-    }
-
     @Override
     public QNameModule getQNameModule() {
         return QNAME;
@@ -121,7 +107,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public Date getRevision() {
+    public Optional<Revision> getRevision() {
         return QNAME.getRevision();
     }
 
@@ -131,27 +117,27 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public String getYangVersion() {
-        return YangVersion.VERSION_1.toString();
+    public YangVersion getYangVersion() {
+        return YangVersion.VERSION_1;
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 
     @Override
-    public String getOrganization() {
+    public Optional<String> getOrganization() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 
     @Override
-    public String getContact() {
+    public Optional<String> getContact() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 
@@ -176,7 +162,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public Set<AugmentationSchema> getAugmentations() {
+    public Set<AugmentationSchemaNode> getAugmentations() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 
@@ -206,7 +192,7 @@ final class FakeRestconfModule implements Module {
     }
 
     @Override
-    public String getSource() {
+    public Optional<SemVer> getSemanticVersion() {
         throw new UnsupportedOperationException("Operation not implemented.");
     }
 }
index 386c991ad387e6ecd34e11fb2104a4b68ad8cff7..bd0942072736c55a82f2833205403c92d4ce46b1 100644 (file)
@@ -36,7 +36,7 @@ public class RestconfImpl implements RestconfService {
         final SchemaContext context = this.schemaContextHandler.get();
         SchemaNode schemaNode = null;
         for (final GroupingDefinition groupingDefinition : context
-                .findModuleByNamespaceAndRevision(RestconfModule.URI_MODULE, RestconfModule.DATE).getGroupings()) {
+                .findModule(RestconfModule.IETF_RESTCONF_QNAME.getModule()).get().getGroupings()) {
             if (groupingDefinition.getQName().equals(RestconfModule.RESTCONF_GROUPING_QNAME)) {
                 schemaNode = ((ContainerSchemaNode) groupingDefinition
                         .getDataChildByName(RestconfModule.RESTCONF_CONTAINER_QNAME))
@@ -44,9 +44,9 @@ public class RestconfImpl implements RestconfService {
             }
         }
         final YangInstanceIdentifier yangIId = YangInstanceIdentifier.of(
-                QName.create(RestconfModule.NAME, RestconfModule.REVISION, RestconfModule.LIB_VER_LEAF_SCHEMA_NODE));
+                QName.create(RestconfModule.IETF_RESTCONF_QNAME, RestconfModule.LIB_VER_LEAF_SCHEMA_NODE));
         final InstanceIdentifierContext<? extends SchemaNode> iid =
-                new InstanceIdentifierContext<SchemaNode>(yangIId, schemaNode, null, context);
+                new InstanceIdentifierContext<>(yangIId, schemaNode, null, context);
         final NormalizedNode<?, ?> data =
                 Builders.leafBuilder((LeafSchemaNode) schemaNode).withValue(IetfYangLibrary.REVISION).build();
         return new NormalizedNodeContext(iid, data);
index 93c99146c49bf1a43ef030ad5b7b8b01342677ea..d51a6347576670520520ca2d70cc5d0398fdfdb3 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfOperationsService;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
@@ -132,7 +133,7 @@ public class RestconfOperationsServiceImpl implements RestconfOperationsService
                 Builders.containerBuilder(fakeCont);
 
         for (final LeafSchemaNode leaf : fakeRpcSchema) {
-            containerBuilder.withChild(Builders.leafBuilder(leaf).build());
+            containerBuilder.withChild(Builders.leafBuilder(leaf).withValue(Empty.getInstance()).build());
         }
 
         final Collection<Module> fakeModules = new ArrayList<>(neededModules.size() + 1);
index 269900231d4847b5dd6d808f2a7c11dd44cd4856..2f1358bfb000627849407d49c696b1ca5471e5e5 100644 (file)
@@ -46,7 +46,7 @@ import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfSchemaS
  *
  */
 @Path("/")
-public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper {
+public final class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper {
 
     private RestconfDataService delegRestconfDataService;
     private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
index 768309fb17a5f5476ac50bb0a9b96b21a44ab1b7..598d4b15cf622e35bf5182074e895f11dbf935a5 100644 (file)
@@ -66,6 +66,7 @@ abstract class AbstractNotificationsData {
      *            {@link MonitoringModule#PATH_TO_STREAM_WITHOUT_KEY} to
      *            {@link YangInstanceIdentifier}
      */
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setCloseVars(final TransactionChainHandler transactionChainHandler,
             final SchemaContextHandler schemaHandler) {
         this.transactionChainHandler = transactionChainHandler;
@@ -88,6 +89,7 @@ abstract class AbstractNotificationsData {
      * @param localName
      *            local name
      */
+    @SuppressWarnings("checkstyle:hiddenField")
     protected void setLocalNameOfPath(final String localName) {
         this.localName = localName;
     }
index e9a412d1f34dc811e475e7113755c402a4d2459e..93dfc8030990af082e91f00a9204773165d41b85 100644 (file)
@@ -71,6 +71,7 @@ abstract class AbstractQueryParams extends AbstractNotificationsData {
      * @param leafNodesOnly
      *            if true, notifications will contain changes to leaf nodes only
      */
+    @SuppressWarnings("checkstyle:hiddenField")
     public void setQueryParams(final Instant start, final Optional<Instant> stop, final Optional<String> filter,
                                final boolean leafNodesOnly) {
         this.start = Preconditions.checkNotNull(start);
index 7e2d89b6ffd8056a8eddc4e8e63312828d2934b4..815f4b413e46ceac7b92fdaaff6ecfdd53f4f003 100644 (file)
@@ -71,11 +71,12 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
 
         this.outputType = Preconditions.checkNotNull(outputType);
         this.path = Preconditions.checkNotNull(path);
-        Preconditions.checkArgument((streamName != null) && !streamName.isEmpty());
+        Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
         this.streamName = streamName;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void onDataChanged(final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
         this.change = change;
         final String xml = prepareXml();
@@ -163,6 +164,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
      * @param change
      *            {@link AsyncDataChangeEvent}
      */
+    @SuppressWarnings("checkstyle:hiddenField")
     private void addValuesToDataChangedNotificationEventElement(final Document doc,
             final Element dataChangedNotificationEventElement,
             final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change,
@@ -197,12 +199,12 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
     private void addValuesFromDataToElement(final Document doc, final Set<YangInstanceIdentifier> data,
             final Element element, final Operation operation, final SchemaContext schemaContext,
             final DataSchemaContextTree dataSchemaContextTree) {
-        if ((data == null) || data.isEmpty()) {
+        if (data == null || data.isEmpty()) {
             return;
         }
-        for (final YangInstanceIdentifier path : data) {
-            if (!dataSchemaContextTree.getChild(path).isMixin()) {
-                final Node node = createDataChangeEventElement(doc, path, operation, schemaContext);
+        for (final YangInstanceIdentifier yiid : data) {
+            if (!dataSchemaContextTree.getChild(yiid).isMixin()) {
+                final Node node = createDataChangeEventElement(doc, yiid, operation, schemaContext);
                 element.appendChild(node);
             }
         }
@@ -212,7 +214,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
             final Set<Entry<YangInstanceIdentifier, NormalizedNode<?, ?>>> data, final Element element,
             final Operation operation, final SchemaContext schemaContext,
             final DataSchemaContextTree dataSchemaContextTree) {
-        if ((data == null) || data.isEmpty()) {
+        if (data == null || data.isEmpty()) {
             return;
         }
         for (final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry : data) {
@@ -238,11 +240,11 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
      *            schema context
      * @return {@link Node} node represented by changed event element.
      */
-    private Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier path,
+    private Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier eventPath,
             final Operation operation, final SchemaContext schemaContext) {
         final Element dataChangeEventElement = doc.createElement("data-change-event");
         final Element pathElement = doc.createElement("path");
-        addPathAsValueToElement(path, pathElement, schemaContext);
+        addPathAsValueToElement(eventPath, pathElement, schemaContext);
         dataChangeEventElement.appendChild(pathElement);
 
         final Element operationElement = doc.createElement("operation");
@@ -257,8 +259,8 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
             final SchemaContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) {
         final Element dataChangeEventElement = doc.createElement("data-change-event");
         final Element pathElement = doc.createElement("path");
-        final YangInstanceIdentifier path = entry.getKey();
-        addPathAsValueToElement(path, pathElement, schemaContext);
+        final YangInstanceIdentifier eventPath = entry.getKey();
+        addPathAsValueToElement(eventPath, pathElement, schemaContext);
         dataChangeEventElement.appendChild(pathElement);
 
         final Element operationElement = doc.createElement("operation");
@@ -268,10 +270,10 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
         try {
             SchemaPath nodePath;
             final NormalizedNode<?, ?> normalized = entry.getValue();
-            if ((normalized instanceof MapEntryNode) || (normalized instanceof UnkeyedListEntryNode)) {
-                nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath();
+            if (normalized instanceof MapEntryNode || normalized instanceof UnkeyedListEntryNode) {
+                nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath();
             } else {
-                nodePath = dataSchemaContextTree.getChild(path).getDataSchemaNode().getPath().getParent();
+                nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath().getParent();
             }
             final DOMResult domResult = writeNormalizedNode(normalized, schemaContext, nodePath);
             final Node result = doc.importNode(domResult.getNode().getFirstChild(), true);
@@ -290,7 +292,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
     /**
      * Adds path as value to element.
      *
-     * @param path
+     * @param eventPath
      *            Path to data in data store.
      * @param element
      *            {@link Element}
@@ -298,11 +300,11 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
      *            schema context
      */
     @SuppressWarnings("rawtypes")
-    private void addPathAsValueToElement(final YangInstanceIdentifier path, final Element element,
+    private void addPathAsValueToElement(final YangInstanceIdentifier eventPath, final Element element,
             final SchemaContext schemaContext) {
         final StringBuilder textContent = new StringBuilder();
 
-        for (final PathArgument pathArgument : path.getPathArguments()) {
+        for (final PathArgument pathArgument : eventPath.getPathArguments()) {
             if (pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier) {
                 continue;
             }
@@ -343,8 +345,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
      */
     private static void writeIdentifierWithNamespacePrefix(final Element element, final StringBuilder textContent,
             final QName qualifiedName, final SchemaContext schemaContext) {
-        final Module module = schemaContext.findModuleByNamespaceAndRevision(qualifiedName.getNamespace(),
-                qualifiedName.getRevision());
+        final Module module = schemaContext.findModule(qualifiedName.getModule()).get();
 
         textContent.append(module.getName());
         textContent.append(":");
index 33e08d2e2f145722fdc95345f6f6303debfa854f..a7b573038bd2626067e826ff42aa9287c7d13882 100644 (file)
@@ -85,6 +85,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
     }
 
     @Override
+    @SuppressWarnings("checkstyle:hiddenField")
     public void onNotification(final DOMNotification notification) {
         this.schemaContext = schemaHandler.get();
         this.notification = notification;
@@ -174,14 +175,13 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
 
         final Element notificationEventElement = doc.createElementNS(
                 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "create-notification-stream");
-        addValuesToNotificationEventElement(doc, notificationEventElement, this.notification, this.schemaContext);
+        addValuesToNotificationEventElement(doc, notificationEventElement);
         notificationElement.appendChild(notificationEventElement);
 
         return transformDoc(doc);
     }
 
-    private void addValuesToNotificationEventElement(final Document doc, final Element element,
-            final DOMNotification notification, final SchemaContext schemaContext) {
+    private void addValuesToNotificationEventElement(final Document doc, final Element element) {
         if (notification == null) {
             return;
         }
index cd4c74ad183c9b26f5545d1e77d0f2450ac5c12e..d26fca4ed230b51755ab87dbdc6d95000ab894ad 100644 (file)
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
  * {@link Notificator} is responsible to create, remove and find
  * {@link ListenerAdapter} listener.
  */
-public class Notificator {
+public final class Notificator {
 
     private static Map<String, ListenerAdapter> dataChangeListener = new ConcurrentHashMap<>();
     private static Map<String, List<NotificationListenerAdapter>> notificationListenersByStreamName =
index b497f74a76e9c3eb20083e49105e8e144a4ad689..029cb27f78672c465cf247520b800d8a306d0953 100644 (file)
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
  * {@link WebSocketServer} is the singleton responsible for starting and stopping the
  * web socket server.
  */
-public class WebSocketServer implements Runnable {
+public final class WebSocketServer implements Runnable {
 
     private static final Logger LOG = LoggerFactory.getLogger(WebSocketServer.class);
 
index 4f645edf9a842467852259dbbacca93946f79905..b0eb474b0a28aedc82e255e5c9a9f33b344ab2e5 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule.QueryParams
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module.ConformanceType;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -119,19 +120,20 @@ public final class RestconfMappingNodeUtil {
         addCommonLeafs(module, mapEntryBuilder, ietfYangLibraryModule);
         addChildOfModuleBySpecificModuleInternal(
                 IetfYangLibrary.SPECIFIC_MODULE_SCHEMA_LEAF_QNAME, mapEntryBuilder, IetfYangLibrary.BASE_URI_OF_SCHEMA
-                        + module.getName() + "/" + module.getQNameModule().getFormattedRevision(),
+                        + module.getName() + "/"
+                        + module.getQNameModule().getRevision().map(Revision::toString).orElse(null),
                 ietfYangLibraryModule);
         if (!isSubmodule) {
             addChildOfModuleBySpecificModuleOfListChild(IetfYangLibrary.SPECIFIC_MODULE_NAMESPACE_LEAF_QNAME,
                     mapEntryBuilder, module.getNamespace().toString(), ietfYangLibraryModule);
 
             // features - not mandatory
-            if ((module.getFeatures() != null) && !module.getFeatures().isEmpty()) {
+            if (module.getFeatures() != null && !module.getFeatures().isEmpty()) {
                 addFeatureLeafList(IetfYangLibrary.SPECIFIC_MODULE_FEATURE_LEAF_LIST_QNAME, mapEntryBuilder,
                         module.getFeatures(), ietfYangLibraryModule);
             }
             // deviations - not mandatory
-            if ((module.getDeviations() != null) && !module.getDeviations().isEmpty()) {
+            if (module.getDeviations() != null && !module.getDeviations().isEmpty()) {
                 addDeviationList(module, mapEntryBuilder, ietfYangLibraryModule, context);
                 addChildOfModuleBySpecificModuleOfListChild(IetfYangLibrary.SPECIFIC_MODULE_CONFORMANCE_LEAF_QNAME,
                         mapEntryBuilder, ConformanceType.Implement.getName(), ietfYangLibraryModule);
@@ -140,7 +142,7 @@ public final class RestconfMappingNodeUtil {
                         mapEntryBuilder, ConformanceType.Import.getName(), ietfYangLibraryModule);
             }
             // submodules - not mandatory
-            if ((module.getSubmodules() != null) && !module.getSubmodules().isEmpty()) {
+            if (module.getSubmodules() != null && !module.getSubmodules().isEmpty()) {
                 addSubmodules(module, mapEntryBuilder, ietfYangLibraryModule, context);
             }
         }
@@ -196,8 +198,7 @@ public final class RestconfMappingNodeUtil {
                     Builders.mapEntryBuilder((ListSchemaNode) deviationsSchema);
             final QName lastComponent = deviation.getTargetPath().getLastComponent();
             addChildOfModuleBySpecificModule(IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF_QNAME, deviationEntryNode,
-                    context.findModuleByNamespaceAndRevision(lastComponent.getNamespace(), lastComponent.getRevision())
-                            .getName(),
+                    context.findModule(lastComponent.getModule()).get().getName(),
                     ietfYangLibraryModule);
             addChildOfModuleBySpecificModule(IetfYangLibrary.SPECIFIC_MODULE_REVISION_LEAF_QNAME, deviationEntryNode,
                     lastComponent.getRevision(), ietfYangLibraryModule);
@@ -249,7 +250,7 @@ public final class RestconfMappingNodeUtil {
         addChildOfModuleBySpecificModuleInternal(IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF_QNAME, mapEntryBuilder,
                 module.getName(), ietfYangLibraryModule);
         addChildOfModuleBySpecificModuleInternal(IetfYangLibrary.SPECIFIC_MODULE_REVISION_LEAF_QNAME, mapEntryBuilder,
-                module.getQNameModule().getFormattedRevision(), ietfYangLibraryModule);
+                module.getQNameModule().getRevision().map(Revision::toString).orElse(""), ietfYangLibraryModule);
     }
 
     /**
@@ -486,15 +487,15 @@ public final class RestconfMappingNodeUtil {
                 final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamEntry =
                         Builders.mapEntryBuilder((ListSchemaNode) streamListSchema);
 
-                final ListSchemaNode listSchema = ((ListSchemaNode) streamListSchema);
+                final ListSchemaNode listSchema = (ListSchemaNode) streamListSchema;
                 prepareLeafAndFillEntryBuilder(streamEntry,
                         listSchema.getDataChildByName(MonitoringModule.LEAF_NAME_STREAM_QNAME),
                         notificationDefinition.getQName().getLocalName());
-                if ((notificationDefinition.getDescription() != null)
-                        && !notificationDefinition.getDescription().equals("")) {
+
+                final java.util.Optional<String> optDesc = notificationDefinition.getDescription();
+                if (optDesc.isPresent()) {
                     prepareLeafAndFillEntryBuilder(streamEntry,
-                            listSchema.getDataChildByName(MonitoringModule.LEAF_DESCR_STREAM_QNAME),
-                            notificationDefinition.getDescription());
+                            listSchema.getDataChildByName(MonitoringModule.LEAF_DESCR_STREAM_QNAME), optDesc.get());
                 }
                 prepareLeafAndFillEntryBuilder(streamEntry,
                         listSchema.getDataChildByName(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME), true);
@@ -589,14 +590,15 @@ public final class RestconfMappingNodeUtil {
         final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamEntry =
                 Builders.mapEntryBuilder((ListSchemaNode) streamListSchema);
 
-        final ListSchemaNode listSchema = ((ListSchemaNode) streamListSchema);
+        final ListSchemaNode listSchema = (ListSchemaNode) streamListSchema;
         prepareLeafAndFillEntryBuilder(streamEntry,
                 listSchema.getDataChildByName(MonitoringModule.LEAF_NAME_STREAM_QNAME),
                 schemaNode.getQName().getLocalName());
-        if ((schemaNode.getDescription() != null) && !schemaNode.getDescription().equals("")) {
+
+        final java.util.Optional<String> optDesc = schemaNode.getDescription();
+        if (optDesc.isPresent()) {
             prepareLeafAndFillEntryBuilder(streamEntry,
-                    listSchema.getDataChildByName(MonitoringModule.LEAF_DESCR_STREAM_QNAME),
-                    schemaNode.getDescription());
+                    listSchema.getDataChildByName(MonitoringModule.LEAF_DESCR_STREAM_QNAME), optDesc.get());
         }
         prepareLeafAndFillEntryBuilder(streamEntry,
                 listSchema.getDataChildByName(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME), true);
index 0ed8a485b0f2fd6bb115a72e72cadc3aec7bfd5e..ffe010cb19267421f9a1f3375117d12c6790362a 100644 (file)
@@ -25,13 +25,17 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class ParserFieldsParameter {
+public final class ParserFieldsParameter {
     private static final char COLON = ':';
     private static final char SEMICOLON = ';';
     private static final char SLASH = '/';
     private static final char STARTING_PARENTHESIS = '(';
     private static final char CLOSING_PARENTHESIS = ')';
 
+    private ParserFieldsParameter() {
+
+    }
+
     /**
      * Parse fields parameter and return complete list of child nodes organized into levels.
      * @param identifier identifier context created from request URI
@@ -102,8 +106,8 @@ public class ParserFieldsParameter {
             switch (currentChar) {
                 case COLON :
                     // new namespace and revision found
-                    currentQNameModule = context.findModuleByName(
-                            input.substring(startPosition, currentPosition), null).getQNameModule();
+                    currentQNameModule = context.findModules(
+                            input.substring(startPosition, currentPosition)).iterator().next().getQNameModule();
                     currentPosition++;
                     break;
                 case STARTING_PARENTHESIS:
@@ -180,10 +184,7 @@ public class ParserFieldsParameter {
             @Nonnull final String identifier,
             @Nonnull final QNameModule currentQNameModule,
             @Nonnull final Set<QName> level) {
-        final QName childQName = QName.create(
-                currentQNameModule.getNamespace().toString(),
-                identifier,
-                currentQNameModule.getRevision());
+        final QName childQName = QName.create(currentQNameModule, identifier);
 
         // resolve parent node
         final DataSchemaContextNode<?> parentNode = resolveMixinNode(
index 0df51eacd3b65b7e0371c56a6208f3e769d5bebe..b5438ff866be2e878739c6a12aebb74b82bbe083 100644 (file)
@@ -10,10 +10,12 @@ package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 import com.google.common.base.Optional;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
-import java.text.ParseException;
+import java.time.format.DateTimeParseException;
+import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map.Entry;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
@@ -25,7 +27,7 @@ import org.opendaylight.restconf.common.schema.SchemaExportContext;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.validations.RestconfValidation;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
@@ -104,7 +106,7 @@ public final class ParserIdentifier {
             final QName rpcQName = pathYangInstanceIdentifier.getLastPathArgument().getNodeType();
             RpcDefinition def = null;
             for (final RpcDefinition rpcDefinition : mountSchemaContext
-                    .findModuleByNamespaceAndRevision(rpcQName.getNamespace(), rpcQName.getRevision()).getRpcs()) {
+                    .findModule(rpcQName.getModule()).get().getRpcs()) {
                 if (rpcDefinition.getQName().getLocalName().equals(rpcQName.getLocalName())) {
                     def = rpcDefinition;
                     break;
@@ -121,9 +123,7 @@ public final class ParserIdentifier {
             }
             final QName rpcQName = deserialize.getLastPathArgument().getNodeType();
             RpcDefinition def = null;
-            for (final RpcDefinition rpcDefinition
-                    : schemaContext.findModuleByNamespaceAndRevision(rpcQName.getNamespace(),
-                        rpcQName.getRevision()).getRpcs()) {
+            for (final RpcDefinition rpcDefinition : schemaContext.findModule(rpcQName.getModule()).get().getRpcs()) {
                 if (rpcDefinition.getQName().getLocalName().equals(rpcQName.getLocalName())) {
                     def = rpcDefinition;
                     break;
@@ -146,13 +146,13 @@ public final class ParserIdentifier {
     }
 
     /**
-     * Make a {@link QName} from identifier.
+     * Make a moduleName/Revision pair from identifier.
      *
      * @param identifier
      *             path parameter
      * @return {@link QName}
      */
-    public static QName makeQNameFromIdentifier(final String identifier) {
+    public static Entry<String, Revision> makeQNameFromIdentifier(final String identifier) {
         // check if more than one slash is not used as path separator
         if (identifier.contains(
                 String.valueOf(RestconfConstants.SLASH).concat(String.valueOf(RestconfConstants.SLASH)))) {
@@ -179,16 +179,16 @@ public final class ParserIdentifier {
                     ErrorTag.INVALID_VALUE);
         }
 
-        final Date moduleRevision;
+        final Revision moduleRevision;
         try {
-            moduleRevision = SimpleDateFormatUtil.getRevisionFormat().parse(pathArgs.get(1));
-        } catch (final ParseException e) {
+            moduleRevision = Revision.of(pathArgs.get(1));
+        } catch (final DateTimeParseException e) {
             LOG.debug("URI has bad format: '{}'. It should be 'moduleName/yyyy-MM-dd'", identifier);
             throw new RestconfDocumentedException("URI has bad format. It should be \'moduleName/yyyy-MM-dd\'",
-                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, e);
         }
 
-        return QName.create(null, moduleRevision, pathArgs.get(0));
+        return new SimpleImmutableEntry<>(pathArgs.get(0), moduleRevision);
     }
 
     /**
@@ -211,9 +211,8 @@ public final class ParserIdentifier {
         final Iterator<String> componentIter = pathComponents.iterator();
         if (!Iterables.contains(pathComponents, RestconfConstants.MOUNT)) {
             final String moduleName = RestconfValidation.validateAndGetModulName(componentIter);
-            final Date revision = RestconfValidation.validateAndGetRevision(componentIter);
-            final Module module = schemaContext.findModuleByName(moduleName, revision);
-
+            final Revision revision = RestconfValidation.validateAndGetRevision(componentIter);
+            final Module module = schemaContext.findModule(moduleName, revision).orElse(null);
             return new SchemaExportContext(schemaContext, module, sourceProvider);
         } else {
             final StringBuilder pathBuilder = new StringBuilder();
@@ -235,8 +234,9 @@ public final class ParserIdentifier {
             final InstanceIdentifierContext<?> point = ParserIdentifier
                     .toInstanceIdentifier(pathBuilder.toString(), schemaContext, Optional.of(domMountPointService));
             final String moduleName = RestconfValidation.validateAndGetModulName(componentIter);
-            final Date revision = RestconfValidation.validateAndGetRevision(componentIter);
-            final Module module = point.getMountPoint().getSchemaContext().findModuleByName(moduleName, revision);
+            final Revision revision = RestconfValidation.validateAndGetRevision(componentIter);
+            final Module module = point.getMountPoint().getSchemaContext().findModule(moduleName, revision)
+                    .orElse(null);
             return new SchemaExportContext(point.getMountPoint().getSchemaContext(), module, sourceProvider);
         }
     }
index 5c1bbf37b08b9c73e8b82d020b4d3513ff176181..7136efbe1785ba151276891c6fd1b86face3e16a 100644 (file)
@@ -75,7 +75,7 @@ public final class YangInstanceIdentifierDeserializer {
 
             // this is the last identifier (input is consumed) or end of identifier (slash)
             if (allCharsConsumed(variables)
-                    || (currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH)) {
+                    || currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH) {
                 prepareIdentifier(qname, path, variables);
                 if (variables.getCurrent() == null) {
                     path.add(NodeIdentifier.create(qname));
@@ -103,7 +103,7 @@ public final class YangInstanceIdentifierDeserializer {
                                                   final MainVarsWrapper variables) {
 
         final DataSchemaNode dataSchemaNode = variables.getCurrent().getDataSchemaNode();
-        checkValid((dataSchemaNode != null), "Data schema node is null", variables.getData(), variables.getOffset());
+        checkValid(dataSchemaNode != null, "Data schema node is null", variables.getData(), variables.getOffset());
 
         final Iterator<QName> keys = ((ListSchemaNode) dataSchemaNode).getKeyDefinition().iterator();
         final ImmutableMap.Builder<QName, Object> values = ImmutableMap.builder();
@@ -112,8 +112,8 @@ public final class YangInstanceIdentifierDeserializer {
         skipCurrentChar(variables);
 
         // read key value separated by comma
-        while (keys.hasNext() && !allCharsConsumed(variables) && (currentChar(variables.getOffset(),
-                variables.getData()) != RestconfConstants.SLASH)) {
+        while (keys.hasNext() && !allCharsConsumed(variables) && currentChar(variables.getOffset(),
+                variables.getData()) != RestconfConstants.SLASH) {
 
             // empty key value
             if (currentChar(variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA) {
@@ -146,8 +146,8 @@ public final class YangInstanceIdentifierDeserializer {
 
 
             // skip comma
-            if (keys.hasNext() && !allCharsConsumed(variables) && (currentChar(
-                    variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA)) {
+            if (keys.hasNext() && !allCharsConsumed(variables) && currentChar(
+                    variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA) {
                 skipCurrentChar(variables);
             }
         }
@@ -155,7 +155,7 @@ public final class YangInstanceIdentifierDeserializer {
         // the last key is considered to be empty
         if (keys.hasNext()) {
             if (allCharsConsumed(variables)
-                    || (currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH)) {
+                    || currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH) {
                 values.put(keys.next(), ParserBuilderConstants.Deserializer.EMPTY_STRING);
             }
 
@@ -189,7 +189,7 @@ public final class YangInstanceIdentifierDeserializer {
         final Codec<Object, Object> codec = RestCodec.from(typedef, null, vars.getSchemaContext());
         decoded = codec.deserialize(value);
         if (decoded == null) {
-            if ((baseType instanceof IdentityrefTypeDefinition)) {
+            if (baseType instanceof IdentityrefTypeDefinition) {
                 decoded = toQName(value, schemaNode, vars.getSchemaContext());
             }
         }
@@ -200,7 +200,7 @@ public final class YangInstanceIdentifierDeserializer {
             final SchemaContext schemaContext) {
         final String moduleName = toModuleName(value);
         final String nodeName = toNodeName(value);
-        final Module module = schemaContext.findModuleByName(moduleName, null);
+        final Module module = schemaContext.findModules(moduleName).iterator().next();
         for (final IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
             final QName qName = identitySchemaNode.getQName();
             if (qName.getLocalName().equals(nodeName)) {
@@ -264,8 +264,8 @@ public final class YangInstanceIdentifierDeserializer {
                         variables.getOffset());
                 localName = nextIdentifierFromNextSequence(ParserBuilderConstants.Deserializer.IDENTIFIER, variables);
 
-                if (!allCharsConsumed(variables) && (currentChar(
-                        variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.EQUAL)) {
+                if (!allCharsConsumed(variables) && currentChar(
+                        variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.EQUAL) {
                     return getQNameOfDataSchemaNode(localName, variables);
                 } else {
                     final Module module = moduleForPrefix(prefix, variables.getSchemaContext());
@@ -327,7 +327,7 @@ public final class YangInstanceIdentifierDeserializer {
         DataSchemaContextNode<?> current = variables.getCurrent();
         if (current == null) {
             for (final RpcDefinition rpcDefinition : variables.getSchemaContext()
-                    .findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()).getRpcs()) {
+                    .findModule(qname.getModule()).orElse(null).getRpcs()) {
                 if (rpcDefinition.getQName().getLocalName().equals(qname.getLocalName())) {
                     return null;
                 }
@@ -382,7 +382,7 @@ public final class YangInstanceIdentifierDeserializer {
     }
 
     private static Module moduleForPrefix(final String prefix, final SchemaContext schemaContext) {
-        return schemaContext.findModuleByName(prefix, null);
+        return schemaContext.findModules(prefix).stream().findFirst().orElse(null);
     }
 
     private static void validArg(final MainVarsWrapper variables) {
index a8c28d7984330e5ab03f9939828c6ff94c1f4f72..b20c5c15bd5606c9f5d617313820ea9b1a42d1ae 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 
 import com.google.common.base.Preconditions;
-import java.net.URI;
 import java.util.Iterator;
 import java.util.Map.Entry;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
@@ -170,9 +169,7 @@ public final class YangInstanceIdentifierSerializer {
      * @return {@link String}
      */
     private static String prefixForNamespace(final QName qname, final SchemaContext schemaContext) {
-        final URI namespace = qname.getNamespace();
-        Preconditions.checkArgument(namespace != null, "Failed to map QName {}", qname);
-        final Module module = schemaContext.findModuleByNamespaceAndRevision(namespace, qname.getRevision());
+        final Module module = schemaContext.findModule(qname.getModule()).orElse(null);
         return module.getName();
     }
 
index 74c5012e3ff9a9d6f60f1c445737d8a7eed90435..84db15e8f1634da1571ff2b533e5ab998215768a 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.utils.validations;
 
-import java.text.ParseException;
+import java.time.format.DateTimeParseException;
 import java.util.Date;
 import java.util.Iterator;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
@@ -15,7 +15,7 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.validation.RestconfValidationUtils;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 /**
  * Util class for validations.
@@ -34,12 +34,12 @@ public final class RestconfValidation {
      *             iterator
      * @return {@link Date}
      */
-    public static Date validateAndGetRevision(final Iterator<String> revisionDate) {
+    public static Revision validateAndGetRevision(final Iterator<String> revisionDate) {
         RestconfValidationUtils.checkDocumentedError(revisionDate.hasNext(), ErrorType.PROTOCOL,
                 ErrorTag.INVALID_VALUE, "Revision date must be supplied.");
         try {
-            return SimpleDateFormatUtil.getRevisionFormat().parse(revisionDate.next());
-        } catch (final ParseException e) {
+            return Revision.of(revisionDate.next());
+        } catch (final DateTimeParseException e) {
             throw new RestconfDocumentedException("Supplied revision is not in expected date format YYYY-mm-dd", e);
         }
     }
index 12d93952b8c402d480c2105cf063a0ce02d7d8f1..86a36649bb397f6804d7d1c2ac331a88ec02cbbf 100644 (file)
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
-public class TestRestconfUtils {
+public final class TestRestconfUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestRestconfUtils.class);
 
@@ -55,14 +55,14 @@ public class TestRestconfUtils {
     public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) {
         try {
             Preconditions.checkArgument(yangPath != null, "Path can not be null.");
-            Preconditions.checkArgument((!yangPath.isEmpty()), "Path can not be empty.");
+            Preconditions.checkArgument(!yangPath.isEmpty(), "Path can not be empty.");
             if (schemaContext == null) {
-                return YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(yangPath));
+                return YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(yangPath));
             } else {
                 throw new UnsupportedOperationException("Unable to add new yang sources to existing schema context.");
             }
         } catch (final Exception e) {
-            LOG.error("Yang files at path: " + yangPath + " weren't loaded.");
+            LOG.error("Yang files at path: " + yangPath + " weren't loaded.", e);
         }
         return schemaContext;
     }
index 4b6992e3f705548c8e5cffed5c5104bdc4500c20..ab7ad9bf87acdff984bf85995e8e00e461ef86bc 100644 (file)
@@ -21,7 +21,6 @@ import java.io.OutputStreamWriter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
-import java.sql.Date;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -38,6 +37,7 @@ import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -48,7 +48,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMa
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,8 +58,12 @@ public final class TestUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
 
+    private TestUtils() {
+
+    }
+
     public static SchemaContext loadSchemaContext(final String... yangPath)
-            throws FileNotFoundException, ReactorException {
+            throws FileNotFoundException {
         final List<File> files = new ArrayList<>();
         for (final String path : yangPath) {
             final String pathToFile = TestUtils.class.getResource(path).getPath();
@@ -78,7 +81,7 @@ public final class TestUtils {
             }
         }
 
-        return YangParserTestUtils.parseYangSources(files);
+        return YangParserTestUtils.parseYangFiles(files);
     }
 
     public static Module findModule(final Set<Module> modules, final String moduleName) {
@@ -160,11 +163,7 @@ public final class TestUtils {
     public static QName buildQName(final String name, final String uri, final String date, final String prefix) {
         try {
             final URI u = new URI(uri);
-            Date dt = null;
-            if (date != null) {
-                dt = Date.valueOf(date);
-            }
-            return QName.create(u, dt, name);
+            return QName.create(u, Revision.ofNullable(date), name);
         } catch (final URISyntaxException e) {
             return null;
         }
index 43cf40a9e27e614bf3d0fe7f46b85ab339b22ed2..ef4c63b985053c1123c290b761b72e8eb7194b38 100644 (file)
@@ -47,7 +47,7 @@ public class SchemaContextHandlerTest {
         this.schemaContextHandler = new SchemaContextHandler(txHandler);
 
         this.schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_ACTUAL_SCHEMA_CONTEXT));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_ACTUAL_SCHEMA_CONTEXT));
         this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
     }
 
@@ -83,7 +83,7 @@ public class SchemaContextHandlerTest {
     public void onGlobalContextUpdateTest() throws Exception {
         // create new SchemaContext and update SchemaContextHandler
         final SchemaContext newSchemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
         this.schemaContextHandler.onGlobalContextUpdated(newSchemaContext);
 
         assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext",
index 9ff864c8c500fbe5aae073faf1232c3dbe17d2a1..51dbdef7af6c88b4c31a325af4194b8918e66cde 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
index 031fc6370fd65cd473f83f7beca616fc706a3cde..37a5b897de6bc162975747e4d4bc1adb1dba5594 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
index 4378a882a5af177198b73121d5b43d99658a99a2..b5365e0c1c992ecd91d168be8a318c84fa349afa 100644 (file)
@@ -19,7 +19,6 @@ import com.google.common.base.Optional;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
@@ -36,7 +35,7 @@ import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyRe
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -51,16 +50,8 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
 
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME =  QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public XmlBodyReaderMountPointTest() throws Exception {
         this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
@@ -75,7 +66,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
     public static void initialization() throws Exception {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
 
         final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
         final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
@@ -140,13 +131,13 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode.getChild(
-                yangCont.getLastPathArgument());
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode
+                .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNodePotential.isPresent());
         final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get();
         final YangInstanceIdentifier yangLeaf =
                 YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
                 yangLeaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
         assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
@@ -168,7 +159,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
                 .getSchemaContext().getDataChildByName(
                         dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
-        if ((qualifiedName != null) && (dataSchemaNode instanceof DataNodeContainer)) {
+        if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) {
             final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
                     .getDataChildByName(qualifiedName);
             dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
index da0e964a953f57d2b5cdbb962f140960293fb557..635c568902d21c8d2789c24b94cff5540701cf76 100644 (file)
@@ -18,7 +18,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
@@ -26,10 +25,11 @@ import org.junit.Test;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -45,16 +45,8 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
     private final JsonNormalizedNodeBodyReader jsonBodyReader;
     private static SchemaContext schemaContext;
 
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public JsonBodyReaderTest() throws Exception {
         this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
@@ -70,8 +62,9 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
             throws NoSuchFieldException, SecurityException, FileNotFoundException, SourceException, ReactorException {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
+        SchemaContextHandler.setActualSchemaContext(schemaContext);
     }
 
     @Test
@@ -126,7 +119,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
     public void moduleSubContainerAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
         final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
                 Sets.newHashSet(contAugmentQName));
@@ -147,7 +140,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
     public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
index 7a6fb00367a80ad1b92bb34e784deeda9ddb10b9..291a383554643dadf19bf14ea4c49b256011f3e3 100644 (file)
@@ -19,7 +19,6 @@ import com.google.common.collect.Sets;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
@@ -34,7 +33,7 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -50,16 +49,8 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
 
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
-    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = initializeInstanceIdentifierModule();
-
-    private static QNameModule initializeInstanceIdentifierModule() {
-        try {
-            return QNameModule.create(URI.create("instance:identifier:module"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2014-01-17"));
-        } catch (final ParseException e) {
-            throw new Error(e);
-        }
-    }
+    private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
+        URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
 
     public XmlBodyReaderTest() throws Exception {
         this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
@@ -75,7 +66,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang"));
-        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
         when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
         SchemaContextHandler.setActualSchemaContext(schemaContext);
     }
@@ -166,7 +157,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
     public void moduleSubContainerAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
         final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
                 Sets.newHashSet(contAugmentQName));
@@ -186,7 +177,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
     public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
-        final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next();
+        final Module augmentModule = schemaContext.findModules(new URI("augment:module")).iterator().next();
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
index cf6066b655c53d3d787b67d43347702da37be810..348569bd731c7081d328fda5913c5fc3d5376d2c 100644 (file)
@@ -282,14 +282,15 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         assertEquals("ContainerNode node type", INTERFACES_QNAME, actualNode.getNodeType());
 
-        final Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(new NodeIdentifier(INTERFACE_QNAME));
+        final java.util.Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(
+            new NodeIdentifier(INTERFACE_QNAME));
         assertEquals(INTERFACE_QNAME.toString() + " present", true, mapChild.isPresent());
         assertTrue("Expected MapNode. Actual " + mapChild.get().getClass(), mapChild.get() instanceof MapNode);
         final MapNode mapNode = (MapNode)mapChild.get();
 
         final NodeIdentifierWithPredicates entryNodeID = new NodeIdentifierWithPredicates(
                 INTERFACE_QNAME, NAME_QNAME, "eth0");
-        final Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
+        final java.util.Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
         assertEquals(entryNodeID.toString() + " present", true, entryChild.isPresent());
         final MapEntryNode entryNode = entryChild.get();
         verifyLeafNode(entryNode, NAME_QNAME, "eth0");
@@ -325,7 +326,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
     }
 
     @Test(expected = TransactionCommitFailedException.class)
-    @SuppressWarnings("checkstyle:IllegalThrows")
+    @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
     public void testPostFailure() throws Throwable {
         doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")))
                 .when(mockReadWriteTx).submit();
@@ -581,7 +582,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
     }
 
     void verifyLeafNode(final DataContainerNode<?> parent, final QName leafType, final Object leafValue) {
-        final Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
+        final java.util.Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
         assertEquals(leafType.toString() + " present", true, leafChild.isPresent());
         assertEquals(leafType.toString() + " value", leafValue, leafChild.get().getValue());
     }
index d767b3dacb58d0bf3991806846c79f61a06476a3..ad05a233209be839809668d1d2c44eb25d049f65 100644 (file)
@@ -175,7 +175,7 @@ public class RestconfDataServiceImplTest {
                 .build();
 
         this.contextRef = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schemaNode = DataSchemaContextTree.from(this.contextRef.get()).getChild(this.iidBase).getDataSchemaNode();
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
@@ -334,7 +334,6 @@ public class RestconfDataServiceImplTest {
     @Test
     public void testPutDataWithMountPoint() {
         final DOMDataBroker dataBroker = Mockito.mock(DOMDataBroker.class);
-        final DOMMountPoint mountPoint = Mockito.mock(DOMMountPoint.class);
         doReturn(Optional.of(dataBroker)).when(mountPoint).getService(DOMDataBroker.class);
         doReturn(this.transactionChainHandler.get()).when(dataBroker)
                 .createTransactionChain(RestConnectorProvider.TRANSACTION_CHAIN_LISTENER);
@@ -533,4 +532,4 @@ public class RestconfDataServiceImplTest {
         final String errorMessage = status.getEditCollection().get(2).getEditErrors().get(0).getErrorMessage();
         assertEquals("Data does not exist", errorMessage);
     }
-}
\ No newline at end of file
+}
index c70960c063cc4a8e9671788e6116a5efc863721e..87998c82aa2bb8db233090e01c9d775242183c93 100644 (file)
@@ -52,7 +52,7 @@ public class RestconfInvokeOperationsServiceImplTest {
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
         final SchemaContextRef contextRef = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
         Mockito.when(txHandler.get()).thenReturn(domTx);
@@ -82,7 +82,7 @@ public class RestconfInvokeOperationsServiceImplTest {
     private NormalizedNodeContext prepNNC(final NormalizedNode result) {
         final InstanceIdentifierContext context = Mockito.mock(InstanceIdentifierContext.class);
         final RpcDefinition schemaNode = Mockito.mock(RpcDefinition.class);
-        final QName qname = QName.create("invoke:rpc:module", "2013-12-3", "rpcTest");
+        final QName qname = QName.create("invoke:rpc:module", "2013-12-03", "rpcTest");
         final SchemaPath schemaPath = SchemaPath.create(true, qname);
         Mockito.when(schemaNode.getPath()).thenReturn(schemaPath);
         Mockito.when(schemaNode.getQName()).thenReturn(qname);
index 9f40febe48e70f709be65011f5d2bce8157ce948..24d9d8b9ee21f683ffd44ce6caa72188ac18fd54 100644 (file)
@@ -109,7 +109,7 @@ public class RestconfStreamsSubscriptionServiceImplTest {
         Mockito.when(uriInfo.getBaseUri()).thenReturn(baseUriBuilder.build());
         Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(baseUriBuilder);
         this.schemaHandler.onGlobalContextUpdated(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/notifications")));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications")));
     }
 
     private static class LocalUriInfo extends SimpleUriInfo {
index a268b1b4c8b2c17e8488c739e599a51b10f452cd..97dde3fdd5456d3949ed2beb64b6ca06da4e4c7f 100644 (file)
@@ -50,7 +50,7 @@ public class CreateStreamUtilTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
     }
 
     @Test
@@ -82,8 +82,7 @@ public class CreateStreamUtilTest {
     private NormalizedNodeContext prepareDomPayload(final String rpcName, final String inputOutput,
             final String toasterValue, final String inputOutputName) {
         final SchemaContext schema = this.refSchemaCtx.get();
-        final Module rpcModule = schema.findModuleByName("sal-remote", null);
-        assertNotNull(rpcModule);
+        final Module rpcModule = schema.findModules("sal-remote").iterator().next();
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), rpcName);
         final QName rpcInputQName = QName.create(rpcModule.getQNameModule(), inputOutput);
         final Set<RpcDefinition> setRpcs = rpcModule.getRpcs();
@@ -111,8 +110,8 @@ public class CreateStreamUtilTest {
         } else {
             o = toasterValue;
         }
-        final LeafNode<Object> lfNode = (Builders.leafBuilder((LeafSchemaNode) lfSchemaNode)
-                .withValue(o)).build();
+        final LeafNode<Object> lfNode = Builders.leafBuilder((LeafSchemaNode) lfSchemaNode)
+                .withValue(o).build();
         container.withChild(lfNode);
 
         return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode, null, schema),
index 1113510a0108bcd1e0f564335cd8b90147ee749d..efb9b05f16d47a0bb0eb61922a52147731c43813 100644 (file)
@@ -63,6 +63,7 @@ public class PatchDataTransactionUtilTest {
     private DOMDataReadWriteTransaction rwTransaction;
 
     private SchemaContextRef refSchemaCtx;
+    private YangInstanceIdentifier instanceIdContainer;
     private YangInstanceIdentifier instanceIdCreateAndDelete;
     private YangInstanceIdentifier instanceIdMerge;
     private ContainerNode buildBaseContainerForTests;
@@ -88,7 +89,7 @@ public class PatchDataTransactionUtilTest {
         PatchDataTransactionUtilTest.broker.set(RestConnectorProvider.class, mock(DOMDataBroker.class));
 
         this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName containerPlayerQName = QName.create(baseQName, "player");
         final QName leafGapQName = QName.create(baseQName, "gap");
@@ -98,13 +99,15 @@ public class PatchDataTransactionUtilTest {
         final YangInstanceIdentifier.NodeIdentifierWithPredicates nodeWithKey =
             new YangInstanceIdentifier.NodeIdentifierWithPredicates(listArtistQName, leafNameQName, "name of artist");
 
-        /* instance identifier for accessing leaf node "gap" */
-        this.instanceIdCreateAndDelete = YangInstanceIdentifier.builder()
+        /* instance identifier for accessing container node "player" */
+        this.instanceIdContainer = YangInstanceIdentifier.builder()
                 .node(baseQName)
                 .node(containerPlayerQName)
-                .node(leafGapQName)
                 .build();
 
+        /* instance identifier for accessing leaf node "gap" */
+        this.instanceIdCreateAndDelete = instanceIdContainer.node(leafGapQName);
+
         /* values that are used for creating leaf for testPatchDataCreateAndDelete test */
         final LeafNode<?> buildGapLeaf = Builders.leafBuilder()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(leafGapQName))
@@ -199,11 +202,13 @@ public class PatchDataTransactionUtilTest {
 
     @Test
     public void testPatchDataCreateAndDelete() throws Exception {
-        doReturn(Futures.immediateCheckedFuture(false)).doReturn(Futures.immediateCheckedFuture(true))
-                .when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
+        doReturn(Futures.immediateCheckedFuture(false))
+                .when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.instanceIdContainer);
+        doReturn(Futures.immediateCheckedFuture(true))
+        .when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
 
         final PatchEntity entityCreate =
-                new PatchEntity("edit1", CREATE, this.targetNodeForCreateAndDelete, this.buildBaseContainerForTests);
+                new PatchEntity("edit1", CREATE, this.instanceIdContainer, this.buildBaseContainerForTests);
         final PatchEntity entityDelete =
                 new PatchEntity("edit2", DELETE, this.targetNodeForCreateAndDelete);
         final List<PatchEntity> entities = new ArrayList<>();
@@ -219,7 +224,7 @@ public class PatchDataTransactionUtilTest {
                 PatchDataTransactionUtil.patchData(patchContext, wrapper, this.refSchemaCtx);
 
         for (final PatchStatusEntity entity : patchStatusContext.getEditCollection()) {
-            assertTrue(entity.isOk());
+            assertTrue("Edit " + entity.getEditId() + " failed", entity.isOk());
         }
         assertTrue(patchStatusContext.isOk());
     }
@@ -255,7 +260,7 @@ public class PatchDataTransactionUtilTest {
                 .when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
 
         final PatchEntity entityMerge =
-                new PatchEntity("edit1", MERGE, this.targetNodeForCreateAndDelete, this.buildBaseContainerForTests);
+                new PatchEntity("edit1", MERGE, this.instanceIdContainer, this.buildBaseContainerForTests);
         final List<PatchEntity> entities = new ArrayList<>();
 
         entities.add(entityMerge);
index aa205a8165e07dc7df8f0bfc65613a46f0d250da..a22edb193331ec3aeae1d57d91cfa4b0569def8e 100644 (file)
@@ -74,7 +74,7 @@ public class PostDataTransactionUtilTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schema = this.refSchemaCtx.get();
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
index 11c9770a23f60c07001b9764481bdfd1d517f99b..9c9bdbe860481c24429956cbec118c8f837ce03a 100644 (file)
@@ -72,7 +72,7 @@ public class PutDataTransactionUtilTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schema = this.refSchemaCtx.get();
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
index 8a269048c3f91fb60ff997b28e0a0269bc50ecfa..dcfa41a80568166421d8b4e56779fcc6fc6ad751 100644 (file)
@@ -28,7 +28,7 @@ public class RestconfImplTest {
     @Test
     public void restImplTest() throws Exception {
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/impl"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl"));
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
index 88bae0c00a710ac043a26df7d1fc4ce07784dbbb..562a1f2bbec8d5698c1e64f7c2e63d8ff6c4dc92 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableSet;
@@ -29,6 +28,7 @@ import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -54,7 +54,7 @@ public class RestconfOperationsServiceTest {
     @Before
     public void init() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
+        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
@@ -67,8 +67,8 @@ public class RestconfOperationsServiceTest {
 
         this.domMountPointServiceHandler = new DOMMountPointServiceHandler(this.domMountPointService);
 
-        final QNameModule module1 = QNameModule.create(new URI("module:1"), null);
-        final QNameModule module2 = QNameModule.create(new URI("module:2"), null);
+        final QNameModule module1 = QNameModule.create(URI.create("module:1"));
+        final QNameModule module2 = QNameModule.create(URI.create("module:2"));
 
         this.listOfRpcsNames = ImmutableSet.of(QName.create(module1, "dummy-rpc1-module1"),
                 QName.create(module1, "dummy-rpc2-module1"), QName.create(module2, "dummy-rpc1-module2"),
@@ -87,7 +87,7 @@ public class RestconfOperationsServiceTest {
         assertEquals(4, data.getValue().size());
 
         for (final DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
-            assertNull(child.getValue());
+            assertEquals(Empty.getInstance(), child.getValue());
 
             final QName qname = child.getNodeType().withoutRevision();
             assertTrue(this.listOfRpcsNames.contains(qname));
index d3c0a19cd94f82c3639114d7ca3eec96816c46f8..80b9231159cd8515c135a22db3cb2e0546b28511 100644 (file)
@@ -36,7 +36,7 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -85,11 +85,11 @@ public class RestconfSchemaServiceTest {
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
 
-        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
+        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
         this.schemaContextBehindMountPoint = YangParserTestUtils
-                .parseYangSources(TestRestconfUtils.loadFiles("/modules/modules-behind-mount-point"));
+                .parseYangFiles(TestRestconfUtils.loadFiles("/modules/modules-behind-mount-point"));
         this.schemaContextWithMountPoints =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules/mount-points"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules/mount-points"));
 
         // create and register mount points
         this.mountPoint = SimpleDOMMountPoint.create(
@@ -139,8 +139,7 @@ public class RestconfSchemaServiceTest {
         assertNotNull("Existing module should be found", module);
 
         assertEquals("Not expected module name", "module1", module.getName());
-        assertEquals("Not expected module revision", "2014-01-01",
-                SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()));
+        assertEquals("Not expected module revision", Revision.ofNullable("2014-01-01"), module.getRevision());
         assertEquals("Not expected module namespace", "module:1", module.getNamespace().toString());
     }
 
@@ -180,8 +179,7 @@ public class RestconfSchemaServiceTest {
         assertNotNull("Existing module should be found", module);
 
         assertEquals("Not expected module name", "module1-behind-mount-point", module.getName());
-        assertEquals("Not expected module revision", "2014-02-03",
-                SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()));
+        assertEquals("Not expected module revision", Revision.ofNullable("2014-02-03"), module.getRevision());
         assertEquals("Not expected module namespace", "module:1:behind:mount:point", module.getNamespace().toString());
     }
 
index 7a076742658daddcf1fbfa17db7c54c3540f289e..5542501bc18e3c6e8d4a4ae924c21051b625efc6 100644 (file)
@@ -12,16 +12,15 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import java.net.URI;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
@@ -31,7 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev14070
 import org.opendaylight.yangtools.util.SingletonSet;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -46,16 +45,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class NotificationListenerTest {
-    private static final QNameModule MODULE;
-
-    static {
-        try {
-            MODULE = QNameModule.create(URI.create("notifi:mod"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("2016-11-23"));
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
+    private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23"));
 
     private SchemaContext schmeaCtx;
 
index d3839245e7d7e9a9d16e2b1890abee8f4d3514fa..c16ebd5396633319fa32b309116d9d78f6e00ed5 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.restconf.nb.rfc8040.Rfc8040.RestconfModule;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -83,11 +83,11 @@ public class RestconfMappingNodeUtilTest {
     @BeforeClass
     public static void loadTestSchemaContextAndModules() throws Exception {
         schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules/restconf-module-testing"));
-        schemaContextMonitoring = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules/restconf-module-testing"));
+        schemaContextMonitoring = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
         modules = schemaContextMonitoring.getModules();
         modulesRest = YangParserTestUtils
-                .parseYangSources(TestRestconfUtils.loadFiles("/modules/restconf-module-testing")).getModules();
+                .parseYangFiles(TestRestconfUtils.loadFiles("/modules/restconf-module-testing")).getModules();
     }
 
     @Before
@@ -98,7 +98,7 @@ public class RestconfMappingNodeUtilTest {
         when(this.leafDescription.getQName()).thenReturn(QName.create("", RestconfMappingNodeConstants.DESCRIPTION));
         when(this.leafReplaySupport.getQName()).thenReturn(
                 QName.create("", RestconfMappingNodeConstants.REPLAY_SUPPORT));
-        when(this.leafReplayLog.getQName()).thenReturn(QName.create(RestconfMappingNodeConstants.REPLAY_LOG));
+        when(this.leafReplayLog.getQName()).thenReturn(QName.create("", RestconfMappingNodeConstants.REPLAY_LOG));
         when(this.leafEvents.getQName()).thenReturn(QName.create("", RestconfMappingNodeConstants.EVENTS));
     }
 
@@ -109,20 +109,18 @@ public class RestconfMappingNodeUtilTest {
     @Test
     public void restconfMappingNodeTest() {
         // write modules into list module in Restconf
-        final Module ietfYangLibMod =
-                schemaContext.findModuleByNamespaceAndRevision(IetfYangLibrary.URI_MODULE, IetfYangLibrary.DATE);
-        final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> modules =
+        final Module ietfYangLibMod = schemaContext.findModule(IetfYangLibrary.MODULE_QNAME).get();
+        final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> mods =
                 RestconfMappingNodeUtil.mapModulesByIetfYangLibraryYang(RestconfMappingNodeUtilTest.modules,
                         ietfYangLibMod, schemaContext, "1");
 
         // verify loaded modules
-        verifyLoadedModules((ContainerNode) modules);
+        verifyLoadedModules((ContainerNode) mods);
     }
 
     @Test
     public void restconfStateCapabilitesTest() {
-        final Module monitoringModule = schemaContextMonitoring
-                .findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+        final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).get();
         final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
                 RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
         assertNotNull(normNode);
@@ -152,8 +150,7 @@ public class RestconfMappingNodeUtilTest {
         final Instant start = Instant.now();
         final String outputType = "XML";
         final URI uri = new URI("uri");
-        final Module monitoringModule = schemaContextMonitoring
-                .findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+        final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
         final boolean exist = true;
 
         final Map<QName, Object> map =
@@ -171,14 +168,13 @@ public class RestconfMappingNodeUtilTest {
         final Instant start = Instant.now();
         final String outputType = "JSON";
         final URI uri = new URI("uri");
-        final Module monitoringModule = schemaContextMonitoring
-                .findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+        final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
         final boolean exist = true;
 
         final Map<QName, Object> map = prepareMap("notifi", uri, start, outputType);
         map.put(MonitoringModule.LEAF_DESCR_STREAM_QNAME, "Notifi");
 
-        final QName notifiQName = QName.create("urn:nested:module", "2014-06-3", "notifi");
+        final QName notifiQName = QName.create("urn:nested:module", "2014-06-03", "notifi");
         final NormalizedNode<?, ?> mappedData =
                 RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(notifiQName,
                     schemaContextMonitoring.getNotifications(), start, outputType, uri, monitoringModule, exist);
@@ -264,8 +260,7 @@ public class RestconfMappingNodeUtilTest {
 
             final String revision = loadedModules.get(name);
             assertNotNull("Expected module not found", revision);
-            assertEquals("Not correct revision of loaded module",
-                    SimpleDateFormatUtil.getRevisionFormat().format(m.getRevision()), revision);
+            assertEquals("Incorrect revision of loaded module", Revision.ofNullable(revision), m.getRevision());
 
             loadedModules.remove(name);
         }
index 5c58ae8d24bc7842bef9b303b5e13676815baf8d..fed9756f6580ddaf19df822f5551413bd74cd599 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.FileNotFoundException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
@@ -30,8 +31,8 @@ public class IdentifierCodecTest {
     private SchemaContext schemaContext;
 
     @Before
-    public void init() throws Exception {
-        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser"));
+    public void init() throws FileNotFoundException {
+        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser"));
     }
 
     /**
index 58d1153960a58053dff11ce52e5b4640ddcd0b3b..8883ac8f88da5e542fd0c34d6ac650e17843fc77 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
@@ -77,10 +77,10 @@ public class ParserFieldsParameterTest {
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/jukebox"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/jukebox"));
 
         final QNameModule qNameModule = QNameModule.create(URI.create("http://example.com/ns/example-jukebox"),
-            SimpleDateFormatUtil.getRevisionFormat().parse("2015-04-04"));
+            Revision.of("2015-04-04"));
 
         this.jukeboxQName = QName.create(qNameModule, "jukebox");
         this.playerQName = QName.create(qNameModule, "player");
@@ -88,7 +88,7 @@ public class ParserFieldsParameterTest {
         this.augmentedLibraryQName = QName.create(
                 QNameModule.create(
                         URI.create("http://example.com/ns/augmented-jukebox"),
-                        SimpleDateFormatUtil.getRevisionFormat().parse("2016-05-05")),
+                        Revision.of("2016-05-05")),
                 "augmented-library");
         this.albumQName = QName.create(qNameModule, "album");
         this.nameQName = QName.create(qNameModule, "name");
index ba33cd6ef0c608ff2a6ea1a5e34cf565d1574c3d..bf0b513375279f8046780a74c158d6af1f1921b4 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Mockito.when;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.collect.Maps;
+import java.util.Map.Entry;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -38,7 +39,7 @@ import org.opendaylight.restconf.common.schema.SchemaExportContext;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -110,9 +111,9 @@ public class ParserIdentifierTest {
     @Before
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/parser-identifier"));
+        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/parser-identifier"));
         this.schemaContextOnMountPoint =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/parser-identifier"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/parser-identifier"));
 
         // create and register mount point
         this.mountPoint = SimpleDOMMountPoint.create(
@@ -286,13 +287,12 @@ public class ParserIdentifierTest {
      */
     @Test
     public void makeQNameFromIdentifierTest() {
-        final QName qName = ParserIdentifier.makeQNameFromIdentifier(TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION);
+        final Entry<String, Revision> qName = ParserIdentifier.makeQNameFromIdentifier(
+            TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION);
 
         assertNotNull("QName should be created", qName);
-        assertEquals("Returned not expected module name",
-                TEST_MODULE_NAME, qName.getLocalName());
-        assertEquals("Returned not expected module revision",
-                TEST_MODULE_REVISION, qName.getFormattedRevision());
+        assertEquals("Returned not expected module name", TEST_MODULE_NAME, qName.getKey());
+        assertEquals("Returned not expected module revision", Revision.of(TEST_MODULE_REVISION), qName.getValue());
     }
 
     /**
@@ -341,7 +341,7 @@ public class ParserIdentifierTest {
      */
     @Test
     public void makeQNameFromIdentifierMountTest() {
-        final QName qName = ParserIdentifier.makeQNameFromIdentifier(
+        final Entry<String, Revision> qName = ParserIdentifier.makeQNameFromIdentifier(
                 MOUNT_POINT_IDENT
                 + "/"
                 + TEST_MODULE_NAME
@@ -349,10 +349,8 @@ public class ParserIdentifierTest {
                 + TEST_MODULE_REVISION);
 
         assertNotNull("QName should be created", qName);
-        assertEquals("Returned not expected module name",
-                TEST_MODULE_NAME, qName.getLocalName());
-        assertEquals("Returned not expected module revision",
-                TEST_MODULE_REVISION, qName.getFormattedRevision());
+        assertEquals("Returned not expected module name", TEST_MODULE_NAME, qName.getKey());
+        assertEquals("Returned not expected module revision", Revision.of(TEST_MODULE_REVISION), qName.getValue());
     }
 
     /**
@@ -477,7 +475,7 @@ public class ParserIdentifierTest {
         assertEquals("Returned not expected module name",
                 TEST_MODULE_NAME, module.getName());
         assertEquals("Returned not expected module revision",
-                TEST_MODULE_REVISION, SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()));
+                Revision.ofNullable(TEST_MODULE_REVISION), module.getRevision());
         assertEquals("Returned not expected module namespace",
                 TEST_MODULE_NAMESPACE, module.getNamespace().toString());
     }
@@ -535,7 +533,7 @@ public class ParserIdentifierTest {
         assertEquals("Returned not expected module name",
                 TEST_MODULE_NAME, module.getName());
         assertEquals("Returned not expected module revision",
-                TEST_MODULE_REVISION, SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()));
+                Revision.ofNullable(TEST_MODULE_REVISION), module.getRevision());
         assertEquals("Returned not expected module namespace",
                 TEST_MODULE_NAMESPACE, module.getNamespace().toString());
     }
index 66157f6816b466212d42da12c04c40fc1df5c569..86aa0307b6ba30ed36cf0823bb2ff54ffb3a7689 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.fail;
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
+import java.io.FileNotFoundException;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -42,9 +43,9 @@ public class YangInstanceIdentifierDeserializerTest {
     private SchemaContext schemaContext;
 
     @Before
-    public void init() throws Exception {
+    public void init() throws FileNotFoundException {
         this.schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
     }
 
     /**
index 824343172b164f1612a567e2670b8c7c6d898cb5..35bb3dc1625b68fb87af883aaccab90197757e87 100644 (file)
@@ -41,7 +41,7 @@ public class YangInstanceIdentifierSerializerTest {
     @Before
     public void init() throws Exception {
         this.schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/serializer"));
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/serializer"));
     }
 
     /**
index 5ccf9634d6ee788b0d95c610c63f4ec52c3543d0..b1929dc79557ce1307d627b64279ae25e64ff785 100644 (file)
@@ -15,12 +15,11 @@ import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 /**
  * Unit test for {@link RestconfValidation}.
@@ -34,15 +33,9 @@ public class RestconfValidationTest {
      */
     @Test
     public void validateAndGetRevisionTest() {
-        final Date revision = RestconfValidation.validateAndGetRevision(REVISIONS.iterator());
+        final Revision revision = RestconfValidation.validateAndGetRevision(REVISIONS.iterator());
         assertNotNull("Correct module revision should be validated", revision);
-
-        final Calendar calendar = Calendar.getInstance();
-        calendar.setTime(revision);
-
-        assertEquals(2014, calendar.get(Calendar.YEAR));
-        assertEquals(0, calendar.get(Calendar.MONTH));
-        assertEquals(1, calendar.get(Calendar.DAY_OF_MONTH));
+        assertEquals(Revision.of("2014-01-01"), revision);
     }
 
     /**
index c23c50ab486ee1f6129d00d411a0fe53300a4ddd..92cf1a9d6cbc112c8f745f807921c5ce7f61eece 100644 (file)
@@ -3,7 +3,7 @@ module invoke-rpc-module {
 
   prefix "inrpcmod";
 
-  revision 2013-12-3 {
+  revision 2013-12-03 {
 
   }
 
@@ -26,4 +26,4 @@ module invoke-rpc-module {
 
   rpc rpc-noop {
   }
-}
\ No newline at end of file
+}
index aa2795afebbe0cf0c8a739a382dfd2d4c5c26eef..794859b0c2566480d9cf80b1cc15379392b634c7 100644 (file)
@@ -1,7 +1,7 @@
 module nested-module {
     namespace "urn:nested:module";
     prefix "nested";
-    revision "2014-06-3";
+    revision "2014-06-03";
 
     container depth1-cont {
         list depth2-cont1 {
index de39413abe2c5858844406881fc9730020bff05e..315be15a0bf8ae9815c8710aafe40c3866386dcc 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
index 3fc78c5b2a7c6a03a899c41d386349a4c834b7da..4359ba9ac42b4fee4f8be03c4ef664dfc541d7a7 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>2.0.5</version>
+        <version>3.0.2</version>
         <relativePath/>
     </parent>
 
@@ -33,7 +33,7 @@
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yangtools-artifacts</artifactId>
-                <version>1.2.0</version>
+                <version>2.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 7a06710f5c1a7f2405bd9c5fed9d304ab7cfa11b..dbb1c1e1ee7a4c44b3352aecf4ecb533a9068bf7 100644 (file)
@@ -17,7 +17,9 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import javax.ws.rs.core.UriInfo;
 import org.apache.maven.project.MavenProject;
 import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocGenerator;
@@ -41,35 +43,27 @@ public class StaticDocGenerator extends ApiDocGenerator implements BasicCodeGene
     private Map<String, String> additionalConfig;
     private File resourceBaseDir;
 
-    /**
-     * Generate sources.
-     *
-     * @param context schema context
-     * @param outputDir output directory
-     * @param yangModules modules
-     * @return {@link Collection} of resource files
-     * @throws IOException when file operation fails
-     */
     @Override
-    public Collection<File> generateSources(final SchemaContext context, final File outputDir,
-            final Set<Module> yangModules) throws IOException {
+    public Collection<File> generateSources(final SchemaContext context, final File outputBaseDir,
+            final Set<Module> currentModules, final Function<Module, Optional<String>> moduleResourcePathResolver)
+                    throws IOException {
         List<File> result = new ArrayList<>();
 
         // Create Base Directory
-        final File outputBaseDir;
-        if (outputDir == null) {
-            outputBaseDir = new File(DEFAULT_OUTPUT_BASE_DIR_PATH);
+        final File outputDir;
+        if (outputBaseDir == null) {
+            outputDir = new File(DEFAULT_OUTPUT_BASE_DIR_PATH);
         } else {
-            outputBaseDir = outputDir;
+            outputDir = outputBaseDir;
         }
-        outputBaseDir.mkdirs();
+        outputDir.mkdirs();
 
         // Create Resources directory
-        File resourcesDir = new File(outputBaseDir, "resources");
+        File resourcesDir = new File(outputDir, "resources");
         resourcesDir.mkdirs();
 
         // Create JS file
-        File resourcesJsFile = new File(outputBaseDir, "resources.js");
+        File resourcesJsFile = new File(outputDir, "resources.js");
         resourcesJsFile.createNewFile();
         BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resourcesJsFile));
         ObjectMapper mapper = new ObjectMapper();
index 3cea96779ee9c7eeb13a4b58fd6e8027608c60c4..2c129148e1cb4831cc5cae92a54c0adeded229fe 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>2.0.5</version>
+    <version>3.0.2</version>
     <relativePath/>
   </parent>
 
@@ -25,7 +25,7 @@
       <dependency>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools-artifacts</artifactId>
-        <version>1.2.0</version>
+        <version>2.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 91612c1eac0354fa9bc42d1de953e1eeb243e82b..9c333f793c2e8aa282fb71348284a385460989d4 100644 (file)
@@ -15,15 +15,13 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.net.URI;
-import java.text.ParseException;
+import java.time.format.DateTimeParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -40,7 +38,7 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.Parameter;
 import org.opendaylight.netconf.sal.rest.doc.swagger.Resource;
 import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -49,7 +47,6 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -88,7 +85,7 @@ public class BaseYangSwaggerGenerator {
         LOG.info("Modules found [{}]", modules.size());
 
         for (final Module module : modules) {
-            final String revisionString = module.getQNameModule().getFormattedRevision();
+            final String revisionString = module.getQNameModule().getRevision().map(Revision::toString).orElse(null);
             final Resource resource = new Resource();
             LOG.debug("Working on [{},{}]...", module.getName(), revisionString);
             final ApiDeclaration doc =
@@ -121,34 +118,22 @@ public class BaseYangSwaggerGenerator {
 
     public ApiDeclaration getApiDeclaration(final String moduleName, final String revision, final UriInfo uriInfo,
             final SchemaContext schemaContext, final String context) {
-        Date rev = null;
+        final Optional<Revision> rev;
 
         try {
-            if (revision != null && !SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(revision)) {
-                rev = SimpleDateFormatUtil.getRevisionFormat().parse(revision);
-            }
-        } catch (final ParseException e) {
+            rev = Revision.ofNullable(revision);
+        } catch (final DateTimeParseException e) {
             throw new IllegalArgumentException(e);
         }
 
-        if (rev != null) {
-            final Calendar cal = new GregorianCalendar();
-
-            cal.setTime(rev);
-
-            if (cal.get(Calendar.YEAR) < 1970) {
-                rev = null;
-            }
-        }
-
-        final Module module = schemaContext.findModuleByName(moduleName, rev);
+        final Module module = schemaContext.findModule(moduleName, rev).orElse(null);
         Preconditions.checkArgument(module != null,
                 "Could not find module by name,revision: " + moduleName + "," + revision);
 
-        return getApiDeclaration(module, rev, uriInfo, context, schemaContext);
+        return getApiDeclaration(module, uriInfo, context, schemaContext);
     }
 
-    public ApiDeclaration getApiDeclaration(final Module module, final Date revision, final UriInfo uriInfo,
+    public ApiDeclaration getApiDeclaration(final Module module, final UriInfo uriInfo,
             final String context, final SchemaContext schemaContext) {
         final String basePath = createBasePathFromUriInfo(uriInfo);
 
@@ -181,7 +166,7 @@ public class BaseYangSwaggerGenerator {
         final Collection<DataSchemaNode> dataSchemaNodes = module.getChildNodes();
         LOG.debug("child nodes size [{}]", dataSchemaNodes.size());
         for (final DataSchemaNode node : dataSchemaNodes) {
-            if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) {
+            if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
                 LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName());
 
                 List<Parameter> pathParams = new ArrayList<>();
@@ -251,7 +236,7 @@ public class BaseYangSwaggerGenerator {
             final Api apiForRootPostUri = new Api();
             apiForRootPostUri.setPath(resourcePath.concat(getContent(dataStore)));
             apiForRootPostUri.setOperations(operationPost(module.getName() + MODULE_NAME_SUFFIX,
-                    module.getDescription(), module, pathParams, true, ""));
+                    module.getDescription().orElse(null), module, pathParams, true, ""));
             apis.add(apiForRootPostUri);
         }
     }
@@ -291,7 +276,7 @@ public class BaseYangSwaggerGenerator {
         api.setPath(resourcePath.concat(getContent(dataStore)));
 
         Iterable<DataSchemaNode> childSchemaNodes = Collections.<DataSchemaNode>emptySet();
-        if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) {
+        if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
             final DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
             childSchemaNodes = dataNodeContainer.getChildNodes();
         }
@@ -299,7 +284,7 @@ public class BaseYangSwaggerGenerator {
         apis.add(api);
 
         for (final DataSchemaNode childNode : childSchemaNodes) {
-            if ((childNode instanceof ListSchemaNode) || (childNode instanceof ContainerSchemaNode)) {
+            if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) {
                 // keep config and operation attributes separate.
                 if (childNode.isConfiguration() == addConfigApi) {
                     final String newParent = parentName + "/" + node.getQName().getLocalName();
@@ -341,14 +326,15 @@ public class BaseYangSwaggerGenerator {
         operations.add(getBuilder.pathParams(pathParams).build());
 
         if (isConfig) {
-            final Put putBuilder = new Put(node.getQName().getLocalName(), node.getDescription(), parentName);
+            final Put putBuilder = new Put(node.getQName().getLocalName(), node.getDescription().orElse(null),
+                parentName);
             operations.add(putBuilder.pathParams(pathParams).build());
 
             final Delete deleteBuilder = new Delete(node);
             operations.add(deleteBuilder.pathParams(pathParams).build());
 
             if (containsListOrContainer(childSchemaNodes)) {
-                operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(),
+                operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription().orElse(null),
                         (DataNodeContainer) node, pathParams, isConfig, parentName + "/"));
             }
         }
@@ -373,7 +359,7 @@ public class BaseYangSwaggerGenerator {
         final String localName = resolvePathArgumentsName(schemaNode, schemaContext);
         path.append(localName);
 
-        if ((schemaNode instanceof ListSchemaNode)) {
+        if (schemaNode instanceof ListSchemaNode) {
             final List<QName> listKeys = ((ListSchemaNode) schemaNode).getKeyDefinition();
             StringBuilder keyBuilder = null;
             if (newDraft) {
@@ -382,7 +368,7 @@ public class BaseYangSwaggerGenerator {
 
             for (final QName listKey : listKeys) {
                 final DataSchemaNode dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey);
-                pathListParams.add(((LeafSchemaNode) dataChildByName));
+                pathListParams.add((LeafSchemaNode) dataChildByName);
                 final String pathParamIdentifier;
                 if (newDraft) {
                     pathParamIdentifier = keyBuilder.append("{").append(listKey.getLocalName()).append("}").toString();
@@ -393,7 +379,7 @@ public class BaseYangSwaggerGenerator {
 
                 final Parameter pathParam = new Parameter();
                 pathParam.setName(listKey.getLocalName());
-                pathParam.setDescription(dataChildByName.getDescription());
+                pathParam.setDescription(dataChildByName.getDescription().orElse(null));
                 pathParam.setType("string");
                 pathParam.setParamType("path");
 
@@ -414,7 +400,7 @@ public class BaseYangSwaggerGenerator {
 
         final Operation operationSpec = new Operation();
         operationSpec.setMethod("POST");
-        operationSpec.setNotes(rpcDefn.getDescription());
+        operationSpec.setNotes(rpcDefn.getDescription().orElse(null));
         operationSpec.setNickname(rpcDefn.getQName().getLocalName());
         if (!rpcDefn.getOutput().getChildNodes().isEmpty()) {
             operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output" + OperationBuilder.TOP);
@@ -442,9 +428,7 @@ public class BaseYangSwaggerGenerator {
         final SortedSet<Module> sortedModules = new TreeSet<>((module1, module2) -> {
             int result = module1.getName().compareTo(module2.getName());
             if (result == 0) {
-                final Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0);
-                final Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0);
-                result = module1Revision.compareTo(module2Revision);
+                result = Revision.compare(module1.getRevision(), module2.getRevision());
             }
             if (result == 0) {
                 result = module1.getNamespace().compareTo(module2.getNamespace());
index ca6cb577a2542be75448f56926640bcffec8ec16..f9b02d6c638a751ec48f464a97880e4768119147 100644 (file)
@@ -14,9 +14,12 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.fasterxml.jackson.databind.node.TextNode;
+import com.google.common.collect.Range;
+import com.google.common.collect.RangeSet;
 import com.mifmif.common.regex.Generex;
 import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.regex.Pattern;
 import javax.annotation.concurrent.NotThreadSafe;
@@ -25,37 +28,37 @@ import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.Post
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MandatoryAware;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.TypedSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeRestrictedTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
@@ -190,7 +193,7 @@ public class ModelGenerator {
         dataNodeProperties.put(TYPE_KEY, schemaNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
         dataNodeProperties.put(ITEMS_KEY, items);
 
-        putIfNonNull(dataNodeProperties, DESCRIPTION_KEY, schemaNode.getDescription());
+        putIfNonNull(dataNodeProperties, DESCRIPTION_KEY, schemaNode.getDescription().orElse(null));
         final ObjectNode properties = JsonNodeFactory.instance.objectNode();
         properties.put(topLevelModule.getName() + ":" + schemaNode.getQName().getLocalName(), dataNodeProperties);
         final ObjectNode finalChildSchema = getSchemaTemplate();
@@ -220,12 +223,11 @@ public class ModelGenerator {
             LOG.debug("Processing Identity: {}", identityName);
 
             identityObj.put(ID_KEY, identityName);
-            putIfNonNull(identityObj, DESCRIPTION_KEY, idNode.getDescription());
+            putIfNonNull(identityObj, DESCRIPTION_KEY, idNode.getDescription().orElse(null));
 
             final ObjectNode props = JsonNodeFactory.instance.objectNode();
-            final IdentitySchemaNode baseId = idNode.getBaseIdentity();
 
-            if (baseId == null) {
+            if (idNode.getBaseIdentities().isEmpty()) {
                 /*
                  * This is a base identity. So lets see if it has sub types. If it does, then add them to the model
                  * definition.
@@ -244,7 +246,7 @@ public class ModelGenerator {
                 /*
                  * This is a derived entity. Add it's base type & move on.
                  */
-                props.put(TYPE_KEY, baseId.getQName().getLocalName());
+                props.put(TYPE_KEY, idNode.getBaseIdentities().iterator().next().getQName().getLocalName());
             }
 
             // Add the properties. For a base type, this will be an empty object as required by the Swagger spec.
@@ -332,9 +334,9 @@ public class ModelGenerator {
                     property = processLeafListNode((LeafListSchemaNode) node, schemaContext);
 
                 } else if (node instanceof ChoiceSchemaNode) {
-                    if (((ChoiceSchemaNode) node).getCases().iterator().hasNext()) {
-                        processChoiceNode(((ChoiceSchemaNode) node).getCases().iterator().next().getChildNodes(),
-                                parentName, models, schemaContext, isConfig, properties);
+                    if (((ChoiceSchemaNode) node).getCases().values().iterator().hasNext()) {
+                        processChoiceNode(((ChoiceSchemaNode) node).getCases().values().iterator().next()
+                            .getChildNodes(), parentName, models, schemaContext, isConfig, properties);
                     }
                     continue;
 
@@ -348,7 +350,7 @@ public class ModelGenerator {
                 } else {
                     throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass());
                 }
-                putIfNonNull(property, DESCRIPTION_KEY, node.getDescription());
+                putIfNonNull(property, DESCRIPTION_KEY, node.getDescription().orElse(null));
                 properties.put(topLevelModule.getName() + ":" + name, property);
             }
         }
@@ -361,8 +363,16 @@ public class ModelGenerator {
         props.put(TYPE_KEY, ARRAY_TYPE);
 
         final ObjectNode itemsVal = JsonNodeFactory.instance.objectNode();
-        final ConstraintDefinition constraints = listNode.getConstraints();
-        int max = constraints.getMaxElements() == null ? 2 : constraints.getMaxElements();
+        final Optional<ElementCountConstraint> optConstraint = listNode.getElementCountConstraint();
+        final int max;
+        if (optConstraint.isPresent()) {
+            final Integer constraintMax = optConstraint.get().getMaxElements();
+            max = constraintMax == null ? 2 : constraintMax;
+            processElementCount(optConstraint.get(), props);
+        } else {
+            max = 2;
+        }
+
         if (max >= 2) {
             processTypeDef(listNode.getType(), listNode, itemsVal, schemaContext);
             processTypeDef(listNode.getType(), listNode, itemsVal, schemaContext);
@@ -371,9 +381,6 @@ public class ModelGenerator {
         }
         props.put(ITEMS_KEY, itemsVal);
 
-
-        processConstraints(constraints, props);
-
         return props;
     }
 
@@ -396,8 +403,8 @@ public class ModelGenerator {
                 property = processLeafListNode((LeafListSchemaNode) node, schemaContext);
 
             } else if (node instanceof ChoiceSchemaNode) {
-                if (((ChoiceSchemaNode) node).getCases().iterator().hasNext()) {
-                    processChoiceNode(((ChoiceSchemaNode) node).getCases().iterator().next().getChildNodes(),
+                if (((ChoiceSchemaNode) node).getCases().values().iterator().hasNext()) {
+                    processChoiceNode(((ChoiceSchemaNode) node).getCases().values().iterator().next().getChildNodes(),
                             moduleName, models, schemaContext, isConfig, properties);
                 }
                 continue;
@@ -413,33 +420,33 @@ public class ModelGenerator {
                 throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass());
             }
 
-            putIfNonNull(property, DESCRIPTION_KEY, node.getDescription());
+            putIfNonNull(property, DESCRIPTION_KEY, node.getDescription().orElse(null));
             properties.put(name, property);
         }
     }
 
-    private static void processConstraints(final ConstraintDefinition constraints,
-                                           final ObjectNode props) {
-        final boolean isMandatory = constraints.isMandatory();
-        props.put(REQUIRED_KEY, isMandatory);
-
-        final Integer minElements = constraints.getMinElements();
-        final Integer maxElements = constraints.getMaxElements();
+    private static void processElementCount(final ElementCountConstraint constraint, final ObjectNode props) {
+        final Integer minElements = constraint.getMinElements();
         if (minElements != null) {
             props.put(MIN_ITEMS, minElements);
         }
+        final Integer maxElements = constraint.getMaxElements();
         if (maxElements != null) {
             props.put(MAX_ITEMS, maxElements);
         }
     }
 
+    private static void processMandatory(final MandatoryAware node, final ObjectNode props) {
+        props.put(REQUIRED_KEY, node.isMandatory());
+    }
+
     private ObjectNode processLeafNode(final LeafSchemaNode leafNode,
                                        final SchemaContext schemaContext) {
         final ObjectNode property = JsonNodeFactory.instance.objectNode();
 
-        final String leafDescription = leafNode.getDescription();
+        final String leafDescription = leafNode.getDescription().orElse(null);
         putIfNonNull(property, DESCRIPTION_KEY, leafDescription);
-        processConstraints(leafNode.getConstraints(), property);
+        processMandatory(leafNode, property);
         processTypeDef(leafNode.getType(), leafNode, property, schemaContext);
 
         return property;
@@ -448,10 +455,10 @@ public class ModelGenerator {
     private static ObjectNode processAnyXMLNode(final AnyXmlSchemaNode leafNode) {
         final ObjectNode property = JsonNodeFactory.instance.objectNode();
 
-        final String leafDescription = leafNode.getDescription();
+        final String leafDescription = leafNode.getDescription().orElse(null);
         putIfNonNull(property, DESCRIPTION_KEY, leafDescription);
 
-        processConstraints(leafNode.getConstraints(), property);
+        processMandatory(leafNode, property);
         final String localName = leafNode.getQName().getLocalName();
         property.put(TYPE_KEY, "example of anyxml " + localName);
 
@@ -473,8 +480,8 @@ public class ModelGenerator {
 
             } else if (leafTypeDef instanceof IdentityrefTypeDefinition) {
                 final String name = topLevelModule.getName();
-                jsonType =
-                        name + ":" + ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName();
+                jsonType = name + ":" + ((IdentityrefTypeDefinition) leafTypeDef).getIdentities().iterator().next()
+                        .getQName().getLocalName();
 
             } else if (leafTypeDef instanceof StringTypeDefinition) {
                 jsonType = processStringType(leafTypeDef, property, node.getQName().getLocalName());
@@ -491,17 +498,11 @@ public class ModelGenerator {
             } else if (leafTypeDef instanceof BooleanTypeDefinition) {
                 jsonType = "true";
 
-            } else if (leafTypeDef instanceof DecimalTypeDefinition) {
-                jsonType = String.valueOf(((DecimalTypeDefinition) leafTypeDef).getRangeConstraints()
-                        .iterator().next().getMin());
-
-            } else if (leafTypeDef instanceof IntegerTypeDefinition) {
-                jsonType = String.valueOf(((IntegerTypeDefinition) leafTypeDef).getRangeConstraints()
-                        .iterator().next().getMin());
-
-            } else if (leafTypeDef instanceof UnsignedIntegerTypeDefinition) {
-                jsonType = String.valueOf(((UnsignedIntegerTypeDefinition) leafTypeDef).getRangeConstraints()
-                        .iterator().next().getMin());
+            } else if (leafTypeDef instanceof RangeRestrictedTypeDefinition) {
+                final Number maybeLower = ((RangeRestrictedTypeDefinition<?, ?>) leafTypeDef).getRangeConstraint()
+                        .map(RangeConstraint::getAllowedRanges).map(RangeSet::span).map(Range::lowerEndpoint)
+                        .orElse(null);
+                jsonType = String.valueOf(maybeLower);
 
             } else {
                 jsonType = OBJECT_TYPE;
@@ -531,13 +532,12 @@ public class ModelGenerator {
             schemaNode = SchemaContextUtil.findDataSchemaNodeForRelativeXPath(schemaContext, module, node, xpath);
         }
 
-        return processTypeDef(((TypedSchemaNode) schemaNode).getType(), (DataSchemaNode) schemaNode,
+        return processTypeDef(((TypedDataSchemaNode) schemaNode).getType(), (DataSchemaNode) schemaNode,
                 property, schemaContext);
     }
 
     private static Module findModule(final SchemaContext schemaContext, final QName qualifiedName) {
-        return schemaContext
-                .findModuleByNamespaceAndRevision(qualifiedName.getNamespace(), qualifiedName.getRevision());
+        return schemaContext.findModule(qualifiedName.getNamespace(), qualifiedName.getRevision()).orElse(null);
     }
 
     private static String processBinaryType(final ObjectNode property) {
@@ -576,23 +576,21 @@ public class ModelGenerator {
     private static String processStringType(final TypeDefinition<?> stringType,
                                             final ObjectNode property, final String nodeName) {
         StringTypeDefinition type = (StringTypeDefinition) stringType;
-        List<LengthConstraint> lengthConstraints = ((StringTypeDefinition) stringType).getLengthConstraints();
-        while (lengthConstraints.isEmpty() && type.getBaseType() != null) {
+        Optional<LengthConstraint> lengthConstraints = ((StringTypeDefinition) stringType).getLengthConstraint();
+        while (!lengthConstraints.isPresent() && type.getBaseType() != null) {
             type = type.getBaseType();
-            lengthConstraints = type.getLengthConstraints();
+            lengthConstraints = type.getLengthConstraint();
         }
 
-        // FIXME: json-schema is not expressive enough to capture min/max laternatives. We should find the true minimum
-        //        and true maximum implied by the constraints and use that.
-        for (final LengthConstraint lengthConstraint : lengthConstraints) {
-            final Number min = lengthConstraint.getMin();
-            final Number max = lengthConstraint.getMax();
-            putIfNonNull(property, MIN_LENGTH_KEY, min);
-            putIfNonNull(property, MAX_LENGTH_KEY, max);
+        if (lengthConstraints.isPresent()) {
+            final Range<Integer> range = lengthConstraints.get().getAllowedRanges().span();
+            putIfNonNull(property, MIN_LENGTH_KEY, range.lowerEndpoint());
+            putIfNonNull(property, MAX_LENGTH_KEY, range.upperEndpoint());
         }
+
         if (type.getPatternConstraints().iterator().hasNext()) {
             final PatternConstraint pattern = type.getPatternConstraints().iterator().next();
-            String regex = pattern.getRegularExpression();
+            String regex = pattern.getJavaPatternString();
             regex = regex.substring(1, regex.length() - 1);
             final Generex generex = new Generex(regex);
             return generex.random();
@@ -621,7 +619,7 @@ public class ModelGenerator {
         return schemaJSON;
     }
 
-    private static void putIfNonNull(ObjectNode property, String key, Number number) {
+    private static void putIfNonNull(final ObjectNode property, final String key, final Number number) {
         if (key != null && number != null) {
             if (number instanceof Double) {
                 property.put(key, (Double) number);
@@ -637,7 +635,7 @@ public class ModelGenerator {
         }
     }
 
-    private static void putIfNonNull(ObjectNode property, String key, String value) {
+    private static void putIfNonNull(final ObjectNode property, final String key, final String value) {
         if (key != null && value != null) {
             property.put(key, value);
         }
index bb14d5a593e75eaac73569cb9cf652f3547b5210..4a4eba98d1d2bc51d09b9cbeeb982b8076c31727 100644 (file)
@@ -29,6 +29,10 @@ public final class OperationBuilder {
         CONSUMES_PUT_POST.add("application/xml");
     }
 
+    private OperationBuilder() {
+
+    }
+
     public static class Get {
 
         protected Operation spec;
@@ -41,7 +45,7 @@ public final class OperationBuilder {
             spec.setMethod(METHOD_NAME);
             spec.setNickname(METHOD_NAME + "-" + node.getQName().getLocalName());
             spec.setType((isConfig ? CONFIG : OPERATIONAL) + node.getQName().getLocalName());
-            spec.setNotes(node.getDescription());
+            spec.setNotes(node.getDescription().orElse(null));
         }
 
         public Get pathParams(final List<Parameter> params) {
index 6c21c267af9889dcbfaeba4f3c54800652fba48e..1fa3a01dc3922a7f478c54756580d5b0222b26e7 100644 (file)
@@ -8,21 +8,22 @@
 package org.opendaylight.netconf.sal.rest.doc.util;
 
 import java.net.URI;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-public class RestDocgenUtil {
+public final class RestDocgenUtil {
 
     private RestDocgenUtil() {
     }
 
-    private static final Map<URI, Map<Date, Module>> NAMESPACE_AND_REVISION_TO_MODULE = new HashMap<>();
+    private static final Map<URI, Map<Optional<Revision>, Module>> NAMESPACE_AND_REVISION_TO_MODULE = new HashMap<>();
 
     /**
      * Resolve path argument name for {@code node}.
@@ -52,16 +53,16 @@ public class RestDocgenUtil {
     private static synchronized String resolveFullNameFromNode(final SchemaNode node,
             final SchemaContext schemaContext) {
         final URI namespace = node.getQName().getNamespace();
-        final Date revision = node.getQName().getRevision();
+        final Optional<Revision> revision = node.getQName().getRevision();
 
-        Map<Date, Module> revisionToModule = NAMESPACE_AND_REVISION_TO_MODULE.get(namespace);
+        Map<Optional<Revision>, Module> revisionToModule = NAMESPACE_AND_REVISION_TO_MODULE.get(namespace);
         if (revisionToModule == null) {
             revisionToModule = new HashMap<>();
             NAMESPACE_AND_REVISION_TO_MODULE.put(namespace, revisionToModule);
         }
         Module module = revisionToModule.get(revision);
         if (module == null) {
-            module = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
+            module = schemaContext.findModule(namespace, revision).orElse(null);
             revisionToModule.put(revision, module);
         }
         if (module != null) {
index a8196dac47d562035afaa33cfa15d626e9e8c122..1c48480a830070f0aac00c49fc30dfb4db1053f0 100644 (file)
@@ -19,18 +19,15 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class DocGenTestHelper {
@@ -39,8 +36,7 @@ public class DocGenTestHelper {
     private ObjectMapper mapper;
     private SchemaContext schemaContext;
 
-    public Set<Module> loadModules(final String resourceDirectory)
-            throws URISyntaxException, FileNotFoundException, ReactorException {
+    public Set<Module> loadModules(final String resourceDirectory) throws URISyntaxException, FileNotFoundException {
 
         final URI resourceDirUri = getClass().getResource(resourceDirectory).toURI();
         final File testDir = new File(resourceDirUri);
@@ -53,7 +49,7 @@ public class DocGenTestHelper {
             files.add(new File(testDir, fileName));
         }
 
-        this.schemaContext = YangParserTestUtils.parseYangSources(files);
+        this.schemaContext = YangParserTestUtils.parseYangFiles(files);
         return this.schemaContext.getModules();
     }
 
@@ -90,36 +86,30 @@ public class DocGenTestHelper {
         when(mockContext.getModules()).thenReturn(this.modules);
 
         final ArgumentCaptor<String> moduleCapture = ArgumentCaptor.forClass(String.class);
-        final ArgumentCaptor<Date> dateCapture = ArgumentCaptor.forClass(Date.class);
+        final ArgumentCaptor<Optional> dateCapture = ArgumentCaptor.forClass(Optional.class);
         final ArgumentCaptor<URI> namespaceCapture = ArgumentCaptor.forClass(URI.class);
-        when(mockContext.findModuleByName(moduleCapture.capture(), dateCapture.capture())).then(
-                new Answer<Module>() {
-                    @Override
-                    public Module answer(final InvocationOnMock invocation) throws Throwable {
-                        final String module = moduleCapture.getValue();
-                        final Date date = dateCapture.getValue();
-                        for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
-                            if (m.getName().equals(module) && m.getRevision().equals(date)) {
-                                return m;
-                            }
-                        }
-                        return null;
+        when(mockContext.findModule(moduleCapture.capture(), dateCapture.capture())).then(
+            invocation -> {
+                final String module = moduleCapture.getValue();
+                final Optional<?> date = dateCapture.getValue();
+                for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
+                    if (m.getName().equals(module) && m.getRevision().equals(date)) {
+                        return Optional.of(m);
                     }
-                });
-        when(mockContext.findModuleByNamespaceAndRevision(namespaceCapture.capture(), dateCapture.capture())).then(
-                new Answer<Module>() {
-                    @Override
-                    public Module answer(final InvocationOnMock invocation) throws Throwable {
-                        final URI namespace = namespaceCapture.getValue();
-                        final Date date = dateCapture.getValue();
-                        for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
-                            if (m.getNamespace().equals(namespace) && m.getRevision().equals(date)) {
-                                return m;
-                            }
-                        }
-                        return null;
+                }
+                return Optional.empty();
+            });
+        when(mockContext.findModule(namespaceCapture.capture(), dateCapture.capture())).then(
+            invocation -> {
+                final URI namespace = namespaceCapture.getValue();
+                final Optional<?> date = dateCapture.getValue();
+                for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
+                    if (m.getNamespace().equals(namespace) && m.getRevision().equals(date)) {
+                        return Optional.of(m);
                     }
-                });
+                }
+                return Optional.empty();
+            });
         return mockContext;
     }
 
@@ -130,12 +120,7 @@ public class DocGenTestHelper {
 
         final ArgumentCaptor<String> subStringCapture = ArgumentCaptor.forClass(String.class);
         when(mockBuilder.path(subStringCapture.capture())).thenReturn(mockBuilder);
-        when(mockBuilder.build()).then(new Answer<URI>() {
-            @Override
-            public URI answer(final InvocationOnMock invocation) throws Throwable {
-                return URI.create(uri + "/" + subStringCapture.getValue());
-            }
-        });
+        when(mockBuilder.build()).then(invocation -> URI.create(uri + "/" + subStringCapture.getValue()));
 
         final UriInfo info = mock(UriInfo.class);
 
index a8c9bebecc46d699268b064262895968103daa53..2ee9a9025587f00e09b9fb6fb67eab40eaae6dc8 100644 (file)
@@ -38,9 +38,9 @@ public class MountPointSwaggerTest {
 
     private static final String HTTP_URL = "http://localhost/path";
     private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder()
-            .node(QName.create("nodes"))
-            .node(QName.create("node"))
-            .nodeWithKey(QName.create("node"), QName.create("id"), "123").build();
+            .node(QName.create("", "nodes"))
+            .node(QName.create("", "node"))
+            .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build();
     private static final String INSTANCE_URL = "/nodes/node/123/";
     private MountPointSwagger swagger;
     private DocGenTestHelper helper;
index 4db7897a99ac4b9837686c5862f47add5581f6e8..05056e905a4bef83202a872e68babaf64d84fa15 100644 (file)
@@ -8,7 +8,7 @@ module toaster-augmented {
     prefix toast;
     import toaster2 {prefix tst; revision-date 2009-11-20;}
 
-    revision "2014-7-14" {
+    revision "2014-07-14" {
     }
 
     augment "/tst:toaster/tst:toasterSlot" {
@@ -18,4 +18,4 @@ module toaster-augmented {
             }
         }
     }
-}
\ No newline at end of file
+}