diff options
author | 2023-06-28 11:38:33 -0400 | |
---|---|---|
committer | 2023-08-10 14:50:16 -0400 | |
commit | c35ad79f3939eebf531f477d62755221789bca12 (patch) | |
tree | 557bc55ff8fee542cb98501e0a8612170a971aa0 /sdnr/wt/common-yang/utils/src/main/java/org/onap | |
parent | 258ca721d952cffc919ad2265e97d73357abeeae (diff) |
Update features for Argon release
Update ccsdk/features for use with OpenDaylight Argon release
Issue-ID: CCSDK-3916
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: Ie28aa66f6c3a9c0c6002e05d8f714613dbe460cf
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/common-yang/utils/src/main/java/org/onap')
2 files changed, 17 insertions, 9 deletions
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/BaseIdentityDeserializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/BaseIdentityDeserializer.java index 1c4226322..9e72e5652 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/BaseIdentityDeserializer.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/BaseIdentityDeserializer.java @@ -25,14 +25,10 @@ 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.google.common.reflect.ClassPath; import java.io.IOException; -import java.lang.reflect.Type; import java.util.List; import java.util.stream.Collectors; - -import com.google.common.reflect.ClassPath; -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.BaseIdentity; import org.slf4j.Logger; @@ -63,13 +59,24 @@ public class BaseIdentityDeserializer<T> extends JsonDeserializer<T> { int lastDot = clazzToSearch.lastIndexOf("."); if (lastDot > -1) { simpleName = clazzToSearch.substring(lastDot + 1); + String finalSimpleName; + if(simpleName.endsWith("Identity")){ + finalSimpleName = simpleName.substring(0, simpleName.length()-8); + } + else{ + finalSimpleName=simpleName; + } clazz = getTypesInNamespace(clazzToSearch.substring(0, lastDot)).stream() - .filter(e -> e.getSimpleName().equals(simpleName)).findFirst().orElse(null); + .filter(e -> e.getSimpleName().equals(finalSimpleName)).findFirst().orElse(null); if (clazz != null) return (T) YangToolsMapperHelper.getIdentityValueFromClass(clazz); } else { simpleName = clazzToSearch.substring(0, 1).toUpperCase() + clazzToSearch.substring(1); + if(simpleName.endsWith("Identity")){ + simpleName = simpleName.substring(0, simpleName.length()-8); + } } + try { clazz = (Class<? extends BaseIdentity>) YangToolsMapperHelper.findClass(simpleName); if (clazz != null) diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java index 8959e913a..ea07c5d05 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import java.io.IOException; -import org.opendaylight.yangtools.yang.binding.Enumeration; +import org.opendaylight.yangtools.yang.binding.EnumTypeObject; + @SuppressWarnings("rawtypes") public class EnumSerializer extends JsonSerializer<Enum> { @@ -33,8 +34,8 @@ public class EnumSerializer extends JsonSerializer<Enum> { @Override public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException { //sadly a seperate serializer for class Enumeration doesn't work, so we have to catch it here - if(value instanceof Enumeration) { - gen.writeString(((Enumeration)value).getName()); + if(value instanceof EnumTypeObject) { + gen.writeString(((EnumTypeObject)value).getName()); } else { gen.writeString(value.name()); |