diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-04-12 10:13:18 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-04-12 10:13:18 +0200 |
commit | e1743c8eccee7d5ea8ad2c247d2575e8fd219fe4 (patch) | |
tree | 285ad26e1e5bff6ef9ff8fdd7a77bd971dfd50ca | |
parent | c7ca517b00f2682987aef3ac390dfc04155a8aee (diff) |
HONEYCOMB-9: Remove references to VPP from translation layer
Change-Id: I281db366a112edc08203e8cb392a212708d4552a
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
-rw-r--r-- | v3po/artifacts/pom.xml | 13 | ||||
-rw-r--r-- | v3po/features/pom.xml | 13 | ||||
-rw-r--r-- | v3po/features/src/main/features/features.xml | 9 | ||||
-rw-r--r-- | v3po/impl/pom.xml | 2 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java | 8 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/ReaderRegistry.java (renamed from v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java) | 59 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java | 19 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java | 6 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java | 6 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java | 8 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java | 4 | ||||
-rw-r--r-- | v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/WriterRegistry.java (renamed from v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriterRegistry.java) | 55 | ||||
-rw-r--r-- | v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java | 31 | ||||
-rw-r--r-- | v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java | 4 | ||||
-rw-r--r-- | v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java | 8 | ||||
-rw-r--r-- | v3po/pom.xml | 9 | ||||
-rw-r--r-- | v3po/translate-api/pom.xml (renamed from v3po/vpp-facade-api/pom.xml) | 2 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/Context.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java) | 2 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/SubtreeManager.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java) | 2 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/TranslationException.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java) | 12 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/VppApiInvocationException.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java) | 4 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ChildReader.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java) | 6 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java) | 6 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadContext.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java) | 4 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadFailedException.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java) | 8 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/Reader.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java) | 10 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReaderRegistry.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java) | 4 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ChildWriter.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java) | 8 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteContext.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java) | 4 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java) | 14 | ||||
-rw-r--r-- | v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java (renamed from v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java) | 16 | ||||
-rw-r--r-- | v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/ReadFailedExceptionTest.java (renamed from v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java) | 11 | ||||
-rw-r--r-- | v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/VppApiInvocationExceptionTest.java (renamed from v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java) | 2 | ||||
-rw-r--r-- | v3po/translate-impl/pom.xml (renamed from v3po/vpp-facade-impl/pom.xml) | 10 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/AbstractCompositeReader.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/AbstractCompositeVppReader.java) | 50 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeChildReader.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeChildVppReader.java) | 50 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeListVppReader.java) | 58 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeRootReader.java | 91 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/AbstractCompositeVppWriter.java) | 86 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeChildVppWriter.java) | 44 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeListVppWriter.java) | 47 | ||||
-rw-r--r-- | v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java (renamed from v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeRootVppWriter.java) | 36 | ||||
-rw-r--r-- | v3po/translate-spi/pom.xml (renamed from v3po/vpp-facade-spi/pom.xml) | 4 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ChildReaderCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ChildVppReaderCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ListReaderCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ListVppReaderCustomizer.java) | 10 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/RootReaderCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/RootVppReaderCustomizer.java) | 10 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ChildWriterCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ChildVppWriterCustomizer.java) | 6 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ListWriterCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ListVppWriterCustomizer.java) | 7 | ||||
-rw-r--r-- | v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/RootWriterCustomizer.java (renamed from v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/RootVppWriterCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-utils/pom.xml (renamed from v3po/vpp-facade-utils/pom.xml) | 11 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppRWUtils.java) | 38 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/ReflectionUtils.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/ReflectionUtils.java) | 2 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/DelegatingReaderRegistry.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/DelegatingReaderRegistry.java) | 34 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/NoopReaderCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/NoopReaderCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveChildReaderCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveChildReaderCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveRootReaderCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveRootReaderCustomizer.java) | 2 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/DelegatingWriterRegistry.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistry.java) | 30 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/NoopWriterCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/ReflexiveChildWriterCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/ReflexiveChildWriterCustomizer.java) | 8 | ||||
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContext.java) | 6 | ||||
-rw-r--r-- | v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/DelegatingWriterRegistryTest.java (renamed from v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java) | 41 | ||||
-rw-r--r-- | v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java (renamed from v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java) | 5 | ||||
-rw-r--r-- | v3po/v3po2vpp/pom.xml | 11 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java (renamed from v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizer.java) | 10 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java (renamed from v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/BridgeDomainCustomizer.java) | 10 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java (renamed from v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VersionCustomizer.java) | 10 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizerTest.java) | 69 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainTestUtils.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainTestUtils.java) | 2 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppTest.java) | 19 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppUtils.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppUtils.java) | 30 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateTest.java) | 18 | ||||
-rw-r--r-- | v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateUtils.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateUtils.java) | 36 | ||||
-rw-r--r-- | v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeRootVppReader.java | 91 | ||||
-rw-r--r-- | v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java | 189 | ||||
-rw-r--r-- | v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java | 138 | ||||
-rw-r--r-- | v3po/vpp-translate-utils/pom.xml | 57 | ||||
-rw-r--r-- | v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/VppApiCustomizer.java (renamed from v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppApiCustomizer.java) | 2 |
77 files changed, 762 insertions, 1025 deletions
diff --git a/v3po/artifacts/pom.xml b/v3po/artifacts/pom.xml index cdfb7c27f..1764b675f 100644 --- a/v3po/artifacts/pom.xml +++ b/v3po/artifacts/pom.xml @@ -31,22 +31,27 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-impl</artifactId> + <artifactId>translate-impl</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-utils</artifactId> + <artifactId>translate-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vpp-translate-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/v3po/features/pom.xml b/v3po/features/pom.xml index 142d803c1..810cec5e0 100644 --- a/v3po/features/pom.xml +++ b/v3po/features/pom.xml @@ -135,22 +135,27 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-impl</artifactId> + <artifactId>translate-impl</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-utils</artifactId> + <artifactId>translate-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vpp-translate-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/v3po/features/src/main/features/features.xml b/v3po/features/src/main/features/features.xml index cea5999ae..1f5237876 100644 --- a/v3po/features/src/main/features/features.xml +++ b/v3po/features/src/main/features/features.xml @@ -35,10 +35,11 @@ <feature version='${netconf.version}'>odl-netconf-connector-ssh</feature> <feature version='${mdsal.version}'>odl-netconf-mdsal</feature> <bundle>mvn:io.fd.honeycomb.v3po/v3po-impl/${project.version}</bundle> - <bundle>mvn:io.fd.honeycomb.v3po/vpp-facade-api/${project.version}</bundle> - <bundle>mvn:io.fd.honeycomb.v3po/vpp-facade-spi/${project.version}</bundle> - <bundle>mvn:io.fd.honeycomb.v3po/vpp-facade-utils/${project.version}</bundle> - <bundle>mvn:io.fd.honeycomb.v3po/vpp-facade-impl/${project.version}</bundle> + <bundle>mvn:io.fd.honeycomb.v3po/translate-api/${project.version}</bundle> + <bundle>mvn:io.fd.honeycomb.v3po/translate-spi/${project.version}</bundle> + <bundle>mvn:io.fd.honeycomb.v3po/translate-utils/${project.version}</bundle> + <bundle>mvn:io.fd.honeycomb.v3po/vpp-translate-utils/${project.version}</bundle> + <bundle>mvn:io.fd.honeycomb.v3po/translate-impl/${project.version}</bundle> <bundle>mvn:io.fd.honeycomb.v3po/v3po2vpp/${project.version}</bundle> <bundle>wrap:mvn:io.fd.vpp/vppjapi/1.0.0-SNAPSHOT</bundle> <configfile finalname="${configfile.directory}/v3po.xml">mvn:io.fd.honeycomb.v3po/v3po-impl/${project.version}/xml/config</configfile> diff --git a/v3po/impl/pom.xml b/v3po/impl/pom.xml index a8109a888..56dcf8555 100644 --- a/v3po/impl/pom.xml +++ b/v3po/impl/pom.xml @@ -36,7 +36,7 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-impl</artifactId> + <artifactId>translate-impl</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java index 931ecefd6..0ea4525f0 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java @@ -21,8 +21,8 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import io.fd.honeycomb.v3po.impl.data.VppDataBrokerInitializationProvider; -import io.fd.honeycomb.v3po.impl.data.VppReaderRegistry; -import io.fd.honeycomb.v3po.impl.data.VppWriterRegistry; +import io.fd.honeycomb.v3po.impl.data.ReaderRegistry; +import io.fd.honeycomb.v3po.impl.data.WriterRegistry; import java.io.IOException; import java.util.Collections; import java.util.HashMap; @@ -196,8 +196,8 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker vppPollOperData); startOperationalUpdateTimer(); - final VppReaderRegistry readerRegistry = VppReaderRegistry.getInstance(api); - final VppWriterRegistry writerRegistry = VppWriterRegistry.getInstance(api); + final ReaderRegistry readerRegistry = ReaderRegistry.getInstance(api); + final WriterRegistry writerRegistry = WriterRegistry.getInstance(api); // TODO make configurable: vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry); diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/ReaderRegistry.java index ba1865494..5e547094f 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/ReaderRegistry.java @@ -18,20 +18,19 @@ package io.fd.honeycomb.v3po.impl.data; import com.google.common.base.Optional; import com.google.common.collect.Multimap; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeListVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeRootVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.DelegatingReaderRegistry; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.ReflexiveChildReaderCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.ReflexiveRootReaderCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; -import io.fd.honeycomb.v3po.vpp.facade.read.VppReader; -import io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate.BridgeDomainCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate.VersionCustomizer; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeRootReader; +import io.fd.honeycomb.v3po.translate.util.read.DelegatingReaderRegistry; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveRootReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.Reader; +import io.fd.honeycomb.v3po.translate.v3po.vppstate.BridgeDomainCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.vppstate.VersionCustomizer; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -50,47 +49,47 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.openvpp.vppjapi.vppApi; // TODO use some DI framework instead of singleton -public class VppReaderRegistry implements ReaderRegistry { +public class ReaderRegistry implements io.fd.honeycomb.v3po.translate.read.ReaderRegistry { - private static VppReaderRegistry instance; + private static ReaderRegistry instance; private final DelegatingReaderRegistry reader; - private VppReaderRegistry(@Nonnull final vppApi vppApi) { - final CompositeRootVppReader<VppState, VppStateBuilder> vppStateReader = initVppStateReader(vppApi); + private ReaderRegistry(@Nonnull final vppApi vppApi) { + final CompositeRootReader<VppState, VppStateBuilder> vppStateReader = initVppStateReader(vppApi); // TODO add more root readers - reader = new DelegatingReaderRegistry(Collections.<VppReader<? extends DataObject>>singletonList(vppStateReader)); + reader = new DelegatingReaderRegistry(Collections.<Reader<? extends DataObject>>singletonList(vppStateReader)); } - private static CompositeRootVppReader<VppState, VppStateBuilder> initVppStateReader(@Nonnull final vppApi vppApi) { + private static CompositeRootReader<VppState, VppStateBuilder> initVppStateReader(@Nonnull final vppApi vppApi) { - final ChildVppReader<Version> versionReader = new CompositeChildVppReader<>( + final ChildReader<Version> versionReader = new CompositeChildReader<>( Version.class, new VersionCustomizer(vppApi)); - final CompositeListVppReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> - bridgeDomainReader = new CompositeListVppReader<>( + final CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> + bridgeDomainReader = new CompositeListReader<>( BridgeDomain.class, new BridgeDomainCustomizer(vppApi)); - final ChildVppReader<BridgeDomains> bridgeDomainsReader = new CompositeChildVppReader<>( + final ChildReader<BridgeDomains> bridgeDomainsReader = new CompositeChildReader<>( BridgeDomains.class, - VppRWUtils.singletonChildReaderList(bridgeDomainReader), + RWUtils.singletonChildReaderList(bridgeDomainReader), new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class)); - final List<ChildVppReader<? extends ChildOf<VppState>>> childVppReaders = new ArrayList<>(); + final List<ChildReader<? extends ChildOf<VppState>>> childVppReaders = new ArrayList<>(); childVppReaders.add(versionReader); childVppReaders.add(bridgeDomainsReader); - return new CompositeRootVppReader<>( + return new CompositeRootReader<>( VppState.class, childVppReaders, - VppRWUtils.<VppState>emptyAugReaderList(), + RWUtils.<VppState>emptyAugReaderList(), new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class)); } - public static synchronized VppReaderRegistry getInstance(@Nonnull final vppApi vppApi) { + public static synchronized ReaderRegistry getInstance(@Nonnull final vppApi vppApi) { if (instance == null) { - instance = new VppReaderRegistry(vppApi); + instance = new ReaderRegistry(vppApi); } return instance; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java index 72848ad0f..1a631fc2e 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java @@ -21,10 +21,9 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.TransactionWriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.util.write.TransactionWriteContext; +import io.fd.honeycomb.v3po.translate.write.WriteContext; import java.util.Collections; import java.util.Map; import javax.annotation.Nonnull; @@ -54,7 +53,7 @@ public final class VppConfigDataTree implements VppDataTree { private final BindingNormalizedNodeSerializer serializer; private final DataTree dataTree; - private final VppWriterRegistry writer; + private final WriterRegistry writer; public static final ReadableVppDataTree EMPTY_OPERATIONAL = new ReadableVppDataTree() { @Override public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read( @@ -72,7 +71,7 @@ public final class VppConfigDataTree implements VppDataTree { * @param vppWriter service for translation between Java Binding Data and Vpp. */ public VppConfigDataTree(@Nonnull final BindingNormalizedNodeSerializer serializer, - @Nonnull final DataTree dataTree, @Nonnull final VppWriterRegistry vppWriter) { + @Nonnull final DataTree dataTree, @Nonnull final WriterRegistry vppWriter) { this.serializer = checkNotNull(serializer, "serializer should not be null"); this.dataTree = checkNotNull(dataTree, "dataTree should not be null"); this.writer = checkNotNull(vppWriter, "vppWriter should not be null"); @@ -85,7 +84,7 @@ public final class VppConfigDataTree implements VppDataTree { @Override public void commit(final DataTreeModification modification) - throws DataValidationFailedException, VppException { + throws DataValidationFailedException, TranslationException { dataTree.validate(modification); final DataTreeCandidate candidate = dataTree.prepare(modification); @@ -109,21 +108,21 @@ public final class VppConfigDataTree implements VppDataTree { final DOMDataReadOnlyTransaction afterTx = new VppReadOnlyTransaction(EMPTY_OPERATIONAL, modificationSnapshot); try(final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) { writer.update(nodesBefore, nodesAfter, ctx); - } catch (WriterRegistry.BulkUpdateException e) { + } catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException e) { LOG.warn("Failed to apply all changes", e); LOG.info("Trying to revert successful changes for current transaction"); try { e.revertChanges(); LOG.info("Changes successfully reverted"); - } catch (WriterRegistry.Reverter.RevertFailedException revertFailedException) { + } catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.RevertFailedException revertFailedException) { // fail with failed revert LOG.error("Failed to revert successful changes", revertFailedException); throw revertFailedException; } throw e; // fail with success revert - } catch (VppException e) { + } catch (TranslationException e) { LOG.error("Error while processing data change (before={}, after={})", nodesBefore, nodesAfter, e); throw e; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java index d84f0b7b7..bdfc89079 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java @@ -24,7 +24,7 @@ import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import io.fd.honeycomb.v3po.impl.LoggingFuturesCallBack; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; +import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import java.util.Collection; import java.util.Collections; import javassist.ClassPool; @@ -85,13 +85,13 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto private final DataBroker bindingBroker; private final ReaderRegistry readerRegistry; private final InstanceIdentifier<Node> mountPointPath; - private final VppWriterRegistry writerRegistry; + private final WriterRegistry writerRegistry; private ObjectRegistration<DOMMountPoint> mountPointRegistration; private DOMDataBroker broker; public VppDataBrokerInitializationProvider(@Nonnull final DataBroker bindingBroker, final ReaderRegistry readerRegistry, - final VppWriterRegistry writerRegistry) { + final WriterRegistry writerRegistry) { this.bindingBroker = checkNotNull(bindingBroker, "bindingBroker should not be null"); this.readerRegistry = checkNotNull(readerRegistry, "readerRegistry should not be null"); this.writerRegistry = checkNotNull(writerRegistry, "writerRegistry should not be null"); diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java index 7e62b57b0..aba8ab133 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java @@ -17,7 +17,7 @@ package io.fd.honeycomb.v3po.impl.data; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.VppException; +import io.fd.honeycomb.v3po.translate.TranslationException; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; @@ -31,9 +31,9 @@ public interface VppDataTree { * * @param modification VPP data tree modification * @throws DataValidationFailedException if modification data is not valid - * @throws VppException if commit failed while updating VPP state + * @throws TranslationException if commit failed while updating VPP state */ - void commit(final DataTreeModification modification) throws DataValidationFailedException, VppException; + void commit(final DataTreeModification modification) throws DataValidationFailedException, TranslationException; /** * Creates read-only snapshot of a VppDataTree. diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java index 12d281611..8f606fdbf 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java @@ -26,10 +26,10 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; +import io.fd.honeycomb.v3po.translate.Context; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import java.util.Collection; import java.util.Map; import javax.annotation.Nonnull; diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java index 1baa586b1..b33fffa68 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java @@ -26,7 +26,7 @@ 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 io.fd.honeycomb.v3po.vpp.facade.VppException; +import io.fd.honeycomb.v3po.translate.TranslationException; import javax.annotation.Nonnull; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; @@ -121,7 +121,7 @@ final class VppWriteTransaction implements DOMDataWriteTransaction { try { configDataTree.commit(modification); status = COMMITED; - } catch (DataValidationFailedException | VppException e) { + } catch (DataValidationFailedException | TranslationException e) { status = FAILED; LOG.error("Failed to commit VPP state modification", e); return Futures.immediateFailedCheckedFuture( diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriterRegistry.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/WriterRegistry.java index 04b4bd631..00dc22520 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriterRegistry.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/WriterRegistry.java @@ -16,19 +16,18 @@ package io.fd.honeycomb.v3po.impl.data; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeListVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeRootVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.DelegatingWriterRegistry; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.NoopWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.ReflexiveChildWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeChildWriter; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeListWriter; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeRootWriter; +import io.fd.honeycomb.v3po.translate.util.write.DelegatingWriterRegistry; +import io.fd.honeycomb.v3po.translate.util.write.NoopWriterCustomizer; +import io.fd.honeycomb.v3po.translate.util.write.ReflexiveChildWriterCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.vpp.BridgeDomainCustomizer; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.write.Writer; +import io.fd.honeycomb.v3po.translate.write.WriteContext; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -45,39 +44,39 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.openvpp.vppjapi.vppApi; // TODO use some DI framework instead of singleton -public class VppWriterRegistry implements WriterRegistry { +public class WriterRegistry implements io.fd.honeycomb.v3po.translate.write.WriterRegistry { - private static VppWriterRegistry instance; + private static WriterRegistry instance; private final DelegatingWriterRegistry writer; - private VppWriterRegistry(@Nonnull final vppApi vppApi) { - final CompositeRootVppWriter<Vpp> vppWriter = initVppStateWriter(vppApi); - writer = new DelegatingWriterRegistry(Collections.<VppWriter<? extends DataObject>>singletonList(vppWriter)); + private WriterRegistry(@Nonnull final vppApi vppApi) { + final CompositeRootWriter<Vpp> vppWriter = initVppStateWriter(vppApi); + writer = new DelegatingWriterRegistry(Collections.<Writer<? extends DataObject>>singletonList(vppWriter)); } - private static CompositeRootVppWriter<Vpp> initVppStateWriter(@Nonnull final vppApi vppApi) { - final CompositeListVppWriter<BridgeDomain, BridgeDomainKey> bridgeDomainWriter = new CompositeListVppWriter<>( + private static CompositeRootWriter<Vpp> initVppStateWriter(@Nonnull final vppApi vppApi) { + final CompositeListWriter<BridgeDomain, BridgeDomainKey> bridgeDomainWriter = new CompositeListWriter<>( BridgeDomain.class, new BridgeDomainCustomizer(vppApi)); - final ChildVppWriter<BridgeDomains> bridgeDomainsWriter = new CompositeChildVppWriter<>( + final ChildWriter<BridgeDomains> bridgeDomainsWriter = new CompositeChildWriter<>( BridgeDomains.class, - VppRWUtils.singletonChildWriterList(bridgeDomainWriter), + RWUtils.singletonChildWriterList(bridgeDomainWriter), new ReflexiveChildWriterCustomizer<BridgeDomains>()); - final List<ChildVppWriter<? extends ChildOf<Vpp>>> childWriters = new ArrayList<>(); + final List<ChildWriter<? extends ChildOf<Vpp>>> childWriters = new ArrayList<>(); childWriters.add(bridgeDomainsWriter); - return new CompositeRootVppWriter<>( + return new CompositeRootWriter<>( Vpp.class, childWriters, new NoopWriterCustomizer<Vpp>()); } - public static synchronized VppWriterRegistry getInstance(@Nonnull final vppApi vppApi) { + public static synchronized WriterRegistry getInstance(@Nonnull final vppApi vppApi) { if (instance == null) { - instance = new VppWriterRegistry(vppApi); + instance = new WriterRegistry(vppApi); } return instance; } @@ -91,7 +90,7 @@ public class VppWriterRegistry implements WriterRegistry { @Override public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, - @Nullable final DataObject data, @Nonnull final WriteContext ctx) throws VppException { + @Nullable final DataObject data, @Nonnull final WriteContext ctx) throws TranslationException { writer.update(id, dataBefore, data, ctx); } @@ -99,7 +98,7 @@ public class VppWriterRegistry implements WriterRegistry { public void update(@Nonnull final Map<InstanceIdentifier<?>, DataObject> dataBefore, @Nonnull final Map<InstanceIdentifier<?>, DataObject> dataAfter, @Nonnull final WriteContext ctx) - throws VppException { + throws TranslationException { writer.update(dataBefore, dataAfter, ctx); } } diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java index 207a64a99..c4315cd38 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java @@ -31,9 +31,8 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.write.WriteContext; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -60,7 +59,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; public class VPPConfigDataTreeTest { @Mock - private VppWriterRegistry vppWriter; + private WriterRegistry vppWriter; @Mock private BindingNormalizedNodeSerializer serializer; @Mock @@ -156,11 +155,12 @@ public class VPPConfigDataTreeTest { final DataObject dataBefore = mockDataObject("before", Ethernet.class); final DataObject dataAfter = mockDataObject("after", Ethernet.class); - final WriterRegistry.Reverter reverter = mock(WriterRegistry.Reverter.class); + final io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter reverter = mock( + io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.class); // Fail on update: - final VppException failedOnUpdateException = new VppException("update failed"); - doThrow(new WriterRegistry.BulkUpdateException(InstanceIdentifier.create(Ethernet.class), reverter, + final TranslationException failedOnUpdateException = new TranslationException("update failed"); + doThrow(new io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException(InstanceIdentifier.create(Ethernet.class), reverter, failedOnUpdateException)).when(vppWriter).update(anyMap(), anyMap(), any(WriteContext.class)); // Prepare modification: @@ -175,7 +175,7 @@ public class VPPConfigDataTreeTest { // Run the test try { proxy.commit(modification); - } catch (WriterRegistry.BulkUpdateException e) { + } catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException e) { verify(vppWriter).update(anyMap(), anyMap(), any(WriteContext.class)); verify(reverter).revert(); assertEquals(failedOnUpdateException, e.getCause()); @@ -191,16 +191,17 @@ public class VPPConfigDataTreeTest { final DataObject dataBefore = mockDataObject("before", Ethernet.class); final DataObject dataAfter = mockDataObject("after", Ethernet.class); - final WriterRegistry.Reverter reverter = mock(WriterRegistry.Reverter.class); + final io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter reverter = mock( + io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.class); // Fail on update: - doThrow(new WriterRegistry.BulkUpdateException(InstanceIdentifier.create(Ethernet.class), reverter, - new VppException("update failed"))).when(vppWriter).update(anyMap(), anyMap(), any(WriteContext.class)); + doThrow(new io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException(InstanceIdentifier.create(Ethernet.class), reverter, + new TranslationException("update failed"))).when(vppWriter).update(anyMap(), anyMap(), any(WriteContext.class)); // Fail on revert: - final VppException failedOnRevertException = new VppException("update failed"); - final WriterRegistry.Reverter.RevertFailedException revertFailedException = - new WriterRegistry.Reverter.RevertFailedException(Collections.<InstanceIdentifier<?>>emptyList(), + final TranslationException failedOnRevertException = new TranslationException("update failed"); + final io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.RevertFailedException revertFailedException = + new io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.RevertFailedException(Collections.<InstanceIdentifier<?>>emptyList(), failedOnRevertException); doThrow(revertFailedException).when(reverter).revert(); @@ -216,7 +217,7 @@ public class VPPConfigDataTreeTest { // Run the test try { proxy.commit(modification); - } catch (WriterRegistry.Reverter.RevertFailedException e) { + } catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.Reverter.RevertFailedException e) { verify(vppWriter).update(anyMap(), anyMap(), any(WriteContext.class)); verify(reverter).revert(); assertEquals(failedOnRevertException, e.getCause()); diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java index 2c50ec92d..51f57a252 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; +import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -45,7 +45,7 @@ public class VppDataBrokerInitializationProviderTest { @Mock private ReaderRegistry readerRegistry; @Mock - private VppWriterRegistry writerRegistry; + private WriterRegistry writerRegistry; private VppDataBrokerInitializationProvider provider; diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java index 09e70941b..049c2a0c8 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java @@ -34,8 +34,8 @@ import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -121,7 +121,7 @@ public class VppOperationalDataTreeTest { @Test public void testReadFailed() throws Exception{ - doThrow(io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException.class).when(reader).readAll(any(ReadContext.class)); + doThrow(io.fd.honeycomb.v3po.translate.read.ReadFailedException.class).when(reader).readAll(any(ReadContext.class)); final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future = operationalData.read( YangInstanceIdentifier.EMPTY); @@ -129,7 +129,7 @@ public class VppOperationalDataTreeTest { try { future.checkedGet(); } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException); + assertTrue(e.getCause() instanceof io.fd.honeycomb.v3po.translate.read.ReadFailedException); return; } fail("ReadFailedException was expected"); diff --git a/v3po/pom.xml b/v3po/pom.xml index cb9073c9b..7fdf97b44 100644 --- a/v3po/pom.xml +++ b/v3po/pom.xml @@ -33,10 +33,11 @@ </prerequisites> <modules> <module>api</module> - <module>vpp-facade-spi</module> - <module>vpp-facade-api</module> - <module>vpp-facade-impl</module> - <module>vpp-facade-utils</module> + <module>translate-spi</module> + <module>translate-api</module> + <module>translate-impl</module> + <module>translate-utils</module> + <module>vpp-translate-utils</module> <module>v3po2vpp</module> <module>impl</module> <module>karaf</module> diff --git a/v3po/vpp-facade-api/pom.xml b/v3po/translate-api/pom.xml index 0406f1e80..42501e752 100644 --- a/v3po/vpp-facade-api/pom.xml +++ b/v3po/translate-api/pom.xml @@ -24,7 +24,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>io.fd.honeycomb.v3po</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>bundle</packaging> diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/Context.java index 16808db1f..b60963678 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/Context.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; import com.google.common.collect.Maps; import java.util.HashMap; diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/SubtreeManager.java index 28eee203b..39e403642 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/SubtreeManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; import com.google.common.annotations.Beta; import javax.annotation.Nonnull; diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/TranslationException.java index ff6101bb8..ee0049977 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/TranslationException.java @@ -14,25 +14,25 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; import com.google.common.annotations.Beta; /** - * Base exception for Vpp translation layer + * Base exception for the translation layer */ @Beta -public class VppException extends Exception { +public class TranslationException extends Exception { - public VppException(final String s) { + public TranslationException(final String s) { super(s); } - public VppException(final String s, final Throwable cause) { + public TranslationException(final String s, final Throwable cause) { super(s, cause); } - public VppException(final Throwable cause) { + public TranslationException(final Throwable cause) { super(cause); } } diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/VppApiInvocationException.java index ac1d7f7db..298c698f7 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/VppApiInvocationException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; @@ -24,7 +24,7 @@ import javax.annotation.Nonnull; * Thrown when Vpp jAPI method invocation failed. */ @Beta -public class VppApiInvocationException extends VppException { +public class VppApiInvocationException extends TranslationException { private final String methodName; private final int ctxId; private final int errorCode; diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ChildReader.java index 1608db4b2..02b6b8d26 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ChildReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; import com.google.common.annotations.Beta; import javax.annotation.Nonnull; @@ -23,12 +23,12 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Child VPP reader allowing its parent to pass the builder object + * Child reader allowing its parent to pass the builder object * * @param <C> Specific DataObject derived type, that is handled by this reader */ @Beta -public interface ChildVppReader<C extends DataObject> extends VppReader<C> { +public interface ChildReader<C extends DataObject> extends Reader<C> { /** * Reads subtree starting from node managed by this reader and place the subtree within parent builder object if the diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java index 950014574..faf6f0a19 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; import com.google.common.annotations.Beta; import java.util.List; @@ -25,12 +25,12 @@ import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * List VPP reader, allowing read of all the elements + * List reader, allowing read of all the elements * * @param <D> Specific DataObject derived type, that is handled by this reader */ @Beta -public interface ListVppReader<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends VppReader<D> { +public interface ListReader<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends Reader<D> { /** * Read all elements in this list diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadContext.java index 527888ab1..6b1473548 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadContext.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; import javax.annotation.Nonnull; /** diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadFailedException.java index 3e87b925b..51d4fcb5a 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReadFailedException.java @@ -14,18 +14,18 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; import static com.google.common.base.Preconditions.checkNotNull; -import io.fd.honeycomb.v3po.vpp.facade.VppException; +import io.fd.honeycomb.v3po.translate.TranslationException; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Thrown when Vpp reader or customizer is not able to read data for the given id. + * Thrown when a reader or customizer is not able to read data for the given id. */ -public class ReadFailedException extends VppException { +public class ReadFailedException extends TranslationException { private final InstanceIdentifier<?> failedId; diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/Reader.java index 6eea594b4..122263cb3 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/Reader.java @@ -14,27 +14,27 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; import com.google.common.annotations.Beta; import com.google.common.base.Optional; -import io.fd.honeycomb.v3po.vpp.facade.SubtreeManager; +import io.fd.honeycomb.v3po.translate.SubtreeManager; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Base VPP reader, responsible for translation between DataObjects and VPP APIs + * Base reader, responsible for translation between DataObjects and any other side * * @param <D> Specific DataObject derived type, that is handled by this reader */ @Beta -public interface VppReader<D extends DataObject> extends SubtreeManager<D> { +public interface Reader<D extends DataObject> extends SubtreeManager<D> { // TODO make async /** - * Reads from VPP data identified by id + * Reads data identified by id * * @param id unique identifier of subtree to be read. The subtree must contain managed data object type. For * identifiers pointing below node managed by this reader, it's reader's responsibility to filter out the diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReaderRegistry.java index 2bd51254f..f34455a27 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ReaderRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.read; +package io.fd.honeycomb.v3po.translate.read; import com.google.common.annotations.Beta; import com.google.common.collect.Multimap; @@ -26,7 +26,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * Simple delegating reader suitable as a holder for all other root readers, providing readAll feature. */ @Beta -public interface ReaderRegistry extends VppReader<DataObject> { +public interface ReaderRegistry extends Reader<DataObject> { /** * Performs read on all registered root readers and merges the results into a Multimap. Keys represent identifiers diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ChildWriter.java index 017f5d9aa..f933cfd4a 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ChildWriter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.write; +package io.fd.honeycomb.v3po.translate.write; import com.google.common.annotations.Beta; import javax.annotation.Nonnull; @@ -22,12 +22,12 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Child VPP writer allowing its parent to pass the builder object + * Child writer allowing its parent to pass the builder object * - * @param <C> Specific DataObject derived type, that is handled by this writer + * @param <D> Specific DataObject derived type, that is handled by this writer */ @Beta -public interface ChildVppWriter<D extends DataObject> extends VppWriter<D> { +public interface ChildWriter<D extends DataObject> extends Writer<D> { /** * Extract data object managed by this writer from parent data and perform write. diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteContext.java index ffc9f20f7..bb0b33145 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteContext.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.write; +package io.fd.honeycomb.v3po.translate.write; import com.google.common.annotations.Beta; import com.google.common.base.Optional; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java index 83f600f5b..08465fdd7 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java @@ -14,24 +14,24 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.write; +package io.fd.honeycomb.v3po.translate.write; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.SubtreeManager; -import io.fd.honeycomb.v3po.vpp.facade.VppException; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.SubtreeManager; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Base VPP writer, responsible for translation between DataObjects and VPP APIs. Handling all update operations(create, + * Base writer, responsible for translation between DataObjects and any other side. Handling all update operations(create, * update, delete) * * @param <D> Specific DataObject derived type, that is handled by this writer */ @Beta -public interface VppWriter<D extends DataObject> extends SubtreeManager<D> { +public interface Writer<D extends DataObject> extends SubtreeManager<D> { /** * Handle update operation. U from CRUD. @@ -40,10 +40,10 @@ public interface VppWriter<D extends DataObject> extends SubtreeManager<D> { * @param dataBefore Old data * @param dataAfter New, updated data * @param ctx Write context enabling writer to get information about candidate data as well as current data - * @throws VppException if update failed + * @throws TranslationException if update failed */ void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter, - @Nonnull final WriteContext ctx) throws VppException; + @Nonnull final WriteContext ctx) throws TranslationException; } diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java index 0d3c17451..c5a8116c8 100644 --- a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.write; +package io.fd.honeycomb.v3po.translate.write; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; -import io.fd.honeycomb.v3po.vpp.facade.VppException; +import io.fd.honeycomb.v3po.translate.TranslationException; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; @@ -28,26 +28,26 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Special {@link VppWriter} capable of performing bulk updates + * Special {@link Writer} capable of performing bulk updates */ @Beta -public interface WriterRegistry extends VppWriter<DataObject> { +public interface WriterRegistry extends Writer<DataObject> { /** * Performs bulk update * * @throws BulkUpdateException in case bulk update fails - * @throws VppException in case some other error occurs while processing update request + * @throws TranslationException in case some other error occurs while processing update request */ void update(@Nonnull final Map<InstanceIdentifier<?>, DataObject> dataBefore, @Nonnull final Map<InstanceIdentifier<?>, DataObject> dataAfter, - @Nonnull final WriteContext ctx) throws VppException; + @Nonnull final WriteContext ctx) throws TranslationException; /** * Thrown when bulk update failed. */ @Beta - class BulkUpdateException extends VppException { + class BulkUpdateException extends TranslationException { private final Reverter reverter; private final InstanceIdentifier<?> failedId; // TODO change to VppDataModification @@ -103,7 +103,7 @@ public interface WriterRegistry extends VppWriter<DataObject> { * Thrown when some of the changes applied during bulk update were not reverted. */ @Beta - class RevertFailedException extends VppException { + class RevertFailedException extends TranslationException { // TODO change to list of VppDataModifications to make debugging easier private final List<InstanceIdentifier<?>> notRevertedChanges; diff --git a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java b/v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/ReadFailedExceptionTest.java index 594168df2..71c0afbd3 100644 --- a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java +++ b/v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/ReadFailedExceptionTest.java @@ -14,20 +14,19 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; import org.junit.Assert; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.bridge.domain.Interface; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class ReadFailedExceptionTest { @Test public void testInstantiation() { - final InstanceIdentifier<BridgeDomain> id = InstanceIdentifier.create(BridgeDomain.class); + final InstanceIdentifier<DataObject> id = InstanceIdentifier.create(DataObject.class); ReadFailedException e = new ReadFailedException(id); Assert.assertEquals(id, e.getFailedId()); Assert.assertNull(e.getCause()); @@ -36,7 +35,7 @@ public class ReadFailedExceptionTest { @Test public void testInstantiationWithCause() { - final InstanceIdentifier<Interface> id = InstanceIdentifier.create(Interface.class); + final InstanceIdentifier<DataObject> id = InstanceIdentifier.create(DataObject.class); final RuntimeException cause = new RuntimeException(); ReadFailedException e = new ReadFailedException(id, cause); Assert.assertEquals(id, e.getFailedId()); diff --git a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java b/v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/VppApiInvocationExceptionTest.java index a3a37c192..b2cfbd216 100644 --- a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java +++ b/v3po/translate-api/src/test/java/io/fd/honeycomb/v3po/translate/VppApiInvocationExceptionTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade; +package io.fd.honeycomb.v3po.translate; import java.util.Random; import org.junit.Assert; diff --git a/v3po/vpp-facade-impl/pom.xml b/v3po/translate-impl/pom.xml index fff69c2b7..214d48ff0 100644 --- a/v3po/vpp-facade-impl/pom.xml +++ b/v3po/translate-impl/pom.xml @@ -24,24 +24,24 @@ <modelVersion>4.0.0</modelVersion> <groupId>io.fd.honeycomb.v3po</groupId> - <artifactId>vpp-facade-impl</artifactId> + <artifactId>translate-impl</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>bundle</packaging> <dependencies> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-utils</artifactId> + <artifactId>translate-utils</artifactId> <version>${project.version}</version> </dependency> @@ -77,7 +77,7 @@ <instructions> <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name> <Export-Package> - io.fd.honeycomb.v3po.vpp.facade.impl.* + io.fd.honeycomb.v3po.translate.impl.* </Export-Package> </instructions> </configuration> diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/AbstractCompositeVppReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/AbstractCompositeReader.java index 2856937ba..f9fa0eeaa 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/AbstractCompositeVppReader.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/AbstractCompositeReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read; +package io.fd.honeycomb.v3po.translate.impl.read; import static com.google.common.base.Preconditions.checkArgument; @@ -22,12 +22,12 @@ import com.google.common.annotations.Beta; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.ReflectionUtils; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.read.VppReader; +import io.fd.honeycomb.v3po.translate.util.ReflectionUtils; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.Reader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; @@ -45,19 +45,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Beta -abstract class AbstractCompositeVppReader<D extends DataObject, B extends Builder<D>> implements VppReader<D> { +abstract class AbstractCompositeReader<D extends DataObject, B extends Builder<D>> implements Reader<D> { - private static final Logger LOG = LoggerFactory.getLogger(AbstractCompositeVppReader.class); + private static final Logger LOG = LoggerFactory.getLogger(AbstractCompositeReader.class); - private final Map<Class<? extends DataObject>, ChildVppReader<? extends ChildOf<D>>> childReaders; - private final Map<Class<? extends DataObject>, ChildVppReader<? extends Augmentation<D>>> augReaders; + private final Map<Class<? extends DataObject>, ChildReader<? extends ChildOf<D>>> childReaders; + private final Map<Class<? extends DataObject>, ChildReader<? extends Augmentation<D>>> augReaders; private final InstanceIdentifier<D> instanceIdentifier; - AbstractCompositeVppReader(final Class<D> managedDataObjectType, - final List<ChildVppReader<? extends ChildOf<D>>> childReaders, - final List<ChildVppReader<? extends Augmentation<D>>> augReaders) { - this.childReaders = VppRWUtils.uniqueLinkedIndex(childReaders, VppRWUtils.MANAGER_CLASS_FUNCTION); - this.augReaders = VppRWUtils.uniqueLinkedIndex(augReaders, VppRWUtils.MANAGER_CLASS_AUG_FUNCTION); + AbstractCompositeReader(final Class<D> managedDataObjectType, + final List<ChildReader<? extends ChildOf<D>>> childReaders, + final List<ChildReader<? extends Augmentation<D>>> augReaders) { + this.childReaders = RWUtils.uniqueLinkedIndex(childReaders, RWUtils.MANAGER_CLASS_FUNCTION); + this.augReaders = RWUtils.uniqueLinkedIndex(augReaders, RWUtils.MANAGER_CLASS_AUG_FUNCTION); this.instanceIdentifier = InstanceIdentifier.create(managedDataObjectType); } @@ -82,12 +82,12 @@ abstract class AbstractCompositeVppReader<D extends DataObject, B extends Builde readCurrentAttributes(id, builder, ctx); // TODO expect exceptions from reader - for (ChildVppReader<? extends ChildOf<D>> child : childReaders.values()) { + for (ChildReader<? extends ChildOf<D>> child : childReaders.values()) { LOG.debug("{}: Reading child from: {}", this, child); child.read(id, builder, ctx); } - for (ChildVppReader<? extends Augmentation<D>> child : augReaders.values()) { + for (ChildReader<? extends Augmentation<D>> child : augReaders.values()) { LOG.debug("{}: Reading augment from: {}", this, child); child.read(id, builder, ctx); } @@ -120,16 +120,16 @@ abstract class AbstractCompositeVppReader<D extends DataObject, B extends Builde @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("{}: Reading subtree: {}", this, id); - final Class<? extends DataObject> next = VppRWUtils.getNextId(id, getManagedDataObjectType()).getType(); - final ChildVppReader<? extends ChildOf<D>> vppReader = childReaders.get(next); + final Class<? extends DataObject> next = RWUtils.getNextId(id, getManagedDataObjectType()).getType(); + final ChildReader<? extends ChildOf<D>> reader = childReaders.get(next); - if (vppReader != null) { - LOG.debug("{}: Reading subtree: {} from: {}", this, id, vppReader); - return vppReader.read(id, ctx); + if (reader != null) { + LOG.debug("{}: Reading subtree: {} from: {}", this, id, reader); + return reader.read(id, ctx); } else { LOG.debug("{}: Dedicated subtree reader missing for: {}. Reading current and filtering", this, next); // If there's no dedicated reader, use read current - final InstanceIdentifier<D> currentId = VppRWUtils.cutId(id, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.cutId(id, getManagedDataObjectType()); final Optional<D> current = readCurrent(currentId, ctx); // then perform post-reading filtering (return only requested sub-node) final Optional<? extends DataObject> readSubtree = current.isPresent() @@ -168,7 +168,7 @@ abstract class AbstractCompositeVppReader<D extends DataObject, B extends Builde // FIXME this needs to be recursive. right now it expects only 1 additional element in ID + test final InstanceIdentifier.PathArgument nextId = - VppRWUtils.getNextId(absolutPath, InstanceIdentifier.create(parent.getClass())); + RWUtils.getNextId(absolutPath, InstanceIdentifier.create(parent.getClass())); Optional<Method> method = ReflectionUtils.findMethodReflex(managedType, "get", Collections.<Class<?>>emptyList(), nextId.getType()); diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeChildVppReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeChildReader.java index 76e793dbe..46a59bb90 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeChildVppReader.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeChildReader.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read; +package io.fd.honeycomb.v3po.translate.impl.read; import com.google.common.annotations.Beta; import com.google.common.base.Optional; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.ChildVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.concurrent.ThreadSafe; @@ -33,18 +33,18 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Composite implementation of {@link ChildVppReader} able to place the read result into + * Composite implementation of {@link ChildReader} able to place the read result into * parent builder object. */ @Beta @ThreadSafe -public final class CompositeChildVppReader<C extends DataObject, B extends Builder<C>> extends AbstractCompositeVppReader<C, B> - implements ChildVppReader<C> { +public final class CompositeChildReader<C extends DataObject, B extends Builder<C>> extends AbstractCompositeReader<C, B> + implements ChildReader<C> { - private final ChildVppReaderCustomizer<C, B> customizer; + private final ChildReaderCustomizer<C, B> customizer; /** - * Create new {@link CompositeChildVppReader} + * Create new {@link CompositeChildReader} * * @param managedDataObjectType Class object for managed data type * @param childReaders Child nodes(container, list) readers @@ -52,29 +52,29 @@ public final class CompositeChildVppReader<C extends DataObject, B extends Build * @param customizer Customizer instance to customize this generic reader * */ - public CompositeChildVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final List<ChildVppReader<? extends Augmentation<C>>> augReaders, - @Nonnull final ChildVppReaderCustomizer<C, B> customizer) { + public CompositeChildReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final List<ChildReader<? extends Augmentation<C>>> augReaders, + @Nonnull final ChildReaderCustomizer<C, B> customizer) { super(managedDataObjectType, childReaders, augReaders); this.customizer = customizer; } /** - * @see {@link CompositeChildVppReader#CompositeChildVppReader(Class, List, List, ChildVppReaderCustomizer)} + * @see {@link CompositeChildReader#CompositeChildReader(Class, List, List, ChildReaderCustomizer)} */ - public CompositeChildVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final ChildVppReaderCustomizer<C, B> customizer) { - this(managedDataObjectType, childReaders, VppRWUtils.<C>emptyAugReaderList(), customizer); + public CompositeChildReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final ChildReaderCustomizer<C, B> customizer) { + this(managedDataObjectType, childReaders, RWUtils.<C>emptyAugReaderList(), customizer); } /** - * @see {@link CompositeChildVppReader#CompositeChildVppReader(Class, List, List, ChildVppReaderCustomizer)} + * @see {@link CompositeChildReader#CompositeChildReader(Class, List, List, ChildReaderCustomizer)} */ - public CompositeChildVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final ChildVppReaderCustomizer<C, B> customizer) { - this(managedDataObjectType, VppRWUtils.<C>emptyChildReaderList(), VppRWUtils.<C>emptyAugReaderList(), + public CompositeChildReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final ChildReaderCustomizer<C, B> customizer) { + this(managedDataObjectType, RWUtils.<C>emptyChildReaderList(), RWUtils.<C>emptyAugReaderList(), customizer); } @@ -82,7 +82,7 @@ public final class CompositeChildVppReader<C extends DataObject, B extends Build public final void read(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final Builder<? extends DataObject> parentBuilder, @Nonnull final ReadContext ctx) throws ReadFailedException { - final Optional<C> read = readCurrent(VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()), ctx); + final Optional<C> read = readCurrent(RWUtils.appendTypeToId(parentId, getManagedDataObjectType()), ctx); if(read.isPresent()) { customizer.merge(parentBuilder, read.get()); diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeListVppReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java index fcfa8b428..fd7b279ca 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeListVppReader.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java @@ -14,18 +14,18 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read; +package io.fd.honeycomb.v3po.translate.impl.read; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.annotations.Beta; import com.google.common.base.Optional; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ListVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.ListVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.read.ListReader; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; @@ -41,7 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Composite implementation of {@link io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader} able to place the read result into parent builder object intended + * Composite implementation of {@link ChildReader} able to place the read result into parent builder object intended * for list node type. * * This reader checks if the IDs are wildcarded in which case it performs read of all list entries. In case the ID has a @@ -49,44 +49,44 @@ import org.slf4j.LoggerFactory; */ @Beta @ThreadSafe -public final class CompositeListVppReader<C extends DataObject & Identifiable<K>, K extends Identifier<C>, B extends Builder<C>> - extends AbstractCompositeVppReader<C, B> implements ChildVppReader<C>, ListVppReader<C, K> { +public final class CompositeListReader<C extends DataObject & Identifiable<K>, K extends Identifier<C>, B extends Builder<C>> + extends AbstractCompositeReader<C, B> implements ChildReader<C>, ListReader<C, K> { - private static final Logger LOG = LoggerFactory.getLogger(CompositeListVppReader.class); + private static final Logger LOG = LoggerFactory.getLogger(CompositeListReader.class); - private final ListVppReaderCustomizer<C, K, B> customizer; + private final ListReaderCustomizer<C, K, B> customizer; /** - * Create new {@link CompositeListVppReader} + * Create new {@link CompositeListReader} * * @param managedDataObjectType Class object for managed data type. Must come from a list node type. * @param childReaders Child nodes(container, list) readers * @param augReaders Child augmentations readers * @param customizer Customizer instance to customize this generic reader */ - public CompositeListVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final List<ChildVppReader<? extends Augmentation<C>>> augReaders, - @Nonnull final ListVppReaderCustomizer<C, K, B> customizer) { + public CompositeListReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final List<ChildReader<? extends Augmentation<C>>> augReaders, + @Nonnull final ListReaderCustomizer<C, K, B> customizer) { super(managedDataObjectType, childReaders, augReaders); this.customizer = customizer; } /** - * @see {@link CompositeListVppReader#CompositeListVppReader(Class, List, List, ListVppReaderCustomizer)} + * @see {@link CompositeListReader#CompositeListReader(Class, List, List, ListReaderCustomizer)} */ - public CompositeListVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final ListVppReaderCustomizer<C, K, B> customizer) { - this(managedDataObjectType, childReaders, VppRWUtils.<C>emptyAugReaderList(), customizer); + public CompositeListReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final ListReaderCustomizer<C, K, B> customizer) { + this(managedDataObjectType, childReaders, RWUtils.<C>emptyAugReaderList(), customizer); } /** - * @see {@link CompositeListVppReader#CompositeListVppReader(Class, List, List, ListVppReaderCustomizer)} + * @see {@link CompositeListReader#CompositeListReader(Class, List, List, ListReaderCustomizer)} */ - public CompositeListVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final ListVppReaderCustomizer<C, K, B> customizer) { - this(managedDataObjectType, VppRWUtils.<C>emptyChildReaderList(), VppRWUtils.<C>emptyAugReaderList(), + public CompositeListReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final ListReaderCustomizer<C, K, B> customizer) { + this(managedDataObjectType, RWUtils.<C>emptyChildReaderList(), RWUtils.<C>emptyAugReaderList(), customizer); } @@ -95,7 +95,7 @@ public final class CompositeListVppReader<C extends DataObject & Identifiable<K> @Nonnull final Builder<? extends DataObject> parentBuilder, @Nonnull final ReadContext ctx) throws ReadFailedException { // Create ID pointing to current node - final InstanceIdentifier<C> currentId = VppRWUtils.appendTypeToId(id, getManagedDataObjectType()); + final InstanceIdentifier<C> currentId = RWUtils.appendTypeToId(id, getManagedDataObjectType()); // Read all, since current ID is definitely wildcarded final List<C> ifcs = readList(currentId, ctx); customizer.merge(parentBuilder, ifcs); @@ -112,8 +112,8 @@ public final class CompositeListVppReader<C extends DataObject & Identifiable<K> final ArrayList<C> allEntries = new ArrayList<>(allIds.size()); for (K key : allIds) { final InstanceIdentifier.IdentifiableItem<C, K> currentBdItem = - VppRWUtils.getCurrentIdItem(id, key); - final InstanceIdentifier<C> keyedId = VppRWUtils.replaceLastInId(id, currentBdItem); + RWUtils.getCurrentIdItem(id, key); + final InstanceIdentifier<C> keyedId = RWUtils.replaceLastInId(id, currentBdItem); final Optional<C> read = readCurrent(keyedId, ctx); final DataObject singleItem = read.get(); checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeRootReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeRootReader.java new file mode 100644 index 000000000..f297abb76 --- /dev/null +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeRootReader.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.v3po.translate.impl.read; + +import com.google.common.annotations.Beta; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.Reader; +import io.fd.honeycomb.v3po.translate.spi.read.RootReaderCustomizer; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.concurrent.ThreadSafe; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Composite implementation of {@link Reader} + */ +@Beta +@ThreadSafe +public final class CompositeRootReader<C extends DataObject, B extends Builder<C>> extends AbstractCompositeReader<C, B> + implements Reader<C> { + + private final RootReaderCustomizer<C, B> customizer; + + /** + * Create new {@link CompositeRootReader} + * + * @param managedDataObjectType Class object for managed data type + * @param childReaders Child nodes(container, list) readers + * @param augReaders Child augmentations readers + * @param customizer Customizer instance to customize this generic reader + * + */ + public CompositeRootReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final List<ChildReader<? extends Augmentation<C>>> augReaders, + @Nonnull final RootReaderCustomizer<C, B> customizer) { + super(managedDataObjectType, childReaders, augReaders); + this.customizer = customizer; + } + + /** + * @see {@link CompositeRootReader#CompositeRootReader(Class, List, List, RootReaderCustomizer)} + */ + public CompositeRootReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final List<ChildReader<? extends ChildOf<C>>> childReaders, + @Nonnull final RootReaderCustomizer<C, B> customizer) { + this(managedDataObjectType, childReaders, RWUtils.<C>emptyAugReaderList(), customizer); + } + + /** + * @see {@link CompositeRootReader#CompositeRootReader(Class, List, List, RootReaderCustomizer)} + */ + public CompositeRootReader(@Nonnull final Class<C> managedDataObjectType, + @Nonnull final RootReaderCustomizer<C, B> customizer) { + this(managedDataObjectType, RWUtils.<C>emptyChildReaderList(), RWUtils.<C>emptyAugReaderList(), + customizer); + } + + @Override + protected void readCurrentAttributes(@Nonnull final InstanceIdentifier<C> id, @Nonnull final B builder, + @Nonnull final ReadContext ctx) throws ReadFailedException { + customizer.readCurrentAttributes(id, builder, ctx.getContext()); + } + + @Override + protected B getBuilder(@Nonnull final InstanceIdentifier<C> id) { + return customizer.getBuilder(id); + } + +} diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/AbstractCompositeVppWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java index add62e2ba..e971fbeff 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/AbstractCompositeVppWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write; +package io.fd.honeycomb.v3po.translate.impl.write; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.base.Optional; import com.google.common.collect.Lists; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.write.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -39,20 +39,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractCompositeVppWriter<D extends DataObject> implements VppWriter<D> { +public abstract class AbstractCompositeWriter<D extends DataObject> implements Writer<D> { - private static final Logger LOG = LoggerFactory.getLogger(AbstractCompositeVppWriter.class); + private static final Logger LOG = LoggerFactory.getLogger(AbstractCompositeWriter.class); - private final Map<Class<? extends DataObject>, ChildVppWriter<? extends ChildOf<D>>> childWriters; - private final Map<Class<? extends DataObject>, ChildVppWriter<? extends Augmentation<D>>> augWriters; + private final Map<Class<? extends DataObject>, ChildWriter<? extends ChildOf<D>>> childWriters; + private final Map<Class<? extends DataObject>, ChildWriter<? extends Augmentation<D>>> augWriters; private final InstanceIdentifier<D> instanceIdentifier; - public AbstractCompositeVppWriter(final Class<D> type, - final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - final List<ChildVppWriter<? extends Augmentation<D>>> augWriters) { + public AbstractCompositeWriter(final Class<D> type, + final List<ChildWriter<? extends ChildOf<D>>> childWriters, + final List<ChildWriter<? extends Augmentation<D>>> augWriters) { this.instanceIdentifier = InstanceIdentifier.create(type); - this.childWriters = VppRWUtils.uniqueLinkedIndex(childWriters, VppRWUtils.MANAGER_CLASS_FUNCTION); - this.augWriters = VppRWUtils.uniqueLinkedIndex(augWriters, VppRWUtils.MANAGER_CLASS_AUG_FUNCTION); + this.childWriters = RWUtils.uniqueLinkedIndex(childWriters, RWUtils.MANAGER_CLASS_FUNCTION); + this.augWriters = RWUtils.uniqueLinkedIndex(augWriters, RWUtils.MANAGER_CLASS_AUG_FUNCTION); } protected void writeCurrent(final InstanceIdentifier<D> id, final D data, final WriteContext ctx) { @@ -61,12 +61,12 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement LOG.trace("{}: Writing current attributes", this); writeCurrentAttributes(id, data, ctx); - for (ChildVppWriter<? extends ChildOf<D>> child : childWriters.values()) { + for (ChildWriter<? extends ChildOf<D>> child : childWriters.values()) { LOG.debug("{}: Writing child in: {}", this, child); child.writeChild(id, data, ctx); } - for (ChildVppWriter<? extends Augmentation<D>> child : augWriters.values()) { + for (ChildWriter<? extends Augmentation<D>> child : augWriters.values()) { LOG.debug("{}: Writing augment in: {}", this, child); child.writeChild(id, data, ctx); } @@ -87,12 +87,12 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement LOG.trace("{}: Updating current attributes", this); updateCurrentAttributes(id, dataBefore, dataAfter, ctx); - for (ChildVppWriter<? extends ChildOf<D>> child : childWriters.values()) { + for (ChildWriter<? extends ChildOf<D>> child : childWriters.values()) { LOG.debug("{}: Updating child in: {}", this, child); child.updateChild(id, dataBefore, dataAfter, ctx); } - for (ChildVppWriter<? extends Augmentation<D>> child : augWriters.values()) { + for (ChildWriter<? extends Augmentation<D>> child : augWriters.values()) { LOG.debug("{}: Updating augment in: {}", this, child); child.updateChild(id, dataBefore, dataAfter, ctx); } @@ -104,12 +104,12 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement LOG.debug("{}: Deleting current: {} dataBefore: {}", this, id, dataBefore); // delete in reversed order - for (ChildVppWriter<? extends Augmentation<D>> child : reverseCollection(augWriters.values())) { + for (ChildWriter<? extends Augmentation<D>> child : reverseCollection(augWriters.values())) { LOG.debug("{}: Deleting augment in: {}", this, child); child.deleteChild(id, dataBefore, ctx); } - for (ChildVppWriter<? extends ChildOf<D>> child : reverseCollection(childWriters.values())) { + for (ChildWriter<? extends ChildOf<D>> child : reverseCollection(childWriters.values())) { LOG.debug("{}: Deleting child in: {}", this, child); child.deleteChild(id, dataBefore, ctx); } @@ -123,7 +123,7 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter, - @Nonnull final WriteContext ctx) throws VppException { + @Nonnull final WriteContext ctx) throws TranslationException { LOG.debug("{}: Updating : {}", this, id); LOG.trace("{}: Updating : {}, from: {} to: {}", this, id, dataBefore, dataAfter); @@ -168,20 +168,20 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement } private void writeSubtree(final InstanceIdentifier<? extends DataObject> id, - final DataObject dataAfter, final WriteContext ctx) throws VppException { + final DataObject dataAfter, final WriteContext ctx) throws TranslationException { LOG.debug("{}: Writing subtree: {}", this, id); - final VppWriter<? extends ChildOf<D>> vppWriter = getNextWriter(id); + final Writer<? extends ChildOf<D>> writer = getNextWriter(id); - if (vppWriter != null) { - LOG.debug("{}: Writing subtree: {} in: {}", this, id, vppWriter); - vppWriter.update(id, null, dataAfter, ctx); + if (writer != null) { + LOG.debug("{}: Writing subtree: {} in: {}", this, id, writer); + writer.update(id, null, dataAfter, ctx); } else { // If there's no dedicated writer, use write current // But we need current data after to do so - final InstanceIdentifier<D> currentId = VppRWUtils.cutId(id, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.cutId(id, getManagedDataObjectType()); Optional<DataObject> currentDataAfter = ctx.readAfter(currentId); LOG.debug("{}: Dedicated subtree writer missing for: {}. Writing current.", this, - VppRWUtils.getNextId(id, getManagedDataObjectType()).getType(), currentDataAfter); + RWUtils.getNextId(id, getManagedDataObjectType()).getType(), currentDataAfter); writeCurrent(currentId, castToManaged(currentDataAfter.get()), ctx); } } @@ -192,13 +192,13 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement @SuppressWarnings("unchecked") private void deleteSubtree(final InstanceIdentifier<? extends DataObject> id, - final DataObject dataBefore, final WriteContext ctx) throws VppException { + final DataObject dataBefore, final WriteContext ctx) throws TranslationException { LOG.debug("{}: Deleting subtree: {}", this, id); - final VppWriter<? extends ChildOf<D>> vppWriter = getNextWriter(id); + final Writer<? extends ChildOf<D>> writer = getNextWriter(id); - if (vppWriter != null) { - LOG.debug("{}: Deleting subtree: {} in: {}", this, id, vppWriter); - vppWriter.update(id, dataBefore, null, ctx); + if (writer != null) { + LOG.debug("{}: Deleting subtree: {} in: {}", this, id, writer); + writer.update(id, dataBefore, null, ctx); } else { updateSubtreeFromCurrent(id, ctx); } @@ -206,11 +206,11 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement @SuppressWarnings("unchecked") private void updateSubtreeFromCurrent(final InstanceIdentifier<? extends DataObject> id, final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.cutId(id, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.cutId(id, getManagedDataObjectType()); Optional<DataObject> currentDataBefore = ctx.readBefore(currentId); Optional<DataObject> currentDataAfter = ctx.readAfter(currentId); LOG.debug("{}: Dedicated subtree writer missing for: {}. Updating current without subtree", this, - VppRWUtils.getNextId(id, getManagedDataObjectType()).getType(), currentDataAfter); + RWUtils.getNextId(id, getManagedDataObjectType()).getType(), currentDataAfter); updateCurrent((InstanceIdentifier<D>) id, castToManaged(currentDataBefore.orNull()), castToManaged(currentDataAfter.orNull()), ctx); } @@ -219,20 +219,20 @@ public abstract class AbstractCompositeVppWriter<D extends DataObject> implement private void updateSubtree(final InstanceIdentifier<? extends DataObject> id, final DataObject dataBefore, final DataObject dataAfter, - final WriteContext ctx) throws VppException { + final WriteContext ctx) throws TranslationException { LOG.debug("{}: Updating subtree: {}", this, id); - final VppWriter<? extends ChildOf<D>> vppWriter = getNextWriter(id); + final Writer<? extends ChildOf<D>> writer = getNextWriter(id); - if (vppWriter != null) { - LOG.debug("{}: Updating subtree: {} in: {}", this, id, vppWriter); - vppWriter.update(id, dataBefore, dataAfter, ctx); + if (writer != null) { + LOG.debug("{}: Updating subtree: {} in: {}", this, id, writer); + writer.update(id, dataBefore, dataAfter, ctx); } else { updateSubtreeFromCurrent(id, ctx); } } - private VppWriter<? extends ChildOf<D>> getNextWriter(final InstanceIdentifier<? extends DataObject> id) { - final Class<? extends DataObject> next = VppRWUtils.getNextId(id, getManagedDataObjectType()).getType(); + private Writer<? extends ChildOf<D>> getNextWriter(final InstanceIdentifier<? extends DataObject> id) { + final Class<? extends DataObject> next = RWUtils.getNextId(id, getManagedDataObjectType()).getType(); return childWriters.get(next); } diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeChildVppWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java index a11004e86..fbfeffbdb 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeChildVppWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write; +package io.fd.honeycomb.v3po.translate.impl.write; import com.google.common.base.Optional; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.ChildVppWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.Augmentation; @@ -28,28 +28,28 @@ import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class CompositeChildVppWriter<D extends DataObject> extends AbstractCompositeVppWriter<D> - implements ChildVppWriter<D> { +public class CompositeChildWriter<D extends DataObject> extends AbstractCompositeWriter<D> + implements ChildWriter<D> { - private final ChildVppWriterCustomizer<D> customizer; + private final ChildWriterCustomizer<D> customizer; - public CompositeChildVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final List<ChildVppWriter<? extends Augmentation<D>>> augWriters, - @Nonnull final ChildVppWriterCustomizer<D> customizer) { + public CompositeChildWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final List<ChildWriter<? extends Augmentation<D>>> augWriters, + @Nonnull final ChildWriterCustomizer<D> customizer) { super(type, childWriters, augWriters); this.customizer = customizer; } - public CompositeChildVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final ChildVppWriterCustomizer<D> customizer) { - this(type, childWriters, VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeChildWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final ChildWriterCustomizer<D> customizer) { + this(type, childWriters, RWUtils.<D>emptyAugWriterList(), customizer); } - public CompositeChildVppWriter(@Nonnull final Class<D> type, - @Nonnull final ChildVppWriterCustomizer<D> customizer) { - this(type, VppRWUtils.<D>emptyChildWriterList(), VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeChildWriter(@Nonnull final Class<D> type, + @Nonnull final ChildWriterCustomizer<D> customizer) { + this(type, RWUtils.<D>emptyChildWriterList(), RWUtils.<D>emptyAugWriterList(), customizer); } @Override @@ -73,7 +73,7 @@ public class CompositeChildVppWriter<D extends DataObject> extends AbstractCompo @Override public void writeChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentData, @Nonnull WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final Optional<D> currentData = customizer.extract(currentId, parentData); if(currentData.isPresent()) { writeCurrent(currentId, currentData.get(), ctx); @@ -84,7 +84,7 @@ public class CompositeChildVppWriter<D extends DataObject> extends AbstractCompo public void deleteChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentData, @Nonnull final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final Optional<D> currentData = customizer.extract(currentId, parentData); if(currentData.isPresent()) { deleteCurrent(currentId, currentData.get(), ctx); @@ -95,7 +95,7 @@ public class CompositeChildVppWriter<D extends DataObject> extends AbstractCompo public void updateChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentDataBefore, @Nonnull final DataObject parentDataAfter, @Nonnull final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final Optional<D> before = customizer.extract(currentId, parentDataBefore); final Optional<D> after = customizer.extract(currentId, parentDataAfter); if(before.isPresent() && after.isPresent()) { diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeListVppWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java index 805d951f9..dc924fe39 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeListVppWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write; +package io.fd.honeycomb.v3po.translate.impl.write; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.ListVppWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.util.RWUtils; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; @@ -34,8 +34,9 @@ import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends AbstractCompositeVppWriter<D> - implements ChildVppWriter<D> { +public class CompositeListWriter<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends + AbstractCompositeWriter<D> + implements ChildWriter<D> { public static final Function<DataObject, Object> INDEX_FUNCTION = new Function<DataObject, Object>() { @Override @@ -47,25 +48,25 @@ public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K ex }; - private final ListVppWriterCustomizer<D, K> customizer; + private final ListWriterCustomizer<D, K> customizer; - public CompositeListVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final List<ChildVppWriter<? extends Augmentation<D>>> augWriters, - @Nonnull final ListVppWriterCustomizer<D, K> customizer) { + public CompositeListWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final List<ChildWriter<? extends Augmentation<D>>> augWriters, + @Nonnull final ListWriterCustomizer<D, K> customizer) { super(type, childWriters, augWriters); this.customizer = customizer; } - public CompositeListVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final ListVppWriterCustomizer<D, K> customizer) { - this(type, childWriters, VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeListWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final ListWriterCustomizer<D, K> customizer) { + this(type, childWriters, RWUtils.<D>emptyAugWriterList(), customizer); } - public CompositeListVppWriter(@Nonnull final Class<D> type, - @Nonnull final ListVppWriterCustomizer<D, K> customizer) { - this(type, VppRWUtils.<D>emptyChildWriterList(), VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeListWriter(@Nonnull final Class<D> type, + @Nonnull final ListWriterCustomizer<D, K> customizer) { + this(type, RWUtils.<D>emptyChildWriterList(), RWUtils.<D>emptyAugWriterList(), customizer); } @@ -91,7 +92,7 @@ public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K ex public void writeChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentData, @Nonnull final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final List<D> currentData = customizer.extract(currentId, parentData); for (D entry : currentData) { writeCurrent(currentId, entry, ctx); @@ -102,7 +103,7 @@ public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K ex public void deleteChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentDataBefore, @Nonnull final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final List<D> dataBefore = customizer.extract(currentId, parentDataBefore); for (D entry : dataBefore) { deleteCurrent(currentId, entry, ctx); @@ -113,7 +114,7 @@ public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K ex public void updateChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, @Nonnull final DataObject parentDataBefore, @Nonnull final DataObject parentDataAfter, @Nonnull final WriteContext ctx) { - final InstanceIdentifier<D> currentId = VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()); + final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final ImmutableMap<Object, D> dataBefore = Maps.uniqueIndex(customizer.extract(currentId, parentDataBefore), INDEX_FUNCTION); final ImmutableMap<Object, D> @@ -172,7 +173,7 @@ public class CompositeListVppWriter<D extends DataObject & Identifiable<K>, K ex } private InstanceIdentifier<D> getSpecificId(final InstanceIdentifier<D> currentId, final D current) { - return VppRWUtils.replaceLastInId(currentId, + return RWUtils.replaceLastInId(currentId, new InstanceIdentifier.IdentifiableItem<>(currentId.getTargetType(), current.getKey())); } } diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeRootVppWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java index 7bcb8dbbb..acf2cfd2e 100644 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/CompositeRootVppWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write; +package io.fd.honeycomb.v3po.translate.impl.write; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.RootVppWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.spi.write.RootWriterCustomizer; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.Augmentation; @@ -27,27 +27,27 @@ import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class CompositeRootVppWriter<D extends DataObject> extends AbstractCompositeVppWriter<D> { +public class CompositeRootWriter<D extends DataObject> extends AbstractCompositeWriter<D> { - private final RootVppWriterCustomizer<D> customizer; + private final RootWriterCustomizer<D> customizer; - public CompositeRootVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final List<ChildVppWriter<? extends Augmentation<D>>> augWriters, - @Nonnull final RootVppWriterCustomizer<D> customizer) { + public CompositeRootWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final List<ChildWriter<? extends Augmentation<D>>> augWriters, + @Nonnull final RootWriterCustomizer<D> customizer) { super(type, childWriters, augWriters); this.customizer = customizer; } - public CompositeRootVppWriter(@Nonnull final Class<D> type, - @Nonnull final List<ChildVppWriter<? extends ChildOf<D>>> childWriters, - @Nonnull final RootVppWriterCustomizer<D> customizer) { - this(type, childWriters, VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeRootWriter(@Nonnull final Class<D> type, + @Nonnull final List<ChildWriter<? extends ChildOf<D>>> childWriters, + @Nonnull final RootWriterCustomizer<D> customizer) { + this(type, childWriters, RWUtils.<D>emptyAugWriterList(), customizer); } - public CompositeRootVppWriter(@Nonnull final Class<D> type, - @Nonnull final RootVppWriterCustomizer<D> customizer) { - this(type, VppRWUtils.<D>emptyChildWriterList(), VppRWUtils.<D>emptyAugWriterList(), customizer); + public CompositeRootWriter(@Nonnull final Class<D> type, + @Nonnull final RootWriterCustomizer<D> customizer) { + this(type, RWUtils.<D>emptyChildWriterList(), RWUtils.<D>emptyAugWriterList(), customizer); } @Override diff --git a/v3po/vpp-facade-spi/pom.xml b/v3po/translate-spi/pom.xml index 87f9c2848..17e108810 100644 --- a/v3po/vpp-facade-spi/pom.xml +++ b/v3po/translate-spi/pom.xml @@ -24,7 +24,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>io.fd.honeycomb.v3po</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>bundle</packaging> @@ -47,7 +47,7 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ChildVppReaderCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ChildReaderCustomizer.java index 376474301..8acc54db9 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ChildVppReaderCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ChildReaderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.read; +package io.fd.honeycomb.v3po.translate.spi.read; import com.google.common.annotations.Beta; import javax.annotation.Nonnull; @@ -22,14 +22,14 @@ import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; /** - * CompositeChildVppReader SPI to customize its behavior + * CompositeChildReader SPI to customize its behavior * * @param <C> Specific DataObject derived type (Identifiable), that is handled by this customizer * @param <B> Specific Builder for handled type (C) */ @Beta -public interface ChildVppReaderCustomizer<C extends DataObject, B extends Builder<C>> extends - RootVppReaderCustomizer<C, B> { +public interface ChildReaderCustomizer<C extends DataObject, B extends Builder<C>> extends + RootReaderCustomizer<C, B> { // FIXME need to capture parent builder type, but that's inconvenient at best, is it ok to leave it Builder<?> and // cast in specific customizers ? ... probably better than adding another type parameter diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ListVppReaderCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ListReaderCustomizer.java index 610b2da8b..746b439a8 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/ListVppReaderCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/ListReaderCustomizer.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.read; +package io.fd.honeycomb.v3po.translate.spi.read; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Builder; @@ -27,15 +27,15 @@ import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * CompositeListVppReader SPI to customize its behavior + * CompositeListReader SPI to customize its behavior * * @param <C> Specific DataObject derived type (Identifiable), that is handled by this customizer * @param <K> Specific Identifier for handled type (C) * @param <B> Specific Builder for handled type (C) */ @Beta -public interface ListVppReaderCustomizer<C extends DataObject & Identifiable<K>, K extends Identifier<C>, B extends Builder<C>> - extends RootVppReaderCustomizer<C, B> { +public interface ListReaderCustomizer<C extends DataObject & Identifiable<K>, K extends Identifier<C>, B extends Builder<C>> + extends RootReaderCustomizer<C, B> { /** * Return list with IDs of all list nodes to be read. diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/RootVppReaderCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/RootReaderCustomizer.java index 8035933df..da599eb58 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/read/RootVppReaderCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/read/RootReaderCustomizer.java @@ -14,24 +14,24 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.read; +package io.fd.honeycomb.v3po.translate.spi.read; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.Context; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * CompositeRootVppReader SPI to customize its behavior + * CompositeRootReader SPI to customize its behavior * * @param <C> Specific DataObject derived type, that is handled by this customizer * @param <B> Specific Builder for handled type (C) */ @Beta -public interface RootVppReaderCustomizer<C extends DataObject, B extends Builder<C>> { +public interface RootReaderCustomizer<C extends DataObject, B extends Builder<C>> { /** * Creates new builder that will be used to build read value. diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ChildVppWriterCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ChildWriterCustomizer.java index 7b7e257a2..e8f248495 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ChildVppWriterCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ChildWriterCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.write; +package io.fd.honeycomb.v3po.translate.spi.write; import com.google.common.annotations.Beta; import com.google.common.base.Optional; @@ -23,12 +23,12 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * CompositeChildVppWriter SPI to customize its behavior + * CompositeChildWriter SPI to customize its behavior * * @param <D> Specific DataObject derived type (Identifiable), that is handled by this customizer */ @Beta -public interface ChildVppWriterCustomizer<D extends DataObject> extends RootVppWriterCustomizer<D> { +public interface ChildWriterCustomizer<D extends DataObject> extends RootWriterCustomizer<D> { /** * Get child of parentData identified by currentId diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ListVppWriterCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ListWriterCustomizer.java index b4bf1aa41..1eb18a238 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/ListVppWriterCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/ListWriterCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.write; +package io.fd.honeycomb.v3po.translate.spi.write; import com.google.common.annotations.Beta; import java.util.List; @@ -25,13 +25,14 @@ import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * CompositeListVppWriter SPI to customize its behavior + * CompositeListWriter SPI to customize its behavior * * @param <C> Specific DataObject derived type (Identifiable), that is handled by this customizer * @param <K> Specific Identifier for handled type (C) */ @Beta -public interface ListVppWriterCustomizer<C extends DataObject & Identifiable<K>, K extends Identifier<C>> extends RootVppWriterCustomizer<C> { +public interface ListWriterCustomizer<C extends DataObject & Identifiable<K>, K extends Identifier<C>> extends + RootWriterCustomizer<C> { /** * Get children of parentData identified by currentId diff --git a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/RootVppWriterCustomizer.java b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/RootWriterCustomizer.java index 1335e8afb..ca4f02dce 100644 --- a/v3po/vpp-facade-spi/src/main/java/io/fd/honeycomb/v3po/vpp/facade/spi/write/RootVppWriterCustomizer.java +++ b/v3po/translate-spi/src/main/java/io/fd/honeycomb/v3po/translate/spi/write/RootWriterCustomizer.java @@ -14,21 +14,21 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.spi.write; +package io.fd.honeycomb.v3po.translate.spi.write; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * CompositeRootVppReader SPI to customize its behavior + * CompositeRootReader SPI to customize its behavior * * @param <D> Specific DataObject derived type, that is handled by this customizer */ @Beta -public interface RootVppWriterCustomizer<D extends DataObject> { +public interface RootWriterCustomizer<D extends DataObject> { /** * Handle write operation. C from CRUD. diff --git a/v3po/vpp-facade-utils/pom.xml b/v3po/translate-utils/pom.xml index 83c7d7415..d547cb483 100644 --- a/v3po/vpp-facade-utils/pom.xml +++ b/v3po/translate-utils/pom.xml @@ -24,7 +24,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>io.fd.honeycomb.v3po</groupId> - <artifactId>vpp-facade-utils</artifactId> + <artifactId>translate-utils</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>bundle</packaging> @@ -50,20 +50,15 @@ <dependencies> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-api</artifactId> + <artifactId>translate-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>io.fd.vpp</groupId> - <artifactId>vppjapi</artifactId> - <version>1.0.0-SNAPSHOT</version> - </dependency> - <dependency> <groupId>org.opendaylight.controller</groupId> <artifactId>sal-core-api</artifactId> </dependency> diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppRWUtils.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java index 64667b85f..027d9bbb7 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppRWUtils.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.util; +package io.fd.honeycomb.v3po.translate.util; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; -import io.fd.honeycomb.v3po.vpp.facade.SubtreeManager; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.SubtreeManager; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -36,9 +36,9 @@ import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public final class VppRWUtils { +public final class RWUtils { - private VppRWUtils() {} + private RWUtils() {} /** * Find next item in ID after provided type @@ -58,35 +58,35 @@ public final class VppRWUtils { return Iterables.get(pathArguments, i + 1); } - public static <T> List<ChildVppReader<? extends ChildOf<T>>> emptyChildReaderList() { + public static <T> List<ChildReader<? extends ChildOf<T>>> emptyChildReaderList() { return Collections.emptyList(); } - public static <T> List<ChildVppWriter<? extends ChildOf<T>>> emptyChildWriterList() { + public static <T> List<ChildWriter<? extends ChildOf<T>>> emptyChildWriterList() { return Collections.emptyList(); } - public static <T> List<ChildVppReader<? extends Augmentation<T>>> emptyAugReaderList() { + public static <T> List<ChildReader<? extends Augmentation<T>>> emptyAugReaderList() { return Collections.emptyList(); } - public static <T> List<ChildVppWriter<? extends Augmentation<T>>> emptyAugWriterList() { + public static <T> List<ChildWriter<? extends Augmentation<T>>> emptyAugWriterList() { return Collections.emptyList(); } - public static <T> List<ChildVppReader<? extends Augmentation<T>>> singletonAugReaderList( - ChildVppReader<? extends Augmentation<T>> item) { - return Collections.<ChildVppReader<? extends Augmentation<T>>>singletonList(item); + public static <T> List<ChildReader<? extends Augmentation<T>>> singletonAugReaderList( + ChildReader<? extends Augmentation<T>> item) { + return Collections.<ChildReader<? extends Augmentation<T>>>singletonList(item); } - public static <T> List<ChildVppReader<? extends ChildOf<T>>> singletonChildReaderList( - ChildVppReader<? extends ChildOf<T>> item) { - return Collections.<ChildVppReader<? extends ChildOf<T>>>singletonList(item); + public static <T> List<ChildReader<? extends ChildOf<T>>> singletonChildReaderList( + ChildReader<? extends ChildOf<T>> item) { + return Collections.<ChildReader<? extends ChildOf<T>>>singletonList(item); } - public static <T> List<ChildVppWriter<? extends ChildOf<T>>> singletonChildWriterList( - ChildVppWriter<? extends ChildOf<T>> item) { - return Collections.<ChildVppWriter<? extends ChildOf<T>>>singletonList(item); + public static <T> List<ChildWriter<? extends ChildOf<T>>> singletonChildWriterList( + ChildWriter<? extends ChildOf<T>> item) { + return Collections.<ChildWriter<? extends ChildOf<T>>>singletonList(item); } /** diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/ReflectionUtils.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/ReflectionUtils.java index db560622c..ea0b3b2c4 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/ReflectionUtils.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/ReflectionUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.util; +package io.fd.honeycomb.v3po.translate.util; import com.google.common.base.Optional; import java.lang.reflect.Method; diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/DelegatingReaderRegistry.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/DelegatingReaderRegistry.java index 5217024e8..387f3cc7c 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/DelegatingReaderRegistry.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/DelegatingReaderRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read.util; +package io.fd.honeycomb.v3po.translate.util.read; import static com.google.common.base.Preconditions.checkNotNull; @@ -22,12 +22,12 @@ import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ListVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.read.ReaderRegistry; -import io.fd.honeycomb.v3po.vpp.facade.read.VppReader; +import io.fd.honeycomb.v3po.translate.read.ListReader; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.ReadFailedException; +import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.Reader; import java.util.Collections; import java.util.List; import java.util.Map; @@ -47,15 +47,15 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { private static final Logger LOG = LoggerFactory.getLogger(DelegatingReaderRegistry.class); - private final Map<Class<? extends DataObject>, VppReader<? extends DataObject>> rootReaders; + private final Map<Class<? extends DataObject>, Reader<? extends DataObject>> rootReaders; /** * Create new {@link DelegatingReaderRegistry} * * @param rootReaders List of delegate readers */ - public DelegatingReaderRegistry(@Nonnull final List<VppReader<? extends DataObject>> rootReaders) { - this.rootReaders = VppRWUtils.uniqueLinkedIndex(checkNotNull(rootReaders), VppRWUtils.MANAGER_CLASS_FUNCTION); + public DelegatingReaderRegistry(@Nonnull final List<Reader<? extends DataObject>> rootReaders) { + this.rootReaders = RWUtils.uniqueLinkedIndex(checkNotNull(rootReaders), RWUtils.MANAGER_CLASS_FUNCTION); } @Override @@ -67,12 +67,12 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { LOG.trace("Reading from all delegates: {}", rootReaders.values()); final Multimap<InstanceIdentifier<? extends DataObject>, DataObject> objects = LinkedListMultimap.create(); - for (VppReader<? extends DataObject> rootReader : rootReaders.values()) { + for (Reader<? extends DataObject> rootReader : rootReaders.values()) { LOG.debug("Reading from delegate: {}", rootReader); - if (rootReader instanceof ListVppReader) { + if (rootReader instanceof ListReader) { final List<? extends DataObject> listEntries = - ((ListVppReader) rootReader).readList(rootReader.getManagedDataObjectType(), ctx); + ((ListReader) rootReader).readList(rootReader.getManagedDataObjectType(), ctx); if (!listEntries.isEmpty()) { objects.putAll(rootReader.getManagedDataObjectType(), listEntries); } @@ -94,11 +94,11 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { throws ReadFailedException { final InstanceIdentifier.PathArgument first = checkNotNull( Iterables.getFirst(id.getPathArguments(), null), "Empty id"); - final VppReader<? extends DataObject> vppReader = rootReaders.get(first.getType()); - checkNotNull(vppReader, + final Reader<? extends DataObject> reader = rootReaders.get(first.getType()); + checkNotNull(reader, "Unable to read %s. Missing reader. Current readers for: %s", id, rootReaders.keySet()); - LOG.debug("Reading from delegate: {}", vppReader); - return vppReader.read(id, ctx); + LOG.debug("Reading from delegate: {}", reader); + return reader.read(id, ctx); } /** diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/NoopReaderCustomizer.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/NoopReaderCustomizer.java index 5b78cdbba..5ed033755 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/NoopReaderCustomizer.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/NoopReaderCustomizer.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read.util; +package io.fd.honeycomb.v3po.translate.util.read; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.RootVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.Context; +import io.fd.honeycomb.v3po.translate.spi.read.RootReaderCustomizer; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public abstract class NoopReaderCustomizer<C extends DataObject, B extends Builder<C>> implements - RootVppReaderCustomizer<C, B> { + RootReaderCustomizer<C, B> { @Override public void readCurrentAttributes(InstanceIdentifier<C> id, final B builder, final Context context) { diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveChildReaderCustomizer.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveChildReaderCustomizer.java index a83269658..3d5f9f4e8 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveChildReaderCustomizer.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveChildReaderCustomizer.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read.util; +package io.fd.honeycomb.v3po.translate.util.read; import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.ReflectionUtils; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.ChildVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.ReflectionUtils; +import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; @@ -31,7 +31,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; */ public class ReflexiveChildReaderCustomizer<C extends DataObject, B extends Builder<C>> extends ReflexiveRootReaderCustomizer<C, B> - implements ChildVppReaderCustomizer<C,B> { + implements ChildReaderCustomizer<C,B> { public ReflexiveChildReaderCustomizer(final Class<B> builderClass) { super(builderClass); diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveRootReaderCustomizer.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveRootReaderCustomizer.java index b78bcdc06..029f359bb 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/util/ReflexiveRootReaderCustomizer.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/read/ReflexiveRootReaderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.read.util; +package io.fd.honeycomb.v3po.translate.util.read; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistry.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/DelegatingWriterRegistry.java index 14cec7a55..fda289e2b 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistry.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/DelegatingWriterRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.util.write; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -24,11 +24,11 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.write.Writer; +import io.fd.honeycomb.v3po.translate.write.WriterRegistry; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -57,15 +57,15 @@ public final class DelegatingWriterRegistry implements WriterRegistry { } }; - private final Map<Class<? extends DataObject>, VppWriter<? extends DataObject>> rootWriters; + private final Map<Class<? extends DataObject>, Writer<? extends DataObject>> rootWriters; /** * Create new {@link DelegatingWriterRegistry} * * @param rootWriters List of delegate writers */ - public DelegatingWriterRegistry(@Nonnull final List<VppWriter<? extends DataObject>> rootWriters) { - this.rootWriters = VppRWUtils.uniqueLinkedIndex(checkNotNull(rootWriters), VppRWUtils.MANAGER_CLASS_FUNCTION); + public DelegatingWriterRegistry(@Nonnull final List<Writer<? extends DataObject>> rootWriters) { + this.rootWriters = RWUtils.uniqueLinkedIndex(checkNotNull(rootWriters), RWUtils.MANAGER_CLASS_FUNCTION); } /** @@ -82,25 +82,25 @@ public final class DelegatingWriterRegistry implements WriterRegistry { public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter, - @Nonnull final WriteContext ctx) throws VppException { + @Nonnull final WriteContext ctx) throws TranslationException { final InstanceIdentifier.PathArgument first = checkNotNull( Iterables.getFirst(id.getPathArguments(), null), "Empty id"); - final VppWriter<? extends DataObject> vppWriter = rootWriters.get(first.getType()); - checkNotNull(vppWriter, + final Writer<? extends DataObject> writer = rootWriters.get(first.getType()); + checkNotNull(writer, "Unable to write %s. Missing writer. Current writers for: %s", id, rootWriters.keySet()); - vppWriter.update(id, dataBefore, dataAfter, ctx); + writer.update(id, dataBefore, dataAfter, ctx); } @Override public void update(@Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesBefore, @Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesAfter, - @Nonnull final WriteContext ctx) throws VppException { + @Nonnull final WriteContext ctx) throws TranslationException { checkAllWritersPresent(nodesBefore); checkAllWritersPresent(nodesAfter); final List<InstanceIdentifier<?>> processedNodes = Lists.newArrayList(); - for (Map.Entry<Class<? extends DataObject>, VppWriter<? extends DataObject>> rootWriterEntry : rootWriters + for (Map.Entry<Class<? extends DataObject>, Writer<? extends DataObject>> rootWriterEntry : rootWriters .entrySet()) { final InstanceIdentifier<? extends DataObject> id = rootWriterEntry.getValue().getManagedDataObjectType(); diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/NoopWriterCustomizer.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterCustomizer.java index 96b7d19b4..266325815 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/NoopWriterCustomizer.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterCustomizer.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.util.write; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.RootVppWriterCustomizer; +import io.fd.honeycomb.v3po.translate.spi.write.RootWriterCustomizer; +import io.fd.honeycomb.v3po.translate.Context; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -26,7 +26,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * Customizer not performing any changes on current level. Suitable for nodes that don't have any leaves and all of * its child nodes are managed by dedicated writers */ -public class NoopWriterCustomizer<D extends DataObject> implements RootVppWriterCustomizer<D> { +public class NoopWriterCustomizer<D extends DataObject> implements RootWriterCustomizer<D> { @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataAfter, diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/ReflexiveChildWriterCustomizer.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/ReflexiveChildWriterCustomizer.java index 820f469d6..ba67e560c 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/ReflexiveChildWriterCustomizer.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/ReflexiveChildWriterCustomizer.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.util.write; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.ReflectionUtils; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.ChildVppWriterCustomizer; +import io.fd.honeycomb.v3po.translate.util.ReflectionUtils; +import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * Might be slow ! */ public class ReflexiveChildWriterCustomizer<C extends DataObject> extends NoopWriterCustomizer<C> implements - ChildVppWriterCustomizer<C> { + ChildWriterCustomizer<C> { @Nonnull @Override diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContext.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java index da124b03c..0bb68e3b2 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContext.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.util.write; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.Context; import java.util.Map; import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; diff --git a/v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/DelegatingWriterRegistryTest.java index 774974d4f..e201890b5 100644 --- a/v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java +++ b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/DelegatingWriterRegistryTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.impl.write.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -24,10 +24,11 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; +import io.fd.honeycomb.v3po.translate.TranslationException; +import io.fd.honeycomb.v3po.translate.util.write.DelegatingWriterRegistry; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.write.Writer; +import io.fd.honeycomb.v3po.translate.write.WriterRegistry; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -49,9 +50,9 @@ public class DelegatingWriterRegistryTest { private final InstanceIdentifier<Interfaces> interfaceId; private WriteContext ctx; - private VppWriter<Vpp> vppWriter; - private VppWriter<VppState> vppStateWriter; - private VppWriter<Interfaces> interfacesWriter; + private Writer<Vpp> writer; + private Writer<VppState> vppStateWriter; + private Writer<Interfaces> interfacesWriter; private DelegatingWriterRegistry registry; @@ -62,8 +63,8 @@ public class DelegatingWriterRegistryTest { } @SuppressWarnings("unchecked") - private <D extends DataObject> VppWriter<D> mockWriter(Class<D> clazz) { - final VppWriter<D> mock = (VppWriter<D>) Mockito.mock(VppWriter.class); + private <D extends DataObject> Writer<D> mockWriter(Class<D> clazz) { + final Writer<D> mock = (Writer<D>) Mockito.mock(Writer.class); doReturn(InstanceIdentifier.create(clazz)).when(mock).getManagedDataObjectType(); return mock; } @@ -89,12 +90,12 @@ public class DelegatingWriterRegistryTest { @Before public void setUp() { ctx = mock(WriteContext.class); - vppWriter = mockWriter(Vpp.class); + writer = mockWriter(Vpp.class); vppStateWriter = mockWriter(VppState.class); interfacesWriter = mockWriter(Interfaces.class); - final List<VppWriter<? extends DataObject>> writers = new ArrayList<>(); - writers.add(vppWriter); + final List<Writer<? extends DataObject>> writers = new ArrayList<>(); + writers.add(writer); writers.add(vppStateWriter); writers.add(interfacesWriter); @@ -116,7 +117,7 @@ public class DelegatingWriterRegistryTest { final DataObject dataAfter2 = mockDataObject("VppState after", VppState.class); // Fail on update - doThrow(new VppException("vpp failed")).when(vppStateWriter) + Mockito.doThrow(new TranslationException("vpp failed")).when(vppStateWriter) .update(vppStateId, dataBefore2, dataAfter2, ctx); // Run the test @@ -125,14 +126,14 @@ public class DelegatingWriterRegistryTest { } catch (WriterRegistry.BulkUpdateException e) { // Check second update failed assertEquals(vppStateId, e.getFailedId()); - verify(vppWriter).update(vppId, dataBefore1, dataAfter1, ctx); + verify(writer).update(vppId, dataBefore1, dataAfter1, ctx); verify(vppStateWriter).update(vppStateId, dataBefore2, dataAfter2, ctx); // Try to revert changes e.revertChanges(); // Check revert was successful - verify(vppWriter).update(vppId, dataAfter1, dataBefore1, ctx); + verify(writer).update(vppId, dataAfter1, dataBefore1, ctx); verify(vppStateWriter, never()).update(vppStateId, dataAfter2, dataBefore2, ctx); return; @@ -153,11 +154,11 @@ public class DelegatingWriterRegistryTest { final DataObject dataAfter3 = mockDataObject("Interfaces after", Interfaces.class); // Fail on the third update - doThrow(new VppException("vpp failed")).when(interfacesWriter) + doThrow(new TranslationException("vpp failed")).when(interfacesWriter) .update(interfaceId, dataBefore3, dataAfter3, ctx); // Fail on the second revert - doThrow(new VppException("vpp failed again")).when(vppWriter) + doThrow(new TranslationException("vpp failed again")).when(writer) .update(vppId, dataAfter1, dataBefore1, ctx); // Run the test @@ -166,7 +167,7 @@ public class DelegatingWriterRegistryTest { } catch (WriterRegistry.BulkUpdateException e) { // Check third update failed assertEquals(interfaceId, e.getFailedId()); - verify(vppWriter).update(vppId, dataBefore1, dataAfter1, ctx); + verify(writer).update(vppId, dataBefore1, dataAfter1, ctx); verify(vppStateWriter).update(vppStateId, dataBefore2, dataAfter2, ctx); verify(interfacesWriter).update(interfaceId, dataBefore3, dataAfter3, ctx); @@ -176,7 +177,7 @@ public class DelegatingWriterRegistryTest { } catch (WriterRegistry.Reverter.RevertFailedException e2) { // Check second revert failed assertEquals(Collections.singletonList(vppId), e2.getNotRevertedChanges()); - verify(vppWriter).update(vppId, dataAfter1, dataBefore1, ctx); + verify(writer).update(vppId, dataAfter1, dataBefore1, ctx); verify(vppStateWriter).update(vppStateId, dataAfter2, dataBefore2, ctx); verify(interfacesWriter, never()).update(interfaceId, dataAfter3, dataBefore3, ctx); return; diff --git a/v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java index 0e46e2fa4..5a8740b2d 100644 --- a/v3po/vpp-facade-utils/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java +++ b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; +package io.fd.honeycomb.v3po.translate.impl.write.util; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -29,7 +29,8 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; +import io.fd.honeycomb.v3po.translate.util.write.TransactionWriteContext; import java.util.Map; import org.junit.Before; import org.junit.Test; diff --git a/v3po/v3po2vpp/pom.xml b/v3po/v3po2vpp/pom.xml index eb4aca7fa..e14730594 100644 --- a/v3po/v3po2vpp/pom.xml +++ b/v3po/v3po2vpp/pom.xml @@ -31,12 +31,17 @@ <dependencies> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-spi</artifactId> + <artifactId>translate-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-utils</artifactId> + <artifactId>translate-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vpp-translate-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> @@ -53,7 +58,7 @@ <!-- Testing Dependencies --> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>vpp-facade-impl</artifactId> + <artifactId>translate-impl</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java index 2c394fe77..ffbc95beb 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vpp; +package io.fd.honeycomb.v3po.translate.v3po.vpp; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppApiCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.spi.write.ListVppWriterCustomizer; +import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.util.VppApiCustomizer; +import io.fd.honeycomb.v3po.translate.Context; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; public class BridgeDomainCustomizer extends VppApiCustomizer - implements ListVppWriterCustomizer<BridgeDomain, BridgeDomainKey> { + implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> { private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java index 178deaddf..36e1da366 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate; +package io.fd.honeycomb.v3po.translate.v3po.vppstate; import com.google.common.collect.Lists; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppApiCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.ListVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.util.VppApiCustomizer; +import io.fd.honeycomb.v3po.translate.Context; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; @@ -41,7 +41,7 @@ import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails; import org.openvpp.vppjapi.vppL2Fib; public final class BridgeDomainCustomizer extends VppApiCustomizer - implements ListVppReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> { + implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> { public BridgeDomainCustomizer(@Nonnull final org.openvpp.vppjapi.vppApi vppApi) { super(vppApi); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java index 3e928176e..31e3166bb 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VersionCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate; +package io.fd.honeycomb.v3po.translate.v3po.vppstate; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppApiCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.ChildVppReaderCustomizer; +import io.fd.honeycomb.v3po.translate.Context; +import io.fd.honeycomb.v3po.translate.v3po.util.VppApiCustomizer; +import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version; @@ -30,7 +30,7 @@ import org.openvpp.vppjapi.vppVersion; public final class VersionCustomizer extends VppApiCustomizer - implements ChildVppReaderCustomizer<Version, VersionBuilder> { + implements ChildReaderCustomizer<Version, VersionBuilder> { public VersionCustomizer(@Nonnull final org.openvpp.vppjapi.vppApi vppApi) { super(vppApi); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java index 059713544..f504918a8 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java @@ -14,13 +14,8 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vpp; +package io.fd.honeycomb.v3po.translate.v3po.vpp; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.bdIdentifierForName; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.bdNameToID; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.booleanToByte; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.intToBoolean; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; @@ -28,7 +23,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; -import io.fd.honeycomb.v3po.vpp.facade.Context; +import io.fd.honeycomb.v3po.translate.Context; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -65,8 +60,8 @@ public class BridgeDomainCustomizerTest { initMocks(this); customizer = new BridgeDomainCustomizer(api); - PowerMockito.doAnswer(BD_NAME_TO_ID_ANSWER).when(api).findOrAddBridgeDomainId(anyString()); - PowerMockito.doAnswer(BD_NAME_TO_ID_ANSWER).when(api).bridgeDomainIdFromName(anyString()); + PowerMockito.doAnswer(BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER).when(api).findOrAddBridgeDomainId(anyString()); + PowerMockito.doAnswer(BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER).when(api).bridgeDomainIdFromName(anyString()); PowerMockito.when(api.getRetval(anyInt(), anyInt())).thenReturn(RESPONSE_NOT_READY).thenReturn(0); PowerMockito.doReturn(0).when(api).getRetval(anyInt(), anyInt()); } @@ -84,41 +79,41 @@ public class BridgeDomainCustomizerTest { final int forward, final int learn, final int uuf) { return new BridgeDomainBuilder() .setName(bdName) - .setArpTermination(intToBoolean(arpTerm)) - .setFlood(intToBoolean(flood)) - .setForward(intToBoolean(forward)) - .setLearn(intToBoolean(learn)) - .setUnknownUnicastFlood(intToBoolean(uuf)) + .setArpTermination(BridgeDomainTestUtils.intToBoolean(arpTerm)) + .setFlood(BridgeDomainTestUtils.intToBoolean(flood)) + .setForward(BridgeDomainTestUtils.intToBoolean(forward)) + .setLearn(BridgeDomainTestUtils.intToBoolean(learn)) + .setUnknownUnicastFlood(BridgeDomainTestUtils.intToBoolean(uuf)) .build(); } private final int verifyBridgeDomainAddOrUpdateWasInvoked(final BridgeDomain bd) { - final int bdn1Id = bdNameToID(bd.getName()); - final byte arpTerm = booleanToByte(bd.isArpTermination()); - final byte flood = booleanToByte(bd.isFlood()); - final byte forward = booleanToByte(bd.isForward()); - final byte learn = booleanToByte(bd.isLearn()); - final byte uuf = booleanToByte(bd.isUnknownUnicastFlood()); + final int bdn1Id = BridgeDomainTestUtils.bdNameToID(bd.getName()); + final byte arpTerm = BridgeDomainTestUtils.booleanToByte(bd.isArpTermination()); + final byte flood = BridgeDomainTestUtils.booleanToByte(bd.isFlood()); + final byte forward = BridgeDomainTestUtils.booleanToByte(bd.isForward()); + final byte learn = BridgeDomainTestUtils.booleanToByte(bd.isLearn()); + final byte uuf = BridgeDomainTestUtils.booleanToByte(bd.isUnknownUnicastFlood()); return verify(api).bridgeDomainAddDel(bdn1Id, flood, forward, learn, uuf, arpTerm, ADD_OR_UPDATE_BD); } private int verifyBridgeDomainAddOrUpdateWasNotInvoked(final BridgeDomain bd) { - final int bdn1Id = bdNameToID(bd.getName()); - final byte arpTerm = booleanToByte(bd.isArpTermination()); - final byte flood = booleanToByte(bd.isFlood()); - final byte forward = booleanToByte(bd.isForward()); - final byte learn = booleanToByte(bd.isLearn()); - final byte uuf = booleanToByte(bd.isUnknownUnicastFlood()); + final int bdn1Id = BridgeDomainTestUtils.bdNameToID(bd.getName()); + final byte arpTerm = BridgeDomainTestUtils.booleanToByte(bd.isArpTermination()); + final byte flood = BridgeDomainTestUtils.booleanToByte(bd.isFlood()); + final byte forward = BridgeDomainTestUtils.booleanToByte(bd.isForward()); + final byte learn = BridgeDomainTestUtils.booleanToByte(bd.isLearn()); + final byte uuf = BridgeDomainTestUtils.booleanToByte(bd.isUnknownUnicastFlood()); return verify(api, never()).bridgeDomainAddDel(bdn1Id, flood, forward, learn, uuf, arpTerm, ADD_OR_UPDATE_BD); } private int verifyBridgeDomainDeletedWasInvoked(final BridgeDomain bd) { - final int bdn1Id = bdNameToID(bd.getName()); + final int bdn1Id = BridgeDomainTestUtils.bdNameToID(bd.getName()); return verify(api).bridgeDomainAddDel(bdn1Id, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO); } private int verifyBridgeDomainDeletedWasNotInvoked(final BridgeDomain bd) { - final int bdn1Id = bdNameToID(bd.getName()); + final int bdn1Id = BridgeDomainTestUtils.bdNameToID(bd.getName()); return verify(api, never()).bridgeDomainAddDel(bdn1Id, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO); } @@ -127,7 +122,7 @@ public class BridgeDomainCustomizerTest { final String bdName = "bd1"; final BridgeDomain bd = generateBridgeDomain("bd1"); - customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); verifyBridgeDomainAddOrUpdateWasInvoked(bd); } @@ -141,7 +136,7 @@ public class BridgeDomainCustomizerTest { PowerMockito.doReturn(-1).when(api).findOrAddBridgeDomainId(bdName); try { - customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainAddOrUpdateWasNotInvoked(bd); return; @@ -158,7 +153,7 @@ public class BridgeDomainCustomizerTest { final BridgeDomain bd = generateBridgeDomain(bdName); try { - customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainAddOrUpdateWasInvoked(bd); return; @@ -171,7 +166,7 @@ public class BridgeDomainCustomizerTest { final String bdName = "bd1"; final BridgeDomain bd = generateBridgeDomain("bd1"); - customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); verifyBridgeDomainDeletedWasInvoked(bd); } @@ -185,7 +180,7 @@ public class BridgeDomainCustomizerTest { PowerMockito.doReturn(-1).when(api).bridgeDomainIdFromName(bdName); try { - customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainDeletedWasNotInvoked(bd); return; @@ -202,7 +197,7 @@ public class BridgeDomainCustomizerTest { final BridgeDomain bd = generateBridgeDomain(bdName); try { - customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, ctx); + customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainDeletedWasInvoked(bd); return; @@ -225,7 +220,7 @@ public class BridgeDomainCustomizerTest { generateBridgeDomain(bdName, arpTermBefore ^ 1, floodBefore ^ 1, forwardBefore ^ 1, learnBefore ^ 1, uufBefore ^ 1); - final KeyedInstanceIdentifier<BridgeDomain, BridgeDomainKey> id = bdIdentifierForName(bdName); + final KeyedInstanceIdentifier<BridgeDomain, BridgeDomainKey> id = BridgeDomainTestUtils.bdIdentifierForName(bdName); customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); @@ -241,7 +236,7 @@ public class BridgeDomainCustomizerTest { PowerMockito.doReturn(-1).when(api).bridgeDomainIdFromName(bdName); try { - customizer.updateCurrentAttributes(bdIdentifierForName(bdName), bd, bd, ctx); + customizer.updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainAddOrUpdateWasNotInvoked(bd); return; @@ -258,7 +253,7 @@ public class BridgeDomainCustomizerTest { final BridgeDomain bd = generateBridgeDomain(bdName); try { - customizer.updateCurrentAttributes(bdIdentifierForName(bdName), bd, bd, ctx); + customizer.updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, bd, ctx); } catch (IllegalStateException e) { verifyBridgeDomainAddOrUpdateWasInvoked(bd); return; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainTestUtils.java index 51a6b023e..ba4df9e49 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/BridgeDomainTestUtils.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainTestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vpp; +package io.fd.honeycomb.v3po.translate.v3po.vpp; import javax.annotation.Nullable; import org.mockito.invocation.InvocationOnMock; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppTest.java index bc5bda383..0ff3ba16d 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppTest.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vpp; +package io.fd.honeycomb.v3po.translate.v3po.vpp; -import static io.fd.honeycomb.v3po.vpp.facade.v3po.vpp.BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; @@ -25,10 +24,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import com.google.common.collect.Lists; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeRootVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.DelegatingWriterRegistry; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeRootWriter; +import io.fd.honeycomb.v3po.translate.write.WriteContext; +import io.fd.honeycomb.v3po.translate.util.write.DelegatingWriterRegistry; +import io.fd.honeycomb.v3po.translate.write.Writer; import java.util.Collections; import java.util.List; import org.junit.Before; @@ -55,7 +54,7 @@ public class VppTest { private vppApi api; private DelegatingWriterRegistry rootRegistry; - private CompositeRootVppWriter<Vpp> vppWriter; + private CompositeRootWriter<Vpp> vppWriter; private WriteContext ctx; final byte zero = (byte) 0; @@ -70,12 +69,12 @@ public class VppTest { public void setUp() throws Exception { api = PowerMockito.mock(vppApi.class); ctx = mock(WriteContext.class); - PowerMockito.doAnswer(BD_NAME_TO_ID_ANSWER).when(api).findOrAddBridgeDomainId(anyString()); - PowerMockito.doAnswer(BD_NAME_TO_ID_ANSWER).when(api).bridgeDomainIdFromName(anyString()); + PowerMockito.doAnswer(BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER).when(api).findOrAddBridgeDomainId(anyString()); + PowerMockito.doAnswer(BridgeDomainTestUtils.BD_NAME_TO_ID_ANSWER).when(api).bridgeDomainIdFromName(anyString()); PowerMockito.doReturn(1).when(api).getRetval(anyInt(), anyInt()); vppWriter = VppUtils.getVppWriter(api); rootRegistry = new DelegatingWriterRegistry( - Collections.<VppWriter<? extends DataObject>>singletonList(vppWriter)); + Collections.<Writer<? extends DataObject>>singletonList(vppWriter)); } @Test diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppUtils.java index ccf19c81c..cb74314e3 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vpp/VppUtils.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/VppUtils.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vpp; - -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeChildVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeListVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeRootVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.NoopWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.util.ReflexiveChildWriterCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.write.ChildVppWriter; +package io.fd.honeycomb.v3po.translate.v3po.vpp; + +import io.fd.honeycomb.v3po.translate.impl.write.CompositeChildWriter; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeListWriter; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeRootWriter; +import io.fd.honeycomb.v3po.translate.util.write.NoopWriterCustomizer; +import io.fd.honeycomb.v3po.translate.util.write.ReflexiveChildWriterCustomizer; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import io.fd.honeycomb.v3po.translate.util.RWUtils; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; @@ -40,21 +40,21 @@ final class VppUtils { /** * Create root Vpp writer with all its children wired */ - static CompositeRootVppWriter<Vpp> getVppWriter(@Nonnull final vppApi vppApi) { + static CompositeRootWriter<Vpp> getVppWriter(@Nonnull final vppApi vppApi) { - final CompositeListVppWriter<BridgeDomain, BridgeDomainKey> bridgeDomainWriter = new CompositeListVppWriter<>( + final CompositeListWriter<BridgeDomain, BridgeDomainKey> bridgeDomainWriter = new CompositeListWriter<>( BridgeDomain.class, new BridgeDomainCustomizer(vppApi)); - final ChildVppWriter<BridgeDomains> bridgeDomainsReader = new CompositeChildVppWriter<>( + final ChildWriter<BridgeDomains> bridgeDomainsReader = new CompositeChildWriter<>( BridgeDomains.class, - VppRWUtils.singletonChildWriterList(bridgeDomainWriter), + RWUtils.singletonChildWriterList(bridgeDomainWriter), new ReflexiveChildWriterCustomizer<BridgeDomains>()); - final List<ChildVppWriter<? extends ChildOf<Vpp>>> childWriters = new ArrayList<>(); + final List<ChildWriter<? extends ChildOf<Vpp>>> childWriters = new ArrayList<>(); childWriters.add(bridgeDomainsReader); - return new CompositeRootVppWriter<>( + return new CompositeRootWriter<>( Vpp.class, childWriters, new NoopWriterCustomizer<Vpp>()); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java index 059c98f56..6f53f6519 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate; +package io.fd.honeycomb.v3po.translate.v3po.vppstate; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -26,11 +26,11 @@ import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeListVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeRootVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.DelegatingReaderRegistry; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.VppReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeRootReader; +import io.fd.honeycomb.v3po.translate.util.read.DelegatingReaderRegistry; +import io.fd.honeycomb.v3po.translate.read.ReadContext; +import io.fd.honeycomb.v3po.translate.read.Reader; import java.util.Collections; import java.util.List; import org.junit.Before; @@ -71,7 +71,7 @@ public class VppStateTest { public static final vppVersion VERSION = new vppVersion("test", "1", "2", "33"); private vppApi api; - private CompositeRootVppReader<VppState, VppStateBuilder> vppStateReader; + private CompositeRootReader<VppState, VppStateBuilder> vppStateReader; private DelegatingReaderRegistry readerRegistry; private vppBridgeDomainDetails bdDetails; private vppBridgeDomainDetails bdDetails2; @@ -120,7 +120,7 @@ public class VppStateTest { PowerMockito.doReturn(new int[] {1, 2}).when(api).bridgeDomainDump(Matchers.anyInt()); PowerMockito.doReturn(VERSION).when(api).getVppVersion(); vppStateReader = VppStateUtils.getVppStateReader(api); - readerRegistry = new DelegatingReaderRegistry(Collections.<VppReader<? extends DataObject>>singletonList(vppStateReader)); + readerRegistry = new DelegatingReaderRegistry(Collections.<Reader<? extends DataObject>>singletonList(vppStateReader)); } private vppL2Fib[] getL2Fibs() { @@ -210,7 +210,7 @@ public class VppStateTest { public void testReadBridgeDomainAll() throws Exception { VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get(); - final CompositeListVppReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader = + final CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader = VppStateUtils.getBridgeDomainReader(api); final List<BridgeDomain> read = diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateUtils.java index 7d5441769..5c619d84d 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/vpp/facade/v3po/vppstate/VppStateUtils.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateUtils.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.v3po.vppstate; +package io.fd.honeycomb.v3po.translate.v3po.vppstate; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeListVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.CompositeRootVppReader; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.ReflexiveChildReaderCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.read.util.ReflexiveRootReaderCustomizer; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeRootReader; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveRootReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.read.ChildReader; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; @@ -44,33 +44,33 @@ final class VppStateUtils { /** * Create root VppState reader with all its children wired */ - static CompositeRootVppReader<VppState, VppStateBuilder> getVppStateReader(@Nonnull final vppApi vppApi) { + static CompositeRootReader<VppState, VppStateBuilder> getVppStateReader(@Nonnull final vppApi vppApi) { - final ChildVppReader<Version> versionReader = new CompositeChildVppReader<>( + final ChildReader<Version> versionReader = new CompositeChildReader<>( Version.class, new VersionCustomizer(vppApi)); - final CompositeListVppReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader = + final CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader = getBridgeDomainReader(vppApi); - final ChildVppReader<BridgeDomains> bridgeDomainsReader = new CompositeChildVppReader<>( + final ChildReader<BridgeDomains> bridgeDomainsReader = new CompositeChildReader<>( BridgeDomains.class, - VppRWUtils.singletonChildReaderList(bridgeDomainReader), + RWUtils.singletonChildReaderList(bridgeDomainReader), new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class)); - final List<ChildVppReader<? extends ChildOf<VppState>>> childVppReaders = new ArrayList<>(); + final List<ChildReader<? extends ChildOf<VppState>>> childVppReaders = new ArrayList<>(); childVppReaders.add(versionReader); childVppReaders.add(bridgeDomainsReader); - return new CompositeRootVppReader<>( + return new CompositeRootReader<>( VppState.class, childVppReaders, - VppRWUtils.<VppState>emptyAugReaderList(), + RWUtils.<VppState>emptyAugReaderList(), new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class)); } - static CompositeListVppReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader( + static CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader( final @Nonnull vppApi vppApi) { - return new CompositeListVppReader<>( + return new CompositeListReader<>( BridgeDomain.class, new BridgeDomainCustomizer(vppApi)); } diff --git a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeRootVppReader.java b/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeRootVppReader.java deleted file mode 100644 index 95f2a8eec..000000000 --- a/v3po/vpp-facade-impl/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/read/CompositeRootVppReader.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.v3po.vpp.facade.impl.read; - -import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.vpp.facade.impl.util.VppRWUtils; -import io.fd.honeycomb.v3po.vpp.facade.read.ChildVppReader; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadContext; -import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException; -import io.fd.honeycomb.v3po.vpp.facade.read.VppReader; -import io.fd.honeycomb.v3po.vpp.facade.spi.read.RootVppReaderCustomizer; -import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.ThreadSafe; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Composite implementation of {@link io.fd.honeycomb.v3po.vpp.facade.read.VppReader} - */ -@Beta -@ThreadSafe -public final class CompositeRootVppReader<C extends DataObject, B extends Builder<C>> extends AbstractCompositeVppReader<C, B> - implements VppReader<C> { - - private final RootVppReaderCustomizer<C, B> customizer; - - /** - * Create new {@link CompositeRootVppReader} - * - * @param managedDataObjectType Class object for managed data type - * @param childReaders Child nodes(container, list) readers - * @param augReaders Child augmentations readers - * @param customizer Customizer instance to customize this generic reader - * - */ - public CompositeRootVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final List<ChildVppReader<? extends Augmentation<C>>> augReaders, - @Nonnull final RootVppReaderCustomizer<C, B> customizer) { - super(managedDataObjectType, childReaders, augReaders); - this.customizer = customizer; - } - - /** - * @see {@link CompositeRootVppReader#CompositeRootVppReader(Class, List, List, RootVppReaderCustomizer)} - */ - public CompositeRootVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final List<ChildVppReader<? extends ChildOf<C>>> childReaders, - @Nonnull final RootVppReaderCustomizer<C, B> customizer) { - this(managedDataObjectType, childReaders, VppRWUtils.<C>emptyAugReaderList(), customizer); - } - - /** - * @see {@link CompositeRootVppReader#CompositeRootVppReader(Class, List, List, RootVppReaderCustomizer)} - */ - public CompositeRootVppReader(@Nonnull final Class<C> managedDataObjectType, - @Nonnull final RootVppReaderCustomizer<C, B> customizer) { - this(managedDataObjectType, VppRWUtils.<C>emptyChildReaderList(), VppRWUtils.<C>emptyAugReaderList(), - customizer); - } - - @Override - protected void readCurrentAttributes(@Nonnull final InstanceIdentifier<C> id, @Nonnull final B builder, - @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder, ctx.getContext()); - } - - @Override - protected B getBuilder(@Nonnull final InstanceIdentifier<C> id) { - return customizer.getBuilder(id); - } - -} diff --git a/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java b/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java deleted file mode 100644 index 6730cfe26..000000000 --- a/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/DelegatingWriterRegistryTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import io.fd.honeycomb.v3po.vpp.facade.VppException; -import io.fd.honeycomb.v3po.vpp.facade.impl.write.CompositeRootVppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.VppWriter; -import io.fd.honeycomb.v3po.vpp.facade.write.WriteContext; -import io.fd.honeycomb.v3po.vpp.facade.write.WriterRegistry; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class DelegatingWriterRegistryTest { - - private final InstanceIdentifier<Vpp> vppId; - private final InstanceIdentifier<VppState> vppStateId; - private final InstanceIdentifier<Interfaces> interfaceId; - - private WriteContext ctx; - private CompositeRootVppWriter<Vpp> vppWriter; - private CompositeRootVppWriter<VppState> vppStateWriter; - private CompositeRootVppWriter<Interfaces> interfacesWriter; - - private DelegatingWriterRegistry registry; - - public DelegatingWriterRegistryTest() { - vppId = InstanceIdentifier.create(Vpp.class); - vppStateId = InstanceIdentifier.create(VppState.class); - interfaceId = InstanceIdentifier.create(Interfaces.class); - } - - @SuppressWarnings("unchecked") - private <D extends DataObject> CompositeRootVppWriter<D> mockWriter(Class<D> clazz) { - final CompositeRootVppWriter<D> mock = (CompositeRootVppWriter<D>) Mockito.mock(CompositeRootVppWriter.class); - doReturn(InstanceIdentifier.create(clazz)).when(mock).getManagedDataObjectType(); - return mock; - } - - private DataObject mockDataObject(final String name, final Class<? extends DataObject> classToMock) { - final DataObject dataBefore = mock(classToMock, name); - doReturn(classToMock).when(dataBefore).getImplementedInterface(); - return dataBefore; - } - - @SuppressWarnings("unchecked") - private static Map<InstanceIdentifier<?>, DataObject> asMap(DataObject... objects) { - final Map<InstanceIdentifier<?>, DataObject> map = new HashMap<>(); - for (DataObject object : objects) { - final Class<? extends DataObject> implementedInterface = - (Class<? extends DataObject>) object.getImplementedInterface(); - final InstanceIdentifier<?> id = InstanceIdentifier.create(implementedInterface); - map.put(id, object); - } - return map; - } - - @Before - public void setUp() { - ctx = mock(WriteContext.class); - vppWriter = mockWriter(Vpp.class); - vppStateWriter = mockWriter(VppState.class); - interfacesWriter = mockWriter(Interfaces.class); - - final List<VppWriter<? extends DataObject>> writers = new ArrayList<>(); - writers.add(vppWriter); - writers.add(vppStateWriter); - writers.add(interfacesWriter); - - registry = new DelegatingWriterRegistry(writers); - } - - @Test(expected = UnsupportedOperationException.class) - public void testGetManagedDataObjectType() { - registry.getManagedDataObjectType(); - } - - @Test - public void testBulkUpdateRevert() throws Exception { - // Prepare data changes: - final DataObject dataBefore1 = mockDataObject("Vpp before", Vpp.class); - final DataObject dataAfter1 = mockDataObject("Vpp after", Vpp.class); - - final DataObject dataBefore2 = mockDataObject("VppState before", VppState.class); - final DataObject dataAfter2 = mockDataObject("VppState after", VppState.class); - - // Fail on update - doThrow(new VppException("vpp failed")).when(vppStateWriter) - .update(vppStateId, dataBefore2, dataAfter2, ctx); - - // Run the test - try { - registry.update(asMap(dataBefore1, dataBefore2), asMap(dataAfter1, dataAfter2), ctx); - } catch (WriterRegistry.BulkUpdateException e) { - // Check second update failed - assertEquals(vppStateId, e.getFailedId()); - verify(vppWriter).update(vppId, dataBefore1, dataAfter1, ctx); - verify(vppStateWriter).update(vppStateId, dataBefore2, dataAfter2, ctx); - - // Try to revert changes - e.revertChanges(); - - // Check revert was successful - verify(vppWriter).update(vppId, dataAfter1, dataBefore1, ctx); - verify(vppStateWriter, never()).update(vppStateId, dataAfter2, dataBefore2, ctx); - - return; - } - fail("BulkUpdateException expected"); - } - - @Test - public void testBulkUpdateRevertFail() throws Exception { - // Prepare data changes: - final DataObject dataBefore1 = mockDataObject("Vpp before", Vpp.class); - final DataObject dataAfter1 = mockDataObject("Vpp after", Vpp.class); - - final DataObject dataBefore2 = mockDataObject("VppState before", VppState.class); - final DataObject dataAfter2 = mockDataObject("VppState after", VppState.class); - - final DataObject dataBefore3 = mockDataObject("Interfaces before", Interfaces.class); - final DataObject dataAfter3 = mockDataObject("Interfaces after", Interfaces.class); - - // Fail on the third update - doThrow(new VppException("vpp failed")).when(interfacesWriter) - .update(interfaceId, dataBefore3, dataAfter3, ctx); - - // Fail on the second revert - doThrow(new VppException("vpp failed again")).when(vppWriter) - .update(vppId, dataAfter1, dataBefore1, ctx); - - // Run the test - try { - registry.update(asMap(dataBefore1, dataBefore2, dataBefore3), asMap(dataAfter1, dataAfter2, dataAfter3), ctx); - } catch (WriterRegistry.BulkUpdateException e) { - // Check third update failed - assertEquals(interfaceId, e.getFailedId()); - verify(vppWriter).update(vppId, dataBefore1, dataAfter1, ctx); - verify(vppStateWriter).update(vppStateId, dataBefore2, dataAfter2, ctx); - verify(interfacesWriter).update(interfaceId, dataBefore3, dataAfter3, ctx); - - // Try to revert changes - try { - e.revertChanges(); - } catch (WriterRegistry.Reverter.RevertFailedException e2) { - // Check second revert failed - assertEquals(Collections.singletonList(vppId), e2.getNotRevertedChanges()); - verify(vppWriter).update(vppId, dataAfter1, dataBefore1, ctx); - verify(vppStateWriter).update(vppStateId, dataAfter2, dataBefore2, ctx); - verify(interfacesWriter, never()).update(interfaceId, dataAfter3, dataBefore3, ctx); - return; - } - fail("WriterRegistry.Revert.RevertFailedException expected"); - } - fail("BulkUpdateException expected"); - } -}
\ No newline at end of file diff --git a/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java b/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java deleted file mode 100644 index 0e46e2fa4..000000000 --- a/v3po/vpp-facade-impl/src/test/java/io/fd/honeycomb/v3po/vpp/facade/impl/write/util/TransactionWriteContextTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.v3po.vpp.facade.impl.write.util; - -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.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.vpp.facade.Context; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -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.DOMDataReadOnlyTransaction; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -public class TransactionWriteContextTest { - - @Mock - private BindingNormalizedNodeSerializer serializer; - @Mock - private DOMDataReadOnlyTransaction beforeTx; - @Mock - private DOMDataReadOnlyTransaction afterTx; - @Mock - private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future; - @Mock - private Optional<org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?, ?>> optional; - @Mock - private Map.Entry entry; - - private TransactionWriteContext transactionWriteContext; - - @Before - public void setUp() { - initMocks(this); - transactionWriteContext = new TransactionWriteContext(serializer, beforeTx, afterTx); - } - - @Test - public void testReadBeforeNoData() throws Exception { - when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(future); - when(future.checkedGet()).thenReturn(optional); - when(optional.isPresent()).thenReturn(false); - - final InstanceIdentifier<BridgeDomain> instanceId = - InstanceIdentifier.create(Vpp.class).child(BridgeDomains.class).child(BridgeDomain.class); - - final Optional<DataObject> dataObjects = transactionWriteContext.readBefore(instanceId); - assertNotNull(dataObjects); - assertFalse(dataObjects.isPresent()); - - verify(serializer).toYangInstanceIdentifier(instanceId); - verify(serializer, never()).fromNormalizedNode(any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - } - - - @Test - public void testReadBefore() throws Exception { - when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(future); - when(future.checkedGet()).thenReturn(optional); - when(optional.isPresent()).thenReturn(true); - - final InstanceIdentifier<BridgeDomain> instanceId = - InstanceIdentifier.create(Vpp.class).child(BridgeDomains.class).child(BridgeDomain.class); - final YangInstanceIdentifier yangId = YangInstanceIdentifier.builder().node(VppState.QNAME).node( - BridgeDomains.QNAME).node(BridgeDomain.QNAME).build(); - when(serializer.toYangInstanceIdentifier(any(InstanceIdentifier.class))).thenReturn(yangId); - when(serializer.fromNormalizedNode(eq(yangId), any(NormalizedNode.class))).thenReturn(entry); - when(entry.getValue()).thenReturn(mock(DataObject.class)); - - final Optional<DataObject> dataObjects = transactionWriteContext.readBefore(instanceId); - assertNotNull(dataObjects); - assertTrue(dataObjects.isPresent()); - - verify(serializer).toYangInstanceIdentifier(instanceId); - verify(serializer).fromNormalizedNode(eq(yangId), any(NormalizedNode.class)); - } - - @Test(expected = IllegalStateException.class) - public void testReadBeforeFailed() throws Exception { - when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(future); - when(future.checkedGet()).thenThrow(ReadFailedException.class); - transactionWriteContext.readBefore(mock(InstanceIdentifier.class)); - } - - @Test(expected = IllegalStateException.class) - public void testReadAfterFailed() throws Exception { - when(afterTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(future); - when(future.checkedGet()).thenThrow(ReadFailedException.class); - transactionWriteContext.readAfter(mock(InstanceIdentifier.class)); - } - - @Test - public void testGetContext() throws Exception { - assertNotNull(transactionWriteContext.getContext()); - } - - @Test - public void testClose() throws Exception { - final Context context = transactionWriteContext.getContext(); - transactionWriteContext.close(); - // TODO verify context was closed - } -}
\ No newline at end of file diff --git a/v3po/vpp-translate-utils/pom.xml b/v3po/vpp-translate-utils/pom.xml new file mode 100644 index 000000000..b63b6d4f3 --- /dev/null +++ b/v3po/vpp-translate-utils/pom.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2015 Cisco and/or its affiliates. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>io.fd.honeycomb.common</groupId> + <artifactId>api-parent</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../common/api-parent</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>io.fd.honeycomb.v3po</groupId> + <artifactId>vpp-translate-utils</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>translate-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.fd.vpp</groupId> + <artifactId>vppjapi</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> + + <!-- Testing Dependencies --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> diff --git a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppApiCustomizer.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/VppApiCustomizer.java index 41090f493..de4602456 100644 --- a/v3po/vpp-facade-utils/src/main/java/io/fd/honeycomb/v3po/vpp/facade/impl/util/VppApiCustomizer.java +++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/VppApiCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.v3po.vpp.facade.impl.util; +package io.fd.honeycomb.v3po.translate.v3po.util; import com.google.common.annotations.Beta; |