# wt - wireless transport microservices
-ODL version: aluminium sr1
+ODL version: sulfur sr1
## apigateway (osgi)
~ ============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>
~ ============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>
~ ============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>
~ ============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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-common</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
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();
+ }
}
~ ============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>
~ ============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>
~ ============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>
~ ============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>
<groupId>org.opendaylight.mdsal</groupId>
<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>
<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>
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());
}
enable(MapperFeature.USE_GETTERS_AS_SETTERS);
setAnnotationIntrospector(yangToolsBuilderAnnotationIntrospector);
}
+
public void addDeserializer(Class<?> clsToDeserialize, String builderClassName) {
this.annotationIntrospector.addDeserializer(clsToDeserialize, builderClassName);
}
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);
}
}
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;
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.
* 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));
* @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
* @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);
}
+
}
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);
+ }
}
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;
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;
+ }
}
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;
+ }
}
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);
+ }
}
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);
+ }
}
--- /dev/null
+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);
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+/*
+ * ============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);
+ }
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}
--- /dev/null
+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)";
+ }
+
+}
--- /dev/null
+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
~ ============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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<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>
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
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;
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;
/**
public GenericRunnableFactory() {
}
- public Runnable create(S arg, GenericRunnableFactoryCallback<T> callback) {
- return null;
- }
+ public abstract Runnable create(final T key, final S arg);
}
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;
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);
+ }
+
+ }
}
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;
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";
--- /dev/null
+/*
+ * ============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 + "]";
+ }
+ }
+}
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";
~ ============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>
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;
ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException;
- ReadStatusOutputBuilder readStatus() throws IOException;
+ ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException;
boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit);
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;
}
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;
}
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;
}
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());
@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);
}
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;
pagination = x.build();
}
+ public Set<T> getResultSet() {
+ return new HashSet<>(this.result);
+ }
public List<T> getResult() {
- return result;
+ return this.result;
}
public PaginationOutputG getPagination() {
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;
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;
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)) {
}
@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());
}
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) {
}
@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;
}
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) {
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;
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;
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,
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);
}
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;
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;
} ;
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();
}
}
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 {
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();
}
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);
}
*/
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) {
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;
+ }
}
+
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");
ReadStatusOutputBuilder status = null;
try {
- status = dbProvider.readStatus();
+ EntityInput input=null;
+ status = dbProvider.readStatus(input);
} catch (IOException e) {
e.printStackTrace();
fail("failed to read status");
-/*
- * ============LICENSE_START=======================================================
+/* ============LICENSE_START=======================================================
* ONAP : ccsdk features
* ================================================================================
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
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;
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);
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);
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);
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();
~ ============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>
~ ============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>
~ ============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>
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-common</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
rpc read-status {
description
"Read status information of controller";
+ input {
+ uses entity-input;
+ }
output {
list data {
uses status-entity;
~ ============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>
~ ============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>
<dependency>
<groupId>org.apache.karaf.bundle</groupId>
<artifactId>org.apache.karaf.bundle.core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<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>
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;
* @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());
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);
* @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);
} 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;
}
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;
}
- 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();
}
.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();
}
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;
}
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;
}
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;
}
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());
*/
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;
@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
private final HtDatabaseMediatorserver mediatorserver;
private final HtDatabaseMaintenance maintenance;
private final DataProvider dataprovider;
-
+
public NoDbDatabaseDataProvider() {
this.usermanger = new NoDbHtUserdataManager();
this.mediatorserver = new NoDbHtDatabaseMediatorserver();
}
@Override
- public ReadStatusOutputBuilder readStatus() throws IOException {
+ public ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException {
return new ReadStatusOutputBuilder();
}
if (onapCCSDKVersion == null) {
return def;
}
+ if (onapCCSDKVersion.startsWith("2.4.")) {
+ return "ONAP Kohn";
+ }
if (onapCCSDKVersion.startsWith("2.3.")) {
return "ONAP Jakarta";
}
}
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)");
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;
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;
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;
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;
// 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() {
@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();
}
}
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();
: 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());
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();
return result;
}
+
public HtUserdataManager getHtDatabaseUserManager() {
return this.dbUserManager;
}
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;
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;
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;
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;
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 {
//== 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 ================================
//== 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";
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 {
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);
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);
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();
//== 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());
}
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");
fail("Problem reading 15m ltp data");
}
- List<String> dataLtp = readltpResult.getData();
+ Set<String> dataLtp = readltpResult.getData();
assertNotNull(dataLtp);
assertEquals(2, dataLtp.size());
fail("Problem reading 15m device data");
}
- List<String> dataDevice = readDeviceResult.getData();
+ Set<String> dataDevice = readDeviceResult.getData();
assertNotNull(dataDevice);
assertEquals(2, dataDevice.size());
fail("Problem reading 24h ltp data");
}
- List<String> dataLtp = readltpResult.getData();
+ Set<String> dataLtp = readltpResult.getData();
assertNotNull(dataLtp);
assertEquals(3, dataLtp.size());
fail("Problem reading 24h device data");
}
- List<String> dataDevice = readDeviceResult.getData();
+ Set<String> dataDevice = readDeviceResult.getData();
assertNotNull(dataDevice);
assertEquals(2, dataDevice.size());
assertEquals("admin", UserdataHttpServlet.decodeJWTPayloadUsername(String.format("Bearer %s",
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkBzZG4iLCJyb2xlcyI6WyJ1c2VyIiwiYWRtaW4iXSwiaXN"
- + "zIjoiT3BlbmRheWxpZ2h0IiwibmFtZSI6ImFkbWluQHNkbiIsImV4cCI6MTYxNTc5NTg1NywiZmFtaWx5X25hbWUiOiIifQ.wB"
- + "PdB45_bryU6_kSCu3be3dq3yth24niSXi6b2_1ufc"),
+ + "zIjoiT3BlbmRheWxpZ2h0IiwibmFtZSI6ImFkbWluQHNkbiIsImV4cCI6MTYxNTc5NTg1NywiZmFtaWx5X25hbWUiOiIifQ.wB"
+ + "PdB45_bryU6_kSCu3be3dq3yth24niSXi6b2_1ufc"),
"sub"));
}
.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 {
}
- 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;
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" + "}");
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());
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;
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());
~ ============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>
<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>
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);
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());
}
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;
// private static DbLibService dbService;
+ private static final String SUFFIX = "";
private static MariaDBTestBase testBase;
private static SqlDBDataProvider dbProvider;
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");
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());
}
~ ============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>
~ ============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>
~ ============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>
<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>
module devicemanager {
- yang-version 1;
+ yang-version 1.1;
namespace "urn:opendaylight:params:xml:ns:yang:devicemanager";
prefix devicemanager;
~ ============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>
~ ============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>
</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>
<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>org.onap.ccsdk.features.sdnr.wt</groupId>
<artifactId>sdnr-wt-websocketmanager-model</artifactId>
<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>
<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>
*/
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;
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;
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);
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);
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();
-
}
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);
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);
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");
return result.buildFuture();
}
-
-
}
*/
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;
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();
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;
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());
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;
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());
}
~ ============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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>
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;
}
}
- 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();
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);
}
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;
@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);
}
--- /dev/null
+/*
+ * 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));
+ }
+}
+++ /dev/null
-/*
- * ============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);
- }
- }
-}
<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>
<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>
<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>
<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>
</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>
<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>
<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>
</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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
<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-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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>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>org.osgi.core</artifactId>
<scope>test</scope>
</dependency>
+ <!-- end for testing -->
</dependencies>
<build>
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;
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) {
~ ============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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>sal-netconf-connector</artifactId>
- <version>2.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<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>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
+ <version>7.0.9</version>
<executions>
<execution>
<id>binding</id>
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;
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) {
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()));
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");
+++ /dev/null
-/*
- * ============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);
- }
- }
-}
--- /dev/null
+/*
+ * 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));
+ }
+}
~ ============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>
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>
<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>
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;
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) {
@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)
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;
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) {
@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 =
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;
@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);
@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);
~ ============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>
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>
<artifactId>sdnr-wt-netconfnode-state-service-model</artifactId>
<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>
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;
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;
}
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);
}
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;
"Mux group grouping";
}
- grouping org-openroadm-device-container {
+ // grouping org-openroadm-device-container {
container org-openroadm-device {
container info {
uses device-common;
uses mux-grp;
}
}
- }
+ // }
grouping common-session-parms {
description
}
}
- uses org-openroadm-device-container;
+ //uses org-openroadm-device-container;
}
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;
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) {
@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)
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;
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) {
@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 =
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;
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;
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;
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;
@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);
@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);
~ ============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>
<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>
~ ============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>
~ ============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>
~ ============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>
<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>
~ ============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>
~ ============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>
<modules>
<module>feature</module>
+<!-- <module>feature-minimal</module> -->
<module>feature-oauth</module>
<module>feature-devicemanager</module>
<module>feature-devicemanager-base</module>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
</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>
<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-devicemanager-core-model</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<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>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
</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>
<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>
<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>
+++ /dev/null
-/*
- * ============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;
- }
-}
+++ /dev/null
-/*
- * ============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;
- }
-}
+++ /dev/null
-/*
- * ============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;
- }
-}
~ ============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>
~ ============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>
~ ============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>
<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>
--- /dev/null
+/*
+ * ============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();
+
+ }
+}
~ ============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>
~ ============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>
<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>
<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>
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;
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;
// 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;
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;
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;
}
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);
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);
}
public DomContext getDomContext() {
- return Objects.requireNonNull(domContext, "Initialization not completed for domContext" );
+ return Objects.requireNonNull(domContext, "Initialization not completed for domContext");
}
public DataBroker getDataBroker() {
}
public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() {
- return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService" );
+ return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService");
}
@Override
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);
}
}
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);
@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;
+ }
+
+ }
}
*/
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;
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;
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
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);
}
}
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;
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);
--- /dev/null
+/*
+ * ============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());
+ }
+}
~ ============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>
~ ============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>
private String title;
private String scope;
private String realmName;
+ private String openIdConfigUrl;
+
private boolean trustAll;
private OAuthProvider type;
private Map<String, String> roleMapping;
}
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;
this.title = title;
this.realmName = realmName;
this.trustAll = trustAll;
+ this.openIdConfigUrl = openIdConfigUrl;
this.roleMapping = new HashMap<>();
}
}
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) {
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)) {
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
return this.internalUrl != null && this.internalUrl.length() > 0 ? this.internalUrl : this.url;
}
+ @JsonIgnore
+ public boolean hasToBeConfigured(){
+ return this.openIdConfigUrl!=null && this.openIdConfigUrl.length()>0;
+ }
}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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));
+ }
+
+}
--- /dev/null
+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;
+ }
+}
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;
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();
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;
protected final OAuthProviderConfig config;
protected final TokenCreator tokenCreator;
private final String redirectUri;
+ private final String tokenEndpoint;
+ private final String authEndpoint;
protected abstract String getTokenVerifierUri();
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() {
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 {
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;
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;
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");
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 {
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");
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;
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) {
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
}
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);
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;
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, "/");
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);
}
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;
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, "/");
public static class KeycloakProviderServiceToTest extends KeycloakProviderService {
public KeycloakProviderServiceToTest(OAuthProviderConfig config, String redirectUri,
- TokenCreator tokenCreator) {
+ TokenCreator tokenCreator) throws UnableToConfigureOAuthService {
super(config, redirectUri, tokenCreator);
}
}
~ ============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>
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,
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>
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
<modules>
<module>common</module>
<module>common-yang</module>
- <module>featureaggregator</module>
<module>data-provider</module>
<module>apigateway</module>
<module>helpserver</module>
<module>netconfnode-state-service</module>
<module>mountpoint-state-provider</module>
<module>oauth-provider</module>
+ <module>featureaggregator</module>
</modules>
</project>
~ ============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>
~ ============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>
~ ============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>
~ ============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>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
~ ============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>
~ ============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>
<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>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>