diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-20 09:32:50 +0200 |
---|---|---|
committer | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-21 12:38:52 +0200 |
commit | 25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch) | |
tree | 811649e2ec44e0332e601c6563e00e914d355b9a | |
parent | cea47224b7b6afdd7b3d3ead8d08baf46eadc575 (diff) |
migrate sdnr features to sulfur
fix sdnr code for sulfur
Issue-ID: CCSDK-3692
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
189 files changed, 3478 insertions, 1342 deletions
diff --git a/sdnr/wt/README.md b/sdnr/wt/README.md index 2b19ff66a..60e2fe8f4 100644 --- a/sdnr/wt/README.md +++ b/sdnr/wt/README.md @@ -1,6 +1,6 @@ # wt - wireless transport microservices -ODL version: aluminium sr1 +ODL version: sulfur sr1 ## apigateway (osgi) diff --git a/sdnr/wt/apigateway/feature/pom.xml b/sdnr/wt/apigateway/feature/pom.xml index 00d63c422..0c0d57a67 100644 --- a/sdnr/wt/apigateway/feature/pom.xml +++ b/sdnr/wt/apigateway/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/apigateway/installer/pom.xml b/sdnr/wt/apigateway/installer/pom.xml index ac10d1721..ba104dd4b 100755 --- a/sdnr/wt/apigateway/installer/pom.xml +++ b/sdnr/wt/apigateway/installer/pom.xml @@ -19,13 +19,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/apigateway/pom.xml b/sdnr/wt/apigateway/pom.xml index 901f385fd..804cefd33 100755 --- a/sdnr/wt/apigateway/pom.xml +++ b/sdnr/wt/apigateway/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/apigateway/provider/pom.xml b/sdnr/wt/apigateway/provider/pom.xml index d56235206..46373b3fa 100644 --- a/sdnr/wt/apigateway/provider/pom.xml +++ b/sdnr/wt/apigateway/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -47,6 +48,7 @@ <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> @@ -66,6 +68,7 @@ <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-common</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> </dependencies> diff --git a/sdnr/wt/common-yang/iana-crypt-hash/pom.xml b/sdnr/wt/common-yang/iana-crypt-hash/pom.xml index 169eaf088..9f8dcfeec 100755 --- a/sdnr/wt/common-yang/iana-crypt-hash/pom.xml +++ b/sdnr/wt/common-yang/iana-crypt-hash/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/ietf-alarms/pom.xml b/sdnr/wt/common-yang/ietf-alarms/pom.xml index 612bbbfa7..ddd059fef 100755 --- a/sdnr/wt/common-yang/ietf-alarms/pom.xml +++ b/sdnr/wt/common-yang/ietf-alarms/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/onap/pom.xml b/sdnr/wt/common-yang/onap/pom.xml index 4d0336008..ad5d3e9e1 100755 --- a/sdnr/wt/common-yang/onap/pom.xml +++ b/sdnr/wt/common-yang/onap/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/openroadm-pm-types/pom.xml b/sdnr/wt/common-yang/openroadm-pm-types/pom.xml index a20e65fcf..fc8d6756f 100755 --- a/sdnr/wt/common-yang/openroadm-pm-types/pom.xml +++ b/sdnr/wt/common-yang/openroadm-pm-types/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/openroadm-pm-types/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java b/sdnr/wt/common-yang/openroadm-pm-types/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java index f89197b82..52ae92c88 100644 --- a/sdnr/wt/common-yang/openroadm-pm-types/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java +++ b/sdnr/wt/common-yang/openroadm-pm-types/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java @@ -1,58 +1,65 @@ package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129; - -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import java.lang.String; +import java.lang.UnsupportedOperationException; import java.math.BigDecimal; + +import javax.annotation.processing.Generated; + +import org.opendaylight.yangtools.yang.common.Decimal64; import org.opendaylight.yangtools.yang.common.Uint64; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; + /** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. * */ +@Generated("mdsal-binding-generator") @JsonPOJOBuilder(buildMethodName = "build", withPrefix = "set") public class PmDataTypeBuilder { - private Uint64 _uint64; - private Long _int64; - private BigDecimal _decimal64; - - public PmDataTypeBuilder() {} - - //Aluminium uses constructor - public PmDataTypeBuilder(String v) { - this.setUint64(v); - } - - public PmDataTypeBuilder setUint64(String v) { - _uint64 = Uint64.valueOf(v); - return this; - } - - public PmDataTypeBuilder setInt64(String v) { - _int64 = Long.valueOf(v); - return this; - } - - public PmDataTypeBuilder setDecimal64(String v) { - _decimal64 = new BigDecimal(v); - return this; - } - - public PmDataType build() { - if (_uint64 != null) { - return new PmDataType(_uint64); - } else if (_int64 != null) { - return new PmDataType(_int64); - } else { - return new PmDataType(_decimal64); - } - } - - public static PmDataType getDefaultInstance(String defaultValue) { - return new PmDataTypeBuilder().setUint64(defaultValue).build(); - } + private Uint64 _uint64; + private Long _int64; + private Decimal64 _decimal64; + + public PmDataTypeBuilder() {} + + //Aluminium uses constructor + public PmDataTypeBuilder(String v) { + this.setUint64(v); + } + + public PmDataTypeBuilder setUint64(String v) { + _uint64 = Uint64.valueOf(v); + return this; + } + + public PmDataTypeBuilder setInt64(String v) { + _int64 = Long.valueOf(v); + return this; + } + + public PmDataTypeBuilder setDecimal64(String v) { + _decimal64 = Decimal64.valueOf(v); + return this; + } + + public PmDataType build() { + if (_uint64 != null) { + return new PmDataType(_uint64); + } else if (_int64 != null) { + return new PmDataType(_int64); + } else { + return new PmDataType(_decimal64); + } + } + + public static PmDataType getDefaultInstance(String defaultValue) { + return new PmDataTypeBuilder().setUint64(defaultValue).build(); + } } diff --git a/sdnr/wt/common-yang/pom.xml b/sdnr/wt/common-yang/pom.xml index 888d02128..ff8820e28 100755 --- a/sdnr/wt/common-yang/pom.xml +++ b/sdnr/wt/common-yang/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml b/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml index f451db97e..94591235c 100755 --- a/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml +++ b/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/rfc8341/pom.xml b/sdnr/wt/common-yang/rfc8341/pom.xml index f8780bb50..c3c3252a9 100755 --- a/sdnr/wt/common-yang/rfc8341/pom.xml +++ b/sdnr/wt/common-yang/rfc8341/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/common-yang/utils/pom.xml b/sdnr/wt/common-yang/utils/pom.xml index 927639ffe..4fb97cce2 100644 --- a/sdnr/wt/common-yang/utils/pom.xml +++ b/sdnr/wt/common-yang/utils/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -73,10 +74,61 @@ <artifactId>mdsal-dom-api</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> + <artifactId>rfc6991-ietf-inet-types</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> <dependency> <groupId>org.opendaylight.netconf</groupId> <artifactId>sal-netconf-connector</artifactId> <scope>test</scope> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/gen/**</exclude> + <exclude>**/generated-sources/**</exclude> + <exclude>**/yang-gen-sal/**</exclude> + <exclude>**/pax/**</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <groupId>org.opendaylight.yangtools</groupId> + <artifactId>yang-maven-plugin</artifactId> + <version>7.0.9</version> + <executions> + <execution> + <id>binding</id> + <goals> + <goal>generate-sources</goal> + </goals> + <configuration> + <yangFilesRootDir>src/test/yang</yangFilesRootDir> + <inspectDependencies>true</inspectDependencies> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.opendaylight.mdsal</groupId> + <artifactId>mdsal-binding-java-api-generator</artifactId> + <version>8.0.7</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> </project> diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java index 7d73afae0..0d9045658 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java @@ -46,7 +46,8 @@ public class YangToolsMapper extends ObjectMapper { private final YangToolsBuilderAnnotationIntrospector annotationIntrospector; private final YangToolsModule module; private static final long serialVersionUID = 1L; - private boolean isModuleRegistered=false; + private boolean isModuleRegistered = false; + public YangToolsMapper() { this(new YangToolsBuilderAnnotationIntrospector()); } @@ -63,6 +64,7 @@ public class YangToolsMapper extends ObjectMapper { enable(MapperFeature.USE_GETTERS_AS_SETTERS); setAnnotationIntrospector(yangToolsBuilderAnnotationIntrospector); } + public void addDeserializer(Class<?> clsToDeserialize, String builderClassName) { this.annotationIntrospector.addDeserializer(clsToDeserialize, builderClassName); } @@ -70,21 +72,23 @@ public class YangToolsMapper extends ObjectMapper { public void addKeyDeserializer(Class<?> type, KeyDeserializer deserializer) { this.module.addKeyDeserializer(type, deserializer); } + @Override public <T> T readValue(String content, Class<T> valueType) throws JsonProcessingException, JsonMappingException { - if(!this.isModuleRegistered) { - this.registerModule(this.module); - this.isModuleRegistered=true; - } - return super.readValue(content, valueType); + if (!this.isModuleRegistered) { + this.registerModule(this.module); + this.isModuleRegistered = true; + } + return super.readValue(content, valueType); } + @Override public String writeValueAsString(Object value) throws JsonProcessingException { - if(!this.isModuleRegistered) { - this.registerModule(this.module); - this.isModuleRegistered=true; - } - return super.writeValueAsString(value); + if (!this.isModuleRegistered) { + this.registerModule(this.module); + this.isModuleRegistered = true; + } + return super.writeValueAsString(value); } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java index 5c5aeb6de..6b5704078 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java @@ -22,6 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.yang.mapper; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import javax.annotation.Nullable; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsBuilderAnnotationIntrospector; @@ -40,7 +42,7 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper { private static final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class); private static final long serialVersionUID = 1L; - private @Nullable final Class<? extends Builder<? extends T>> builderClazz; + private @Nullable final Class<?> builderClazz; /** * Generic Object creation of yangtools java class builder pattern. @@ -52,7 +54,7 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper { * If null the clazz is expected to support normal jackson build pattern. * @throws ClassNotFoundException if builderClazz not available in bundle */ - public <X extends T, B extends Builder<X>> YangToolsMapper2(@NonNull Class<T> clazz, + public <X extends T, B> YangToolsMapper2(@NonNull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException { super(new YangToolsBuilderAnnotationIntrospector(clazz, builderClazz)); @@ -67,10 +69,10 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper { * @param clazz class with interface. * @return builder for interface or null if not existing */ - public @Nullable Builder<? extends T> getBuilder(Class<T> clazz) { + public @Nullable<B> B getBuilder(Class<T> clazz) { try { if (builderClazz != null) - return builderClazz.getDeclaredConstructor().newInstance(); + return (B) builderClazz.getDeclaredConstructor().newInstance(); else return null; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException @@ -90,8 +92,9 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper { * @throws ClassNotFoundException */ @SuppressWarnings("unchecked") - private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException { + private <X extends T, B> Class<B> getBuilderClass(String name) throws ClassNotFoundException { return (Class<B>) YangToolsMapperHelper.getBuilderClass(name); } + } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java index fe7631a6d..e72e962bb 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java @@ -311,4 +311,10 @@ public class YangToolsMapperHelper { public static <K extends Identifier<V>, V extends Identifiable<K>> Map<K,V> toMap(List<V> list) { return list == null || list.isEmpty() ? null : Maps.uniqueIndex(list, Identifiable::key); } + + @SuppressWarnings("unchecked") + public static <S,T> T callBuild(S builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Method method = builder.getClass().getMethod("build"); + return (T) method.invoke(builder); + } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java index 0fe8ab9d7..b7f1782b6 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java @@ -29,18 +29,19 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.KeyDeserializer; import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; -import com.fasterxml.jackson.databind.type.ArrayType; import com.fasterxml.jackson.databind.type.MapType; - import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.NoSuchElementException; import java.util.Optional; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.BaseIdentityDeserializer; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.ClassDeserializer; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.IdentifierDeserializer; +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.SetDeserializer; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.TypeObjectDeserializer; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.Identifier; @@ -51,87 +52,87 @@ import org.slf4j.LoggerFactory; public class YangToolsDeserializerModifier extends BeanDeserializerModifier { - private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier.class); - private static final String getEnumMethodName = "valueOf"; - private static final String getEnumMethodName2 = "forName"; + private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier.class); + private static final String getEnumMethodName = "valueOf"; + private static final String getEnumMethodName2 = "forName"; - @SuppressWarnings("unchecked") - public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - try { - Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class); - Enum<?> result = (Enum<?>) method.invoke(null, value); - LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); - return result; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | NoSuchElementException | SecurityException e) { - Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class); - Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value); - LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); - return result.orElseThrow(); - } - } + @SuppressWarnings("unchecked") + public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException, + IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + try { + Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class); + Enum<?> result = (Enum<?>) method.invoke(null, value); + LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); + return result; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException + | NoSuchElementException | SecurityException e) { + Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class); + Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value); + LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); + return result.orElseThrow(); + } + } - @Override - public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, - BeanDescription beanDesc, final JsonDeserializer<?> deserializer) { - return new JsonDeserializer<Enum<?>>() { + @Override + public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, + BeanDescription beanDesc, final JsonDeserializer<?> deserializer) { + return new JsonDeserializer<Enum<?>>() { - @Override - public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - Class<?> clazz = type.getRawClass(); + @Override + public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { + Class<?> clazz = type.getRawClass(); - try { - return parseEnum(jp.getValueAsString(), clazz); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException - | NoSuchMethodException | NoSuchElementException | SecurityException e) { - LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(), - jp.getValueAsString(), e); - } - throw new IOException( - "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString()); - } - }; - } + try { + return parseEnum(jp.getValueAsString(), clazz); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | NoSuchElementException | SecurityException e) { + LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(), + jp.getValueAsString(), e); + } + throw new IOException( + "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString()); + } + }; + } - @Override - public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, - JsonDeserializer<?> deserializer) { - final JavaType type = beanDesc.getType(); - final Class<?> rawClass = type.getRawClass(); + @Override + public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, + JsonDeserializer<?> deserializer) { + final JavaType type = beanDesc.getType(); + final Class<?> rawClass = type.getRawClass(); - JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer); + JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer); - if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) { - deser = new TypeObjectDeserializer<TypeObject>(type, deser); - } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) { - deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser); - } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) { - deser = new BaseIdentityDeserializer<BaseIdentity>(deser); - } else if (rawClass.equals(Class.class)) { - deser = new ClassDeserializer(rawClass); - } + if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) { + deser = new TypeObjectDeserializer<TypeObject>(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) { + deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) { + deser = new BaseIdentityDeserializer<BaseIdentity>(deser); + } else if (rawClass.equals(Class.class)) { + deser = new ClassDeserializer(rawClass); + } - LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName()); - return deser; - } + LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName()); + return deser; + } - @Override - public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type, - BeanDescription beanDesc, JsonDeserializer<?> deserializer) { - final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass(); - return new YangtoolsMapDesirializer(rawClass); - } + @Override + public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type, + BeanDescription beanDesc, JsonDeserializer<?> deserializer) { + final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass(); + return new YangtoolsMapDesirializer(rawClass); + } - @Override - public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) { - KeyDeserializer res; - if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) { - res = new IdentifierDeserializer(); - } else { - res = super.modifyKeyDeserializer(config, type, deser); - } - LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName()); - return res; - } + @Override + public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) { + KeyDeserializer res; + if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) { + res = new IdentifierDeserializer(); + } else { + res = super.modifyKeyDeserializer(config, type, deser); + } + LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName()); + return res; + } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java index 0697f5f2e..800f41481 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java @@ -49,87 +49,87 @@ import org.slf4j.LoggerFactory; public class YangToolsDeserializerModifier2 extends BeanDeserializerModifier { - private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier2.class); - private static final String getEnumMethodName = "valueOf"; - private static final String getEnumMethodName2 = "forName"; + private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier2.class); + private static final String getEnumMethodName = "valueOf"; + private static final String getEnumMethodName2 = "forName"; - @SuppressWarnings("unchecked") - public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - try { - Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class); - Enum<?> result = (Enum<?>) method.invoke(null, value); - LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); - return result; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | NoSuchElementException | SecurityException e) { - Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class); - Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value); - LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); - return result.orElseThrow(); - } - } + @SuppressWarnings("unchecked") + public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException, + IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + try { + Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class); + Enum<?> result = (Enum<?>) method.invoke(null, value); + LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); + return result; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException + | NoSuchElementException | SecurityException e) { + Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class); + Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value); + LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result); + return result.orElseThrow(); + } + } - @Override - public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, - BeanDescription beanDesc, final JsonDeserializer<?> deserializer) { - return new JsonDeserializer<Enum<?>>() { + @Override + public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, + BeanDescription beanDesc, final JsonDeserializer<?> deserializer) { + return new JsonDeserializer<Enum<?>>() { - @Override - public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - Class<?> clazz = type.getRawClass(); + @Override + public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { + Class<?> clazz = type.getRawClass(); - try { - return parseEnum(jp.getValueAsString(), clazz); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException - | NoSuchMethodException | NoSuchElementException | SecurityException e) { - LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(), - jp.getValueAsString(), e); - } - throw new IOException( - "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString()); - } - }; - } + try { + return parseEnum(jp.getValueAsString(), clazz); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | NoSuchElementException | SecurityException e) { + LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(), + jp.getValueAsString(), e); + } + throw new IOException( + "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString()); + } + }; + } - @Override - public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, - JsonDeserializer<?> deserializer) { - final JavaType type = beanDesc.getType(); - final Class<?> rawClass = type.getRawClass(); + @Override + public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, + JsonDeserializer<?> deserializer) { + final JavaType type = beanDesc.getType(); + final Class<?> rawClass = type.getRawClass(); - JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer); + JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer); - if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) { - deser = new TypeObjectDeserializer<TypeObject>(type, deser); - } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) { - deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser); - } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) { - deser = new BaseIdentityDeserializer<BaseIdentity>(deser); - } else if (rawClass.equals(Class.class)) { - deser = new ClassDeserializer(rawClass); - } + if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) { + deser = new TypeObjectDeserializer<TypeObject>(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) { + deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser); + } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) { + deser = new BaseIdentityDeserializer<BaseIdentity>(deser); + } else if (rawClass.equals(Class.class)) { + deser = new ClassDeserializer(rawClass); + } - LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName()); - return deser; - } + LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName()); + return deser; + } - @Override - public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type, - BeanDescription beanDesc, JsonDeserializer<?> deserializer) { - final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass(); - return new YangtoolsMapDesirializer(rawClass); - } + @Override + public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type, + BeanDescription beanDesc, JsonDeserializer<?> deserializer) { + final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass(); + return new YangtoolsMapDesirializer(rawClass); + } - @Override - public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) { - KeyDeserializer res; - if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) { - res = new IdentifierDeserializer(); - } else { - res = super.modifyKeyDeserializer(config, type, deser); - } - LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName()); - return res; - } + @Override + public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) { + KeyDeserializer res; + if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) { + res = new IdentifierDeserializer(); + } else { + res = super.modifyKeyDeserializer(config, type, deser); + } + LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName()); + return res; + } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java index 2fe7fa11f..922257d13 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java @@ -1,44 +1,36 @@ package org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.type.CollectionLikeType; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.Map; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.type.CollectionLikeType; -import com.fasterxml.jackson.databind.type.TypeFactory; -import com.google.common.collect.Maps; public class YangtoolsMapDesirializer<K extends Identifier<V>, V extends Identifiable<K>> - extends JsonDeserializer<Map<K, V>> { + extends JsonDeserializer<Map<K, V>> { + + private final Class<V> clazz; + private final YangToolsMapper mapper; - private final Class<V> clazz; - private final YangToolsMapper mapper; - - public YangtoolsMapDesirializer(Class<V> clazz) { - super(); - this.clazz = clazz; - this.mapper = new YangToolsMapper(); - } + public YangtoolsMapDesirializer(Class<V> clazz) { + super(); + this.clazz = clazz; + this.mapper = new YangToolsMapper(); + } - @Override - public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz); - List<V> list = mapper.readValue(p,type); - return YangToolsMapperHelper.toMap(list); - } + @Override + public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz); + List<V> list = mapper.readValue(p, type); + return YangToolsMapperHelper.toMap(list); + } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java index 6a419eee1..4a52f57ee 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java @@ -14,23 +14,23 @@ import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; public class YangtoolsMapDesirializer2<K extends Identifier<V>, V extends Identifiable<K>> - extends JsonDeserializer<Map<K, V>> { + extends JsonDeserializer<Map<K, V>> { - private final Class<V> clazz; - private final YangToolsMapper mapper; + private final Class<V> clazz; + private final YangToolsMapper mapper; - public YangtoolsMapDesirializer2(Class<V> clazz) { - super(); - this.clazz = clazz; - this.mapper = new YangToolsMapper(); - } + public YangtoolsMapDesirializer2(Class<V> clazz) { + super(); + this.clazz = clazz; + this.mapper = new YangToolsMapper(); + } - @Override - public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz); - List<V> list = mapper.readValue(p,type); - return YangToolsMapperHelper.toMap(list); - } + @Override + public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz); + List<V> list = mapper.readValue(p, type); + return YangToolsMapperHelper.toMap(list); + } } diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java new file mode 100644 index 000000000..2ab3fe7c3 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java @@ -0,0 +1,39 @@ +package org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.type.CollectionLikeType; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper; +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; +import org.opendaylight.yangtools.yang.binding.Identifiable; +import org.opendaylight.yangtools.yang.binding.Identifier; + +public class SetDeserializer<V> + extends JsonDeserializer<Set<V>> { + + private final Class<V> clazz; + private final YangToolsMapper mapper; + + public SetDeserializer(Class<V> clazz) { + super(); + this.clazz = clazz; + this.mapper = new YangToolsMapper(); + } + + @Override + public Set<V> deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(Set.class, clazz); + List<V> list = mapper.readValue(p, type); + return new HashSet<>(list); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java new file mode 100644 index 000000000..3d859e8b5 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class HostBuilder { + private HostBuilder() { + //Exists only to defeat instantiation. + } + + public static Host getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java new file mode 100644 index 000000000..62771f669 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpAddressBuilder { + private IpAddressBuilder() { + //Exists only to defeat instantiation. + } + + public static IpAddress getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java new file mode 100644 index 000000000..d7b295263 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpAddressNoZoneBuilder { + private IpAddressNoZoneBuilder() { + //Exists only to defeat instantiation. + } + + public static IpAddressNoZone getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java new file mode 100644 index 000000000..d5fff3db4 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpPrefixBuilder { + private IpPrefixBuilder() { + //Exists only to defeat instantiation. + } + + public static IpPrefix getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangToolsMapper.java b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangToolsMapper.java new file mode 100644 index 000000000..2e51e8404 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/TestYangToolsMapper.java @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.yang.mapper; + +import static org.junit.Assert.assertEquals; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.HashMap; +import java.util.Map; +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.IdentifierDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.AddressLocation; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.AddressLocationBuilder; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.AddressType; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.ItemCode; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.address.location.entity.ItemList; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.address.location.entity.ItemListBuilder; +import org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.address.location.entity.ItemListKey; + +public class TestYangToolsMapper { + + private static final YangToolsMapper MAPPER = new YangToolsMapper(); + + @Before + public void init() { + MAPPER.addKeyDeserializer(ItemListKey.class, new IdentifierDeserializer()); + } + + @Test + public void testYangMapperDeser() { + AddressLocation al = null; + + try { + al = MAPPER.readValue( + "{\n" + + " \"address-type\": \"OFFICE\",\n" + + " \"delivery-date-time\": \"2022-03-15T11:12:13.890Z\",\n" + + " \"delivery-url\": \"delivery.uri\",\n" + + " \"item-list\": [\n" + + " {\n" + + " \"item-key\": \"org.opendaylight.yang.gen.v1.urn.test.yang.utils.norev.ItemCode\"\n" + + " }\n" + + " ]\n" + + "}", + AddressLocation.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + assertEquals(AddressType.OFFICE, al.getAddressType()); + assertEquals("2022-03-15T11:12:13.890Z", al.getDeliveryDateTime().getValue()); + System.out.println("Delivery Date = " + al.getDeliveryDateTime().getValue()); + System.out.println(al.getItemList()); + System.out.println(al.getDeliveryUrl().getValue()); + } + + @Test + public void testYangMapperSer() { + Map<ItemListKey, ItemList> items = new HashMap<ItemListKey, ItemList>(); + ItemList il = new ItemListBuilder().setItemKey(ItemCode.class).build(); + items.put(new ItemListKey(ItemCode.class), il); + + Uri uri = new Uri("delivery.uri"); + + AddressLocation al = new AddressLocationBuilder().setId("99").setAddressType(AddressType.HOME) + .setDeliveryDateTime(new DateAndTime("2022-03-15T11:12:13.890Z")).setItemList(items) + .setDeliveryUrl(uri).build(); + String str = null; + + try { + str = MAPPER.writeValueAsString(al); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + assertEquals("HOME", new JSONObject(str).getString("address-type")); + assertEquals("2022-03-15T11:12:13.890Z", new JSONObject(str).getString("delivery-date-time")); + System.out.println(new JSONObject(str).getJSONArray("item-list")); + System.out.println(str); + } +} diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java new file mode 100644 index 000000000..3d859e8b5 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class HostBuilder { + private HostBuilder() { + //Exists only to defeat instantiation. + } + + public static Host getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java new file mode 100644 index 000000000..62771f669 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpAddressBuilder { + private IpAddressBuilder() { + //Exists only to defeat instantiation. + } + + public static IpAddress getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java new file mode 100644 index 000000000..d7b295263 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpAddressNoZoneBuilder { + private IpAddressNoZoneBuilder() { + //Exists only to defeat instantiation. + } + + public static IpAddressNoZone getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java new file mode 100644 index 000000000..d5fff3db4 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715; +import java.lang.String; +import java.lang.UnsupportedOperationException; +import javax.annotation.processing.Generated; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +@Generated("mdsal-binding-generator") +public class IpPrefixBuilder { + private IpPrefixBuilder() { + //Exists only to defeat instantiation. + } + + public static IpPrefix getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/yang/ietf-inet-types.yang b/sdnr/wt/common-yang/utils/src/test/yang/ietf-inet-types.yang new file mode 100644 index 000000000..f91aa1fb8 --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/yang/ietf-inet-types.yang @@ -0,0 +1,429 @@ +module ietf-inet-types { + + namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; + prefix "inet"; + + organization + "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; + + contact + "WG Web: <http://tools.ietf.org/wg/netmod/> + WG List: <mailto:netmod@ietf.org> + WG Chair: David Kessens + <mailto:david.kessens@nsn.com> + WG Chair: Juergen Schoenwaelder + <mailto:j.schoenwaelder@jacobs-university.de> + Editor: Juergen Schoenwaelder + <mailto:j.schoenwaelder@jacobs-university.de>"; + + description + "This module contains a collection of generally useful derived + YANG data types for Internet addresses and related things. + Copyright (c) 2013 IETF Trust and the persons identified as + authors of the code. All rights reserved. + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info). + This version of this YANG module is part of RFC 6991; see + the RFC itself for full legal notices."; + + revision 2013-07-15 { + description + "This revision adds the following new data types: + - ip-address-no-zone + - ipv4-address-no-zone + - ipv6-address-no-zone"; + reference + "RFC 6991: Common YANG Data Types"; + } + + revision 2010-09-24 { + description + "Initial revision."; + reference + "RFC 6021: Common YANG Data Types"; + } + + /*** collection of types related to protocol fields ***/ + + typedef ip-version { + type enumeration { + enum unknown { + value "0"; + description + "An unknown or unspecified version of the Internet + protocol."; + } + enum ipv4 { + value "1"; + description + "The IPv4 protocol as defined in RFC 791."; + } + enum ipv6 { + value "2"; + description + "The IPv6 protocol as defined in RFC 2460."; + } + } + description + "This value represents the version of the IP protocol. + In the value set and its semantics, this type is equivalent + to the InetVersion textual convention of the SMIv2."; + reference + "RFC 791: Internet Protocol + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + typedef dscp { + type uint8 { + range "0..63"; + } + description + "The dscp type represents a Differentiated Services Code Point + that may be used for marking packets in a traffic stream. + In the value set and its semantics, this type is equivalent + to the Dscp textual convention of the SMIv2."; + reference + "RFC 3289: Management Information Base for the Differentiated + Services Architecture + RFC 2474: Definition of the Differentiated Services Field + (DS Field) in the IPv4 and IPv6 Headers + RFC 2780: IANA Allocation Guidelines For Values In + the Internet Protocol and Related Headers"; + } + + typedef ipv6-flow-label { + type uint32 { + range "0..1048575"; + } + description + "The ipv6-flow-label type represents the flow identifier or Flow + Label in an IPv6 packet header that may be used to + discriminate traffic flows. + In the value set and its semantics, this type is equivalent + to the IPv6FlowLabel textual convention of the SMIv2."; + reference + "RFC 3595: Textual Conventions for IPv6 Flow Label + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; + } + + typedef port-number { + type uint16 { + range "0..65535"; + } + description + "The port-number type represents a 16-bit port number of an + Internet transport-layer protocol such as UDP, TCP, DCCP, or + SCTP. Port numbers are assigned by IANA. A current list of + all assignments is available from <http://www.iana.org/>. + Note that the port number value zero is reserved by IANA. In + situations where the value zero does not make sense, it can + be excluded by subtyping the port-number type. + In the value set and its semantics, this type is equivalent + to the InetPortNumber textual convention of the SMIv2."; + reference + "RFC 768: User Datagram Protocol + RFC 793: Transmission Control Protocol + RFC 4960: Stream Control Transmission Protocol + RFC 4340: Datagram Congestion Control Protocol (DCCP) + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + /*** collection of types related to autonomous systems ***/ + + typedef as-number { + type uint32; + description + "The as-number type represents autonomous system numbers + which identify an Autonomous System (AS). An AS is a set + of routers under a single technical administration, using + an interior gateway protocol and common metrics to route + packets within the AS, and using an exterior gateway + protocol to route packets to other ASes. IANA maintains + the AS number space and has delegated large parts to the + regional registries. + Autonomous system numbers were originally limited to 16 + bits. BGP extensions have enlarged the autonomous system + number space to 32 bits. This type therefore uses an uint32 + base type without a range restriction in order to support + a larger autonomous system number space. + In the value set and its semantics, this type is equivalent + to the InetAutonomousSystemNumber textual convention of + the SMIv2."; + reference + "RFC 1930: Guidelines for creation, selection, and registration + of an Autonomous System (AS) + RFC 4271: A Border Gateway Protocol 4 (BGP-4) + RFC 4001: Textual Conventions for Internet Network Addresses + RFC 6793: BGP Support for Four-Octet Autonomous System (AS) + Number Space"; + } + + /*** collection of types related to IP addresses and hostnames ***/ + + typedef ip-address { + type union { + type inet:ipv4-address; + type inet:ipv6-address; + } + description + "The ip-address type represents an IP address and is IP + version neutral. The format of the textual representation + implies the IP version. This type supports scoped addresses + by allowing zone identifiers in the address format."; + reference + "RFC 4007: IPv6 Scoped Address Architecture"; + } + + typedef ipv4-address { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' + + '(%[\p{N}\p{L}]+)?'; + } + description + "The ipv4-address type represents an IPv4 address in + dotted-quad notation. The IPv4 address may include a zone + index, separated by a % sign. + The zone index is used to disambiguate identical address + values. For link-local addresses, the zone index will + typically be the interface index number or the name of an + interface. If the zone index is not present, the default + zone of the device will be used. + The canonical format for the zone index is the numerical + format"; + } + + typedef ipv6-address { + type string { + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' + + '(%[\p{N}\p{L}]+)?'; + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' + + '(%.+)?'; + } + description + "The ipv6-address type represents an IPv6 address in full, + mixed, shortened, and shortened-mixed notation. The IPv6 + address may include a zone index, separated by a % sign. + The zone index is used to disambiguate identical address + values. For link-local addresses, the zone index will + typically be the interface index number or the name of an + interface. If the zone index is not present, the default + zone of the device will be used. + The canonical format of IPv6 addresses uses the textual + representation defined in Section 4 of RFC 5952. The + canonical format for the zone index is the numerical + format as described in Section 11.2 of RFC 4007."; + reference + "RFC 4291: IP Version 6 Addressing Architecture + RFC 4007: IPv6 Scoped Address Architecture + RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + typedef ip-address-no-zone { + type union { + type inet:ipv4-address-no-zone; + type inet:ipv6-address-no-zone; + } + description + "The ip-address-no-zone type represents an IP address and is + IP version neutral. The format of the textual representation + implies the IP version. This type does not support scoped + addresses since it does not allow zone identifiers in the + address format."; + reference + "RFC 4007: IPv6 Scoped Address Architecture"; + } + + typedef ipv4-address-no-zone { + type inet:ipv4-address { + pattern '[0-9\.]*'; + } + description + "An IPv4 address without a zone index. This type, derived from + ipv4-address, may be used in situations where the zone is + known from the context and hence no zone index is needed."; + } + + typedef ipv6-address-no-zone { + type inet:ipv6-address { + pattern '[0-9a-fA-F:\.]*'; + } + description + "An IPv6 address without a zone index. This type, derived from + ipv6-address, may be used in situations where the zone is + known from the context and hence no zone index is needed."; + reference + "RFC 4291: IP Version 6 Addressing Architecture + RFC 4007: IPv6 Scoped Address Architecture + RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + typedef ip-prefix { + type union { + type inet:ipv4-prefix; + type inet:ipv6-prefix; + } + description + "The ip-prefix type represents an IP prefix and is IP + version neutral. The format of the textual representations + implies the IP version."; + } + + typedef ipv4-prefix { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' + + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; + } + description + "The ipv4-prefix type represents an IPv4 address prefix. + The prefix length is given by the number following the + slash character and must be less than or equal to 32. + A prefix length value of n corresponds to an IP address + mask that has n contiguous 1-bits from the most + significant bit (MSB) and all other bits set to 0. + The canonical format of an IPv4 prefix has all bits of + the IPv4 address set to zero that are not part of the + IPv4 prefix."; + } + + typedef ipv6-prefix { + type string { + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' + + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' + + '(/.+)'; + } + + description + "The ipv6-prefix type represents an IPv6 address prefix. + The prefix length is given by the number following the + slash character and must be less than or equal to 128. + A prefix length value of n corresponds to an IP address + mask that has n contiguous 1-bits from the most + significant bit (MSB) and all other bits set to 0. + The IPv6 address should have all bits that do not belong + to the prefix set to zero. + The canonical format of an IPv6 prefix has all bits of + the IPv6 address set to zero that are not part of the + IPv6 prefix. Furthermore, the IPv6 address is represented + as defined in Section 4 of RFC 5952."; + reference + "RFC 5952: A Recommendation for IPv6 Address Text + Representation"; + } + + /*** collection of domain name and URI types ***/ + + typedef domain-name { + type string { + pattern + '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + + '|\.'; + length "1..253"; + } + description + "The domain-name type represents a DNS domain name. The + name SHOULD be fully qualified whenever possible. + Internet domain names are only loosely specified. Section + 3.5 of RFC 1034 recommends a syntax (modified in Section + 2.1 of RFC 1123). The pattern above is intended to allow + for current practice in domain name use, and some possible + future expansion. It is designed to hold various types of + domain names, including names used for A or AAAA records + (host names) and other records, such as SRV records. Note + that Internet host names have a stricter syntax (described + in RFC 952) than the DNS recommendations in RFCs 1034 and + 1123, and that systems that want to store host names in + schema nodes using the domain-name type are recommended to + adhere to this stricter standard to ensure interoperability. + The encoding of DNS names in the DNS protocol is limited + to 255 characters. Since the encoding consists of labels + prefixed by a length bytes and there is a trailing NULL + byte, only 253 characters can appear in the textual dotted + notation. + The description clause of schema nodes using the domain-name + type MUST describe when and how these names are resolved to + IP addresses. Note that the resolution of a domain-name value + may require to query multiple DNS records (e.g., A for IPv4 + and AAAA for IPv6). The order of the resolution process and + which DNS record takes precedence can either be defined + explicitly or may depend on the configuration of the + resolver. + Domain-name values use the US-ASCII encoding. Their canonical + format uses lowercase US-ASCII characters. Internationalized + domain names MUST be A-labels as per RFC 5890."; + reference + "RFC 952: DoD Internet Host Table Specification + RFC 1034: Domain Names - Concepts and Facilities + RFC 1123: Requirements for Internet Hosts -- Application + and Support + RFC 2782: A DNS RR for specifying the location of services + (DNS SRV) + RFC 5890: Internationalized Domain Names in Applications + (IDNA): Definitions and Document Framework"; + } + + typedef host { + type union { + type inet:ip-address; + type inet:domain-name; + } + description + "The host type represents either an IP address or a DNS + domain name."; + } + + typedef uri { + type string; + description + "The uri type represents a Uniform Resource Identifier + (URI) as defined by STD 66. + Objects using the uri type MUST be in US-ASCII encoding, + and MUST be normalized as described by RFC 3986 Sections + 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary + percent-encoding is removed, and all case-insensitive + characters are set to lowercase except for hexadecimal + digits, which are normalized to uppercase as described in + Section 6.2.2.1. + The purpose of this normalization is to help provide + unique URIs. Note that this normalization is not + sufficient to provide uniqueness. Two URIs that are + textually distinct after this normalization may still be + equivalent. + Objects using the uri type may restrict the schemes that + they permit. For example, 'data:' and 'urn:' schemes + might not be appropriate. + A zero-length URI is not a valid URI. This can be used to + express 'URI absent' where required. + In the value set and its semantics, this type is equivalent + to the Uri SMIv2 textual convention defined in RFC 5017."; + reference + "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax + RFC 3305: Report from the Joint W3C/IETF URI Planning Interest + Group: Uniform Resource Identifiers (URIs), URLs, + and Uniform Resource Names (URNs): Clarifications + and Recommendations + RFC 5017: MIB Textual Conventions for Uniform Resource + Identifiers (URIs)"; + } + +} diff --git a/sdnr/wt/common-yang/utils/src/test/yang/test-yang-utils.yang b/sdnr/wt/common-yang/utils/src/test/yang/test-yang-utils.yang new file mode 100644 index 000000000..eb62a859a --- /dev/null +++ b/sdnr/wt/common-yang/utils/src/test/yang/test-yang-utils.yang @@ -0,0 +1,79 @@ +module test-yang-utils { + + yang-version 1.1; + namespace "urn:test:yang:utils"; + prefix tesyangutils; + + import ietf-yang-types { + prefix yang; + reference + "RFC 6991: Common YANG Data Types."; + } + + import ietf-inet-types { + prefix inet; + } + + typedef AddressType { + type enumeration { + enum OFFICE { + description + "Office Address"; + } + enum HOME { + description + "Home Address"; + } + } + } + + identity item-code { + description + "Base identity"; + } + + typedef item-code { + type identityref { + base item-code; + } + description + "Item code - Could be bar code, QR code or any other code to uniquely identify an item"; + } + + grouping address-location-entity { + leaf id { + type string; + description + "Unique ID of the address"; + } + leaf address-type { + type AddressType; + description + "Type of Address"; + } + leaf delivery-date-time { + type yang:date-and-time; + description + "Package delivery date and time"; + } + leaf delivery-url { + type inet:uri; + description + "Delivery URL"; + } + list item-list { + key "item-key"; + leaf item-key { + type item-code; + } + description + "Unique code of the ordered item"; + } + } + + container address-location { + description + "builder"; + uses address-location-entity; + } +}
\ No newline at end of file diff --git a/sdnr/wt/common/pom.xml b/sdnr/wt/common/pom.xml index 11fb27c51..cda4e9739 100644 --- a/sdnr/wt/common/pom.xml +++ b/sdnr/wt/common/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -62,6 +63,7 @@ <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> @@ -71,44 +73,27 @@ <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-client</artifactId> </dependency> -<!-- <dependency> --> -<!-- <groupId>com.fasterxml.jackson.core</groupId> --> -<!-- <artifactId>jackson-core</artifactId> --> -<!-- </dependency> --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> + <scope>provided</scope> </dependency> -<!-- <dependency> --> -<!-- <groupId>com.fasterxml.jackson.core</groupId> --> -<!-- <artifactId>jackson-databind</artifactId> --> -<!-- </dependency> --> - <dependency> - <groupId>com.google.code.findbugs</groupId> - <artifactId>annotations</artifactId> - </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> <plugins> <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/gen/**</exclude> - <exclude>**/generated-sources/**</exclude> - <exclude>**/yang-gen-sal/**</exclude> - <exclude>**/pax/**</exclude> - </excludes> - </configuration> - </plugin> - <plugin> <groupId>com.github.alexcojocaru</groupId> <artifactId>elasticsearch-maven-plugin</artifactId> <configuration> diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java index 529853e08..233f48fa3 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java @@ -23,7 +23,9 @@ package org.onap.ccsdk.features.sdnr.wt.common.database; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class SearchResult<T> { @@ -53,6 +55,9 @@ public class SearchResult<T> { public List<T> getHits() { return this.hits; } + public Set<T> getHitSets() { + return new HashSet<>(this.hits); + } public long getTotal() { return this.total; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java index b73d3eadc..914ee1cf1 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java @@ -22,11 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.data; import java.text.ParseException; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; /** diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/GenericRunnableFactory.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/GenericRunnableFactory.java index c163facbb..2f052d6b2 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/GenericRunnableFactory.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/GenericRunnableFactory.java @@ -26,7 +26,5 @@ public abstract class GenericRunnableFactory<T,S> { public GenericRunnableFactory() { } - public Runnable create(S arg, GenericRunnableFactoryCallback<T> callback) { - return null; - } + public abstract Runnable create(final T key, final S arg); } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java index f41a9038f..f507eec13 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java @@ -23,23 +23,27 @@ package org.onap.ccsdk.features.sdnr.wt.common.threading; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map.Entry; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Threadpool for running n instances per key T * * @author jack * - * @param <T> - * @param <S> + * @param <T> type of key for the pools + * @param <S> type of arg to create a runner */ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback<T> { + private static final Logger LOG = LoggerFactory.getLogger(KeyBasedThreadpool.class); private final Queue<Entry<T, S>> queue; private final List<T> runningKeys; private final int keyPoolSize; @@ -57,37 +61,80 @@ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback< this.keyPoolSize = keyPoolSize; this.factory = factory; this.executor = Executors.newFixedThreadPool(poolSize); - this.runningKeys = new ArrayList<>(); + this.runningKeys = Collections.synchronizedList(new ArrayList<T>()); + LOG.info("starting key-based threadpool with keysize={} and size={}", keyPoolSize, poolSize); } public void execute(T key, S arg) { if (this.isKeyPoolSizeReached(key)) { + LOG.debug("pool size for key {} reached. add to queue", key); queue.add(new SimpleEntry<>(key, arg)); + } else { + LOG.debug("starting executor for key {}.", key); this.runningKeys.add(key); - this.executor.execute(this.factory.create(arg, this)); + this.executor.execute(new RunnableWrapper<T>(this.factory.create(key, arg), key, this)); } } private void executeNext() { Entry<T, S> entry = this.queue.peek(); - if (!this.isKeyPoolSizeReached(entry.getKey())) { - this.queue.poll(); - this.runningKeys.add(entry.getKey()); - this.executor.execute(this.factory.create(entry.getValue(), this)); + if (entry != null) { + LOG.debug("executing next for key {} with arg {}", entry.getKey(), entry.getValue()); + if (!this.isKeyPoolSizeReached(entry.getKey())) { + this.queue.poll(); + this.runningKeys.add(entry.getKey()); + this.executor.execute(new RunnableWrapper<T>(this.factory.create(entry.getKey(), entry.getValue()), + entry.getKey(), this)); + } else { + LOG.debug("key pool size reached. waiting for someone else to stop"); + } + } else { + LOG.info("nothing to execute. queue is empty."); } } private boolean isKeyPoolSizeReached(T key) { + LOG.trace("running keys size={}", this.runningKeys.size()); return this.runningKeys.stream().filter(e -> e == key).count() >= this.keyPoolSize; } @Override - public void onFinish(T key) { + public synchronized void onFinish(T key) { + LOG.debug("executor finished for key {}.", key); this.runningKeys.remove(key); this.executeNext(); } + public void join() { + LOG.debug("wait for all executors to finish"); + while (this.runningKeys.size() > 0 && this.queue.size() > 0) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } + + private static class RunnableWrapper<T> implements Runnable { + + private final Runnable inner; + private final GenericRunnableFactoryCallback<T> callback; + private final T key; + public RunnableWrapper(Runnable inner, T key, GenericRunnableFactoryCallback<T> cb) { + this.inner = inner; + this.callback = cb; + this.key = key; + } + + @Override + public void run() { + this.inner.run(); + this.callback.onFinish(this.key); + } + + } } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java index 3584d7f28..253b790eb 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java @@ -25,7 +25,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; import java.io.IOException; import java.io.OutputStream; import java.net.InetSocketAddress; @@ -33,18 +35,12 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; - -@SuppressWarnings("restriction") public class TestBaseHttpClient { public static final String HTTPMETHOD_GET = "GET"; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestKeybasedThreadpool.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestKeybasedThreadpool.java new file mode 100644 index 000000000..868275690 --- /dev/null +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestKeybasedThreadpool.java @@ -0,0 +1,100 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.common.test; + +import java.util.Random; + +import org.junit.Ignore; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.threading.GenericRunnableFactory; +import org.onap.ccsdk.features.sdnr.wt.common.threading.KeyBasedThreadpool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestKeybasedThreadpool { + + + private static final Logger LOG = LoggerFactory.getLogger(TestKeybasedThreadpool.class); + private static final String KEY_A = "a"; + private static final String KEY_B = "b"; + private static final String KEY_C = "c"; + private static final String KEY_D = "d"; + + @Ignore + @Test + public void test1() { + GenericRunnableFactory<String, TestClass> factory1 = + new GenericRunnableFactory<String, TestKeybasedThreadpool.TestClass>() { + @Override + public Runnable create(final String key, final TestClass arg) { + return new Runnable() { + + @Override + public void run() { + final String key2 = arg.value; + final long sleep = arg.sleep; + LOG.info("{}: sleeping now for {} seconds",key2, sleep); + try { + Thread.sleep(sleep*1000); + } catch (InterruptedException e) { + LOG.error("InterruptedException",e); + Thread.currentThread().interrupt(); + } + LOG.info("{}: finished",key2); + } + }; + } + }; + LOG.info("starting"); + KeyBasedThreadpool<String, TestClass> threadpool = new KeyBasedThreadpool<String, TestClass>(10, 1, factory1); + threadpool.execute(KEY_A, new TestClass(KEY_A)); + threadpool.execute(KEY_A, new TestClass(KEY_A)); + threadpool.execute(KEY_A, new TestClass(KEY_A)); + threadpool.execute(KEY_B, new TestClass(KEY_B)); + threadpool.execute(KEY_C, new TestClass(KEY_C)); + threadpool.execute(KEY_D, new TestClass(KEY_D)); + threadpool.execute(KEY_D, new TestClass(KEY_D)); + threadpool.join(); + LOG.info("done"); + } + + private static int counter=0; + + + public class TestClass { + protected final long sleep; + private final String value; + + public TestClass(String value) { + + this.value = value+ String.valueOf(counter++); + Random rnd = new Random(); + this.sleep = rnd.nextInt(20); + LOG.info("instatiate {}",this); + } + + @Override + public String toString() { + return "TestClass [sleep=" + sleep + ", value=" + value + "]"; + } + } +} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java index a3d2c9be9..6913ec21e 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java @@ -45,7 +45,6 @@ import org.junit.Before; import org.onap.ccsdk.features.sdnr.wt.common.test.ServletInputStreamFromByteArrayInputStream; import org.onap.ccsdk.features.sdnr.wt.common.test.ServletOutputStreamToStringWriter; -@SuppressWarnings("restriction") public class HelpServletBase { public static final String RESPONSE_GET = "This is the response get"; diff --git a/sdnr/wt/data-provider/dblib/pom.xml b/sdnr/wt/data-provider/dblib/pom.xml index 3e7329056..073d95ac8 100644 --- a/sdnr/wt/data-provider/dblib/pom.xml +++ b/sdnr/wt/data-provider/dblib/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java index 20b86e661..fbd105aa1 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java @@ -48,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutputBuilder; @@ -102,7 +103,7 @@ public interface DatabaseDataProvider { ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException; - ReadStatusOutputBuilder readStatus() throws IOException; + ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException; boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit); diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java index 1bb30dc69..cabe6bed0 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java @@ -297,7 +297,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.ltp.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult()); + outputBuilder.setData(result.getResultSet()); return outputBuilder; } @@ -308,7 +308,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.device.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult()); + outputBuilder.setData(result.getResultSet()); return outputBuilder; } @@ -322,7 +322,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.ltp.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult()); + outputBuilder.setData(result.getResultSet()); return outputBuilder; } @@ -335,14 +335,14 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.device.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult()); + outputBuilder.setData(result.getResultSet()); return outputBuilder; } @Override - public ReadStatusOutputBuilder readStatus() throws IOException { + public ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException { QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data> result = - readStatus.getDataStatus(); + readStatus.getDataStatus(input); ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder(); outputBuilder.setData(result.getResult()); @@ -352,7 +352,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa @Override public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection( NetworkElementConnectionEntity input) throws IOException { - String id = this.networkelementConnectionRW.write(input, input.getNodeId()); + String id = this.networkelementConnectionRW.updateOrInsert(input, input.getNodeId()); if (id == null) { throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE); } diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java index c81725073..db4e980af 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java @@ -22,7 +22,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; + import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PaginationOutputG; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.PaginationBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -43,8 +46,11 @@ public class QueryResult<T> { pagination = x.build(); } + public Set<T> getResultSet() { + return new HashSet<>(this.result); + } public List<T> getResult() { - return result; + return this.result; } public PaginationOutputG getPagination() { diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java index 19323b9f7..1c24636db 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java @@ -33,6 +33,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.DBKeyValuePair; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; @@ -40,7 +42,6 @@ import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsBui import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsDeserializerModifier; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; -import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Enumeration; import org.opendaylight.yangtools.yang.common.Uint16; @@ -223,7 +224,7 @@ public class SqlDBMapper { String type = mariaDBTypeMap.getOrDefault(valueType, null); if (type == null) { if (implementsInterface(valueType, DataObject.class) || implementsInterface(valueType, List.class) - || implementsInterface(valueType, Map.class)) { + || implementsInterface(valueType, Map.class) || implementsInterface(valueType, Set.class)) { return "JSON"; } if (implementsInterface(valueType, Enumeration.class)) { @@ -352,13 +353,13 @@ public class SqlDBMapper { } @SuppressWarnings("unchecked") - public static <T> List<T> read(ResultSet data, Class<T> clazz, String column) + public static <S,T> List<T> read(ResultSet data, Class<T> clazz, String column) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, SQLException, InstantiationException, SecurityException, NoSuchMethodException, JsonProcessingException { if(data==null) { return Arrays.asList(); } - Builder<T> builder = findPOJOBuilder(clazz); + S builder = findPOJOBuilder(clazz); if(builder==null && column==null) { throw new InstantiationException("unable to find builder for class "+clazz.getName()); } @@ -374,7 +375,7 @@ public class SqlDBMapper { m.setAccessible(true); m.invoke(builder, getValueOrDefault(data, col, argType, null)); } - list.add(builder.build()); + list.add(callBuild(builder)); } else { Object value = getValueOrDefault(data, column, clazz, null); if (value != null) { @@ -386,7 +387,13 @@ public class SqlDBMapper { } @SuppressWarnings("unchecked") - private static <T> Builder<T> findPOJOBuilder(Class<T> ac) throws InstantiationException, IllegalAccessException, + private static <S,T> T callBuild(S builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Method method = builder.getClass().getMethod("build"); + return (T) method.invoke(builder); + } + + @SuppressWarnings("unchecked") + private static <S,T> S findPOJOBuilder(Class<T> ac) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException { try { String builder = null; @@ -400,8 +407,8 @@ public class SqlDBMapper { } if (builder != null) { Class<?> innerBuilder = YangToolsMapperHelper.findClass(builder); - Class<Builder<T>> builderClass = (Class<Builder<T>>) innerBuilder; - return builderClass.getDeclaredConstructor().newInstance(); + //Class<Builder<T>> builderClass = (Class<Builder<T>>) innerBuilder; + return (S) innerBuilder.getDeclaredConstructor().newInstance(); } } catch (ClassNotFoundException e) { diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java index b0b169d18..75d8c9ad2 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java @@ -24,11 +24,16 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; +import java.util.Map; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper.QueryResult; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SqlQuery; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.FaultsBuilder; @@ -49,8 +54,8 @@ public class SqlDBStatusReader { this.controllerId = controllerId; } - public QueryResult<Data> getDataStatus() { - String selectQuery = createCountQuery("severity", Entity.Faultcurrent, this.controllerId); + public QueryResult<Data> getDataStatus(EntityInput input) { + String selectQuery = createCountQuery("severity", Entity.Faultcurrent, this.controllerId, input); long criticalCount = 0; long majorCount = 0; long minorCount = 0; @@ -81,7 +86,7 @@ public class SqlDBStatusReader { DataBuilder builder = new DataBuilder().setFaults( new FaultsBuilder().setCriticals(Uint32.valueOf(criticalCount)).setMajors(Uint32.valueOf(majorCount)) .setMinors(Uint32.valueOf(minorCount)).setWarnings(Uint32.valueOf(warningCount)).build()); - selectQuery = createCountQuery("status", Entity.NetworkelementConnection, this.controllerId); + selectQuery = createCountQuery("status", Entity.NetworkelementConnection, this.controllerId, input); NetworkElementConnectionsBuilder neBuilder = new NetworkElementConnectionsBuilder(); String state; long connectedCount = 0, connectingCount = 0, disconnectedCount = 0, mountedCount = 0, unableToConnectCount = 0, @@ -123,10 +128,11 @@ public class SqlDBStatusReader { return new QueryResult<Data>(Arrays.asList(builder.build()), 1, 1, 1); } - private static String createCountQuery(String key, Entity e, String controllerId) { + private static String createCountQuery(String key, Entity e, String controllerId, EntityInput input) { + Map<FilterKey, Filter> filter = input != null ? input.getFilter() : null; return String.format("SELECT `%s`, COUNT(`%s`) " + "FROM `%s` " + "%s " + "GROUP BY `%s`;", key, key, e.getName(), - controllerId != null ? String.format("WHERE `%s`='%s'", SqlDBMapper.ODLID_DBCOL, controllerId) : "", + SqlQuery.getWhereExpression(filter!=null?filter.values():null, controllerId), key); } diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java index 6403a5c1d..a4df26bae 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper; @@ -114,7 +115,7 @@ public class SelectQuery implements SqlQuery { private static Filter cleanFilter(Filter filter) { final String sFilter = filter.getFiltervalue(); - final List<String> sFilters = filter.getFiltervalues(); + final Set<String> sFilters = filter.getFiltervalues(); //if only single filter value is set if (sFilter != null && (sFilters == null || sFilter.isEmpty())) { return "*".equals(filter.getFiltervalue()) ? null : filter; @@ -128,7 +129,7 @@ public class SelectQuery implements SqlQuery { } ; return new FilterBuilder().setProperty(filter.getProperty()).setFiltervalue(filter.getFiltervalue()) .setFiltervalues( - filter.getFiltervalues().stream().filter(e -> !"*".equals(e)).collect(Collectors.toList())) + filter.getFiltervalues().stream().filter(e -> !"*".equals(e)).collect(Collectors.toSet())) .build(); } } diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java index 3e26d0935..c954faadb 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java @@ -24,18 +24,22 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.Set; import java.util.TimeZone; import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.common.database.data.DbFilter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.DBFilterKeyValuePair; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.RangeSqlDBFilter; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.RegexSqlDBFilter; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter; +import io.netty.util.internal.StringUtil; public interface SqlQuery { @@ -50,18 +54,25 @@ public interface SqlQuery { static final boolean DEFAULT_IGNORE_CONTROLLERID = false; static final boolean DEFAULT_IGNORE_ID_FIELD = false; - public static String getWhereExpression(List<Filter> filters) { - if (filters == null) { + public static String getWhereExpression(Collection<Filter> filters) { + return getWhereExpression(filters, null); + } + public static String getWhereExpression(Collection<Filter> filters, String controllerId) { + if (filters == null && controllerId == null) { return ""; } StringBuilder sb = new StringBuilder(); - filters = filters.stream().filter(e -> !"*".equals(e.getFiltervalue())).collect(Collectors.toList()); - if (!filters.isEmpty()) { - - sb.append(" WHERE (" + getFilterExpression(filters.get(0)) + ")"); - for (int i = 1; i < filters.size(); i++) { - sb.append(" AND (" + getFilterExpression(filters.get(i)) + ")"); - } + List<String> filters2 = + filters != null + ? filters.stream().filter(e -> !"*".equals(e.getFiltervalue())).map(e -> getFilterExpression(e)) + .collect(Collectors.toList()) + : new ArrayList<>(); + if(controllerId!=null) { + filters2.add(getFilterExpression(SqlDBMapper.ODLID_DBCOL, controllerId)); + } + if (!filters2.isEmpty() ) { + sb.append(" WHERE "); + sb.append(StringUtil.join(" AND ", filters2)); } return sb.toString(); } @@ -107,7 +118,7 @@ public interface SqlQuery { return new DBFilterKeyValuePair(property, value).getFilterExpression(); } - static List<String> collectValues(String filtervalue, List<String> filtervalues) { + static List<String> collectValues(String filtervalue, Set<String> filtervalues) { if (filtervalues == null) { return Arrays.asList(filtervalue); } diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java index 4ef1b9a55..65e0c54e4 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java @@ -21,7 +21,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters; -public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFilter{ +public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFilter { public RegexSqlDBFilter(String key, String value) { @@ -32,4 +32,11 @@ public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFil public String getFilterExpression() { return String.format("`%s` RLIKE '%s'", this.getKey(), this.getValue()); } + + @Override + public String getValue() { + String value = super.getValue(); + return value != null ? value.replace("*", ".*") : null; + } } + diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java index c9cf27c68..34c4d6fe8 100644 --- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java +++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java @@ -183,7 +183,8 @@ public class TestMariaDataProvider { assertEquals(2, faultCurrents.getData().size()); ReadStatusOutputBuilder status = null; try { - status = dbProvider.readStatus(); + EntityInput input=null; + status = dbProvider.readStatus(input); } catch (IOException e) { e.printStackTrace(); fail("failed to read status"); @@ -567,7 +568,8 @@ public class TestMariaDataProvider { ReadStatusOutputBuilder status = null; try { - status = dbProvider.readStatus(); + EntityInput input=null; + status = dbProvider.readStatus(input); } catch (IOException e) { e.printStackTrace(); fail("failed to read status"); diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java index 576a3825c..7dd2464f9 100644 --- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java +++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java @@ -1,5 +1,4 @@ -/* - * ============LICENSE_START======================================================= +/* ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. @@ -27,6 +26,8 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Set; + import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.CountQuery; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SelectQuery; @@ -169,7 +170,7 @@ public class TestQuerySyntax { public void testSelectForFilterValues() { EntityInput input = new ReadGuiCutThroughEntryInputBuilder() .setFilter(YangToolsMapperHelper.toMap(Arrays.asList( - new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("das", "das2")).build()))) + new FilterBuilder().setProperty("id").setFiltervalues(Set.of("das", "das2")).build()))) .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build()) .build(); SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID); @@ -190,7 +191,7 @@ public class TestQuerySyntax { public void testSelectForFilterValues3() { EntityInput input = new ReadGuiCutThroughEntryInputBuilder() .setFilter(YangToolsMapperHelper.toMap(Arrays.asList( - new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("*","abc")).build()))) + new FilterBuilder().setProperty("id").setFiltervalues(Set.of("*","abc")).build()))) .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build()) .build(); SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID); @@ -201,8 +202,8 @@ public class TestQuerySyntax { public void testSelectForFilterValues4() { EntityInput input = new ReadGuiCutThroughEntryInputBuilder() .setFilter(YangToolsMapperHelper.toMap(Arrays.asList( - new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("abc")).build(), - new FilterBuilder().setProperty("node-id").setFiltervalues(Arrays.asList("*")).build()))) + new FilterBuilder().setProperty("id").setFiltervalues(Set.of("abc")).build(), + new FilterBuilder().setProperty("node-id").setFiltervalues(Set.of("*")).build()))) .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build()) .build(); SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID); @@ -210,6 +211,20 @@ public class TestQuerySyntax { assertFalse(query.toSql().contains("RLIKE")); } @Test + public void testSelectForFilterValues5() { + EntityInput input = new ReadGuiCutThroughEntryInputBuilder() + .setFilter(YangToolsMapperHelper.toMap(Arrays.asList( + new FilterBuilder().setProperty("id").setFiltervalues(Set.of("abc")).build(), + new FilterBuilder().setProperty("node-id").setFiltervalues(Set.of("*ran*")).build()))) + .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build()) + .build(); + SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID); + System.out.println(query.toSql()); + assertTrue(query.toSql().contains("RLIKE")); + assertTrue(query.toSql().contains(".*")); + + } + @Test public void testCount() { CountQuery query = new CountQuery(Entity.Eventlog, TestMariaDataProvider.createInput(1, 20)); String sQuery = query.toSql(); diff --git a/sdnr/wt/data-provider/feature/pom.xml b/sdnr/wt/data-provider/feature/pom.xml index 1a8d0fda1..d6a0c4d2c 100644 --- a/sdnr/wt/data-provider/feature/pom.xml +++ b/sdnr/wt/data-provider/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/data-provider/installer/pom.xml b/sdnr/wt/data-provider/installer/pom.xml index fd50c9020..6160686a4 100755 --- a/sdnr/wt/data-provider/installer/pom.xml +++ b/sdnr/wt/data-provider/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml index d5a6fc7f7..a673741fb 100644 --- a/sdnr/wt/data-provider/model/pom.xml +++ b/sdnr/wt/data-provider/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -59,6 +60,7 @@ <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-common</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.netconf</groupId> @@ -68,6 +70,7 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> + <scope>provided</scope> </dependency> </dependencies> diff --git a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang index 8b905f49e..72ac45a56 100644 --- a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang +++ b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang @@ -2018,6 +2018,9 @@ module data-provider { rpc read-status { description "Read status information of controller"; + input { + uses entity-input; + } output { list data { uses status-entity; diff --git a/sdnr/wt/data-provider/pom.xml b/sdnr/wt/data-provider/pom.xml index 9530b1094..fb3a00037 100755 --- a/sdnr/wt/data-provider/pom.xml +++ b/sdnr/wt/data-provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml index 21206419d..cc4313374 100644 --- a/sdnr/wt/data-provider/provider/pom.xml +++ b/sdnr/wt/data-provider/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -60,6 +61,7 @@ <dependency> <groupId>org.apache.karaf.bundle</groupId> <artifactId>org.apache.karaf.bundle.core</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> @@ -90,6 +92,7 @@ <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> @@ -99,10 +102,12 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.karaf.shell</groupId> diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java index cb0f22da1..a10864c96 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -92,7 +93,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { * @param syncAfterWrite * @throws ClassNotFoundException */ - public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, + public <X extends T, B> EsDataObjectReaderWriter2(DatabaseClient db, String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz, boolean syncAfterWrite) throws ClassNotFoundException { LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName()); @@ -111,13 +112,13 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { public void setFullsizeRequest(boolean fullsizeRequest) { this.doFullsizeRequest = fullsizeRequest; } - public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, + public <X extends T, B> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException { this(db, dataTypeName.getName(), clazz, builderClazz, false); } - public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, + public <X extends T, B> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz, boolean syncAfterWrite) throws ClassNotFoundException { this(db, dataTypeName.getName(), clazz, builderClazz, syncAfterWrite); @@ -160,20 +161,20 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { * @return this for further operations. * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name. */ - public EsDataObjectReaderWriter2<T> setEsIdAttributeName(String esIdAttributeName) { + public <B> EsDataObjectReaderWriter2<T> setEsIdAttributeName(String esIdAttributeName) { LOG.debug("Set attribute '{}'", esIdAttributeName); this.esIdAddAtributteName = null; // Reset status this.field = null; Field attributeField; try { - Builder<? extends T> builder = yangtoolsMapper.getBuilder(clazz); + B builder = yangtoolsMapper.getBuilder(clazz); if (builder == null) { String msg = "No builder for " + clazz; LOG.debug(msg); throw new IllegalArgumentException(msg); } else { - T object = builder.build(); + T object = YangToolsMapperHelper.callBuild(builder); attributeField = object.getClass().getDeclaredField(esIdAttributeName); if (attributeField.getType().equals(String.class)) { attributeField.setAccessible(true); @@ -193,7 +194,19 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { } catch (SecurityException e) { LOG.debug("Access problem " + esIdAttributeName, e); throw e; - } + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return this; } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java index 5811550e6..9a4033b99 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java @@ -26,14 +26,15 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; -import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryByFilter; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryResult; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.FaultsBuilder; @@ -54,9 +55,11 @@ public class DataObjectAcessorStatus extends DataObjectAcessor<Data> { } - public QueryResult<Data> getDataStatus() throws IOException { + public QueryResult<Data> getDataStatus(EntityInput input) throws IOException { SearchRequest request = getNewInstanceOfSearchRequest(Entity.Faultcurrent); - QueryBuilder query = QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0); + QueryByFilter queryByFilter = new QueryByFilter(input); + QueryBuilder query = queryByFilter.getQueryBuilderByFilter(); + query.aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0); if(this.doFullsizeRequest) { query.doFullsizeRequest(); } @@ -71,7 +74,7 @@ public class DataObjectAcessorStatus extends DataObjectAcessor<Data> { .setWarnings(YangHelper2.getLongOrUint32(aggs.getOrDefault("Warning", 0L))).build()); request = getNewInstanceOfSearchRequest(Entity.NetworkelementConnection); - query = QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_NECON_CONNECTIONSTATE_KEY).size(0); + query.aggregations(ESDATATYPE_NECON_CONNECTIONSTATE_KEY).size(0); if(this.doFullsizeRequest) { query.doFullsizeRequest(); } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java index 38ea8044e..753930cdd 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java @@ -352,7 +352,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider { outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.ltp.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult().getHits()); + outputBuilder.setData(result.getResult().getHitSets()); return outputBuilder; } @@ -363,7 +363,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider { outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.device.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult().getHits()); + outputBuilder.setData(result.getResult().getHitSets()); return outputBuilder; } @@ -377,7 +377,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider { outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.ltp.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult().getHits()); + outputBuilder.setData(result.getResult().getHitSets()); return outputBuilder; } @@ -390,14 +390,15 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider { outputBuilder.setPagination( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.device.list.output.PaginationBuilder( result.getPagination()).build()); - outputBuilder.setData(result.getResult().getHits()); + outputBuilder.setData(result.getResult().getHitSets()); return outputBuilder; } + @Override - public ReadStatusOutputBuilder readStatus() throws IOException { + public ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException { QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data> result = - readStatus.getDataStatus(); + readStatus.getDataStatus(input); ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder(); outputBuilder.setData(result.getResult().getHits()); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java index 7b7dccc96..21e2694a9 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java @@ -21,7 +21,6 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl; -import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; @@ -47,9 +46,7 @@ public class HtUserdataManagerImpl extends HtUserdataManagerBase { @Override public boolean setUserdata(String username, String data) { - JSONObject o = new JSONObject(this.getUserdata(username)); - JSONObject merge = mergeData(new JSONObject(data), o); - return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, merge.toString()) != null; + return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, data) != null; } @Override diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java index e2ba9567e..54cf32ce0 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java @@ -72,7 +72,7 @@ public class NoDbDatabaseDataProvider implements DatabaseDataProvider { private final HtDatabaseMediatorserver mediatorserver; private final HtDatabaseMaintenance maintenance; private final DataProvider dataprovider; - + public NoDbDatabaseDataProvider() { this.usermanger = new NoDbHtUserdataManager(); this.mediatorserver = new NoDbHtDatabaseMediatorserver(); @@ -160,7 +160,7 @@ public class NoDbDatabaseDataProvider implements DatabaseDataProvider { } @Override - public ReadStatusOutputBuilder readStatus() throws IOException { + public ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException { return new ReadStatusOutputBuilder(); } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java index 29d9ee9db..6ddc092d5 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java @@ -32,6 +32,9 @@ public class ODLVersionLUT { if (onapCCSDKVersion == null) { return def; } + if (onapCCSDKVersion.startsWith("2.4.")) { + return "ONAP Kohn"; + } if (onapCCSDKVersion.startsWith("2.3.")) { return "ONAP Jakarta"; } @@ -66,6 +69,8 @@ public class ODLVersionLUT { } if(odlMdsalVersionLUT==null) { odlMdsalVersionLUT = new HashMap<>(); + odlMdsalVersionLUT.put("9.0.2","sulfur-SR0 (0.16.0)"); + odlMdsalVersionLUT.put("8.0.11","phosphorus-SR2 (0.15.2)"); odlMdsalVersionLUT.put("8.0.7","phosphorus-SR1 (0.15.1)"); odlMdsalVersionLUT.put("8.0.5","phosphorus-SR0 (0.15.0)"); odlMdsalVersionLUT.put("7.0.9","silicon-SR2 (0.14.2)"); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java index 41fee76ad..b75108ab2 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java @@ -27,9 +27,12 @@ import com.google.common.util.concurrent.ListenableFuture; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -38,7 +41,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRep import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.ElasticSearchDataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.HtUserdataManagerImpl; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.nodb.NoDbDatabaseDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; @@ -47,6 +49,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType; +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.binding.api.RpcProviderService; @@ -112,11 +115,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.tls.key.entry.output.Pagination; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.tls.key.entry.output.PaginationBuilder; -import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; @@ -165,7 +167,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab // Register ourselves as the REST API RPC implementation LOG.info("Register RPC Service {}", DataProviderServiceImpl.class.getSimpleName()); this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this); - + } private void sendResyncCallbackToApiGateway() { @@ -279,7 +281,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab @Override public ListenableFuture<RpcResult<ReadStatusOutput>> readStatus(ReadStatusInput input) { LOG.debug("RPC Request: readStatusEntityList with input {}", input); - RpcResultBuilder<ReadStatusOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readStatus()); + RpcResultBuilder<ReadStatusOutput> result = + read(() -> DataProviderServiceImpl.this.dataProvider.readStatus(input)); return result.buildFuture(); } @@ -460,11 +463,11 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab } ReadTlsKeyEntryOutputBuilder output = new ReadTlsKeyEntryOutputBuilder(); if (result.isEmpty()) { - return output.setData(Arrays.asList()).setPagination(EMPTY_PAGINATION); + return output.setData(Set.of()).setPagination(EMPTY_PAGINATION); } Map<KeyCredentialKey, KeyCredential> keyCredential = result.get().getKeyCredential(); if (keyCredential == null) { - return output.setData(Arrays.asList()).setPagination(EMPTY_PAGINATION); + return output.setData(Set.of()).setPagination(EMPTY_PAGINATION); } org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Pagination pagination = input.getPagination(); @@ -474,7 +477,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab : pagination.getSize() == null ? DEFAULT_PAGESIZE : pagination.getSize().longValue(); long from = pageNum > 0 ? (pageNum - 1) * size : 0; output.setData(keyCredential.keySet().stream().skip(from).limit(size).map(e -> e.getKeyId()) - .collect(Collectors.toList())); + .collect(Collectors.toSet())); output.setPagination(new PaginationBuilder().setPage(Uint64.valueOf(pageNum)) .setSize(Uint32.valueOf(output.getData().size())).setTotal(Uint64.valueOf(keyCredential.size())) .build()); @@ -492,16 +495,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab return buf.toString(); } - private interface GetEntityInput<O extends DataObject> { - Builder<O> get() throws IOException; + private interface GetEntityInput<O extends DataObject,B> { + B get() throws IOException; } - private static <O extends DataObject, I extends DataObject> RpcResultBuilder<O> read( - GetEntityInput<O> inputgetter) { + private static <O extends DataObject, B> RpcResultBuilder<O> read( + GetEntityInput<O,B> inputgetter) { RpcResultBuilder<O> result; try { - Builder<O> outputBuilder = inputgetter.get(); - result = RpcResultBuilder.success(outputBuilder); + B outputBuilder = inputgetter.get(); + result = RpcResultBuilder.success(YangToolsMapperHelper.callBuild(outputBuilder)); } catch (Exception e) { LOG.info("Exception", e); result = RpcResultBuilder.failed(); @@ -510,6 +513,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab return result; } + public HtUserdataManager getHtDatabaseUserManager() { return this.dbUserManager; } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java index 00e8075f9..08b1d00aa 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java @@ -31,8 +31,13 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; import java.math.BigInteger; +import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; + +import org.eclipse.jdt.annotation.Nullable; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; @@ -48,10 +53,12 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.UserdataHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.DataProviderYangToolsMapper; +import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmNotificationType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder; @@ -68,9 +75,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultlog; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder; @@ -116,6 +125,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInputBuilder; @@ -126,11 +136,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Pagination; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data; +import org.opendaylight.yangtools.yang.common.Uint32; public class TestCRUDforDatabase { @@ -164,27 +176,49 @@ public class TestCRUDforDatabase { //== CLEAR AND CREATE ================================ clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateFaultcurrentInput", - SeverityType.Critical); + SeverityType.Critical, "nodeA"); createFaultEntity("Lorem Ipsum", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateFaultcurrentInput", - SeverityType.Major); + SeverityType.Major, "nodeB"); createFaultEntity("3", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateFaultcurrentInput", - SeverityType.Minor); + SeverityType.Minor, "nodeC"); createFaultEntity("4", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateFaultcurrentInput", - SeverityType.Warning); - + SeverityType.Warning, "nodeA"); + + createNeConnection("nodeA","10.20.30.40",30000, ConnectionLogStatus.Connected); + createNeConnection("nodeB","10.20.30.40",31000, ConnectionLogStatus.Connected); + createNeConnection("nodeC","10.20.30.40",32000, ConnectionLogStatus.Connected); + createNeConnection("nodeAD","10.20.30.40",33000, ConnectionLogStatus.Connected); + createNeConnection("nodeE","10.20.30.40",34000, ConnectionLogStatus.Connected); + createNeConnection("nodeF","10.20.30.40",35000, ConnectionLogStatus.Connected); //== READ ================================ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data> readOutput = - dbProvider.readStatus().getData(); + dbProvider.readStatus(null).getData(); System.out.println(readOutput); + + assertEquals(1, readOutput.get(0).getFaults().getMajors().intValue()); assertEquals(1, readOutput.get(0).getFaults().getMinors().intValue()); assertEquals(1, readOutput.get(0).getFaults().getWarnings().intValue()); assertEquals(1, readOutput.get(0).getFaults().getCriticals().intValue()); + Map<FilterKey, Filter> filter = YangToolsMapperHelper + .toMap(Arrays.asList(new FilterBuilder().setProperty("node-id").setFiltervalue("nodeA").build())); + EntityInput input = new ReadStatusInputBuilder().setFilter(filter).build(); + readOutput = dbProvider.readStatus(input).getData(); + System.out.println(readOutput); + assertEquals(1, readOutput.get(0).getNetworkElementConnections().getConnected().intValue()); + assertEquals(0, readOutput.get(0).getNetworkElementConnections().getConnecting().intValue()); + assertEquals(0, readOutput.get(0).getNetworkElementConnections().getDisconnected().intValue()); + assertEquals(0, readOutput.get(0).getNetworkElementConnections().getMounted().intValue()); + assertEquals(0, readOutput.get(0).getFaults().getMajors().intValue()); + assertEquals(0, readOutput.get(0).getFaults().getMinors().intValue()); + assertEquals(1, readOutput.get(0).getFaults().getWarnings().intValue()); + assertEquals(1, readOutput.get(0).getFaults().getCriticals().intValue()); + //== DELETE ================================ @@ -197,13 +231,15 @@ public class TestCRUDforDatabase { //== VERIFY DELETE =========================== System.out.println("verify entries were deleted"); - readOutput = dbProvider.readStatus().getData(); + readOutput = dbProvider.readStatus(null).getData(); assertEquals(0, readOutput.get(0).getFaults().getMajors().intValue()); assertEquals(0, readOutput.get(0).getFaults().getMinors().intValue()); assertEquals(0, readOutput.get(0).getFaults().getWarnings().intValue()); assertEquals(0, readOutput.get(0).getFaults().getCriticals().intValue()); } + + @Test public void testMediatorServer() { final String NAME = "ms1"; @@ -599,14 +635,14 @@ public class TestCRUDforDatabase { public void testCMLog() { System.out.println("Starting CM log test..."); String dbId = clearAndCreateCMEntity("1", Entity.Cmlog.getName(), - "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateCmlogInput"); + "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateCmlogInput"); // ==READ=========================== System.out.println("try to read entry"); ReadCmlogListInput readinput = new ReadCmlogListInputBuilder() - .setFilter(YangHelper2.getListOrMap(FilterKey.class, - new FilterBuilder().setProperty("id").setFiltervalue(dbId).build())) - .setPagination(getPagination(20, 1)).build(); + .setFilter(YangHelper2.getListOrMap(FilterKey.class, + new FilterBuilder().setProperty("id").setFiltervalue(dbId).build())) + .setPagination(getPagination(20, 1)).build(); ReadCmlogListOutputBuilder readResult = null; try { @@ -616,8 +652,8 @@ public class TestCRUDforDatabase { fail("CM log not read: " + e.getMessage()); } - List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> - data = readResult.getData(); + List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> data = + readResult.getData(); assertNotNull(data); assertEquals("1", dbId); @@ -634,13 +670,13 @@ public class TestCRUDforDatabase { System.out.println("try to update entry"); dbRawProvider.doUpdateOrCreate(Entity.Cmlog.getName(), "1", - "{'node-id': 'test4657-78','operation': 'CREATE', 'notification-id': '1'}"); + "{'node-id': 'test4657-78','operation': 'CREATE', 'notification-id': '1'}"); System.out.println("try to search entry 1"); readinput = new ReadCmlogListInputBuilder() - .setFilter(YangHelper2.getListOrMap(FilterKey.class, - new FilterBuilder().setProperty("node-id").setFiltervalue("test").build())) - .setPagination(getPagination(20, 1)).build(); + .setFilter(YangHelper2.getListOrMap(FilterKey.class, + new FilterBuilder().setProperty("node-id").setFiltervalue("test").build())) + .setPagination(getPagination(20, 1)).build(); //== VERIFY UPDATE ================================ readResult = dbProvider.readCMLogList(readinput); @@ -652,9 +688,9 @@ public class TestCRUDforDatabase { System.out.println("try to search entry 2"); readinput = new ReadCmlogListInputBuilder() - .setFilter(YangHelper2.getListOrMap(FilterKey.class, - new FilterBuilder().setProperty("node-id").setFiltervalue("test*").build())) - .setPagination(getPagination(20, 1)).build(); + .setFilter(YangHelper2.getListOrMap(FilterKey.class, + new FilterBuilder().setProperty("node-id").setFiltervalue("test*").build())) + .setPagination(getPagination(20, 1)).build(); readResult = dbProvider.readCMLogList(readinput); data = readResult.getData(); @@ -676,7 +712,7 @@ public class TestCRUDforDatabase { //== VERIFY DELETE =========================== System.out.println("verify entries deleted"); readResult = dbProvider - .readCMLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build()); + .readCMLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build()); data = readResult.getData(); assertEquals(0, data.size()); } @@ -1012,10 +1048,11 @@ public class TestCRUDforDatabase { assertEquals("2008-11-21T00:00:00.0Z", data.get(0).getDate()); assertEquals("sd-dsa-eww", data.get(0).getSerial()); assertEquals(holderArray.length, data.get(0).getContainedHolder().size()); - assertEquals(holderArray[0], data.get(0).getContainedHolder().get(0)); - assertEquals(holderArray[1], data.get(0).getContainedHolder().get(1)); - assertEquals(holderArray[2], data.get(0).getContainedHolder().get(2)); - + Set<String> holder = data.get(0).getContainedHolder(); + assertTrue(holder.contains(holderArray[0])); + assertTrue(holder.contains(holderArray[1])); + assertTrue(holder.contains(holderArray[2])); + // ==DELETE============================ System.out.println("delete after test"); @@ -1159,7 +1196,7 @@ public class TestCRUDforDatabase { fail("Problem reading 15m ltp data"); } - List<String> dataLtp = readltpResult.getData(); + Set<String> dataLtp = readltpResult.getData(); assertNotNull(dataLtp); assertEquals(2, dataLtp.size()); @@ -1179,7 +1216,7 @@ public class TestCRUDforDatabase { fail("Problem reading 15m device data"); } - List<String> dataDevice = readDeviceResult.getData(); + Set<String> dataDevice = readDeviceResult.getData(); assertNotNull(dataDevice); assertEquals(2, dataDevice.size()); @@ -1278,7 +1315,7 @@ public class TestCRUDforDatabase { fail("Problem reading 24h ltp data"); } - List<String> dataLtp = readltpResult.getData(); + Set<String> dataLtp = readltpResult.getData(); assertNotNull(dataLtp); assertEquals(3, dataLtp.size()); @@ -1300,7 +1337,7 @@ public class TestCRUDforDatabase { fail("Problem reading 24h device data"); } - List<String> dataDevice = readDeviceResult.getData(); + Set<String> dataDevice = readDeviceResult.getData(); assertNotNull(dataDevice); assertEquals(2, dataDevice.size()); @@ -1505,8 +1542,8 @@ public class TestCRUDforDatabase { assertEquals("admin", UserdataHttpServlet.decodeJWTPayloadUsername(String.format("Bearer %s", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkBzZG4iLCJyb2xlcyI6WyJ1c2VyIiwiYWRtaW4iXSwiaXN" - + "zIjoiT3BlbmRheWxpZ2h0IiwibmFtZSI6ImFkbWluQHNkbiIsImV4cCI6MTYxNTc5NTg1NywiZmFtaWx5X25hbWUiOiIifQ.wB" - + "PdB45_bryU6_kSCu3be3dq3yth24niSXi6b2_1ufc"), + + "zIjoiT3BlbmRheWxpZ2h0IiwibmFtZSI6ImFkbWluQHNkbiIsImV4cCI6MTYxNTc5NTg1NywiZmFtaWx5X25hbWUiOiIifQ.wB" + + "PdB45_bryU6_kSCu3be3dq3yth24niSXi6b2_1ufc"), "sub")); } @@ -1515,9 +1552,13 @@ public class TestCRUDforDatabase { .setSize(YangHelper2.getLongOrUint32(pageSize)).build(); } - private String clearAndCreatefaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) { + return clearAndCreatefaultEntity(initialDbId, entityType, implementedInterface, severity, "s1"); + } + + private String clearAndCreatefaultEntity(String initialDbId, String entityType, String implementedInterface, + SeverityType severity, String nodeId) { // ==CLEAR BEFORE TEST============================ System.out.println("try to clear entry"); try { @@ -1527,11 +1568,24 @@ public class TestCRUDforDatabase { } - return createFaultEntity(initialDbId, entityType, implementedInterface, severity); + return createFaultEntity(initialDbId, entityType, implementedInterface, severity, nodeId); } + private void createNeConnection(String nodeId, String host, int port, ConnectionLogStatus connectionStatus) { + try { + dbProvider.createNetworkElementConnection(new NetworkElementConnectionBuilder().setId(nodeId) + .setNodeId(nodeId).setStatus(connectionStatus).setHost(host).setPort(Uint32.valueOf(port)).build()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } private String createFaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) { + return createFaultEntity(initialDbId, entityType, implementedInterface, severity, "s1"); + } + private String createFaultEntity(String initialDbId, String entityType, String implementedInterface, + SeverityType severity, String nodeId) { // ==CREATE============================ System.out.println("try to create entry"); String dbId = null; @@ -1540,7 +1594,7 @@ public class TestCRUDforDatabase { dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId, "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" + "\"object-id\": \"LP-MWPS-RADIO\",\n" - + "\"severity\": \"" + severity.toString() + "\",\n" + "\"node-id\": \"s1\",\n" + + "\"severity\": \"" + severity.toString() + "\",\n" + "\"node-id\": \""+nodeId+"\",\n" + "\"implemented-interface\": \"" + implementedInterface + "\",\n" + "\"counter\": 4340,\n" + "\"problem\": \"signalIsLost\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}"); @@ -1566,23 +1620,19 @@ public class TestCRUDforDatabase { private String createCMEntity(String initialDbId, String entityType, String implementedInterface) { // ==CREATE============================ - System.out.println("try to create entry"); - String dbId = null; + System.out.println("try to create entry"); + String dbId = null; try { dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId, - "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" - + "\" object-id\": \"LP-MWPS-RADIO\",\n" - + "\"node-id\": \"node-1\",\n" - + "\"counter\": 1,\n" - + "\"notification-type\": \"" + CmNotificationType.NotifyMOIChanges.toString() + "\",\n" - + "\"notification-id\": 123,\n" - + "\"source-indicator\": \"" + CmSourceIndicator.MANAGEMENTOPERATION.toString() + "\",\n" - + "\" path\": \"https://samsung.com/3GPP/simulation/network-function/ves=1\",\n" - + "\"operation\": \"" + CmOperation.REPLACE.toString() + "\",\n" - + "\"value\": \"pnf-registration:true\",\n" - + "\"implemented-interface\": \"" + implementedInterface + "\"\n" - + "}"); + "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" + "\" object-id\": \"LP-MWPS-RADIO\",\n" + + "\"node-id\": \"node-1\",\n" + "\"counter\": 1,\n" + "\"notification-type\": \"" + + CmNotificationType.NotifyMOIChanges.toString() + "\",\n" + "\"notification-id\": 123,\n" + + "\"source-indicator\": \"" + CmSourceIndicator.MANAGEMENTOPERATION.toString() + "\",\n" + + "\" path\": \"https://samsung.com/3GPP/simulation/network-function/ves=1\",\n" + + "\"operation\": \"" + CmOperation.REPLACE.toString() + "\",\n" + + "\"value\": \"pnf-registration:true\",\n" + "\"implemented-interface\": \"" + + implementedInterface + "\"\n" + "}"); } catch (Exception e) { fail("Problem creating CM log entry" + e.getMessage()); diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java index 611533ba1..910f63daf 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java @@ -24,7 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; + import org.eclipse.jdt.annotation.Nullable; import org.json.JSONObject; import org.junit.Test; @@ -81,7 +84,7 @@ public class TestYangGenSalMapping { OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder = new OdlHelloMessageCapabilitiesBuilder(); - List<Uri> uriList = new ArrayList<>(); + Set<Uri> uriList = new HashSet<>(); uriList.add(new Uri("test.uri")); odlHelloMessageCapabilitiesBuilder.setCapability(uriList); netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build()); diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml index ec5f36539..f36d5ae94 100644 --- a/sdnr/wt/data-provider/setup/pom.xml +++ b/sdnr/wt/data-provider/setup/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -97,6 +98,10 @@ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> <artifactId>rfc6991-ietf-yang-types</artifactId> </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + </dependency> </dependencies> <build> <plugins> diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java index a2a1fcdec..2845613cb 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java @@ -61,6 +61,7 @@ public class MariaDBTestBase { private static final Map<String, String> envDefaultValues = initEnvDefaultValues(); private static final String SDNRDBDATABASETEST="test"; private static final String TESTPROPFILE = "test.properties"; + private static final String SUFFIX = ""; public MariaDBTestBase() throws ManagedProcessException { this(new Random().nextInt(1000) + 50000); @@ -169,7 +170,7 @@ public class MariaDBTestBase { boolean withControllerId) { String createStatement = null; try { - createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId); + createStatement = SqlDBMapper.createTable(cls, entity, SUFFIX, autoIndex,withControllerId); } catch (UnableToMapClassException e) { fail(e.getMessage()); } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java index ef8998875..ceec97e36 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java @@ -27,6 +27,7 @@ import java.lang.reflect.InvocationTargetException; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.concurrent.TimeUnit; import org.junit.AfterClass; @@ -72,6 +73,7 @@ public class TestMariaDBMapper { // private static DbLibService dbService; + private static final String SUFFIX = ""; private static MariaDBTestBase testBase; private static SqlDBDataProvider dbProvider; @@ -123,10 +125,10 @@ public class TestMariaDBMapper { builder.setDeviceType(NetworkElementDeviceType.OROADM); builder.setHost("10.20.30.40"); builder.setIsRequired(true); - NodeDetails nodeDetails = new NodeDetailsBuilder().setAvailableCapabilities(Arrays.asList( + NodeDetails nodeDetails = new NodeDetailsBuilder().setAvailableCapabilities(new HashSet<>(Arrays.asList( "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all," + "report-all-tagged,trim,explicit", - "urn:ietf:params:netconf:capability:validate:1.1", "urn:ietf:params:netconf:capability:url:1.0")) + "urn:ietf:params:netconf:capability:validate:1.1", "urn:ietf:params:netconf:capability:url:1.0"))) .build(); builder.setNodeDetails(nodeDetails); builder.setPassword("password"); @@ -202,7 +204,7 @@ public class TestMariaDBMapper { boolean withControllerId) { String createStatement = null; try { - createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId); + createStatement = SqlDBMapper.createTable(cls, entity, SUFFIX, autoIndex,withControllerId); } catch (UnableToMapClassException e) { fail(e.getMessage()); } diff --git a/sdnr/wt/devicemanager-core/feature/pom.xml b/sdnr/wt/devicemanager-core/feature/pom.xml index 5882823b2..e65580d83 100644 --- a/sdnr/wt/devicemanager-core/feature/pom.xml +++ b/sdnr/wt/devicemanager-core/feature/pom.xml @@ -22,13 +22,15 @@ ~ ============LICENSE_END======================================================= ~ --> + + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-core/installer/pom.xml b/sdnr/wt/devicemanager-core/installer/pom.xml index 1124c5b09..1d84071b4 100755 --- a/sdnr/wt/devicemanager-core/installer/pom.xml +++ b/sdnr/wt/devicemanager-core/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-core/model/pom.xml b/sdnr/wt/devicemanager-core/model/pom.xml index 070d3840e..56bec8c84 100644 --- a/sdnr/wt/devicemanager-core/model/pom.xml +++ b/sdnr/wt/devicemanager-core/model/pom.xml @@ -22,16 +22,18 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <parent> + <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> <artifactId>sdnr-wt-devicemanager-core-model</artifactId> <version>1.4.0-SNAPSHOT</version> @@ -60,11 +62,17 @@ <artifactId>sdnr-wt-data-provider-model</artifactId> <version>${project.version}</version> <scope>provided</scope> + </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-websocketmanager-model</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> diff --git a/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang b/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang index e12991b29..5edf3949d 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang +++ b/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang @@ -1,6 +1,6 @@ module devicemanager { - yang-version 1; + yang-version 1.1; namespace "urn:opendaylight:params:xml:ns:yang:devicemanager"; prefix devicemanager; diff --git a/sdnr/wt/devicemanager-core/pom.xml b/sdnr/wt/devicemanager-core/pom.xml index 18be33b40..24a99fe39 100755 --- a/sdnr/wt/devicemanager-core/pom.xml +++ b/sdnr/wt/devicemanager-core/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-core/provider/pom.xml b/sdnr/wt/devicemanager-core/provider/pom.xml index 05a6127d2..4c373d58d 100644 --- a/sdnr/wt/devicemanager-core/provider/pom.xml +++ b/sdnr/wt/devicemanager-core/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -52,13 +53,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-devicemanager-core-model</artifactId> @@ -71,6 +65,12 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> <artifactId>sdnr-wt-websocketmanager-model</artifactId> <version>${project.version}</version> @@ -85,11 +85,12 @@ <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> <artifactId>ietf-topology</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.netconf</groupId> @@ -156,6 +157,23 @@ <artifactId>jaxb-runtime</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java index e31b79aea..4d5823a00 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java @@ -19,8 +19,14 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl; +import com.google.common.util.concurrent.ForwardingListenableFuture; import com.google.common.util.concurrent.ListenableFuture; + +import java.util.HashSet; import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementsListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI; @@ -52,7 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -105,7 +111,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { GetRequiredNetworkElementKeysOutputBuilder outputBuilder = maintenanceService.getRequiredNetworkElementKeys(); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -123,7 +129,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { ShowRequiredNetworkElementOutputBuilder outputBuilder = maintenanceService.showRequiredNetworkElement(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -139,13 +145,12 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { SetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.setMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); } return result.buildFuture(); - } @@ -154,11 +159,11 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl public ListenableFuture<RpcResult<GetMaintenanceModeOutput>> getMaintenanceMode(GetMaintenanceModeInput input) { LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName()); - RpcResultBuilder<GetMaintenanceModeOutput> result; + @NonNull RpcResultBuilder<GetMaintenanceModeOutput> result; try { GetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.getMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -174,7 +179,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { TestMaintenanceModeOutputBuilder outputBuilder = maintenanceService.testMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -192,10 +197,10 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { if (this.resyncCallbackListener != null) { List<String> nodeNames = - this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames()); + this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames().stream().collect(Collectors.toList())); ClearCurrentFaultByNodenameOutputBuilder outputBuilder = new ClearCurrentFaultByNodenameOutputBuilder(); - outputBuilder.setNodenames(nodeNames); - result = RpcResultBuilder.success(outputBuilder); + outputBuilder.setNodenames(new HashSet<>(nodeNames)); + result = RpcResultBuilder.success(outputBuilder.build()); } else { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Startup running"); @@ -251,6 +256,4 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl return result.buildFuture(); } - - } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java index 4369af019..13eca8f25 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java @@ -17,6 +17,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util; +import java.util.HashSet; import java.util.Optional; import javax.annotation.Nonnull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus; @@ -82,8 +83,8 @@ public class NetworkElementConnectionEntitiyUtil { Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); NodeDetailsBuilder nodeDetails = - new NodeDetailsBuilder().setAvailableCapabilities(availableCapabilities.getCapabilities()) - .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); + new NodeDetailsBuilder().setAvailableCapabilities(new HashSet<>(availableCapabilities.getCapabilities())) + .setUnavailableCapabilities(new HashSet<>(unAvailableCapabilities.getCapabilities())); eb.setNodeDetails(nodeDetails.build()); // -- host information Host host = nNode.getHost(); diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java index 6351f3958..b8b67fde4 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java @@ -19,7 +19,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService; @@ -79,7 +82,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP public GetRequiredNetworkElementKeysOutputBuilder getRequiredNetworkElementKeys() { List<MaintenanceEntity> all = database.getAll(); - List<String> mountpointList = new ArrayList<>(); + Set<String> mountpointList = new HashSet<>(); for (MaintenanceEntity oneOfAll : all) { mountpointList.add(oneOfAll.getNodeId()); diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java index 06b825934..07c4f6ae4 100644 --- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java +++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java @@ -22,6 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import static org.junit.Assert.assertTrue; import java.util.Arrays; +import java.util.HashSet; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -179,7 +181,7 @@ public class TestDevicemanager extends Mockito { log.info("testResync"); ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder(); - inputBuilder.setNodenames(Arrays.asList("test1", "test2")); + inputBuilder.setNodenames(new HashSet<>(Arrays.asList("test1", "test2"))); apiService.clearCurrentFaultByNodename(inputBuilder.build()); } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml index 475ba0f28..635d3b97e 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml index 76993dd1b..0e137d980 100755 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml index a22154353..2354c3a40 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml index aaf472714..9cbe89787 100755 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml index ebb1c63cf..ee4f84f72 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -53,38 +54,44 @@ </properties> <dependencies> - <!-- begin for testing --> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-devicemanager-core-provider</artifactId> + <artifactId>sdnr-wt-devicemanager-o-ran-sc-oran-model</artifactId> <version>${project.version}</version> - <scope>test</scope> + <scope>provided</scope> </dependency> - <!-- end for testing --> <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-devicemanager-core-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-devicemanager-o-ran-sc-oran-model</artifactId> + <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-devicemanager-core-model</artifactId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> @@ -113,6 +120,25 @@ <artifactId>onap-system</artifactId> <version>${project.version}</version> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-devicemanager-core-provider</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>test</scope> + </dependency> + <!-- end for testing --> + </dependencies> <build> diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java index 279620cf8..a3bd14e3e 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java @@ -24,8 +24,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import java.time.Instant; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; + import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yangtools.yang.common.QName; @@ -63,8 +66,8 @@ public class ORanDMDOMUtility { } } - public static List<String> getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { - List<String> containsChildList = new ArrayList<String>(); + public static Set<String> getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { + Set<String> containsChildList = new HashSet<String>(); try { DataContainerChild childSet = componentEntry.getChildByArg(new NodeIdentifier(leafListQName)); Collection<?> childEntry = (Collection<?>) childSet.body(); diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java index b157ae4b5..25a54f013 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java @@ -90,8 +90,8 @@ public class ORanDOMToInternalDataModel { inventoryResultList.add(oInventory.get()); } //Walk through list of child keys and add to list - for (String childUuid : CodeHelpers.nonnull(ORanDMDOMUtility.getLeafListValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD))) { + for (String childUuid : CodeHelpers.nonnull(new ArrayList<>(ORanDMDOMUtility.getLeafListValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)))) { for (MapEntryNode c : getComponentsByName(childUuid, componentList)) { inventoryResultList = recurseGetInventory(nodeId, c, componentList, treeLevel + 1, inventoryResultList); } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java index b2c669819..e3113db3c 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java @@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util.TestYangParserUtil; import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; @@ -80,7 +79,7 @@ public class TestORanDOMToInternalDataModel { @BeforeClass public static void setup() throws IOException { - schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); + schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); hwContainerSchema = Inference.ofDataTreePath(schemaContext, HW_CONTAINER); systemSchema = Inference.ofDataTreePath(schemaContext, IETF_CONTAINER); } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java new file mode 100644 index 000000000..80c18aef2 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; + +import com.google.common.annotations.Beta; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.stream.Collectors; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.YangConstants; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.parser.api.YangParser; +import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.api.YangParserException; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; +import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +/** + * Utility class which provides convenience methods for producing effective schema context based on the supplied + * yang/yin sources or paths to these sources. + */ +@Beta +public final class YangParserTestUtils { + + private static final FileFilter YANG_FILE_FILTER = file -> { + // Locale keeps SpotBugs happy. It should not matter that much anyway. + final String name = file.getName().toLowerCase(Locale.ENGLISH); + return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); + }; + + private static final @NonNull YangParserFactory PARSER_FACTORY; + + static { + final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); + if (!it.hasNext()) { + throw new IllegalStateException("No YangParserFactory found"); + } + PARSER_FACTORY = it.next(); + } + + private YangParserTestUtils() { + // Hidden on purpose + } + + /** + * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param resource relative path to the YANG file to be parsed + * + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource) { + return parseYangResource(resource, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG source. All YANG features are supported. + * + * @param resource relative path to the YANG file to be parsed + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config) { + return parseYangResource(resource, config, null); + } + + /** + * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to + * default mode. + * + * @param resource relative path to the YANG file to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * model are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final Set<QName> supportedFeatures) { + return parseYangResource(resource, YangParserConfiguration.DEFAULT, supportedFeatures); + } + + /** + * Creates a new effective schema context containing the specified YANG source. + * + * @param resource relative path to the YANG file to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * model are resolved + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config, + final Set<QName> supportedFeatures) { + final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource); + return parseYangSources(config, supportedFeatures, source); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final File... files) { + return parseYangFiles(Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param files collection of YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Collection<File> files) { + return parseYangFiles(YangParserConfiguration.DEFAULT, files); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) { + return parseYangFiles(supportedFeatures, Arrays.asList(files)); + } + + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final Collection<File> files) { + return parseYangFiles(supportedFeatures, YangParserConfiguration.DEFAULT, files); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { + return parseYangFiles(config, Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param parserMode mode of statement parser + * @param files collection of YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, + final Collection<File> files) { + return parseYangFiles(null, config, files); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final File... files) { + return parseYangFiles(supportedFeatures, config, Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final Collection<File> files) { + return parseSources(config, supportedFeatures, + files.stream().map(e->e.toPath()).map(YangTextSchemaSource::forPath).collect(Collectors.toList())); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { + return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final YangParserConfiguration config) { + return parseYangResourceDirectory(resourcePath, null, config); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final Set<QName> supportedFeatures) { + return parseYangResourceDirectory(resourcePath, supportedFeatures, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @return effective schema context + */ + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final Set<QName> supportedFeatures, final YangParserConfiguration config) { + final URI directoryPath; + try { + directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); + } + return parseYangFiles(supportedFeatures, config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param clazz Resource lookup base + * @param resources Resource names to be looked up + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final Class<?> clazz, final String... resources) { + return parseYangResources(clazz, Arrays.asList(resources)); + } + + public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) { + final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size()); + for (final String r : resources) { + sources.add(YangTextSchemaSource.forResource(clazz, r)); + } + return parseSources(YangParserConfiguration.DEFAULT, null, sources); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param yangDirs relative paths to the directories containing YANG files to be parsed + * @param yangFiles relative paths to the YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles, + final Set<QName> supportedFeatures) { + return parseYangResources(yangDirs, yangFiles, supportedFeatures, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed + * @param yangResources relative paths to the YANG files to be parsed + * @param statementParserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, + final List<String> yangResources, final YangParserConfiguration config) { + return parseYangResources(yangResourceDirs, yangResources, null, config); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed + * @param yangResources relative paths to the YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param statementParserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, + final List<String> yangResources, final Set<QName> supportedFeatures, + final YangParserConfiguration config) { + final List<File> allYangFiles = new ArrayList<>(); + for (final String yangDir : yangResourceDirs) { + allYangFiles.addAll(getYangFiles(yangDir)); + } + + for (final String yangFile : yangResources) { + try { + allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI())); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Invalid resource " + yangFile, e); + } + } + + return parseYangFiles(supportedFeatures, config, allYangFiles); + } + + public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { + return parseSources(config, supportedFeatures, Arrays.asList(sources)); + } + + public static EffectiveModelContext parseSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { + final YangParser parser = PARSER_FACTORY.createParser(config); + if (supportedFeatures != null) { + parser.setSupportedFeatures(supportedFeatures); + } + + try { + parser.addSources(sources); + } catch (YangSyntaxErrorException e) { + throw new IllegalArgumentException("Malformed source", e); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to read a source", e); + } + + try { + return parser.buildEffectiveModel(); + } catch (YangParserException e) { + throw new IllegalStateException("Failed to assemble SchemaContext", e); + } + } + + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") + private static Collection<File> getYangFiles(final String resourcePath) { + final URI directoryPath; + try { + directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e); + } + return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER)); + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java deleted file mode 100644 index 35a66055a..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.stream.Collectors; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -import org.opendaylight.yangtools.yang.parser.api.YangParser; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.api.YangParserException; -import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; -import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; - -public final class TestYangParserUtil { - - private static final FileFilter YANG_FILE_FILTER = file -> { - final String name = file.getName(); - return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); - }; - - private static final @NonNull YangParserFactory PARSER_FACTORY; - - static { - final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); - if (!it.hasNext()) { - throw new IllegalStateException("No YangParserFactory found"); - } - PARSER_FACTORY = it.next(); - } - - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { - return parseYangFiles(config, Arrays.asList(files)); - } - - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, - final Collection<File> files) { - return parseSources(config, files.stream().map(YangTextSchemaSource::forFile).collect(Collectors.toList())); - } - - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { - return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); - } - - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final YangParserConfiguration config) { - final URI directoryPath; - try { - directoryPath = TestYangParserUtil.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); - } - return parseYangFiles(config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); - } - - public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { - return parseSources(config, Arrays.asList(sources)); - } - - public static EffectiveModelContext parseSources(final YangParserConfiguration config, - final Collection<? extends SchemaSourceRepresentation> sources) { - final YangParser parser = PARSER_FACTORY.createParser(config); - - try { - parser.addSources(sources); - } catch (YangSyntaxErrorException e) { - throw new IllegalArgumentException("Malformed source", e); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to read a source", e); - } - - try { - return parser.buildEffectiveModel(); - } catch (YangParserException e) { - throw new IllegalStateException("Failed to assemble SchemaContext", e); - } - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml index 433c51cba..60f998630 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml @@ -8,10 +8,10 @@ <admin-state>unlocked</admin-state> <oper-state>enabled</oper-state> </state> - <serial-num>1234</serial-num> - <software-rev>1.2.3 (2022-10-30 09:34:59)</software-rev> - <mfg-name>Highstreet</mfg-name> - <model-name>HS O-RU</model-name> + <serial-num>10283</serial-num> + <software-rev>3.8.1 (2020-10-30 11:47:59)</software-rev> + <mfg-name>ISCO</mfg-name> + <model-name>ProteusCPRI Compact</model-name> <description>HighStreet-ONAP40</description> <contains-child>chassis-temperature-exhaust</contains-child> <contains-child>chassis-temperature-inlet</contains-child> @@ -36,7 +36,7 @@ <sensor-data> <value>30</value> <value-type>celsius</value-type> - <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -53,7 +53,7 @@ <sensor-data> <value>29</value> <value-type>celsius</value-type> - <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -82,7 +82,7 @@ <sensor-data> <value>4100</value> <value-type>rpm</value-type> - <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp> + <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp> <oper-status>ok</oper-status> </sensor-data> </component> @@ -212,10 +212,10 @@ </state> <parent>chassis</parent> <parent-rel-pos>7</parent-rel-pos> - <serial-num>1020304050</serial-num> - <firmware-rev>123456 (0ABC56D1)</firmware-rev> + <serial-num>7220530</serial-num> + <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev> <software-rev>0</software-rev> - <model-name>00AA-SFP-99-BB-CCC</model-name> + <model-name>385A-SFP-2P-40-FHL-JC3</model-name> <contains-child>slot0-temperature</contains-child> <contains-child>slot0-logical0</contains-child> <contains-child>slot0-logical1</contains-child> @@ -263,9 +263,9 @@ <parent>slot0-logical0</parent> <parent-rel-pos>0</parent-rel-pos> <o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-bbu</o-ran-name> - <serial-num>ABC12DF3</serial-num> - <mfg-name>Highstreet</mfg-name> - <model-name>HS-99-56</model-name> + <serial-num>AYR3GA2</serial-num> + <mfg-name>FINISAR CORP.</mfg-name> + <model-name>FTLX1475D3BTL-E7</model-name> <contains-child>slot0-logical0-bbu-temperature</contains-child> </component> <component> @@ -296,9 +296,9 @@ <parent>slot0-logical0</parent> <parent-rel-pos>1</parent-rel-pos> <o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-rrh</o-ran-name> - <serial-num>ABC78YZ</serial-num> - <mfg-name>Highstreet</mfg-name> - <model-name>2W3E4R5T6Y</model-name> + <serial-num>AYR3GA9</serial-num> + <mfg-name>FINISAR CORP.</mfg-name> + <model-name>FTLX1475D3BTL-E7</model-name> <contains-child>slot0-logical0-rrh-temperature</contains-child> </component> <component> @@ -352,10 +352,10 @@ </state> <parent>chassis</parent> <parent-rel-pos>9</parent-rel-pos> - <serial-num>23561289</serial-num> - <firmware-rev>12.00.42-S (0ABC45HJ)</firmware-rev> + <serial-num>7220718</serial-num> + <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev> <software-rev>0</software-rev> - <model-name>ABC-123-DEF-XYZ</model-name> + <model-name>385A-SFP-2P-40-FHL-JC3</model-name> <mfg-date>2021-10-12T14:41:55.234Z</mfg-date> <contains-child>slot2-temperature</contains-child> <contains-child>slot2-logical0</contains-child> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/feature/pom.xml b/sdnr/wt/devicemanager-onap/adapter-manager/feature/pom.xml index e5425edb2..4a8865d0b 100644 --- a/sdnr/wt/devicemanager-onap/adapter-manager/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/adapter-manager/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/installer/pom.xml b/sdnr/wt/devicemanager-onap/adapter-manager/installer/pom.xml index c57d1af0a..d110338bd 100755 --- a/sdnr/wt/devicemanager-onap/adapter-manager/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/adapter-manager/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/model/pom.xml b/sdnr/wt/devicemanager-onap/adapter-manager/model/pom.xml index 840418add..521b43c7a 100644 --- a/sdnr/wt/devicemanager-onap/adapter-manager/model/pom.xml +++ b/sdnr/wt/devicemanager-onap/adapter-manager/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/pom.xml b/sdnr/wt/devicemanager-onap/adapter-manager/pom.xml index 0b4c48502..f95768b64 100755 --- a/sdnr/wt/devicemanager-onap/adapter-manager/pom.xml +++ b/sdnr/wt/devicemanager-onap/adapter-manager/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/pom.xml b/sdnr/wt/devicemanager-onap/adapter-manager/provider/pom.xml index 4f98031f0..32699ddd8 100644 --- a/sdnr/wt/devicemanager-onap/adapter-manager/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -74,11 +75,29 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.opendaylight.netconf</groupId> <artifactId>sal-netconf-connector</artifactId> <scope>provided</scope> diff --git a/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml b/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml index 5549506f1..f25cdb9f1 100644 --- a/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml b/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml index 9de3910f3..ad95be3b3 100755 --- a/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf12/model/pom.xml b/sdnr/wt/devicemanager-onap/onf12/model/pom.xml index fc64b649f..90574155e 100644 --- a/sdnr/wt/devicemanager-onap/onf12/model/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf12/pom.xml b/sdnr/wt/devicemanager-onap/onf12/pom.xml index 40eb33097..8d4dd1fcb 100755 --- a/sdnr/wt/devicemanager-onap/onf12/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml b/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml index f86a3982f..0a5d1d5d2 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -52,17 +53,22 @@ </properties> <dependencies> - <!-- begin for testing --> + <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-devicemanager-onap-onf12-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> - - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-devicemanager-onap-onf12-model</artifactId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> @@ -79,10 +85,23 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.opendaylight.netconf</groupId> <artifactId>sal-netconf-connector</artifactId> <scope>provided</scope> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>3.4.2</version> + <scope>test</scope> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-yang-utils</artifactId> @@ -94,6 +113,7 @@ <artifactId>org.osgi.core</artifactId> <scope>test</scope> </dependency> + <!-- end for testing --> </dependencies> <build> diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java index e6c3865f7..bbdf66ce7 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java +++ b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java @@ -19,7 +19,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder; @@ -91,7 +94,7 @@ public class ExtendedEquipment { if (getEquipment() != null) { inventoryBuilder.setUuid(getEquipment().getUuid().getValue()); // -- String list with ids of holders - List<String> containerHolderKeyList = new ArrayList<>(); + Set<String> containerHolderKeyList = new HashSet<>(); Collection<ContainedHolder> containerHolderList = YangHelper.getCollection(getEquipment().getContainedHolder()); if (containerHolderList != null) { for (ContainedHolder containerHolder : containerHolderList) { diff --git a/sdnr/wt/devicemanager-onap/onf14/feature/pom.xml b/sdnr/wt/devicemanager-onap/onf14/feature/pom.xml index b935690c5..d1598adca 100644 --- a/sdnr/wt/devicemanager-onap/onf14/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf14/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf14/installer/pom.xml b/sdnr/wt/devicemanager-onap/onf14/installer/pom.xml index 23da17b80..74474ea20 100755 --- a/sdnr/wt/devicemanager-onap/onf14/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf14/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf14/model/pom.xml b/sdnr/wt/devicemanager-onap/onf14/model/pom.xml index 35c38a0c6..6bec8692f 100644 --- a/sdnr/wt/devicemanager-onap/onf14/model/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf14/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf14/pom.xml b/sdnr/wt/devicemanager-onap/onf14/pom.xml index 48cc2b802..ec810996d 100755 --- a/sdnr/wt/devicemanager-onap/onf14/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf14/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/pom.xml b/sdnr/wt/devicemanager-onap/onf14/provider/pom.xml index b1040dedd..4714fe94c 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf14/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -53,14 +54,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-devicemanager-onap-onf14-model</artifactId> @@ -71,8 +64,26 @@ <artifactId>sdnr-wt-devicemanager-core-model</artifactId> <version>${project.version}</version> <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.opendaylight.mdsal</groupId> <artifactId>mdsal-binding-dom-codec-api</artifactId> <scope>provided</scope> @@ -86,7 +97,6 @@ <dependency> <groupId>org.opendaylight.netconf</groupId> <artifactId>sal-netconf-connector</artifactId> - <version>2.0.4</version> <scope>provided</scope> </dependency> <dependency> @@ -99,6 +109,13 @@ <artifactId>rfc6991-ietf-yang-types</artifactId> <scope>provided</scope> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> @@ -112,6 +129,7 @@ <plugin> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-maven-plugin</artifactId> + <version>7.0.9</version> <executions> <execution> <id>binding</id> diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java index 8a75bbc11..2a931378f 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java @@ -2,8 +2,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovide import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; @@ -35,7 +38,7 @@ public class Onf14DomToInternalDataModel { inventoryBuilder.setUuid(Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); inventoryBuilder.setParentUuid(parentUuid); - List<String> containedHolderKeyList = new ArrayList<>(); + Set<String> containedHolderKeyList = new HashSet<>(); MapNode containedHolderMap = (MapNode) currentEq .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_CONTAINED_HOLDER)); if (containedHolderMap != null) { diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java index ad79a5c43..6dc9b50b5 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/Onf14DomTestUtils.java @@ -82,7 +82,7 @@ public class Onf14DomTestUtils { public static NormalizedNode getNormalizedNodeFromJson() throws IOException, URISyntaxException { - schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); + schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); lhotkaCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext); streamAsString = loadTextFile(new File(Onf14DomTestUtils.class.getResource("/ControlConstruct-data-test.json").toURI())); @@ -105,7 +105,7 @@ public class Onf14DomTestUtils { public static NormalizedNode getNormalizedNodeFromXML() throws XMLStreamException, URISyntaxException, IOException, SAXException { - schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); + schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); hwContainerSchema = Inference.ofDataTreePath(schemaContext, CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER); final InputStream resourceAsStream = Onf14DomTestUtils.class.getResourceAsStream("/ControlConstruct-data-test.xml"); diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java deleted file mode 100644 index a0cfa6760..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/TestYangParserUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.util; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.stream.Collectors; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -import org.opendaylight.yangtools.yang.parser.api.YangParser; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.api.YangParserException; -import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; -import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; - -public final class TestYangParserUtil { - - private static final FileFilter YANG_FILE_FILTER = file -> { - final String name = file.getName(); - return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); - }; - - private static final @NonNull YangParserFactory PARSER_FACTORY; - - static { - final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); - if (!it.hasNext()) { - throw new IllegalStateException("No YangParserFactory found"); - } - PARSER_FACTORY = it.next(); - } - - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { - return parseYangFiles(config, Arrays.asList(files)); - } - - public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, - final Collection<File> files) { - return parseSources(config, files.stream().map(YangTextSchemaSource::forFile).collect(Collectors.toList())); - } - - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { - return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); - } - - public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, - final YangParserConfiguration config) { - final URI directoryPath; - try { - directoryPath = TestYangParserUtil.class.getResource(resourcePath).toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); - } - return parseYangFiles(config, new File(directoryPath).listFiles(YANG_FILE_FILTER)); - } - - public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, - final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { - return parseSources(config, Arrays.asList(sources)); - } - - public static EffectiveModelContext parseSources(final YangParserConfiguration config, - final Collection<? extends SchemaSourceRepresentation> sources) { - final YangParser parser = PARSER_FACTORY.createParser(config); - - try { - parser.addSources(sources); - } catch (YangSyntaxErrorException e) { - throw new IllegalArgumentException("Malformed source", e); - } catch (IOException e) { - throw new IllegalArgumentException("Failed to read a source", e); - } - - try { - return parser.buildEffectiveModel(); - } catch (YangParserException e) { - throw new IllegalStateException("Failed to assemble SchemaContext", e); - } - } -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java new file mode 100644 index 000000000..ee20dccae --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/util/YangParserTestUtils.java @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.util; + +import com.google.common.annotations.Beta; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.stream.Collectors; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.YangConstants; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.parser.api.YangParser; +import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.api.YangParserException; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; +import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +/** + * Utility class which provides convenience methods for producing effective schema context based on the supplied + * yang/yin sources or paths to these sources. + */ +@Beta +public final class YangParserTestUtils { + + private static final FileFilter YANG_FILE_FILTER = file -> { + // Locale keeps SpotBugs happy. It should not matter that much anyway. + final String name = file.getName().toLowerCase(Locale.ENGLISH); + return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); + }; + + private static final @NonNull YangParserFactory PARSER_FACTORY; + + static { + final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator(); + if (!it.hasNext()) { + throw new IllegalStateException("No YangParserFactory found"); + } + PARSER_FACTORY = it.next(); + } + + private YangParserTestUtils() { + // Hidden on purpose + } + + /** + * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param resource relative path to the YANG file to be parsed + * + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource) { + return parseYangResource(resource, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG source. All YANG features are supported. + * + * @param resource relative path to the YANG file to be parsed + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config) { + return parseYangResource(resource, config, null); + } + + /** + * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to + * default mode. + * + * @param resource relative path to the YANG file to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * model are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final Set<QName> supportedFeatures) { + return parseYangResource(resource, YangParserConfiguration.DEFAULT, supportedFeatures); + } + + /** + * Creates a new effective schema context containing the specified YANG source. + * + * @param resource relative path to the YANG file to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * model are resolved + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config, + final Set<QName> supportedFeatures) { + final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource); + return parseYangSources(config, supportedFeatures, source); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final File... files) { + return parseYangFiles(Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param files collection of YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Collection<File> files) { + return parseYangFiles(YangParserConfiguration.DEFAULT, files); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) { + return parseYangFiles(supportedFeatures, Arrays.asList(files)); + } + + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final Collection<File> files) { + return parseYangFiles(supportedFeatures, YangParserConfiguration.DEFAULT, files.stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) { + return parseYangFiles(config, Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param parserMode mode of statement parser + * @param files collection of YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, + final Collection<File> files) { + return parseYangFiles(null, config, files.stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final Path... files) { + return parseYangFiles(supportedFeatures, config, Arrays.asList(files)); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @param files YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, + final YangParserConfiguration config, final Collection<Path> files) { + return parseSources(config, supportedFeatures, + files.stream().map(YangTextSchemaSource::forPath).collect(Collectors.toList())); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) { + return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param parserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final YangParserConfiguration config) { + return parseYangResourceDirectory(resourcePath, null, config); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final Set<QName> supportedFeatures) { + return parseYangResourceDirectory(resourcePath, supportedFeatures, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param resourcePath relative path to the directory with YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param parserMode mode of statement parser + * @return effective schema context + */ + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") + public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath, + final Set<QName> supportedFeatures, final YangParserConfiguration config) { + final URI directoryPath; + try { + directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource " + resourcePath, e); + } + File[] files = new File(directoryPath).listFiles(YANG_FILE_FILTER); + return parseYangFiles(supportedFeatures, config, Arrays.asList(files).stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode and all YANG features are supported. + * + * @param clazz Resource lookup base + * @param resources Resource names to be looked up + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final Class<?> clazz, final String... resources) { + return parseYangResources(clazz, Arrays.asList(resources)); + } + + public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) { + final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size()); + for (final String r : resources) { + sources.add(YangTextSchemaSource.forResource(clazz, r)); + } + return parseSources(YangParserConfiguration.DEFAULT, null, sources); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to + * default mode. + * + * @param yangDirs relative paths to the directories containing YANG files to be parsed + * @param yangFiles relative paths to the YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles, + final Set<QName> supportedFeatures) { + return parseYangResources(yangDirs, yangFiles, supportedFeatures, YangParserConfiguration.DEFAULT); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported. + * + * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed + * @param yangResources relative paths to the YANG files to be parsed + * @param statementParserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, + final List<String> yangResources, final YangParserConfiguration config) { + return parseYangResources(yangResourceDirs, yangResources, null, config); + } + + /** + * Creates a new effective schema context containing the specified YANG sources. + * + * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed + * @param yangResources relative paths to the YANG files to be parsed + * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG + * models are resolved + * @param statementParserMode mode of statement parser + * @return effective schema context + */ + public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs, + final List<String> yangResources, final Set<QName> supportedFeatures, + final YangParserConfiguration config) { + final List<File> allYangFiles = new ArrayList<>(); + for (final String yangDir : yangResourceDirs) { + allYangFiles.addAll(getYangFiles(yangDir)); + } + + for (final String yangFile : yangResources) { + try { + allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI())); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Invalid resource " + yangFile, e); + } + } + + return parseYangFiles(supportedFeatures, config, allYangFiles.stream().map(e->e.toPath()).collect(Collectors.toList())); + } + + public static EffectiveModelContext parseYangSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) { + return parseSources(config, supportedFeatures, Arrays.asList(sources)); + } + + public static EffectiveModelContext parseSources(final YangParserConfiguration config, + final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) { + final YangParser parser = PARSER_FACTORY.createParser(config); + if (supportedFeatures != null) { + parser.setSupportedFeatures(supportedFeatures); + } + + try { + parser.addSources(sources); + } catch (YangSyntaxErrorException e) { + throw new IllegalArgumentException("Malformed source", e); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to read a source", e); + } + + try { + return parser.buildEffectiveModel(); + } catch (YangParserException e) { + throw new IllegalStateException("Failed to assemble SchemaContext", e); + } + } + + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles") + private static Collection<File> getYangFiles(final String resourcePath) { + final URI directoryPath; + try { + directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e); + } + return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER)); + } +} diff --git a/sdnr/wt/devicemanager-onap/openroadm/feature/pom.xml b/sdnr/wt/devicemanager-onap/openroadm/feature/pom.xml index 74abefe7a..ecfdaa63c 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm/feature/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm/installer/pom.xml b/sdnr/wt/devicemanager-onap/openroadm/installer/pom.xml index b956c1c15..ccb62033f 100755 --- a/sdnr/wt/devicemanager-onap/openroadm/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm/installer/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm/model/pom.xml b/sdnr/wt/devicemanager-onap/openroadm/model/pom.xml index b6b9c1cd9..b628bfa93 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/model/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm/model/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm/pom.xml b/sdnr/wt/devicemanager-onap/openroadm/pom.xml index bd1d4860c..11ce28e95 100755 --- a/sdnr/wt/devicemanager-onap/openroadm/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/pom.xml b/sdnr/wt/devicemanager-onap/openroadm/provider/pom.xml index 5098575cb..0505bb06c 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -50,26 +51,11 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.28.2</version> - <scope>test</scope> - </dependency> - <dependency> - <artifactId>byte-buddy</artifactId> - <groupId>net.bytebuddy</groupId> - <version>1.9.10</version> - <scope>test</scope> - </dependency> - - <!-- end for testing --> - <dependency> <groupId>${project.groupId}</groupId> <artifactId>ietf-alarms</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> @@ -87,7 +73,19 @@ <artifactId>sdnr-wt-data-provider-model</artifactId> <version>${project.version}</version> <scope>provided</scope> - </dependency> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> @@ -104,6 +102,19 @@ <artifactId>org.osgi.core</artifactId> <scope>provided</scope> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>3.2.4</version> + <scope>test</scope> + </dependency> + <dependency> + <artifactId>byte-buddy</artifactId> + <groupId>net.bytebuddy</groupId> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java index 87f195dc3..4d64cca19 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java @@ -32,6 +32,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmChangeNotificationListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.pack.features.CircuitPackComponents; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; @@ -56,7 +57,7 @@ public class TestChangeNotificationListener { OpenroadmChangeNotificationListener notifListener = new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, notificationService); when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { + List<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { @Override public int compareTo(PathArgument arg0) { @@ -65,10 +66,10 @@ public class TestChangeNotificationListener { @Override public Class<? extends DataObject> getType() { - return DataObject.class; + return CircuitPackComponents.class; } }); - InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); + InstanceIdentifier<?> target = InstanceIdentifier.unsafeOf(pathArguments); notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create, target)); EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java index ca9ce351c..2e94e79ef 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java @@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTe import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTechInfoNotificationBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.Edit; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.EditBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.pack.features.circuit.pack.components.Component; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; @@ -65,7 +66,7 @@ public class TestOpenRoadmDeviceChangeNotification { public void testOnChangeNotification() { when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { + List<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { @Override public int compareTo(PathArgument arg0) { @@ -74,10 +75,10 @@ public class TestOpenRoadmDeviceChangeNotification { @Override public Class<? extends DataObject> getType() { - return DataObject.class; + return Component.class; } }); - InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); + InstanceIdentifier<?> target = InstanceIdentifier.unsafeOf(pathArguments); deviceChangeListener.onChangeNotification(createNotification(EditOperationType.Create, target)); EventlogEntity event = diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java index 2a70ec7b6..202449033 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java @@ -40,6 +40,7 @@ import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Direction; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Location; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.pack.features.circuit.pack.components.Component; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.HistoricalPmList; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPm; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPmBuilder; @@ -142,10 +143,10 @@ public class TestOpenRoadmPMDataBuilder { @Override public @NonNull Class<? extends DataObject> getType() { // TODO Auto-generated method stub - return Pmdata15mEntity.class; + return Component.class; } }; - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.unsafeOf(Arrays.asList(pa))) .setPmResourceTypeExtension("dshjdekjdewkk") .setPmResourceType(ResourceTypeEnum.CircuitPack).setHistoricalPm(historicalPMCollection); @@ -179,11 +180,11 @@ public class TestOpenRoadmPMDataBuilder { @Override public Class<? extends DataObject> getType() { // TODO Auto-generated method stub - return Pmdata15mEntity.class; + return Component.class; } }; historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.unsafeOf(Arrays.asList(pa))) .setPmResourceTypeExtension("dshjdekjdewkk") .setPmResourceType(ResourceTypeEnum.Device).setHistoricalPm(historicalPMCollection); diff --git a/sdnr/wt/devicemanager-onap/openroadm71/feature/pom.xml b/sdnr/wt/devicemanager-onap/openroadm71/feature/pom.xml index e8603fac8..b74d9e1b2 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm71/feature/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm71/installer/pom.xml b/sdnr/wt/devicemanager-onap/openroadm71/installer/pom.xml index 45f41a0df..c1aa2ac65 100755 --- a/sdnr/wt/devicemanager-onap/openroadm71/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm71/installer/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm71/model/pom.xml b/sdnr/wt/devicemanager-onap/openroadm71/model/pom.xml index 264b224af..b5e6933ea 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/model/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm71/model/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm71/pom.xml b/sdnr/wt/devicemanager-onap/openroadm71/pom.xml index 93814a098..7dc7a5f54 100755 --- a/sdnr/wt/devicemanager-onap/openroadm71/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm71/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/pom.xml b/sdnr/wt/devicemanager-onap/openroadm71/provider/pom.xml index 40d1b6e2c..2d94bc2c7 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/pom.xml @@ -20,13 +20,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -50,21 +51,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> -<!-- <version>2.28.2</version> --> - <scope>test</scope> - </dependency> - <dependency> - <artifactId>byte-buddy</artifactId> - <groupId>net.bytebuddy</groupId> -<!-- <version>1.9.10</version> --> - <scope>test</scope> - </dependency> - - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> @@ -91,6 +77,18 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> <version>${project.version}</version> <scope>provided</scope> @@ -105,6 +103,18 @@ <artifactId>org.osgi.core</artifactId> <scope>provided</scope> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <artifactId>byte-buddy</artifactId> + <groupId>net.bytebuddy</groupId> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmInventoryInput.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmInventoryInput.java index 1f6cfd658..2f48d79f7 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmInventoryInput.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmInventoryInput.java @@ -22,11 +22,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Xponder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java index 180091718..2a22e1e9d 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java @@ -33,10 +33,10 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServic import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Xponder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.Slots; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.xponder.XpdrPort; @@ -310,7 +310,8 @@ public class OpenroadmNetworkElement extends OpenroadmNetworkElementBase { } private OrgOpenroadmDevice readDevice(NetconfBindingAccessor accessor) { - InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.create(OrgOpenroadmDevice.class); + final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; + InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); return accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, deviceId); } diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElementFactory.java index 552058fd8..04b6b2ae1 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElementFactory.java @@ -28,7 +28,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/yang/org-openroadm-device.yang b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/yang/org-openroadm-device.yang index 5e690f5a5..281e94bdb 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/yang/org-openroadm-device.yang +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/yang/org-openroadm-device.yang @@ -1851,7 +1851,7 @@ module org-openroadm-device { "Mux group grouping"; } - grouping org-openroadm-device-container { + // grouping org-openroadm-device-container { container org-openroadm-device { container info { uses device-common; @@ -2286,7 +2286,7 @@ module org-openroadm-device { uses mux-grp; } } - } + // } grouping common-session-parms { description @@ -2604,5 +2604,5 @@ module org-openroadm-device { } } - uses org-openroadm-device-container; + //uses org-openroadm-device-container; } diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java index f7732c7af..fa21e77fe 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java @@ -32,6 +32,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmChangeNotificationListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.features.circuit.pack.components.Component; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; @@ -56,7 +57,7 @@ public class TestChangeNotificationListener { OpenroadmChangeNotificationListener notifListener = new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, notificationService); when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { + List<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { @Override public int compareTo(PathArgument arg0) { @@ -65,10 +66,10 @@ public class TestChangeNotificationListener { @Override public Class<? extends DataObject> getType() { - return DataObject.class; + return Component.class; } }); - InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); + InstanceIdentifier<?> target = InstanceIdentifier.unsafeOf(pathArguments); notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create, target)); EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java index 6188cc5e6..f9b5b514d 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java @@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTe import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotificationBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.Edit; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.EditBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.features.circuit.pack.components.Component; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; @@ -65,7 +66,7 @@ public class TestOpenRoadmDeviceChangeNotification { public void testOnChangeNotification() { when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { + List<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { @Override public int compareTo(PathArgument arg0) { @@ -74,10 +75,10 @@ public class TestOpenRoadmDeviceChangeNotification { @Override public Class<? extends DataObject> getType() { - return DataObject.class; + return Component.class; } }); - InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); + InstanceIdentifier<?> target = InstanceIdentifier.unsafeOf(pathArguments); deviceChangeListener.onChangeNotification(createNotification(EditOperationType.Create, target)); EventlogEntity event = diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java index 2b2b2c618..7a03aa385 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java @@ -32,12 +32,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev1911 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.InfoBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Xponder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java index 9ef0f6474..a018df739 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java @@ -50,16 +50,16 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev1911 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.ParentCircuitPack; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacksKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.XponderKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.InfoBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.XponderKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.Slots; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.SlotsKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java index a35c5f0ae..5e71fac44 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java @@ -37,7 +37,7 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAcc import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java index 3a0781e8f..49585acb2 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java @@ -40,6 +40,7 @@ import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Direction; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Location; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.features.circuit.pack.components.Component; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.HistoricalPmList; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPm; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmBuilder; @@ -142,10 +143,10 @@ public class TestOpenRoadmPMDataBuilder { @Override public @NonNull Class<? extends DataObject> getType() { // TODO Auto-generated method stub - return Pmdata15mEntity.class; + return Component.class; } }; - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.unsafeOf(Arrays.asList(pa))) .setPmResourceTypeExtension("dshjdekjdewkk") .setPmResourceType(ResourceTypeEnum.CircuitPack).setHistoricalPm(historicalPMCollection); @@ -179,11 +180,11 @@ public class TestOpenRoadmPMDataBuilder { @Override public Class<? extends DataObject> getType() { // TODO Auto-generated method stub - return Pmdata15mEntity.class; + return Component.class; } }; historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.unsafeOf(Arrays.asList(pa))) .setPmResourceTypeExtension("dshjdekjdewkk") .setPmResourceType(ResourceTypeEnum.Device).setHistoricalPm(historicalPMCollection); diff --git a/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml b/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml index 10b129b0d..d61cb28d6 100644 --- a/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml +++ b/sdnr/wt/featureaggregator/feature-devicemanager-base/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -75,13 +76,13 @@ <type>xml</type> <classifier>features</classifier> </dependency> - <dependency> + <!-- <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-mountpoint-registrar-feature</artifactId> <version>${project.version}</version> <type>xml</type> <classifier>features</classifier> - </dependency> + </dependency> --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-mountpoint-state-provider-feature</artifactId> diff --git a/sdnr/wt/featureaggregator/feature-devicemanager/pom.xml b/sdnr/wt/featureaggregator/feature-devicemanager/pom.xml index 063aae23e..155cf1423 100644 --- a/sdnr/wt/featureaggregator/feature-devicemanager/pom.xml +++ b/sdnr/wt/featureaggregator/feature-devicemanager/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/featureaggregator/feature-oauth/pom.xml b/sdnr/wt/featureaggregator/feature-oauth/pom.xml index f33ad4eef..2137872d8 100644 --- a/sdnr/wt/featureaggregator/feature-oauth/pom.xml +++ b/sdnr/wt/featureaggregator/feature-oauth/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/featureaggregator/feature/pom.xml b/sdnr/wt/featureaggregator/feature/pom.xml index 164f0733d..b5398a5ef 100644 --- a/sdnr/wt/featureaggregator/feature/pom.xml +++ b/sdnr/wt/featureaggregator/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -76,13 +77,13 @@ <type>xml</type> <classifier>features</classifier> </dependency> - <dependency> + <!-- <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-mountpoint-registrar-feature</artifactId> <version>${project.version}</version> <type>xml</type> <classifier>features</classifier> - </dependency> + </dependency>--> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-mountpoint-state-provider-feature</artifactId> diff --git a/sdnr/wt/featureaggregator/installer/pom.xml b/sdnr/wt/featureaggregator/installer/pom.xml index aed60f7e7..a6ce80825 100755 --- a/sdnr/wt/featureaggregator/installer/pom.xml +++ b/sdnr/wt/featureaggregator/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/featureaggregator/pom.xml b/sdnr/wt/featureaggregator/pom.xml index b467f8c6e..7ea89d0c5 100755 --- a/sdnr/wt/featureaggregator/pom.xml +++ b/sdnr/wt/featureaggregator/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -41,6 +42,7 @@ <modules> <module>feature</module> +<!-- <module>feature-minimal</module> --> <module>feature-oauth</module> <module>feature-devicemanager</module> <module>feature-devicemanager-base</module> diff --git a/sdnr/wt/helpserver/feature/pom.xml b/sdnr/wt/helpserver/feature/pom.xml index cdfda4e29..4dc7fd85f 100644 --- a/sdnr/wt/helpserver/feature/pom.xml +++ b/sdnr/wt/helpserver/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/helpserver/installer/pom.xml b/sdnr/wt/helpserver/installer/pom.xml index 81e9e5f97..bff0ed975 100755 --- a/sdnr/wt/helpserver/installer/pom.xml +++ b/sdnr/wt/helpserver/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/helpserver/pom.xml b/sdnr/wt/helpserver/pom.xml index 40a47a6f4..37c14aa3d 100755 --- a/sdnr/wt/helpserver/pom.xml +++ b/sdnr/wt/helpserver/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/helpserver/provider/pom.xml b/sdnr/wt/helpserver/provider/pom.xml index 7a33bea01..a961d52d7 100644 --- a/sdnr/wt/helpserver/provider/pom.xml +++ b/sdnr/wt/helpserver/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -52,6 +53,7 @@ <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> diff --git a/sdnr/wt/mountpoint-registrar/feature/pom.xml b/sdnr/wt/mountpoint-registrar/feature/pom.xml index f8a9d1ad1..d6a36a2e7 100644 --- a/sdnr/wt/mountpoint-registrar/feature/pom.xml +++ b/sdnr/wt/mountpoint-registrar/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-registrar/installer/pom.xml b/sdnr/wt/mountpoint-registrar/installer/pom.xml index 6cc83af31..66673a2d8 100755 --- a/sdnr/wt/mountpoint-registrar/installer/pom.xml +++ b/sdnr/wt/mountpoint-registrar/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-registrar/model/pom.xml b/sdnr/wt/mountpoint-registrar/model/pom.xml index 71dab843b..d83d93437 100644 --- a/sdnr/wt/mountpoint-registrar/model/pom.xml +++ b/sdnr/wt/mountpoint-registrar/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-registrar/pom.xml b/sdnr/wt/mountpoint-registrar/pom.xml index ab9c87b26..dfe93c053 100755 --- a/sdnr/wt/mountpoint-registrar/pom.xml +++ b/sdnr/wt/mountpoint-registrar/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-registrar/provider/pom.xml b/sdnr/wt/mountpoint-registrar/provider/pom.xml index 8aea0b012..dc75bb30d 100644 --- a/sdnr/wt/mountpoint-registrar/provider/pom.xml +++ b/sdnr/wt/mountpoint-registrar/provider/pom.xml @@ -22,14 +22,15 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> - <relativePath/> + <version>2.4.1-SNAPSHOT</version> + <relativePath /> </parent> <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> @@ -52,13 +53,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-mountpoint-registrar-model</artifactId> @@ -71,6 +65,18 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-devicemanager-core-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <scope>provided</scope> @@ -105,17 +111,18 @@ <artifactId>dmaapClient</artifactId> </dependency> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-data-provider-model</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- begin for testing --> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>sdnr-wt-devicemanager-core-model</artifactId> - <version>${project.version}</version> - <scope>provided</scope> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> </dependency> + <!-- end for testing --> + </dependencies> <build> diff --git a/sdnr/wt/mountpoint-state-provider/feature/pom.xml b/sdnr/wt/mountpoint-state-provider/feature/pom.xml index 346b2fafd..e2922a389 100644 --- a/sdnr/wt/mountpoint-state-provider/feature/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-state-provider/installer/pom.xml b/sdnr/wt/mountpoint-state-provider/installer/pom.xml index 117028955..2b8367c8b 100755 --- a/sdnr/wt/mountpoint-state-provider/installer/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-state-provider/pom.xml b/sdnr/wt/mountpoint-state-provider/pom.xml index 2af5f9dfc..5473bb893 100755 --- a/sdnr/wt/mountpoint-state-provider/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/mountpoint-state-provider/provider/pom.xml b/sdnr/wt/mountpoint-state-provider/provider/pom.xml index 9bc1530b3..5094f4954 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -52,13 +53,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-common</artifactId> @@ -75,6 +69,7 @@ <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> @@ -105,7 +100,37 @@ <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <scope>provided</scope> </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <!-- <version>3.4.2</version> --> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-websocketmanager-model</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESCommonEventHeaderPOJO.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESCommonEventHeaderPOJO.java deleted file mode 100644 index 7b15ae152..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESCommonEventHeaderPOJO.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * 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. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonPropertyOrder({"domain", "eventId", "eventName", "eventType", "lastEpochMicrosec", "nfcNamingCode", "nfNamingCode", "nfVendorName", "priority", "reportingEntityId", - "reportingEntityName", "sequence", "sourceId", "sourceName", "startEpochMicrosec", "timeZoneOffset", "version", "vesEventListenerVersion"}) -public class VESCommonEventHeaderPOJO { - - private String domain = ""; - private String eventId = ""; - private String eventName = ""; - private String eventType = ""; - private long sequence = 0L; - private String priority = ""; - @JsonIgnore - private String reportingEntityId = ""; - private String reportingEntityName = ""; - private String sourceId = ""; - private String sourceName = ""; - private long startEpochMicrosec = 0L; - private long lastEpochMicrosec = 0L; - private String nfcNamingCode = ""; - private String nfNamingCode = ""; - private String nfVendorName = ""; - private String timeZoneOffset = "+00:00"; - private String version = "4.1"; - private String vesEventListenerVersion = "7.1.1"; - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getEventId() { - return eventId; - } - - public void setEventId(String eventId) { - this.eventId = eventId; - } - - public String getEventName() { - return eventName; - } - - public void setEventName(String eventName) { - this.eventName = eventName; - } - - public String getEventType() { - return eventType; - } - - public void setEventType(String eventType) { - this.eventType = eventType; - } - - public Long getSequence() { - return sequence; - } - - public void setSequence(long sequenceNo) { - this.sequence = sequenceNo; - } - - public String getPriority() { - return priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public String getReportingEntityId() { - return reportingEntityId; - } - - public void setReportingEntityId(String reportingEntityId) { - this.reportingEntityId = reportingEntityId; - } - - public String getReportingEntityName() { - return reportingEntityName; - } - - public void setReportingEntityName(String reportingEntityName) { - this.reportingEntityName = reportingEntityName; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String getSourceName() { - return sourceName; - } - - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - public long getStartEpochMicrosec() { - return startEpochMicrosec; - } - - public void setStartEpochMicrosec(long startEpochMicrosec) { - this.startEpochMicrosec = startEpochMicrosec; - } - - public long getLastEpochMicrosec() { - return lastEpochMicrosec; - } - - public void setLastEpochMicrosec(long lastEpochMicrosec) { - this.lastEpochMicrosec = lastEpochMicrosec; - } - - public String getNfcNamingCode() { - return nfcNamingCode; - } - - public void setNfcNamingCode(String nfcNamingCode) { - this.nfcNamingCode = nfcNamingCode; - } - - public String getNfNamingCode() { - return nfNamingCode; - } - - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - - public String getNfVendorName() { - return nfVendorName; - } - - public void setNfVendorName(String nfVendorName) { - this.nfVendorName = nfVendorName; - } - - public String getTimeZoneOffset() { - return timeZoneOffset; - } - - public void setTimeZoneOffset(String timeZoneOffset) { - this.timeZoneOffset = timeZoneOffset; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getVesEventListenerVersion() { - return vesEventListenerVersion; - } - - public void setVesEventListenerVersion(String vesEventListenerVersion) { - this.vesEventListenerVersion = vesEventListenerVersion; - } -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java deleted file mode 100644 index 7989166f6..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * 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. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; - -import java.util.HashMap; -import java.util.Map; - -public class VESEvent { - private Map<String, Object> event = new HashMap<>(); - - public void addEventObjects(Object eventObject) { - if (eventObject instanceof VESCommonEventHeaderPOJO) - event.put("commonEventHeader", eventObject); - else if (eventObject instanceof VESNotificationFieldsPOJO) - event.put("notificationFields", eventObject); - - } - - public Map<String, Object> getEvent() { - return event; - } -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java deleted file mode 100644 index 1d2c2dcb5..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * 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. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@JsonPropertyOrder({"arrayOfNamedHashMap", "changeContact", "changeIdentifier", "changeType", "newState", "oldState", "notificationFieldsVersion"}) -public class VESNotificationFieldsPOJO { - - private List<HashMap<String, Object>> arrayOfNamedHashMap = new ArrayList<>(); - @JsonIgnore - private Map<String, Object> namedHashMap = new HashMap<>(); - @JsonIgnore - private Map<String, String> hashMap = new HashMap<>(); - @JsonIgnore - private String changeContact = ""; - private String changeIdentifier = ""; - private String changeType = ""; - //@JsonIgnore - private String newState = ""; - @JsonIgnore - private String oldState = ""; - @JsonIgnore - private String stateInterface = ""; - private String notificationFieldsVersion = "2.0"; - - public List<HashMap<String, Object>> getArrayOfNamedHashMap() { - return arrayOfNamedHashMap; - } - - public void setArrayOfNamedHashMap(List<HashMap<String, Object>> arrayOfNamedHashMap) { - this.arrayOfNamedHashMap = arrayOfNamedHashMap; - } - - public String getChangeContact() { - return changeContact; - } - - public void setChangeContact(String changeContact) { - this.changeContact = changeContact; - } - - public String getChangeIdentifier() { - return changeIdentifier; - } - - public void setChangeIdentifier(String changeIdentifier) { - this.changeIdentifier = changeIdentifier; - } - - public String getChangeType() { - return changeType; - } - - public void setChangeType(String changeType) { - this.changeType = changeType; - } - - public String getNewState() { - return newState; - } - - public void setNewState(String newState) { - this.newState = newState; - } - - public String getOldState() { - return oldState; - } - - public void setOldState(String oldState) { - this.oldState = oldState; - } - - public String getStateInterface() { - return stateInterface; - } - - public void setStateInterface(String stateInterface) { - this.stateInterface = stateInterface; - } - - public String getNotificationFieldsVersion() { - return notificationFieldsVersion; - } - - public void setNotificationFieldsVersion(String notificationFieldsVersion) { - this.notificationFieldsVersion = notificationFieldsVersion; - } -} diff --git a/sdnr/wt/netconfnode-state-service/feature/pom.xml b/sdnr/wt/netconfnode-state-service/feature/pom.xml index b972d7407..07e69cf5b 100644 --- a/sdnr/wt/netconfnode-state-service/feature/pom.xml +++ b/sdnr/wt/netconfnode-state-service/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/netconfnode-state-service/installer/pom.xml b/sdnr/wt/netconfnode-state-service/installer/pom.xml index 90a15232d..2b6bdc6f8 100755 --- a/sdnr/wt/netconfnode-state-service/installer/pom.xml +++ b/sdnr/wt/netconfnode-state-service/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/netconfnode-state-service/model/pom.xml b/sdnr/wt/netconfnode-state-service/model/pom.xml index 8f15f3e24..e1b2a42cf 100644 --- a/sdnr/wt/netconfnode-state-service/model/pom.xml +++ b/sdnr/wt/netconfnode-state-service/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -64,6 +65,12 @@ <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-data-provider-model</artifactId> <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> </dependency> </dependencies> diff --git a/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java b/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java new file mode 100644 index 000000000..0471460a8 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java @@ -0,0 +1,93 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilitiesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapability; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapabilityBuilder; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.Revision; + +public class TestCapabilities { + + @Test + public void testavailableCapabilities() { + + NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setAvailableCapabilities(getAvailableCapabilities()); + Capabilities avcapabilities = Capabilities.getAvailableCapabilities(nnodeBuilder.build()); + + assertTrue(avcapabilities != null); + + } + + @Test + public void testunavailableCapabilities() { + + List<UnavailableCapability> ucapList = + Arrays.asList(new UnavailableCapabilityBuilder().setCapability("(test-unavailable-capability?revision=2022-11-03)test").build()); + UnavailableCapabilitiesBuilder ucb = new UnavailableCapabilitiesBuilder().setUnavailableCapability(ucapList); + + NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setUnavailableCapabilities(ucb.build()); + Capabilities uavcapabilities = Capabilities.getUnavailableCapabilities(nnodeBuilder.build()); + assert (uavcapabilities != null); + + } + + @Test + public void testNameSpaceRevision() { + QName qname = QName.create("test-capability", "test", Revision.of("2022-11-03")); + NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setAvailableCapabilities(getAvailableCapabilities()); + Capabilities avcapabilities = Capabilities.getAvailableCapabilities(nnodeBuilder.build()); + + NetconfAccessor accessor = mock(NetconfAccessor.class); + when(accessor.getCapabilites()).thenReturn(avcapabilities); + assertEquals("2022-11-03", accessor.getCapabilites().getRevisionForNamespace(qname)); + assertEquals("test-capability?2022-11-03", Capabilities.getNamespaceAndRevisionAsString(qname)); + assertTrue(accessor.getCapabilites().isSupportingNamespace(qname)); + assertTrue(accessor.getCapabilites().isSupportingNamespace("test-capability")); + assertTrue(accessor.getCapabilites().isSupportingNamespaceAndRevision(qname)); + + } + + private AvailableCapabilities getAvailableCapabilities() { + + List<AvailableCapability> acapList = + Arrays.asList(new AvailableCapabilityBuilder().setCapability("(test-capability?revision=2022-11-03)test").build()); + AvailableCapabilitiesBuilder acb = new AvailableCapabilitiesBuilder().setAvailableCapability(acapList); + return acb.build(); + + } +} diff --git a/sdnr/wt/netconfnode-state-service/pom.xml b/sdnr/wt/netconfnode-state-service/pom.xml index bdc018cfe..04add46ae 100755 --- a/sdnr/wt/netconfnode-state-service/pom.xml +++ b/sdnr/wt/netconfnode-state-service/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/netconfnode-state-service/provider/pom.xml b/sdnr/wt/netconfnode-state-service/provider/pom.xml index 927c709d0..fe374bea8 100644 --- a/sdnr/wt/netconfnode-state-service/provider/pom.xml +++ b/sdnr/wt/netconfnode-state-service/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -87,6 +88,11 @@ <groupId>org.opendaylight.mdsal</groupId> <artifactId>mdsal-singleton-common-api</artifactId> <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> </dependency> <!-- md-sal --> <dependency> @@ -105,11 +111,23 @@ <artifactId>config</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <scope>provided</scope> + </dependency> <!-- wt --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-common</artifactId> <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>${project.groupId}</groupId> diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java index 8605274db..988dbd257 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java @@ -18,18 +18,16 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl; import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import javax.annotation.Nullable; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; +import org.onap.ccsdk.features.sdnr.wt.common.threading.GenericRunnableFactory; +import org.onap.ccsdk.features.sdnr.wt.common.threading.KeyBasedThreadpool; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; @@ -76,7 +74,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.parser.api.YangParserException; import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -102,6 +99,7 @@ public class NetconfNodeStateServiceImpl // Name of ODL controller NETCONF instance private static final NodeId CONTROLLER = new NodeId("controller-config"); + private static final int ASYNC_EXECUTION_POOLSIZE = 20; // -- OSGi services, provided private DataBroker dataBroker; @@ -147,7 +145,8 @@ public class NetconfNodeStateServiceImpl private String clusterName; /** nodeId to threadPool (size=1) for datatreechange handling) **/ - private final Map<String, ExecutorService> handlingPool; + // private final Map<String, ExecutorService> handlingPool; + private KeyBasedThreadpool<NodeId, NetconfChangeDataHolder> handlingPool; private boolean handleDataTreeAsync; @@ -177,10 +176,8 @@ public class NetconfNodeStateServiceImpl this.netconfNodeStateListenerList = new CopyOnWriteArrayList<>(); this.vesNotificationListenerList = new CopyOnWriteArrayList<>(); this.accessorManager = null; - this.handlingPool = new HashMap<>(); - + this.handlingPool = null; } - public void setDataBroker(DataBroker dataBroker) { this.dataBroker = dataBroker; } @@ -221,13 +218,17 @@ public class NetconfNodeStateServiceImpl this.bindingNormalizedNodeSerializer = bindingNormalizedNodeSerializer; } - /** Blueprint initialization - * @throws YangParserException **/ + /** + * Blueprint initialization + * + * @throws YangParserException + **/ public void init() { LOG.info("Session Initiated start {}", APPLICATION_NAME); this.domContext = new DomContext(this.yangParserFactory, this.bindingNormalizedNodeSerializer); - this.netconfCommunicatorManager = new NetconfCommunicatorManager(mountPointService, domMountPointService, domContext); + this.netconfCommunicatorManager = + new NetconfCommunicatorManager(mountPointService, domMountPointService, domContext); this.accessorManager = new NetconfAccessorManager(netconfCommunicatorManager, domContext, this); // Start RPC Service this.rpcApiService = new NetconfnodeStateServiceRpcApiImpl(rpcProviderRegistry, vesNotificationListenerList); @@ -257,7 +258,19 @@ public class NetconfNodeStateServiceImpl listenerL1 = dataBroker.registerDataTreeChangeListener(NETCONF_NODE_TOPO_TREE_ID, new L1()); listenerL2 = dataBroker.registerDataTreeChangeListener(NETCONF_NODE_TOPO_TREE_ID, new L2()); - + this.handlingPool = new KeyBasedThreadpool<NodeId, NetconfChangeDataHolder>(this.config.getAsyncHandlingPoolsize(), 1, + new GenericRunnableFactory<>() { + public Runnable create(final NodeId key, final NetconfChangeDataHolder arg) { + return new Runnable() { + + @Override + public void run() { + NetconfNodeStateServiceImpl.this.handleDataTreeChange(arg.root, key, + arg.modificationTyp); + } + }; + }; + }); this.initializationSuccessful = true; LOG.info("Session Initiated end. Initialization done {}", initializationSuccessful); @@ -270,7 +283,7 @@ public class NetconfNodeStateServiceImpl } public DomContext getDomContext() { - return Objects.requireNonNull(domContext, "Initialization not completed for domContext" ); + return Objects.requireNonNull(domContext, "Initialization not completed for domContext"); } public DataBroker getDataBroker() { @@ -282,7 +295,7 @@ public class NetconfNodeStateServiceImpl } public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() { - return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService" ); + return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService"); } @Override @@ -418,19 +431,19 @@ public class NetconfNodeStateServiceImpl LOG.info("isNetconfNodeMaster indication {} for mountpoint {}", isNetconfNodeMaster, mountPointNodeName); if (isNetconfNodeMaster) { NetconfAccessor acessor = accessorManager.getAccessor(nNodeId, netconfNode); - /* - * --> Call Listers for onConnect() Indication - for (all) - */ - netconfNodeConnectListenerList.forEach(item -> { - try { - item.onEnterConnected(acessor); - } catch (Exception e) { - LOG.info("Exception during onEnterConnected listener call", e); - } - }); + /* + * --> Call Listers for onConnect() Indication + for (all) + */ + netconfNodeConnectListenerList.forEach(item -> { + try { + item.onEnterConnected(acessor); + } catch (Exception e) { + LOG.info("Exception during onEnterConnected listener call", e); + } + }); - LOG.info("Connect indication forwarded for {}", mountPointNodeName); + LOG.info("Connect indication forwarded for {}", mountPointNodeName); } } @@ -565,18 +578,9 @@ public class NetconfNodeStateServiceImpl if (modificationTyp == null) { LOG.warn("L1 empty modification type"); } else { + LOG.trace("handle data tree change with async={}",this.handleDataTreeAsync); if (this.handleDataTreeAsync) { - ExecutorService executor = this.handlingPool.getOrDefault(nodeId.getValue(), null); - if (executor == null) { - executor = Executors.newFixedThreadPool(5); - this.handlingPool.put(nodeId.getValue(), executor); - } - executor.execute(new Thread() { - @Override - public void run() { - handleDataTreeChange(root, nodeId, modificationTyp); - } - }); + this.handlingPool.execute(nodeId, new NetconfChangeDataHolder(root, modificationTyp)); } else { handleDataTreeChange(root, nodeId, modificationTyp); @@ -683,7 +687,20 @@ public class NetconfNodeStateServiceImpl @Override public void onConfigChanged() { this.handleDataTreeAsync = this.config.handleAsync(); + //setting poolsize is not possible atm + //this.handlingPool.setPoolSize(this.config.getAsyncHandlingPoolsize()); } + public class NetconfChangeDataHolder { + + protected final DataObjectModification<Node> root; + protected final ModificationType modificationTyp; + + public NetconfChangeDataHolder(DataObjectModification<Node> root, ModificationType modificationTyp) { + this.root = root; + this.modificationTyp = modificationTyp; + } + + } } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/NetconfStateConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/NetconfStateConfig.java index af095372d..c781575a3 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/NetconfStateConfig.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/NetconfStateConfig.java @@ -21,6 +21,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf; +import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.slf4j.Logger; @@ -34,9 +35,11 @@ public class NetconfStateConfig implements Configuration { public static final String SECTION_MARKER_NCSTATE = "netconfstate"; private static final String PROPERTY_KEY_HANDLEASYNC = "asynchandling"; - - private static final Object DEFAULT_VALUE_TRUSTALLCERTS = false; - + private static final String PROPERTY_KEY_POOLSIZE= "poolsize"; + private static final String DEFAULT_HANDLEASYNC = "${SDNR_ASYNC_HANDLING}"; + private static final String DEFAULT_POOLSIZE = "${SDNR_ASYNC_POOLSIZE}"; + private static final boolean DEFAULT_HANDLEASYNC_IFNOTSET = false; + private static final int DEFAULT_POOLSIZE_IFNOTSET = 20; private final ConfigurationFileRepresentation configuration; @@ -50,7 +53,18 @@ public class NetconfStateConfig implements Configuration { public boolean handleAsync() { - return configuration.getPropertyBoolean(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC); + final String s = this.configuration.getProperty(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC); + if(s!= null && !s.isBlank()) { + return "true".equals(s); + } + return DEFAULT_HANDLEASYNC_IFNOTSET; + } + public int getAsyncHandlingPoolsize() { + Optional<Long> optional = this.configuration.getPropertyLong(SECTION_MARKER_NCSTATE,PROPERTY_KEY_POOLSIZE); + if(optional.isPresent()) { + return optional.get().intValue(); + } + return DEFAULT_POOLSIZE_IFNOTSET; } @Override @@ -62,7 +76,9 @@ public class NetconfStateConfig implements Configuration { public synchronized void defaults() { // Add default if not available configuration.setPropertyIfNotAvailable(SECTION_MARKER_NCSTATE, PROPERTY_KEY_HANDLEASYNC, - DEFAULT_VALUE_TRUSTALLCERTS); + DEFAULT_HANDLEASYNC); + configuration.setPropertyIfNotAvailable(SECTION_MARKER_NCSTATE, PROPERTY_KEY_POOLSIZE, + DEFAULT_POOLSIZE); } } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java index 896f010d8..818f8a370 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java @@ -30,7 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfn import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushFaultNotificationInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushFaultNotificationOutput; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -83,7 +83,7 @@ public class NetconfnodeStateServiceRpcApiImpl implements NetconfnodeStateServic try { GetStatusOutputBuilder outputBuilder = new GetStatusOutputBuilder(); getStatusCallback.getStatus(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestConfig.java new file mode 100644 index 000000000..d66508f1b --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestConfig.java @@ -0,0 +1,66 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test; + +import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.NetconfStateConfig; + +public class TestConfig { + + private static final String FILENAME="test.config"; + @BeforeClass + @AfterClass + public static void clearFiles(){ + try { + Files.deleteIfExists(new File(FILENAME).toPath()); + } catch (IOException e) { + + } + } + @Test + public void test() { + + ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(FILENAME); + NetconfStateConfig config = new NetconfStateConfig(cfg); + + Section.setEnvGetter(new EnvGetter() { + + @Override + public String getenv(String env) { + if("SDNR_ASYNC_HANDLING".equals(env)) { + return "true"; + } + return null; + } + }); + assertTrue(config.handleAsync()); + } +} diff --git a/sdnr/wt/oauth-provider/pom.xml b/sdnr/wt/oauth-provider/pom.xml index faba3bee9..b6d86cdba 100755 --- a/sdnr/wt/oauth-provider/pom.xml +++ b/sdnr/wt/oauth-provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/oauth-provider/provider-jar/pom.xml b/sdnr/wt/oauth-provider/provider-jar/pom.xml index 974e4330e..0657cb541 100644 --- a/sdnr/wt/oauth-provider/provider-jar/pom.xml +++ b/sdnr/wt/oauth-provider/provider-jar/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OAuthProviderConfig.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OAuthProviderConfig.java index 11e13e226..4fb0d0069 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OAuthProviderConfig.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OAuthProviderConfig.java @@ -36,6 +36,8 @@ public class OAuthProviderConfig { private String title; private String scope; private String realmName; + private String openIdConfigUrl; + private boolean trustAll; private OAuthProvider type; private Map<String, String> roleMapping; @@ -45,7 +47,7 @@ public class OAuthProviderConfig { } public OAuthProviderConfig(String id, String url, String internalUrl, String clientId, String secret, String scope, - String title, String realmName, boolean trustAll) { + String title, String realmName, String openIdConfigUrl, boolean trustAll) { this.id = id; this.url = url; this.internalUrl = internalUrl; @@ -55,6 +57,7 @@ public class OAuthProviderConfig { this.title = title; this.realmName = realmName; this.trustAll = trustAll; + this.openIdConfigUrl = openIdConfigUrl; this.roleMapping = new HashMap<>(); } @@ -70,7 +73,7 @@ public class OAuthProviderConfig { } public OAuthProviderConfig() { - this(null, null, null, null, null, null, null, null, false); + this(null, null, null, null, null, null, null, null, null, false); } public void setUrl(String url) { @@ -153,6 +156,9 @@ public class OAuthProviderConfig { this.internalUrl = internalUrl; } + public void setOpenIdConfigUrl(String openIdConfigUrl){ this.openIdConfigUrl = openIdConfigUrl;} + + public String getOpenIdConfigUrl() { return this.openIdConfigUrl;} @JsonIgnore public void handleEnvironmentVars() { if (Config.isEnvExpression(this.id)) { @@ -179,6 +185,9 @@ public class OAuthProviderConfig { if (Config.isEnvExpression(this.realmName)) { this.realmName = Config.getProperty(this.realmName, null); } + if (Config.isEnvExpression(this.openIdConfigUrl)) { + this.openIdConfigUrl = Config.getProperty(this.openIdConfigUrl, null); + } } @JsonIgnore @@ -186,4 +195,8 @@ public class OAuthProviderConfig { return this.internalUrl != null && this.internalUrl.length() > 0 ? this.internalUrl : this.url; } + @JsonIgnore + public boolean hasToBeConfigured(){ + return this.openIdConfigUrl!=null && this.openIdConfigUrl.length()>0; + } } diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OpenIdConfigResponseData.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OpenIdConfigResponseData.java new file mode 100644 index 000000000..2af46b6b4 --- /dev/null +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/OpenIdConfigResponseData.java @@ -0,0 +1,54 @@ +package org.onap.ccsdk.features.sdnr.wt.oauthprovider.data; + +public class OpenIdConfigResponseData { + + private String issuer; + private String authorization_endpoint; + private String token_endpoint; + private String userinfo_endpoint; + private String jwks_uri; + + public OpenIdConfigResponseData(){ + + } + + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + public String getAuthorization_endpoint() { + return authorization_endpoint; + } + + public void setAuthorization_endpoint(String authorization_endpoint) { + this.authorization_endpoint = authorization_endpoint; + } + + public String getToken_endpoint() { + return token_endpoint; + } + + public void setToken_endpoint(String token_endpoint) { + this.token_endpoint = token_endpoint; + } + + public String getUserinfo_endpoint() { + return userinfo_endpoint; + } + + public void setUserinfo_endpoint(String userinfo_endpoint) { + this.userinfo_endpoint = userinfo_endpoint; + } + + public String getJwks_uri() { + return jwks_uri; + } + + public void setJwks_uri(String jwks_uri) { + this.jwks_uri = jwks_uri; + } +} diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/UnableToConfigureOAuthService.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/UnableToConfigureOAuthService.java new file mode 100644 index 000000000..b791a4040 --- /dev/null +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/data/UnableToConfigureOAuthService.java @@ -0,0 +1,12 @@ +package org.onap.ccsdk.features.sdnr.wt.oauthprovider.data; + +public class UnableToConfigureOAuthService extends Exception { + + public UnableToConfigureOAuthService(String configUrl){ + super(String.format("Unable to configure OAuth service from url %s", configUrl)); + } + public UnableToConfigureOAuthService(String configUrl, int responseCode){ + super(String.format("Unable to configure OAuth service from url %s. bad response with code %d", configUrl, responseCode)); + } + +} diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/filters/CustomizedMDSALDynamicAuthorizationFilter.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/filters/CustomizedMDSALDynamicAuthorizationFilter.java new file mode 100644 index 000000000..80d9d1bb6 --- /dev/null +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/filters/CustomizedMDSALDynamicAuthorizationFilter.java @@ -0,0 +1,155 @@ +package org.onap.ccsdk.features.sdnr.wt.oauthprovider.filters; + +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + +import com.google.common.collect.Iterables; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +import java.util.*; +import java.util.concurrent.ExecutionException; +import javax.servlet.Filter; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.web.filter.authz.AuthorizationFilter; +import org.opendaylight.aaa.shiro.web.env.ThreadLocals; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.HttpAuthorization; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.authorization.policies.Policies; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.permission.Permissions; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("checkstyle:AbbreviationAsWordInName") +public class CustomizedMDSALDynamicAuthorizationFilter extends AuthorizationFilter + implements ClusteredDataTreeChangeListener<HttpAuthorization> { + + private static final Logger LOG = LoggerFactory.getLogger(CustomizedMDSALDynamicAuthorizationFilter.class); + + private static final DataTreeIdentifier<HttpAuthorization> AUTHZ_CONTAINER = DataTreeIdentifier.create( + LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(HttpAuthorization.class)); + + private final DataBroker dataBroker; + + private ListenerRegistration<?> reg; + private volatile ListenableFuture<Optional<HttpAuthorization>> authContainer; + + public CustomizedMDSALDynamicAuthorizationFilter() { + dataBroker = requireNonNull(ThreadLocals.DATABROKER_TL.get()); + } + + @Override + public Filter processPathConfig(final String path, final String config) { + try (ReadTransaction tx = dataBroker.newReadOnlyTransaction()) { + authContainer = tx.read(AUTHZ_CONTAINER.getDatastoreType(), AUTHZ_CONTAINER.getRootIdentifier()); + } + this.reg = dataBroker.registerDataTreeChangeListener(AUTHZ_CONTAINER, this); + return super.processPathConfig(path, config); + } + + @Override + public void destroy() { + if (reg != null) { + reg.close(); + reg = null; + } + super.destroy(); + } + + @Override + public void onDataTreeChanged(final Collection<DataTreeModification<HttpAuthorization>> changes) { + final HttpAuthorization newVal = Iterables.getLast(changes).getRootNode().getDataAfter(); + LOG.debug("Updating authorization information to {}", newVal); + authContainer = Futures.immediateFuture(Optional.ofNullable(newVal)); + } + + @Override + public boolean isAccessAllowed(final ServletRequest request, final ServletResponse response, + final Object mappedValue) { + checkArgument(request instanceof HttpServletRequest, "Expected HttpServletRequest, received {}", request); + + final Subject subject = getSubject(request, response); + final HttpServletRequest httpServletRequest = (HttpServletRequest)request; + final String requestURI = httpServletRequest.getRequestURI(); + LOG.debug("isAccessAllowed for user={} to requestURI={}", subject, requestURI); + + final Optional<HttpAuthorization> authorizationOptional; + try { + authorizationOptional = authContainer.get(); + } catch (ExecutionException | InterruptedException e) { + // Something went completely wrong trying to read the authz container. Deny access. + LOG.warn("MDSAL attempt to read Http Authz Container failed, disallowing access", e); + return false; + } + + if (!authorizationOptional.isPresent()) { + // The authorization container does not exist-- hence no authz rules are present + // Allow access. + LOG.debug("Authorization Container does not exist"); + return true; + } + + final HttpAuthorization httpAuthorization = authorizationOptional.get(); + final var policies = httpAuthorization.getPolicies(); + List<Policies> policiesList = policies != null ? policies.getPolicies() : null; + if (policiesList == null || policiesList.isEmpty()) { + // The authorization container exists, but no rules are present. Allow access. + LOG.debug("Exiting successfully early since no authorization rules exist"); + return true; + } + + // Sort the Policies list based on index + policiesList = new ArrayList<>(policiesList); + policiesList.sort(Comparator.comparing(Policies::getIndex)); + + for (Policies policy : policiesList) { + final String resource = policy.getResource(); + final boolean pathsMatch = pathsMatch(resource, requestURI); + if (pathsMatch) { + LOG.debug("paths match for pattern={} and requestURI={}", resource, requestURI); + final String method = httpServletRequest.getMethod(); + LOG.trace("method={}", method); + List<Permissions> permissions = policy.getPermissions(); + if(permissions !=null) { + for (Permissions permission : permissions) { + final String role = permission.getRole(); + LOG.trace("role={}", role); + Set<Permissions.Actions> actions = permission.getActions(); + if (actions != null) { + for (Permissions.Actions action : actions) { + LOG.trace("action={}", action.getName()); + if (action.getName().equalsIgnoreCase(method)) { + final boolean hasRole = subject.hasRole(role); + LOG.trace("hasRole({})={}", role, hasRole); + if (hasRole) { + return true; + } + } + } + } + else{ + LOG.trace("no actions found"); + } + } + } + else { + LOG.trace("no permissions found"); + } + LOG.debug("couldn't authorize the user for access"); + return false; + } + } + LOG.debug("successfully authorized the user for access"); + return true; + } +} diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/http/AuthHttpServlet.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/http/AuthHttpServlet.java index 15ff9c480..7c88e50b0 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/http/AuthHttpServlet.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/http/AuthHttpServlet.java @@ -44,13 +44,7 @@ import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; import org.jolokia.osgi.security.Authenticator; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.Config; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.InvalidConfigurationException; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.NoDefinitionFoundException; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthToken; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OdlPolicy; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UserTokenPayload; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.*; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.AuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.AuthService.PublicOAuthProviderConfig; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.MdSalAuthorizationStore; @@ -102,7 +96,8 @@ public class AuthHttpServlet extends HttpServlet { private static ShiroConfiguration shiroConfiguration; private static MdSalAuthorizationStore mdsalAuthStore; - public AuthHttpServlet() throws IllegalArgumentException, IOException, InvalidConfigurationException { + public AuthHttpServlet() throws IllegalArgumentException, IOException, InvalidConfigurationException, + UnableToConfigureOAuthService { this.config = Config.getInstance(); this.tokenCreator = TokenCreator.getInstance(this.config); this.mapper = new ObjectMapper(); diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/AuthService.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/AuthService.java index 835ea8c09..192da6371 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/AuthService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/AuthService.java @@ -41,9 +41,8 @@ import java.util.stream.Collectors; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthResponseData; -import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UserTokenPayload; + +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.*; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.http.AuthHttpServlet; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.http.client.MappedBaseHttpResponse; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.http.client.MappingBaseHttpClient; @@ -60,6 +59,8 @@ public abstract class AuthService { protected final OAuthProviderConfig config; protected final TokenCreator tokenCreator; private final String redirectUri; + private final String tokenEndpoint; + private final String authEndpoint; protected abstract String getTokenVerifierUri(); @@ -78,13 +79,30 @@ public abstract class AuthService { protected abstract boolean verifyState(String state); - public AuthService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) { + public AuthService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) throws UnableToConfigureOAuthService { this.config = config; this.tokenCreator = tokenCreator; this.redirectUri = redirectUri; this.mapper = new ObjectMapper(); this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); this.httpClient = new MappingBaseHttpClient(this.config.getUrlOrInternal(), this.config.trustAll()); + if (this.config.hasToBeConfigured()){ + Optional<MappedBaseHttpResponse<OpenIdConfigResponseData>> oresponse = this.httpClient.sendMappedRequest( + this.config.getOpenIdConfigUrl(), "GET", null, null, OpenIdConfigResponseData.class); + if(oresponse.isEmpty()){ + throw new UnableToConfigureOAuthService(this.config.getOpenIdConfigUrl()); + } + MappedBaseHttpResponse<OpenIdConfigResponseData> response = oresponse.get(); + if(!response.isSuccess()){ + throw new UnableToConfigureOAuthService(this.config.getOpenIdConfigUrl(), response.code); + } + this.tokenEndpoint = response.body.getToken_endpoint(); + this.authEndpoint = response.body.getAuthorization_endpoint(); + } + else{ + this.tokenEndpoint = null; + this.authEndpoint = null; + } } public PublicOAuthProviderConfig getConfig() { @@ -110,7 +128,11 @@ public abstract class AuthService { public void sendLoginRedirectResponse(HttpServletResponse resp, String callbackUrl) { resp.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); - resp.setHeader("Location", this.getLoginUrl(callbackUrl)); + String url = this.authEndpoint!=null?String.format( + "%s?client_id=%s&response_type=code&scope=%s&redirect_uri=%s", + this.authEndpoint, urlEncode(this.config.getClientId()), this.config.getScope(), + urlEncode(callbackUrl)):this.getLoginUrl(callbackUrl); + resp.setHeader("Location", url); } private static void sendErrorResponse(HttpServletResponse resp, String message) throws IOException { @@ -204,8 +226,9 @@ public abstract class AuthService { body.append(String.format("%s=%s&", p.getKey(), urlEncode(p.getValue()))); } + String url = this.tokenEndpoint!=null?this.tokenEndpoint:this.getTokenVerifierUri(); Optional<MappedBaseHttpResponse<OAuthResponseData>> response = - this.httpClient.sendMappedRequest(this.getTokenVerifierUri(), "POST", + this.httpClient.sendMappedRequest(url, "POST", body.substring(0, body.length() - 1), headers, OAuthResponseData.class); if (response.isPresent() && response.get().isSuccess()) { return response.get().body; diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/GitlabProviderService.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/GitlabProviderService.java index 1111603c9..10f701ec2 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/GitlabProviderService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/GitlabProviderService.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.Config; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UserTokenPayload; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.http.client.MappedBaseHttpResponse; import org.slf4j.Logger; @@ -43,7 +44,7 @@ public class GitlabProviderService extends AuthService { private static final String API_USER_URI = "/api/v4/user"; private static final String API_GROUP_URI = "/api/v4/groups?min_access_level=10"; - public GitlabProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) { + public GitlabProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) throws UnableToConfigureOAuthService { super(config, redirectUri, tokenCreator); this.additionalTokenVerifierParams = new HashMap<>(); this.additionalTokenVerifierParams.put("grant_type", "authorization_code"); diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/KeycloakProviderService.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/KeycloakProviderService.java index dbc577664..05000199e 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/KeycloakProviderService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/KeycloakProviderService.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.stream.Collectors; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.KeycloakUserTokenPayload; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UserTokenPayload; public class KeycloakProviderService extends AuthService { @@ -36,7 +37,7 @@ public class KeycloakProviderService extends AuthService { public static final String ID = "keycloak"; private Map<String, String> additionalTokenVerifierParams; - public KeycloakProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) { + public KeycloakProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) throws UnableToConfigureOAuthService { super(config, redirectUri, tokenCreator); this.additionalTokenVerifierParams = new HashMap<>(); this.additionalTokenVerifierParams.put("grant_type", "authorization_code"); diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/MdSalAuthorizationStore.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/MdSalAuthorizationStore.java index ca7f47138..4bf35e72d 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/MdSalAuthorizationStore.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/MdSalAuthorizationStore.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.concurrent.ExecutionException; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OdlPolicy; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OdlPolicy.PolicyMethods; @@ -85,7 +86,7 @@ public class MdSalAuthorizationStore { return Optional.of(mapPolicy(path, rolePm.get().getActions())); } - private OdlPolicy mapPolicy(String path, List<Actions> actions) { + private OdlPolicy mapPolicy(String path, Set<Actions> actions) { PolicyMethods methods = new PolicyMethods(); String action; for (Actions a : actions) { diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/NextcloudProviderService.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/NextcloudProviderService.java index b6f045cdd..336de5600 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/NextcloudProviderService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/NextcloudProviderService.java @@ -25,11 +25,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import java.util.Map; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UserTokenPayload; public class NextcloudProviderService extends AuthService { - public NextcloudProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) { + public NextcloudProviderService(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) throws UnableToConfigureOAuthService { super(config, redirectUri, tokenCreator); // TODO Auto-generated constructor stub } diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/OAuthProviderFactory.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/OAuthProviderFactory.java index 193e7a7f7..152569930 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/OAuthProviderFactory.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/OAuthProviderFactory.java @@ -22,12 +22,13 @@ package org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; public class OAuthProviderFactory { public static AuthService create(OAuthProvider key, OAuthProviderConfig config, String redirectUri, - TokenCreator tokenCreator) { + TokenCreator tokenCreator) throws UnableToConfigureOAuthService { switch (key) { case KEYCLOAK: return new KeycloakProviderService(config, redirectUri, tokenCreator); diff --git a/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestGitlabAuthService.java b/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestGitlabAuthService.java index dda3ba1e0..6c2390ea0 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestGitlabAuthService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestGitlabAuthService.java @@ -43,6 +43,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.Config; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.GitlabProviderService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.TokenCreator; @@ -62,7 +63,7 @@ public class TestGitlabAuthService { TokenCreator tokenCreator = TokenCreator.getInstance(Config.TOKENALG_HS256, TOKENCREATOR_SECRET, "issuer", 30*60); OAuthProviderConfig config = new OAuthProviderConfig("git", GITURL, null, "odlux.app", OAUTH_SECRET, "openid", - "gitlab test", "", false); + "gitlab test", "", null, false); oauthService = new GitlabProviderServiceToTest(config, REDIRECT_URI, tokenCreator); try { initGitlabTestWebserver(PORT, "/"); @@ -102,7 +103,7 @@ public class TestGitlabAuthService { public static class GitlabProviderServiceToTest extends GitlabProviderService { - public GitlabProviderServiceToTest(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) { + public GitlabProviderServiceToTest(OAuthProviderConfig config, String redirectUri, TokenCreator tokenCreator) throws UnableToConfigureOAuthService { super(config, redirectUri, tokenCreator); } diff --git a/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestKeycloakAuthService.java b/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestKeycloakAuthService.java index e4c5e4d82..e5ec2fb32 100644 --- a/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestKeycloakAuthService.java +++ b/sdnr/wt/oauth-provider/provider-jar/src/test/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/test/TestKeycloakAuthService.java @@ -43,6 +43,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.Config; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.OAuthProviderConfig; +import org.onap.ccsdk.features.sdnr.wt.oauthprovider.data.UnableToConfigureOAuthService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.KeycloakProviderService; import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.TokenCreator; @@ -62,7 +63,7 @@ public class TestKeycloakAuthService { TokenCreator tokenCreator = TokenCreator.getInstance(Config.TOKENALG_HS256, TOKENCREATOR_SECRET, "issuer", 30*60); OAuthProviderConfig config = new OAuthProviderConfig("kc", KEYCLOAKURL, null, "odlux.app", OAUTH_SECRET, - "openid", "keycloak test", "onap", false); + "openid", "keycloak test", "onap",null, false); oauthService = new KeycloakProviderServiceToTest(config, REDIRECT_URI, tokenCreator); try { initKeycloakTestWebserver(PORT, "/"); @@ -102,7 +103,7 @@ public class TestKeycloakAuthService { public static class KeycloakProviderServiceToTest extends KeycloakProviderService { public KeycloakProviderServiceToTest(OAuthProviderConfig config, String redirectUri, - TokenCreator tokenCreator) { + TokenCreator tokenCreator) throws UnableToConfigureOAuthService { super(config, redirectUri, tokenCreator); } } diff --git a/sdnr/wt/oauth-provider/provider-osgi/pom.xml b/sdnr/wt/oauth-provider/provider-osgi/pom.xml index 87805b0a1..2db8e6ec7 100644 --- a/sdnr/wt/oauth-provider/provider-osgi/pom.xml +++ b/sdnr/wt/oauth-provider/provider-osgi/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -112,6 +113,7 @@ org.apache.shiro.authz, org.apache.shiro.realm, org.apache.shiro.subject, + org.apache.shiro.web.filter.authz, org.jolokia.osgi.security, org.onap.ccsdk.features.sdnr.wt.common.http, org.opendaylight.aaa.api, @@ -132,7 +134,9 @@ com.fasterxml.jackson.annotation, com.fasterxml.jackson.core.type, com.fasterxml.jackson.core, - org.apache.commons.codec.binary + org.apache.commons.codec.binary, + com.google.common.collect, + com.google.common.util.concurrent </Import-Package> <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency> <Embed-Dependency>*;scope=compile|runtime;artifactId=!shiro-core;inline=false</Embed-Dependency> diff --git a/sdnr/wt/pom.xml b/sdnr/wt/pom.xml index 65a590f68..e27ae0c37 100644 --- a/sdnr/wt/pom.xml +++ b/sdnr/wt/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -39,7 +39,6 @@ <modules> <module>common</module> <module>common-yang</module> - <module>featureaggregator</module> <module>data-provider</module> <module>apigateway</module> <module>helpserver</module> @@ -52,5 +51,6 @@ <module>netconfnode-state-service</module> <module>mountpoint-state-provider</module> <module>oauth-provider</module> + <module>featureaggregator</module> </modules> </project> diff --git a/sdnr/wt/readthedocs/pom.xml b/sdnr/wt/readthedocs/pom.xml index 6643042eb..c3625a5f1 100644 --- a/sdnr/wt/readthedocs/pom.xml +++ b/sdnr/wt/readthedocs/pom.xml @@ -19,19 +19,20 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> <artifactId>sdnr-wt-readthedocs-installer</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <packaging>pom</packaging> <name>ccsdk-features :: ${project.artifactId}</name> diff --git a/sdnr/wt/websocketmanager/feature/pom.xml b/sdnr/wt/websocketmanager/feature/pom.xml index 65686b136..7e5386d03 100644 --- a/sdnr/wt/websocketmanager/feature/pom.xml +++ b/sdnr/wt/websocketmanager/feature/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/websocketmanager/installer/pom.xml b/sdnr/wt/websocketmanager/installer/pom.xml index a2aa1f26e..cc0915544 100755 --- a/sdnr/wt/websocketmanager/installer/pom.xml +++ b/sdnr/wt/websocketmanager/installer/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/websocketmanager/model/pom.xml b/sdnr/wt/websocketmanager/model/pom.xml index e640bc51a..c02d8463b 100644 --- a/sdnr/wt/websocketmanager/model/pom.xml +++ b/sdnr/wt/websocketmanager/model/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -62,6 +63,7 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> + <scope>provided</scope> </dependency> </dependencies> </project> diff --git a/sdnr/wt/websocketmanager/pom.xml b/sdnr/wt/websocketmanager/pom.xml index 56a63a4c2..be59c0907 100755 --- a/sdnr/wt/websocketmanager/pom.xml +++ b/sdnr/wt/websocketmanager/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/websocketmanager/provider/pom.xml b/sdnr/wt/websocketmanager/provider/pom.xml index 7c34ca1f8..83005e3f1 100644 --- a/sdnr/wt/websocketmanager/provider/pom.xml +++ b/sdnr/wt/websocketmanager/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -63,14 +64,17 @@ <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-yang-utils</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.eclipse.jetty.websocket</groupId> <artifactId>websocket-servlet</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>com.typesafe</groupId> @@ -84,6 +88,7 @@ <dependency> <groupId>org.opendaylight.mdsal</groupId> <artifactId>mdsal-binding-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.mdsal</groupId> |