A great update on the alto-commons implementation. 22/18522/2
authorGao Kai <gaok12@mails.tsinghua.edu.cn>
Fri, 17 Apr 2015 09:40:32 +0000 (17:40 +0800)
committerGao Kai <gaok12@mails.tsinghua.edu.cn>
Fri, 17 Apr 2015 13:19:59 +0000 (21:19 +0800)
WARNING: NOT tested for functionalities and compatibilities

- Rename the classes to resolve name conflict
- Using Jackson to parse Model-Oriented JSON files
- A converter design to translate between RFC types and Model types

It is worth pointing out that the current type implementation in both
the rfc7285 and model150404 packages are not quite ready to handle
extensions.

Change-Id: I248b34025b0269c92704ec84189abfff8d97552d
Signed-off-by: Gao Kai <gaok12@mails.tsinghua.edu.cn>
51 files changed:
.gitignore
alto-commons/src/main/java/org/opendaylight/alto/commons/helper/Converter.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/helper/TypeWrapper.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelEndpointAddressGroupConverter.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapConverter.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapDataConverter.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpoint.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpointAddressGroup.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelJSONMapper.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelNetworkMap.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/JSONMapper.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Mark.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285CostMap.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/CostMap.java with 79% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285CostType.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/CostType.java with 66% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Endpoint.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Endpoint.java with 75% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285IRD.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/IRD.java with 86% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285JSONMapper.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285NetworkMap.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/NetworkMap.java with 60% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285QueryPairs.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/QueryPairs.java with 90% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285VersionTag.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/VersionTag.java with 84% similarity]
alto-extensions/cli/file-converter/pom.xml [new file with mode: 0644]
alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/ConvertType.java [new file with mode: 0644]
alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/FileConverterHelper.java [new file with mode: 0644]
alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/RFC2Yang.java [new file with mode: 0644]
alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/Yang2RFC.java [new file with mode: 0644]
alto-extensions/cli/file-converter/src/main/resources/OSGI-INF/blueprint/config.xml [new file with mode: 0644]
alto-extensions/cli/pom.xml [moved from alto-services/ext/pom.xml with 85% similarity]
alto-extensions/fake/pom.xml [moved from alto-services/ext/fake/pom.xml with 94% similarity]
alto-extensions/fake/src/main/java/org/opendaylight/alto/ext/fake/FakeAltoService.java [moved from alto-services/ext/fake/src/main/java/org/opendaylight/alto/services/ext/fake/FakeAltoService.java with 61% similarity]
alto-extensions/fs-map/pom.xml [moved from alto-services/ext/fs-map/pom.xml with 91% similarity]
alto-extensions/fs-map/src/main/java/org/opendaylight/alto/ext/fsmap/FileSystemNetworkMapGenerator.java [moved from alto-services/ext/fs-map/src/main/java/org/opendaylight/alto/services/ext/fsmap/FileSystemNetworkMapGenerator.java with 89% similarity]
alto-extensions/pom.xml [new file with mode: 0644]
alto-northbound/pom.xml
alto-northbound/src/main/java/org/opendaylight/alto/northbound/AltoNorthbound.java
alto-northbound/src/main/java/org/opendaylight/alto/northbound/AltoNorthboundRSApplication.java
alto-northbound/src/main/java/org/opendaylight/alto/northbound/Echo.java [new file with mode: 0644]
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/configuration/AltoProviderImplBuilder.java
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/configuration/alto/provider/impl/DataBrokerBuilder.java
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/configuration/alto/provider/impl/RpcRegistryBuilder.java
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/state/AltoProviderImplBuilder.java
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/CostMapService.java
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointCostService.java
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointPropertyService.java
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/IRDService.java
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/NetworkMapService.java
pom.xml

index de24afe051f2c9a5b9353aa5a69ccbc5854addea..dcd00626546a4f05e9962adc83132817f2035ffd 100644 (file)
@@ -30,3 +30,4 @@ maven-eclipse.xml
 *.swp
 **/*.swp
 **/*.checkstyle
+**/*.swo
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/helper/Converter.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/helper/Converter.java
new file mode 100644 (file)
index 0000000..afd9da1
--- /dev/null
@@ -0,0 +1,38 @@
+package org.opendaylight.alto.commons.helper;
+
+public abstract class Converter<I, O> {
+    private I _in = null;
+    private O _out = null;
+
+    public Converter() {
+    }
+
+    public Converter(I in) {
+        this._in = in;
+        this._out = convert();
+    }
+
+    public O convert() {
+        return (O)_convert();
+    }
+
+    protected abstract Object _convert();
+
+    public O convert(I in) {
+        return reset(in).out();
+    }
+
+    public Converter<I, O> reset(I in) {
+        this._in = in;
+        this._out = convert();
+        return this;
+    }
+
+    public I in() {
+        return _in;
+    }
+
+    public O out() {
+        return _out;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/helper/TypeWrapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/helper/TypeWrapper.java
new file mode 100644 (file)
index 0000000..16bcc26
--- /dev/null
@@ -0,0 +1,31 @@
+package org.opendaylight.alto.commons.helper;
+
+public class TypeWrapper<T extends TypeWrapper, E> {
+
+    private E data = null;
+
+    public static <T extends TypeWrapper, E> T wrap(T wrapper, E data) {
+        wrapper.set(data);
+        return wrapper;
+    }
+
+    public TypeWrapper() {
+        data = null;
+    }
+
+    public TypeWrapper(E data) {
+        this.data = data;
+    }
+
+    public TypeWrapper(TypeWrapper<T, E> wrapper) {
+        this.set(wrapper.get());
+    }
+
+    public E get() {
+        return this.data;
+    }
+
+    public void set(E newData) {
+        this.data = newData;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelEndpointAddressGroupConverter.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelEndpointAddressGroupConverter.java
new file mode 100644 (file)
index 0000000..cf80fa1
--- /dev/null
@@ -0,0 +1,37 @@
+package org.opendaylight.alto.commons.types.converter;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
+import org.opendaylight.alto.commons.types.model150404.ModelEndpointAddressGroup;
+
+public class RFC2ModelEndpointAddressGroupConverter
+        extends Converter<RFC7285Endpoint.AddressGroup, List<ModelEndpointAddressGroup>> {
+
+    public RFC2ModelEndpointAddressGroupConverter() {
+    }
+
+    public RFC2ModelEndpointAddressGroupConverter(RFC7285Endpoint.AddressGroup _in) {
+        super(_in);
+    }
+
+    @Override
+    protected Object _convert() {
+        List<ModelEndpointAddressGroup> out = new LinkedList<ModelEndpointAddressGroup>();
+        if ((in().ipv4 != null) && (!in().ipv4.isEmpty())) {
+            ModelEndpointAddressGroup v4 = new ModelEndpointAddressGroup();
+            v4.setJSONAddressType(ModelEndpointAddressGroup.IPV4);
+            v4.setJSONEndpointPrefix(in().ipv4);
+            out.add(v4);
+        }
+        if ((in().ipv6 != null) && (!in().ipv6.isEmpty())) {
+            ModelEndpointAddressGroup v6 = new ModelEndpointAddressGroup();
+            v6.setJSONAddressType(ModelEndpointAddressGroup.IPV6);
+            v6.setJSONEndpointPrefix(in().ipv6);
+            out.add(v6);
+        }
+        return out;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapConverter.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapConverter.java
new file mode 100644 (file)
index 0000000..cc5def8
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.alto.commons.types.converter;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+
+public class RFC2ModelNetworkMapConverter
+        extends Converter<RFC7285NetworkMap, ModelNetworkMap> {
+
+    protected RFC2ModelNetworkMapDataConverter conv = new RFC2ModelNetworkMapDataConverter();
+
+    public RFC2ModelNetworkMapConverter() {
+    }
+
+    public RFC2ModelNetworkMapConverter(RFC7285NetworkMap _in) {
+        super(_in);
+    }
+
+    @Override
+    public Object _convert() {
+        ModelNetworkMap out = new ModelNetworkMap();
+        out.setJSONResourceId(in().meta.vtag.rid);
+        out.setJSONTag(in().meta.vtag.tag);
+        out.setJSONMap(conv.reset(in().map).out());
+
+        return out;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapDataConverter.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/converter/RFC2ModelNetworkMapDataConverter.java
new file mode 100644 (file)
index 0000000..48a3fd1
--- /dev/null
@@ -0,0 +1,35 @@
+package org.opendaylight.alto.commons.types.converter;
+
+import java.util.Map;
+import java.util.List;
+import java.util.LinkedList;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
+import org.opendaylight.alto.commons.types.model150404.ModelEndpoint;
+
+public class RFC2ModelNetworkMapDataConverter
+        extends Converter<Map<String, RFC7285Endpoint.AddressGroup>, List<ModelEndpoint>> {
+
+    protected RFC2ModelEndpointAddressGroupConverter conv = new RFC2ModelEndpointAddressGroupConverter();
+
+    public RFC2ModelNetworkMapDataConverter() {
+    }
+
+    public RFC2ModelNetworkMapDataConverter(Map<String, RFC7285Endpoint.AddressGroup> _in) {
+        super(_in);
+    }
+
+    @Override
+    public Object _convert() {
+        List<ModelEndpoint> out = new LinkedList<ModelEndpoint>();
+
+        for (Map.Entry<String, RFC7285Endpoint.AddressGroup> rep: in().entrySet()) {
+            ModelEndpoint mep = new ModelEndpoint();
+            mep.setJSONPid(rep.getKey());
+            mep.setJSONEndpointAddressGroup(conv.reset(rep.getValue()).out());
+            out.add(mep);
+        }
+        return out;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java
deleted file mode 100644 (file)
index dc4e704..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.opendaylight.alto.commons.types.convertor;
-
-public class Model2RFCConvertor {
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java
deleted file mode 100644 (file)
index 82b98c8..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.opendaylight.alto.commons.types.convertor;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Arrays;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Type;
-import org.opendaylight.alto.commons.types.model150404.ModelType;
-
-public class RFC2ModelConvertor {
-
-    public static final String IPV4 = "ipv4";
-    public static final String IPV6 = "ipv6";
-
-    public ModelType.NetworkMap convert(RFC7285Type.NetworkMap nmap) {
-        ResourceId rid = new ResourceId(nmap.meta.vtag.rid);
-        TagString tag = new TagString(nmap.meta.vtag.tag);
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> mapData
-                = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map>(convert(nmap.map));
-        ModelType.NetworkMap result = (ModelType.NetworkMap)(new NetworkMapBuilder()
-                                        .setResourceId(rid)
-                                        .setTag(tag)
-                                        .setMap(mapData).build());
-        return result;
-    }
-
-    public List<ModelType.NetworkMapData> convert(Map<String, RFC7285Type.Endpoint.AddressGroup> mapData) {
-        List<ModelType.NetworkMapData> result = new ArrayList<ModelType.NetworkMapData>();
-        for (Map.Entry<String, RFC7285Type.Endpoint.AddressGroup> entry: mapData.entrySet()) {
-            String pid = entry.getKey();
-            RFC7285Type.Endpoint.AddressGroup addresses = entry.getValue();
-
-            result.add(convert(pid, addresses));
-        }
-        return result;
-    }
-
-    public ModelType.NetworkMapData convert(String pid, RFC7285Type.Endpoint.AddressGroup data) {
-        PidName _pid = new PidName(pid);
-        return (ModelType.NetworkMapData)new MapBuilder()
-                    .setPid(_pid)
-                    .setKey(new MapKey(_pid))
-                    .setEndpointAddressGroup(convert(data))
-                    .build();
-    }
-
-    public List<EndpointAddressGroup> convert(RFC7285Type.Endpoint.AddressGroup addressGroup) {
-        EndpointAddressGroup result[] = {
-            buildAddressGroup(EndpointAddressType.Enumeration.Ipv4, str2IpPrefix(addressGroup.ipv4)),
-            buildAddressGroup(EndpointAddressType.Enumeration.Ipv6, str2IpPrefix(addressGroup.ipv6)),
-        };
-
-        return Arrays.asList(result);
-    }
-
-    private EndpointAddressGroup buildAddressGroup(EndpointAddressType.Enumeration type, List<IpPrefix> prefixes) {
-        EndpointAddressType _type = new EndpointAddressType(type);
-        return new EndpointAddressGroupBuilder()
-                    .setAddressType(_type)
-                    .setEndpointPrefix(prefixes).build();
-    }
-
-    private List<IpPrefix> str2IpPrefix(List<String> ipList) {
-        List<IpPrefix> prefixList = new ArrayList<IpPrefix>();
-        for (String ip : ipList) {
-            prefixList.add(IpPrefixBuilder.getDefaultInstance(ip));
-        }
-        return prefixList;
-    }
-
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java
deleted file mode 100644 (file)
index 57aa0a6..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package org.opendaylight.alto.commons.types.model150404;
-public class JSONMapper {
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpoint.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpoint.java
new file mode 100644 (file)
index 0000000..277bfa2
--- /dev/null
@@ -0,0 +1,85 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelEndpoint implements Map {
+
+    @JsonIgnore
+    protected PidName pid = null;
+
+    @JsonIgnore
+    protected List<EndpointAddressGroup> data = new LinkedList<EndpointAddressGroup>();
+
+    public ModelEndpoint() {
+    }
+
+    public ModelEndpoint(Map model) {
+        this.pid = model.getPid();
+        this.setEndpointAddressGroup(model.getEndpointAddressGroup());
+    }
+
+    @JsonIgnore
+    @Override
+    public Class<Map> getImplementedInterface() {
+        return Map.class;
+    }
+
+    @JsonIgnore
+    @Override
+    public <E extends Augmentation<Map>> E getAugmentation(Class<E> augmentationType) {
+        return null;
+    }
+
+    @JsonIgnore
+    @Override
+    public MapKey getKey() {
+        return new MapKey(pid);
+    }
+
+    @JsonIgnore
+    @Override
+    public PidName getPid() {
+        return pid;
+    }
+
+    @JsonProperty("alto-service:pid")
+    public String getJSONPid() {
+        return pid.getValue();
+    }
+
+    @JsonProperty("alto-service:pid")
+    public void setJSONPid(String pid) {
+        this.pid = new PidName(pid);
+    }
+
+    @JsonIgnore
+    @Override
+    public List<EndpointAddressGroup> getEndpointAddressGroup() {
+        return data;
+    }
+
+    @JsonIgnore
+    public void setEndpointAddressGroup(List<EndpointAddressGroup> rhs) {
+        data = new LinkedList<EndpointAddressGroup>(rhs);
+    }
+
+    @JsonProperty("alto-service:endpoint-address-group")
+    public List<EndpointAddressGroup> getJSONEndpointAddressGroup() {
+        return data;
+    }
+
+    @JsonProperty("alto-service:endpoint-address-group")
+    public void setJSONEndpointAddressGroup(List<ModelEndpointAddressGroup> rhs) {
+        data = new LinkedList<EndpointAddressGroup>(rhs);
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpointAddressGroup.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelEndpointAddressGroup.java
new file mode 100644 (file)
index 0000000..16739b9
--- /dev/null
@@ -0,0 +1,109 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelEndpointAddressGroup implements EndpointAddressGroup {
+
+    public static final String IPV4 = "ipv4";
+    public static final String IPV6 = "ipv6";
+
+
+    @JsonIgnore
+    protected EndpointAddressType type;
+
+    @JsonIgnore
+    protected List<IpPrefix> data = new LinkedList<IpPrefix>();
+
+    @JsonIgnore
+    protected List<String> prefixes = new LinkedList<String>();
+
+    public ModelEndpointAddressGroup() {
+    }
+
+    public ModelEndpointAddressGroup(EndpointAddressGroup model) {
+    }
+
+    @JsonIgnore
+    @Override
+    public Class<EndpointAddressGroup> getImplementedInterface() {
+            return EndpointAddressGroup.class;
+    }
+
+    @JsonIgnore
+    @Override
+    public EndpointAddressType getAddressType() {
+        return type;
+    }
+
+    @JsonProperty("alto-service:address-type")
+    public String getJSONAddressType() {
+        if (type == null)
+            return null;
+        if (EndpointAddressType.Enumeration.Ipv4.equals(type.getEnumeration()))
+            return IPV4;
+        if (EndpointAddressType.Enumeration.Ipv6.equals(type.getEnumeration()))
+            return IPV6;
+        return "unsupported";
+    }
+
+    @JsonProperty
+    public void setJSONAddressType(String type) {
+        if (IPV4.equals(type))
+            this.type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
+        if (IPV6.equals(type))
+            this.type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
+        this.type = null;
+    }
+
+    @JsonIgnore
+    @Override
+    public List<IpPrefix> getEndpointPrefix() {
+        return data;
+    }
+
+    @JsonIgnore
+    public void setEndpointPrefix(List<IpPrefix> rhs) {
+        data = new LinkedList<IpPrefix>(rhs);
+        prefixes = new LinkedList<String>();
+        for (IpPrefix p: rhs) {
+            prefixes.add(p.getValue().toString());
+        }
+    }
+
+    @JsonProperty("alto-service:endpoint-prefix")
+    public List<String> getJSONEndpointAddressGroup() {
+        return prefixes;
+    }
+
+    @JsonProperty("alto-service:endpoint-prefix")
+    public void setJSONEndpointPrefix(List<String> rhs) {
+        prefixes = rhs;
+        data = new LinkedList<IpPrefix>();
+        for (String p: rhs) {
+            data.add(IpPrefixBuilder.getDefaultInstance(p));
+        }
+    }
+
+    @JsonIgnore
+    @Override
+    public EndpointAddressGroupKey getKey() {
+        return new EndpointAddressGroupKey(type);
+    }
+
+    @JsonIgnore
+    @Override
+    public <E extends Augmentation<EndpointAddressGroup>> E getAugmentation(Class<E> augmentationType) {
+        return null;
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelJSONMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelJSONMapper.java
new file mode 100644 (file)
index 0000000..5eaeedf
--- /dev/null
@@ -0,0 +1,20 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ModelJSONMapper {
+
+    private ObjectMapper mapper = new ObjectMapper()
+                            .setSerializationInclusion(Include.NON_DEFAULT)
+                            .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+    public ModelNetworkMap asNetworkMap(String json) throws Exception {
+        return mapper.readValue(json, ModelNetworkMap.class);
+    }
+
+    public String asJSON(Object obj) throws Exception {
+        return mapper.writeValueAsString(obj);
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelNetworkMap.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelNetworkMap.java
new file mode 100644 (file)
index 0000000..e7f9b3d
--- /dev/null
@@ -0,0 +1,92 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelNetworkMap implements NetworkMap {
+
+    @JsonIgnore
+    protected ResourceId rid = null;
+
+    @JsonIgnore
+    protected TagString tag = null;
+
+    @JsonIgnore
+    protected List<Map> data = new LinkedList<Map>();
+
+    public ModelNetworkMap() {
+    }
+
+    public ModelNetworkMap(NetworkMap map) {
+        this.rid = map.getResourceId();
+        this.tag = map.getTag();
+        this.setMap(map.getMap());
+    }
+
+    @JsonIgnore
+    @Override
+    public Class<NetworkMap> getImplementedInterface() {
+        return NetworkMap.class;
+    }
+
+    @JsonIgnore
+    @Override
+    public ResourceId getResourceId() {
+        return rid;
+    }
+
+    @JsonProperty("alto-service:resource-id")
+    public String getJSONResourceId() {
+        return rid.getValue();
+    }
+
+    @JsonProperty("alto-service:resource-id")
+    public void setJSONResourceId(String rid) {
+        this.rid = new ResourceId(rid);
+    }
+
+    @JsonIgnore
+    @Override
+    public TagString getTag() {
+        return tag;
+    }
+
+    @JsonProperty("alto-service:tag")
+    public String getJSONTag() {
+        return tag.getValue();
+    }
+
+    @JsonProperty("alto-service:tag")
+    public void setJSONTag(String tag) {
+        this.tag = new TagString(tag);
+    }
+
+    @JsonIgnore
+    @Override
+    public List<Map> getMap() {
+        return data;
+    }
+
+    @JsonIgnore
+    public void setMap(List<Map> data) {
+        this.data = new LinkedList<Map>(data);
+    }
+
+    @JsonProperty("alto-service:map")
+    public List<Map> getJSONMap() {
+        return data;
+    }
+
+    @JsonProperty("alto-service:map")
+    public void setJSONMap(List<ModelEndpoint> data) {
+        this.data = new LinkedList<Map>(data);
+    }
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java
deleted file mode 100644 (file)
index ddf5fa9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.opendaylight.alto.commons.types.model150404;
-
-public class ModelType {
-
-    public static interface NetworkMap
-            extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap {}
-
-    public static interface NetworkMapData
-            extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map {
-    }
-
-    public static class JSONMapper
-            extends org.opendaylight.alto.commons.types.model150404.JSONMapper {}
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/JSONMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/JSONMapper.java
deleted file mode 100644 (file)
index 51a6885..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class JSONMapper {
-
-    private ObjectMapper mapper = new ObjectMapper()
-                            .setSerializationInclusion(Include.NON_DEFAULT)
-                            .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
-
-    public Endpoint.AddressGroup asAddressGroup(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.AddressGroup.class);
-    }
-
-    public Endpoint.PropertyRequest asPropertyRequest(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.PropertyRequest.class);
-    }
-
-    public Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.PropertyResponse.class);
-    }
-
-    public Endpoint.CostRequest asCostRequest(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.CostRequest.class);
-    }
-
-    public Endpoint.CostResponse asCostResponse(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.CostResponse.class);
-    }
-
-    public CostMap asCostMap(String json) throws Exception {
-        return mapper.readValue(json, CostMap.class);
-    }
-
-    public CostType asCostType(String json) throws Exception {
-        return mapper.readValue(json, CostType.class);
-    }
-
-    public Endpoint asEndpoint(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.class);
-    }
-
-    public Extensible asExtensible(String json) throws Exception {
-        return mapper.readValue(json, Extensible.class);
-    }
-
-    public IRD asIRD(String json) throws Exception {
-        return mapper.readValue(json, IRD.class);
-    }
-
-    public NetworkMap asNetworkMap(String json) throws Exception {
-        return mapper.readValue(json, NetworkMap.class);
-    }
-
-    public NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
-        return mapper.readValue(json, NetworkMap.Filter.class);
-    }
-
-    public CostMap.Filter asCostMapFilter(String json) throws Exception {
-        return mapper.readValue(json, CostMap.Filter.class);
-    }
-
-    public VersionTag asVersionTag(String json) throws Exception {
-        return mapper.readValue(json, VersionTag.class);
-    }
-
-    public String asJSON(Object obj) throws Exception {
-        return mapper.writeValueAsString(obj);
-    }
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Mark.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Mark.java
deleted file mode 100644 (file)
index 21cb752..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.opendaylight.alto.commons.types.rfc7285;
-
-public class Mark {
-    public static int marker = 2;
-}
similarity index 79%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/CostMap.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285CostMap.java
index ce07217e36efbf0065bd92886c525bcaa6e29b90..b6dc0e1c044cc94dda5e49c1047768863269ea78 100644 (file)
@@ -9,15 +9,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 /**
  * Cost Map: defined in RFC7285 secion 11.2.3
  * */
-public class CostMap {
+public class RFC7285CostMap {
 
     public static class Meta extends Extensible {
 
         @JsonProperty("dependent-vtags")
-        public List<VersionTag> netmap_tags;
+        public List<RFC7285VersionTag> netmap_tags;
 
         @JsonProperty("cost-type")
-        public CostType costType;
+        public RFC7285CostType costType;
     }
 
     /**
@@ -26,10 +26,10 @@ public class CostMap {
     public static class Filter {
 
         @JsonProperty("cost-type")
-        public CostType costType;
+        public RFC7285CostType costType;
 
         @JsonProperty("pids")
-        public QueryPairs pids;
+        public RFC7285QueryPairs pids;
     }
 
     @JsonProperty("meta")
similarity index 66%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/CostType.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285CostType.java
index 0ef11c6dd55dbe1b0785657c1eff04d9ac780ad6..f2ebb63a02fba9c05a550328799057818611c4e4 100644 (file)
@@ -3,26 +3,26 @@ package org.opendaylight.alto.commons.types.rfc7285;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.util.Arrays;
 
-public class CostType {
+public class RFC7285CostType {
 
     @JsonProperty("cost-mode")
-    public String mode;
+    public String mode = "";
 
     @JsonProperty("cost-metric")
-    public String metric;
+    public String metric = "";
 
     @JsonProperty("description")
-    public String description;
+    public String description = "";
 
-    public CostType() {
+    public RFC7285CostType() {
     }
 
-    public CostType(String mode, String metric) {
+    public RFC7285CostType(String mode, String metric) {
         this.mode = mode;
         this.metric = metric;
     }
 
-    public CostType(String mode, String metric, String description) {
+    public RFC7285CostType(String mode, String metric, String description) {
         this.mode = mode;
         this.metric = metric;
         this.description = description;
@@ -38,10 +38,10 @@ public class CostType {
     public boolean equals(Object obj) {
         if (this == obj)
             return true;
-        if (!(obj != null ? (obj instanceof CostType) : false))
+        if (!(obj != null ? (obj instanceof RFC7285CostType) : false))
             return false;
 
-        CostType other = (CostType)obj;
+        RFC7285CostType other = (RFC7285CostType)obj;
         String[] lhs = { metric, mode };
         String[] rhs = { other.metric, other.mode };
         return Arrays.equals(lhs, rhs);
similarity index 75%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Endpoint.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Endpoint.java
index ab67a97780926e2af4cf0864901d9505d8fac3de..3dafddc41545020f7d38a23a2792eee8b1e25b68 100644 (file)
@@ -8,7 +8,8 @@ import java.util.ArrayList;
 import java.util.Map;
 import java.util.LinkedHashMap;
 
-public class Endpoint {
+
+public class RFC7285Endpoint {
 
     public static class AddressGroup extends Extensible {
 
@@ -29,10 +30,10 @@ public class Endpoint {
     public static class PropertyRequest {
 
         @JsonProperty("properties")
-        public List<String> properties;
+        public List<String> properties = new ArrayList<String>();
 
         @JsonProperty("endpoints")
-        public List<String> endpoints;
+        public List<String> endpoints = new ArrayList<String>();
     }
 
     public static class PropertyResponse {
@@ -40,12 +41,12 @@ public class Endpoint {
         public static class Meta extends Extensible {
 
             @JsonProperty("dependent-vtags")
-            public List<VersionTag> netmap_tags;
+            public List<RFC7285VersionTag> netmap_tags = new ArrayList<RFC7285VersionTag>();
 
         }
 
         @JsonProperty("meta")
-        public Meta meta;
+        public Meta meta = new Meta();
 
         @JsonProperty("endpoint-properties")
         public Map<String, Map<String, Object>> answer
@@ -55,10 +56,10 @@ public class Endpoint {
     public static class CostRequest {
 
         @JsonProperty("cost-type")
-        public CostType costType;
+        public RFC7285CostType costType = new RFC7285CostType();
 
         @JsonProperty("endpoints")
-        public QueryPairs endpoints;
+        public RFC7285QueryPairs endpoints = new RFC7285QueryPairs();
     }
 
     public static class CostResponse {
@@ -66,12 +67,12 @@ public class Endpoint {
         public static class Meta extends Extensible {
 
             @JsonProperty("cost-type")
-            public CostType costType;
+            public RFC7285CostType costType = new RFC7285CostType();
 
         }
 
         @JsonProperty("meta")
-        public Meta meta;
+        public Meta meta = new Meta();
 
         @JsonProperty("endpoint-cost-map")
         public Map<String, Map<String, Object>> answer
similarity index 86%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/IRD.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285IRD.java
index 2daf5eb995df766f49b50d1de7777e27a55f896c..79d072e0a301747f703a67fb286ecb8a5789dfa4 100644 (file)
@@ -6,7 +6,7 @@ import java.util.LinkedHashMap;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 
-public class IRD {
+public class RFC7285IRD {
 
     public class Meta extends Extensible {
 
@@ -14,11 +14,11 @@ public class IRD {
         public String defaultAltoNetworkMap;
 
         @JsonProperty("cost-types")
-        public Map<String, CostType> costTypes;
+        public Map<String, RFC7285CostType> costTypes;
 
         public Meta() {
             defaultAltoNetworkMap = null;
-            costTypes = new LinkedHashMap<String, CostType>();
+            costTypes = new LinkedHashMap<String, RFC7285CostType>();
         }
 
     }
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285JSONMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285JSONMapper.java
new file mode 100644 (file)
index 0000000..286e79e
--- /dev/null
@@ -0,0 +1,72 @@
+package org.opendaylight.alto.commons.types.rfc7285;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RFC7285JSONMapper {
+
+    private ObjectMapper mapper = new ObjectMapper()
+                            .setSerializationInclusion(Include.NON_DEFAULT)
+                            .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+    public RFC7285Endpoint.AddressGroup asAddressGroup(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.AddressGroup.class);
+    }
+
+    public RFC7285Endpoint.PropertyRequest asPropertyRequest(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.PropertyRequest.class);
+    }
+
+    public RFC7285Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.PropertyResponse.class);
+    }
+
+    public RFC7285Endpoint.CostRequest asCostRequest(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.CostRequest.class);
+    }
+
+    public RFC7285Endpoint.CostResponse asCostResponse(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.CostResponse.class);
+    }
+
+    public RFC7285CostMap asCostMap(String json) throws Exception {
+        return mapper.readValue(json, RFC7285CostMap.class);
+    }
+
+    public RFC7285CostType asCostType(String json) throws Exception {
+        return mapper.readValue(json, RFC7285CostType.class);
+    }
+
+    public RFC7285Endpoint asEndpoint(String json) throws Exception {
+        return mapper.readValue(json, RFC7285Endpoint.class);
+    }
+
+    public Extensible asExtensible(String json) throws Exception {
+        return mapper.readValue(json, Extensible.class);
+    }
+
+    public RFC7285IRD asIRD(String json) throws Exception {
+        return mapper.readValue(json, RFC7285IRD.class);
+    }
+
+    public RFC7285NetworkMap asNetworkMap(String json) throws Exception {
+        return mapper.readValue(json, RFC7285NetworkMap.class);
+    }
+
+    public RFC7285NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
+        return mapper.readValue(json, RFC7285NetworkMap.Filter.class);
+    }
+
+    public RFC7285CostMap.Filter asCostMapFilter(String json) throws Exception {
+        return mapper.readValue(json, RFC7285CostMap.Filter.class);
+    }
+
+    public RFC7285VersionTag asVersionTag(String json) throws Exception {
+        return mapper.readValue(json, RFC7285VersionTag.class);
+    }
+
+    public String asJSON(Object obj) throws Exception {
+        return mapper.writeValueAsString(obj);
+    }
+}
similarity index 60%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/NetworkMap.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285NetworkMap.java
index c9e3d98fa4979bb93d3c4b211113601ba36da8f2..3d3d8f423903e2ea5c83e1f0e447f14941920110 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.alto.commons.types.rfc7285;
 
 import java.util.LinkedHashMap;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -9,12 +10,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 /**
  * Network Map: defined in RFC 7285 section 11.2.1
  * */
-public class NetworkMap {
+public class RFC7285NetworkMap {
 
     public static class Meta extends Extensible {
 
         @JsonProperty("vtag")
-        public VersionTag vtag;
+        public RFC7285VersionTag vtag = new RFC7285VersionTag();
 
     }
 
@@ -24,14 +25,14 @@ public class NetworkMap {
     public static class Filter {
 
         @JsonProperty("pids")
-        public List<String> pids;
+        public List<String> pids = new ArrayList<String>();
 
     }
 
     @JsonProperty("meta")
-    public Meta meta;
+    public Meta meta = new Meta();
 
     @JsonProperty("network-map")
-    public Map<String, Endpoint.AddressGroup> map
-                    = new LinkedHashMap<String, Endpoint.AddressGroup>();
+    public Map<String, RFC7285Endpoint.AddressGroup> map
+                    = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>();
 }
similarity index 90%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/QueryPairs.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285QueryPairs.java
index 8342d973483420f5b3ac8ae98c12363e00bf0397..465a604f56528cb15699ac5def8c9e55a8ae67b0 100644 (file)
@@ -5,7 +5,7 @@ import java.util.LinkedList;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 
-public class QueryPairs {
+public class RFC7285QueryPairs {
 
     @JsonProperty("srcs")
     List<String> src = new LinkedList<String>();
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java
deleted file mode 100644 (file)
index 7bf72f3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.opendaylight.alto.commons.types.rfc7285;
-
-public class RFC7285Type {
-
-    public static class NetworkMap
-            extends org.opendaylight.alto.commons.types.rfc7285.NetworkMap {}
-
-    public static class CostMap
-            extends org.opendaylight.alto.commons.types.rfc7285.CostMap {}
-
-    public static class CostType
-            extends org.opendaylight.alto.commons.types.rfc7285.CostType {}
-
-    public static class Endpoint
-            extends org.opendaylight.alto.commons.types.rfc7285.Endpoint {}
-
-    public static class IRD
-            extends org.opendaylight.alto.commons.types.rfc7285.IRD {}
-
-    public static class MediaType
-            extends org.opendaylight.alto.commons.types.rfc7285.MediaType {}
-
-    public static class JSONMapper
-            extends org.opendaylight.alto.commons.types.rfc7285.JSONMapper {}
-
-    public static class VersionTag
-            extends org.opendaylight.alto.commons.types.rfc7285.VersionTag {}
-}
similarity index 84%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/VersionTag.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285VersionTag.java
index ccfc4889fcb704ec6d54ac8d2bf143b7f56308b8..3aebb7d7c96dae8ea064b594bd83e46674bd2b61 100644 (file)
@@ -2,7 +2,7 @@ package org.opendaylight.alto.commons.types.rfc7285;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 
-public class VersionTag {
+public class RFC7285VersionTag {
 
     @JsonProperty("resource-id")
     public String rid;
@@ -10,12 +10,12 @@ public class VersionTag {
     @JsonProperty("tag")
     public String tag;
 
-    public VersionTag() {
+    public RFC7285VersionTag() {
         rid = "";
         tag = "";
     }
 
-    public VersionTag(String rid, String tag) {
+    public RFC7285VersionTag(String rid, String tag) {
         this.rid = (rid != null ? rid : "");
         this.tag = (tag != null ? tag : "");
     }
@@ -38,7 +38,7 @@ public class VersionTag {
         if (obj == null)
             return false;
 
-        VersionTag other = (VersionTag)obj;
+        RFC7285VersionTag other = (RFC7285VersionTag)obj;
         boolean _rid = (rid == null ? (other.rid == null) : rid.equals(other.rid));
         boolean _tag = (tag == null ? (other.tag == null) : tag.equals(other.tag));
         return (_rid && _tag);
diff --git a/alto-extensions/cli/file-converter/pom.xml b/alto-extensions/cli/file-converter/pom.xml
new file mode 100644 (file)
index 0000000..acf1010
--- /dev/null
@@ -0,0 +1,64 @@
+<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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-extensions</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <relativePath>../../</relativePath>
+  </parent>
+
+  <artifactId>file-converter</artifactId>
+  <packaging>bundle</packaging>
+  <name>${project.artifactId}</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-model</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.karaf.shell</groupId>
+      <artifactId>org.apache.karaf.shell.console</artifactId>
+      <version>2.2.11</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-commons</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>${bundle.plugin.version}</version>
+        <configuration>
+          <instructions>
+            <Import-Package>
+              org.apache.felix.service.command,
+              org.apache.felix.gogo.commands,
+              org.apache.karaf.shell.console,
+              org.opendaylight.alto.commons.types.*,
+              *
+            </Import-Package>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/ConvertType.java b/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/ConvertType.java
new file mode 100644 (file)
index 0000000..4dcc3f6
--- /dev/null
@@ -0,0 +1,9 @@
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+public class ConvertType {
+
+    //TODO add more types
+
+    public static final String NETWORK_MAP = "networkmap";
+
+}
diff --git a/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/FileConverterHelper.java b/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/FileConverterHelper.java
new file mode 100644 (file)
index 0000000..6072596
--- /dev/null
@@ -0,0 +1,19 @@
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+
+import com.google.common.io.Files;
+
+class FileConverterHelper {
+
+    public String load(String path) throws Exception {
+        File file = new File(path);
+        return Files.toString(file, StandardCharsets.US_ASCII);
+    }
+
+    public void save(String path, String content) throws Exception {
+        File file = new File(path);
+        Files.write(content, file, StandardCharsets.US_ASCII);
+    }
+}
diff --git a/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/RFC2Yang.java b/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/RFC2Yang.java
new file mode 100644 (file)
index 0000000..92db17b
--- /dev/null
@@ -0,0 +1,52 @@
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import org.opendaylight.alto.commons.types.converter.RFC2ModelNetworkMapConverter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Command(scope = "alto", name = "file-rfc2yang", description = "Convert file from RFC 7285 format to Yang Data format")
+public class RFC2Yang extends OsgiCommandSupport {
+
+    private static final Logger logger = LoggerFactory.getLogger(RFC2Yang.class);
+
+    @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
+    String type = null;
+
+    @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
+    String source = null;
+
+    @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
+    String target = null;
+
+    protected RFC7285JSONMapper rfcMapper = new RFC7285JSONMapper();
+    protected ModelJSONMapper modelMapper = new ModelJSONMapper();
+    protected FileConverterHelper helper = new FileConverterHelper();
+
+    @Override
+    protected Object doExecute() throws Exception {
+        logger.info("command: alto:rfc2yang {} {} {}",
+                        type, source, target);
+        if (ConvertType.NETWORK_MAP.equals(type)) {
+            String input = helper.load(source);
+            RFC7285NetworkMap rfcMap = rfcMapper.asNetworkMap(input);
+
+            RFC2ModelNetworkMapConverter conv = new RFC2ModelNetworkMapConverter();
+
+            ModelNetworkMap modelMap = conv.convert(rfcMap);
+            String output = modelMapper.asJSON(modelMap);
+            helper.save(target, output);
+        }
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+}
+
diff --git a/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/Yang2RFC.java b/alto-extensions/cli/file-converter/src/main/java/org/opendaylight/alto/ext/cli/fileconverter/Yang2RFC.java
new file mode 100644 (file)
index 0000000..ca17e02
--- /dev/null
@@ -0,0 +1,33 @@
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Command(scope = "alto", name = "file-yang2rfc", description = "The converter between RFC 7285 and Yang Model files")
+public class Yang2RFC extends OsgiCommandSupport {
+
+    private static final Logger logger = LoggerFactory.getLogger(Yang2RFC.class);
+
+    @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
+    String type = null;
+
+    @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
+    String source = null;
+
+    @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
+    String target = null;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        logger.info("command: alto:rfc2yang {} {} {}",
+                        type, source, target);
+
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+}
+
diff --git a/alto-extensions/cli/file-converter/src/main/resources/OSGI-INF/blueprint/config.xml b/alto-extensions/cli/file-converter/src/main/resources/OSGI-INF/blueprint/config.xml
new file mode 100644 (file)
index 0000000..7cf76b0
--- /dev/null
@@ -0,0 +1,11 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+  <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+    <command name="alto/file-yang2rfc">
+      <action class="org.opendaylight.alto.ext.cli.fileconvertor.Yang2RFC"/>
+    </command>
+
+    <command name="alto/file-rfc2yang">
+      <action class="org.opendaylight.alto.ext.cli.fileconvertor.RFC2Yang"/>
+    </command>
+  </command-bundle>
+</blueprint>
similarity index 85%
rename from alto-services/ext/pom.xml
rename to alto-extensions/cli/pom.xml
index 63767eb00a2a68d423f760d29d31cc43c21431c8..afe243fc8831c218cbc0c7add9379bb460ffa92e 100644 (file)
   </parent>
 
   <groupId>org.opendaylight.alto</groupId>
-  <artifactId>services.ext</artifactId>
+  <artifactId>alto-cli-extension</artifactId>
   <packaging>pom</packaging>
 
   <modules>
-    <module>fs-map</module>
-    <module>fake</module>
+    <module>file-converter</module>
   </modules>
 
 </project>
similarity index 94%
rename from alto-services/ext/fake/pom.xml
rename to alto-extensions/fake/pom.xml
index e7875d5d0562aeaa7236e01d8f2fd1fecdf23c7c..0141e95e351985c6f8005bd1ec671dcf2c785c22 100644 (file)
@@ -6,12 +6,12 @@
 
   <parent>
     <groupId>org.opendaylight.alto</groupId>
-    <artifactId>services.ext</artifactId>
+    <artifactId>alto-extensions</artifactId>
     <version>0.1.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
-  <artifactId>services.ext.fake</artifactId>
+  <artifactId>alto-fake-extension</artifactId>
   <packaging>bundle</packaging>
 
   <build>
@@ -58,7 +58,7 @@
               org.slf4j,
             </Import-Package>
             <Export-Package>
-              org.opendaylight.alto.services.ext.fake;
+              org.opendaylight.alto.ext.fake;
             </Export-Package>
             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
           </instructions>
similarity index 61%
rename from alto-services/ext/fake/src/main/java/org/opendaylight/alto/services/ext/fake/FakeAltoService.java
rename to alto-extensions/fake/src/main/java/org/opendaylight/alto/ext/fake/FakeAltoService.java
index f9a7031fe02b14ac4a1b6ebd928aea27afaf9d9a..25a66c9b34468e3947240dd1f7e8ba8337aa669d 100644 (file)
@@ -1,17 +1,17 @@
-package org.opendaylight.alto.services.ext.fake;
+package org.opendaylight.alto.ext.fake;
 
 import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
 
 public class FakeAltoService implements AltoService {
 
-    private JSONMapper mapper = new JSONMapper();
+    private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
 
     private static final String NETWORKMAP_JSON =
             "{"
@@ -46,7 +46,7 @@ public class FakeAltoService implements AltoService {
 
     private static final String DEFAULT_NETWORKMAP_ID = "default-networkmap";
     private static final String DEFAULT_NETWORKMAP_TAG = "3ee2cb7e8d63d9fab71b9b34cbf764436315542e";
-    private NetworkMap networkMap = null;
+    private RFC7285NetworkMap networkMap = null;
 
     private static final String COSTMAP_JSON =
             "{"
@@ -71,7 +71,7 @@ public class FakeAltoService implements AltoService {
 
     private static final String DEFAULT_COSTMAP_ID = "default-costmap";
 
-    private CostMap costMap = null;
+    private RFC7285CostMap costMap = null;
 
     public FakeAltoService() {
         try {
@@ -83,17 +83,17 @@ public class FakeAltoService implements AltoService {
         }
     }
 
-    public CostMap getCostMap(String id) {
+    public RFC7285CostMap getCostMap(String id) {
         if (!DEFAULT_COSTMAP_ID.equals(id))
             return null;
         return costMap;
     }
 
-    public CostMap getCostMap(VersionTag vtag) {
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
         return getCostMap(vtag.rid);
     }
 
-    public CostMap getCostMap(String id, CostType type) {
+    public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
         if (!DEFAULT_COSTMAP_ID.equals(id))
             return null;
         if (!(costMap.meta.costType.equals(type)))
@@ -101,23 +101,23 @@ public class FakeAltoService implements AltoService {
         return costMap;
     }
 
-    public CostMap getCostMap(VersionTag vtag, CostType type) {
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
         return getCostMap(vtag.rid, type);
     }
 
-    public CostMap getCostMap(String id, CostMap.Filter filter) {
+    public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
         return null;
     }
 
-    public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter) {
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
         return null;
     }
 
-    public Boolean supportCostType(String id, CostType type) {
+    public Boolean supportCostType(String id, RFC7285CostType type) {
         return null;
     }
 
-    public Boolean supportCostType(VersionTag vtag, CostType type) {
+    public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
         if (!DEFAULT_COSTMAP_ID.equals(vtag.rid))
             return new Boolean(false);
         if (!costMap.meta.costType.equals(type))
@@ -125,26 +125,26 @@ public class FakeAltoService implements AltoService {
         return new Boolean(true);
     }
 
-    public Boolean validateCostMapFilter(String id, CostMap.Filter filter) {
+    public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
         return false;
     }
 
-    public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter) {
+    public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
         return false;
     }
 
 
-    public NetworkMap getDefaultNetworkMap() {
+    public RFC7285NetworkMap getDefaultNetworkMap() {
         return networkMap;
     }
 
-    public NetworkMap getNetworkMap(String id) {
+    public RFC7285NetworkMap getNetworkMap(String id) {
         if (!DEFAULT_NETWORKMAP_ID.equals(id))
             return null;
         return networkMap;
     }
 
-    public NetworkMap getNetworkMap(VersionTag vtag) {
+    public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag) {
         if (!DEFAULT_NETWORKMAP_ID.equals(vtag.rid))
             return null;
         if (!DEFAULT_NETWORKMAP_TAG.equals(vtag.tag))
@@ -152,43 +152,43 @@ public class FakeAltoService implements AltoService {
         return networkMap;
     }
 
-    public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter) {
+    public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter) {
         return null;
     }
 
-    public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter) {
+    public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
         return null;
     }
 
-    public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter) {
+    public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter) {
         return new Boolean(false);
     }
 
-    public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter) {
+    public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
         return new Boolean(false);
     }
 
-    public IRD getDefaultIRD() {
+    public RFC7285IRD getDefaultIRD() {
         return null;
     }
 
-    public IRD getIRD(String id) {
+    public RFC7285IRD getIRD(String id) {
         return null;
     }
 
-    public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request) {
+    public RFC7285Endpoint.CostResponse getEndpointCost(String id, RFC7285Endpoint.CostRequest request) {
         return null;
     }
 
-    public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request) {
+    public RFC7285Endpoint.CostResponse getEndpointCost(RFC7285VersionTag vtag, RFC7285Endpoint.CostRequest request) {
         return null;
     }
 
-    public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request) {
+    public RFC7285Endpoint.PropertyResponse getEndpointProperty(String id, RFC7285Endpoint.PropertyRequest request) {
         return null;
     }
 
-    public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request) {
+    public RFC7285Endpoint.PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, RFC7285Endpoint.PropertyRequest request) {
         return null;
     }
 
similarity index 91%
rename from alto-services/ext/fs-map/pom.xml
rename to alto-extensions/fs-map/pom.xml
index 8e1efa606f59ec8025b7dc3727891de631a91e33..b80d52551e20e8f83f64e9a8b11c5cef3f248fb9 100644 (file)
@@ -6,12 +6,12 @@
 
   <parent>
     <groupId>org.opendaylight.alto</groupId>
-    <artifactId>services.ext</artifactId>
+    <artifactId>alto-extensions</artifactId>
     <version>0.1.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
-  <artifactId>services.ext.fs-map</artifactId>
+  <artifactId>fs-map-generator</artifactId>
   <packaging>bundle</packaging>
 
   <build>
@@ -34,7 +34,7 @@
               org.slf4j,
             </Import-Package>
             <Export-Package>
-              org.opendaylight.alto.services.ext.fsmap;
+              org.opendaylight.alto.ext.fsmap;
             </Export-Package>
             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
           </instructions>
similarity index 89%
rename from alto-services/ext/fs-map/src/main/java/org/opendaylight/alto/services/ext/fsmap/FileSystemNetworkMapGenerator.java
rename to alto-extensions/fs-map/src/main/java/org/opendaylight/alto/ext/fsmap/FileSystemNetworkMapGenerator.java
index d9ef039d767b0de6e8286ff1b0751ac358805b6a..abc69f67420104c29012ce842774e5013dccad0c 100644 (file)
@@ -1,4 +1,4 @@
-package org.opendaylight.alto.services.ext.fsmap;
+package org.opendaylight.alto.ext.fsmap;
 
 import java.net.URI;
 import java.nio.file.FileSystem;
@@ -22,9 +22,9 @@ import java.util.concurrent.locks.ReentrantLock;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.HashMap;
 
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,9 +40,9 @@ public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
     private HashMap<WatchKey, Path> paths = new HashMap<WatchKey, Path>();
     private MapFileLoader loader = null;
     private AtomicBoolean cancelled = new AtomicBoolean(false);
-    private HashMap<Path, VersionTag> path_to_id = new HashMap<Path, VersionTag>();
-    private HashMap<VersionTag, NetworkMap> id_to_map = new HashMap<VersionTag, NetworkMap>();
-    private JSONMapper mapper = new JSONMapper();
+    private HashMap<Path, RFC7285VersionTag> path_to_id = new HashMap<Path, RFC7285VersionTag>();
+    private HashMap<RFC7285VersionTag, RFC7285NetworkMap> id_to_map = new HashMap<RFC7285VersionTag, RFC7285NetworkMap>();
+    private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
 
     public FileSystemNetworkMapGenerator(URI uri) throws Exception {
         source = Paths.get(uri);
@@ -163,7 +163,7 @@ public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
         } catch (Exception e) {
         }
 
-        for (VersionTag vtag: path_to_id.values()) {
+        for (RFC7285VersionTag vtag: path_to_id.values()) {
             // TODO remove network map
             if (vtag.incomplete())
                 continue;
@@ -182,9 +182,9 @@ public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
         //TODO
         try {
             String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
-            NetworkMap map = mapper.asNetworkMap(content);
+            RFC7285NetworkMap map = mapper.asNetworkMap(content);
 
-            VersionTag vtag = map.meta.vtag;
+            RFC7285VersionTag vtag = map.meta.vtag;
             logger.info("vtag: <" + vtag.rid + ", " + vtag.tag + ">");
             if (id_to_map.get(map.meta.vtag) != null) {
                 logger.warn("Version tag already registered: ("
@@ -218,7 +218,7 @@ public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
     public void onDelete(Path file) {
         //TODO
         try {
-            VersionTag vtag = path_to_id.get(file);
+            RFC7285VersionTag vtag = path_to_id.get(file);
             if (vtag == null)
                 return;
 
@@ -250,9 +250,9 @@ public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
         //TODO
         try {
             String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
-            NetworkMap map = mapper.asNetworkMap(content);
-            VersionTag vtag = map.meta.vtag;
-            VersionTag old = path_to_id.get(file);
+            RFC7285NetworkMap map = mapper.asNetworkMap(content);
+            RFC7285VersionTag vtag = map.meta.vtag;
+            RFC7285VersionTag old = path_to_id.get(file);
 
             if (old != null) {
                 if (vtag.rid != old.rid) {
diff --git a/alto-extensions/pom.xml b/alto-extensions/pom.xml
new file mode 100644 (file)
index 0000000..994e6b3
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.alto</groupId>
+  <artifactId>alto-extensions</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>fs-map</module>
+    <module>fake</module>
+    <module>cli</module>
+  </modules>
+
+</project>
+
index 78594f780adb08c7e99c5d4792308bcd94b58079..3e50fabd820dd2389abd2efb719eea67fe22392d 100644 (file)
@@ -34,7 +34,7 @@
           <instructions>
             <Import-Package>
               org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*,
-              org.opendaylight.alto.services.ext.fake,
+              org.opendaylight.alto.ext.fake,
               org.opendaylight.alto.services.api.rfc7285,
               org.opendaylight.alto.commons.*,
               org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
 
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>services.ext.fake</artifactId>
+      <artifactId>alto-fake-extension</artifactId>
       <version>${project.version}</version>
     </dependency>
   </dependencies>
index 4725b6b0726efc6a8d362e86c5c8ab761a77ad08..0c29ab5d472d982901468f1a6d190f232a170bc9 100644 (file)
@@ -16,19 +16,19 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
 import org.opendaylight.alto.commons.types.rfc7285.FormatValidator;
 import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
 
 import org.opendaylight.alto.services.api.rfc7285.AltoService;
 
-import org.opendaylight.alto.services.ext.fake.FakeAltoService;
+import org.opendaylight.alto.ext.fake.FakeAltoService;
 
 import org.opendaylight.alto.northbound.exception.AltoBasicException;
 import org.opendaylight.alto.northbound.exception.AltoBadFormatException;
@@ -42,7 +42,7 @@ public class AltoNorthbound {
     private static final Logger logger = LoggerFactory.getLogger(AltoNorthbound.class);
 
     private AltoService altoService = new FakeAltoService();
-    private JSONMapper mapper = new JSONMapper();
+    private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
 
     private void checkAltoService() throws Exception {
         if (altoService == null)
@@ -87,7 +87,7 @@ public class AltoNorthbound {
     public Response retrieveIRD() throws Exception {
         checkAltoService();
 
-        IRD ird = altoService.getDefaultIRD();
+        RFC7285IRD ird = altoService.getDefaultIRD();
         if (ird == null)
             return fail(Status.NOT_FOUND, null);
         return success(ird, MediaType.ALTO_DIRECTORY);
@@ -101,7 +101,7 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        IRD ird = altoService.getIRD(id);
+        RFC7285IRD ird = altoService.getIRD(id);
         if (ird == null)
             return fail(Status.NOT_FOUND, id);
         return success(ird, MediaType.ALTO_DIRECTORY);
@@ -113,7 +113,7 @@ public class AltoNorthbound {
     public Response retrieveDefaultNetworkMap() throws Exception {
         checkAltoService();
 
-        NetworkMap map = altoService.getDefaultNetworkMap();
+        RFC7285NetworkMap map = altoService.getDefaultNetworkMap();
         if (map == null)
             return fail(Status.NOT_FOUND, null);
         return success(map, MediaType.ALTO_NETWORKMAP);
@@ -127,7 +127,7 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        NetworkMap map = altoService.getNetworkMap(id);
+        RFC7285NetworkMap map = altoService.getNetworkMap(id);
         if (map == null)
             return fail(Status.NOT_FOUND, id);
         return success(map, MediaType.ALTO_NETWORKMAP);
@@ -143,8 +143,8 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        NetworkMap map = altoService.getNetworkMap(vtag);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285NetworkMap map = altoService.getNetworkMap(vtag);
         if (map == null)
             return fail(Status.NOT_FOUND, vtag);
         return success(map, MediaType.ALTO_NETWORKMAP);
@@ -157,7 +157,7 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        CostMap map = altoService.getCostMap(id);
+        RFC7285CostMap map = altoService.getCostMap(id);
         if (map == null)
             return fail(Status.NOT_FOUND, id);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -173,8 +173,8 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        CostMap map = altoService.getCostMap(vtag);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285CostMap map = altoService.getCostMap(vtag);
         if (map == null)
             return fail(Status.NOT_FOUND, vtag);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -190,10 +190,10 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        CostType costType = new CostType(mode, metric);
+        RFC7285CostType costType = new RFC7285CostType(mode, metric);
         if (!altoService.supportCostType(id, costType))
             return fail(Status.NOT_FOUND, costType);
-        CostMap map = altoService.getCostMap(id, costType);
+        RFC7285CostMap map = altoService.getCostMap(id, costType);
         if (map == null)
             return fail(Status.NOT_FOUND, id);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -211,11 +211,11 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        CostType costType = new CostType(mode, metric);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285CostType costType = new RFC7285CostType(mode, metric);
         if (!altoService.supportCostType(vtag, costType))
             return fail(Status.NOT_FOUND, costType);
-        CostMap map = altoService.getCostMap(vtag, costType);
+        RFC7285CostMap map = altoService.getCostMap(vtag, costType);
         if (map == null)
             return fail(Status.NOT_FOUND, vtag);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -230,11 +230,11 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+        RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
 
         if (!altoService.validateNetworkMapFilter(id, filter))
             return fail(Status.BAD_REQUEST, filter);
-        NetworkMap map = altoService.getNetworkMap(id, filter);
+        RFC7285NetworkMap map = altoService.getNetworkMap(id, filter);
         if (map == null)
             return fail(Status.NOT_FOUND, id);
         return success(map, MediaType.ALTO_NETWORKMAP);
@@ -252,12 +252,12 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
         if (!altoService.validateNetworkMapFilter(vtag, filter))
             return fail(Status.BAD_REQUEST, filter);
 
-        NetworkMap map = altoService.getNetworkMap(vtag, filter);
+        RFC7285NetworkMap map = altoService.getNetworkMap(vtag, filter);
         if (map == null)
             return fail(Status.NOT_FOUND, vtag);
         return success(map, MediaType.ALTO_NETWORKMAP);
@@ -272,11 +272,11 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+        RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
         if (!altoService.validateCostMapFilter(id, filter))
             return fail(Status.BAD_REQUEST, filter);
 
-        CostMap map = altoService.getCostMap(id, filter);
+        RFC7285CostMap map = altoService.getCostMap(id, filter);
         if (map == null)
             return fail(Status.NOT_FOUND, id);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -293,12 +293,12 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
         if (!altoService.validateCostMapFilter(vtag, filter))
             return fail(Status.BAD_REQUEST, filter);
 
-        CostMap map = altoService.getCostMap(vtag, filter);
+        RFC7285CostMap map = altoService.getCostMap(vtag, filter);
         if (map == null)
             return fail(Status.NOT_FOUND, vtag);
         return success(map, MediaType.ALTO_COSTMAP);
@@ -314,8 +314,8 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
-        Endpoint.PropertyResponse response = altoService.getEndpointProperty(id, request);
+        RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+        RFC7285Endpoint.PropertyResponse response = altoService.getEndpointProperty(id, request);
         if (response == null)
             return fail(Status.NOT_FOUND, request);
         return success(response, MediaType.ALTO_ENDPOINT_PROP);
@@ -333,9 +333,9 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
-        Endpoint.PropertyResponse response = altoService.getEndpointProperty(vtag, request);
+       RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+        RFC7285Endpoint.PropertyResponse response = altoService.getEndpointProperty(vtag, request);
         if (response == null)
             return fail(Status.NOT_FOUND, request);
         return success(response, MediaType.ALTO_ENDPOINT_PROP);
@@ -351,8 +351,8 @@ public class AltoNorthbound {
         checkAltoService();
         checkResourceId(id);
 
-        Endpoint.CostRequest request = mapper.asCostRequest(params);
-        Endpoint.CostResponse response = altoService.getEndpointCost(id, request);
+        RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
+        RFC7285Endpoint.CostResponse response = altoService.getEndpointCost(id, request);
         if (response == null)
             return fail(Status.NOT_FOUND, request);
         return success(response, MediaType.ALTO_ENDPOINT_COST);
@@ -370,9 +370,9 @@ public class AltoNorthbound {
         checkResourceId(id);
         checkTag(tag);
 
-        VersionTag vtag = new VersionTag(id, tag);
-        Endpoint.CostRequest request = mapper.asCostRequest(params);
-        Endpoint.CostResponse response = altoService.getEndpointCost(vtag, request);
+        RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+        RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
+        RFC7285Endpoint.CostResponse response = altoService.getEndpointCost(vtag, request);
         if (response == null)
             return fail(Status.NOT_FOUND, request);
         return success(response, MediaType.ALTO_ENDPOINT_COST);
index 6ab9bc6f4f410ea54ad879345a57a8239381cbb6..3239286463638fedc6b57d16c3b6b7c027711d3f 100644 (file)
@@ -9,6 +9,7 @@ public class AltoNorthboundRSApplication extends Application {
     public Set<Class<?>> getClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(AltoNorthbound.class);
+        classes.add(Echo.class);
         return classes;
     }
 }
diff --git a/alto-northbound/src/main/java/org/opendaylight/alto/northbound/Echo.java b/alto-northbound/src/main/java/org/opendaylight/alto/northbound/Echo.java
new file mode 100644 (file)
index 0000000..63a8b14
--- /dev/null
@@ -0,0 +1,29 @@
+package org.opendaylight.alto.northbound;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
+
+@Path("/echo")
+class Echo {
+
+    protected ModelJSONMapper modelMapper = new ModelJSONMapper();
+
+    @Path("/model/networkmap")
+    @POST
+    Response echoModelNetworkMap(String content) throws Exception {
+        ModelNetworkMap nmap = modelMapper.asNetworkMap(content);
+        String output = modelMapper.asJSON(nmap);
+        return Response.ok(output).build();
+    }
+
+    @Path("/model/networkmap")
+    @GET
+    Response echoModelNetworkMap() throws Exception {
+        return Response.ok("not implemented").build();
+    }
+}
index 5e6508a03facf2d28267ca2f91cff05498811fc7..66a053a16ad0d209efb244725ae210fa91e46bff 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.control
 import java.util.Collections;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
 import java.util.HashMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker;
@@ -29,8 +30,12 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
         this._dataBroker = base.getDataBroker();
         this._rpcRegistry = base.getRpcRegistry();
         if (base instanceof AltoProviderImplImpl) {
-            AltoProviderImplImpl _impl = (AltoProviderImplImpl) base;
-            this.augmentation = new HashMap<>(_impl.augmentation);
+            AltoProviderImplImpl impl = (AltoProviderImplImpl) base;
+            this.augmentation = new HashMap<>(impl.augmentation);
+        } else if (base instanceof AugmentationHolder) {
+            @SuppressWarnings("unchecked")
+            AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>) base;
+            this.augmentation = new HashMap<>(casted.augmentations());
         }
     }
 
@@ -92,17 +97,17 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
         private AltoProviderImplImpl(AltoProviderImplBuilder base) {
             this._dataBroker = base.getDataBroker();
             this._rpcRegistry = base.getRpcRegistry();
-                switch (base.augmentation.size()) {
-                case 0:
-                    this.augmentation = Collections.emptyMap();
-                    break;
-                    case 1:
-                        final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
-                        this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
-                    break;
-                default :
-                    this.augmentation = new HashMap<>(base.augmentation);
-                }
+            switch (base.augmentation.size()) {
+            case 0:
+                this.augmentation = Collections.emptyMap();
+                break;
+                case 1:
+                    final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
+                    this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
+                break;
+            default :
+                this.augmentation = new HashMap<>(base.augmentation);
+            }
         }
 
         @Override
index db564ae8b3b948872d25da0def8f5f14a485c3d0..f2de4081375f72b16510d6b93b8e6cb8d6c80d77 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.control
 import java.util.Collections;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
 import java.util.HashMap;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
@@ -31,8 +32,12 @@ public class DataBrokerBuilder implements Builder <org.opendaylight.yang.gen.v1.
         this._name = base.getName();
         this._type = base.getType();
         if (base instanceof DataBrokerImpl) {
-            DataBrokerImpl _impl = (DataBrokerImpl) base;
-            this.augmentation = new HashMap<>(_impl.augmentation);
+            DataBrokerImpl impl = (DataBrokerImpl) base;
+            this.augmentation = new HashMap<>(impl.augmentation);
+        } else if (base instanceof AugmentationHolder) {
+            @SuppressWarnings("unchecked")
+            AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>) base;
+            this.augmentation = new HashMap<>(casted.augmentations());
         }
     }
 
@@ -117,17 +122,17 @@ public class DataBrokerBuilder implements Builder <org.opendaylight.yang.gen.v1.
         private DataBrokerImpl(DataBrokerBuilder base) {
             this._name = base.getName();
             this._type = base.getType();
-                switch (base.augmentation.size()) {
-                case 0:
-                    this.augmentation = Collections.emptyMap();
-                    break;
-                    case 1:
-                        final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>> e = base.augmentation.entrySet().iterator().next();
-                        this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>singletonMap(e.getKey(), e.getValue());
-                    break;
-                default :
-                    this.augmentation = new HashMap<>(base.augmentation);
-                }
+            switch (base.augmentation.size()) {
+            case 0:
+                this.augmentation = Collections.emptyMap();
+                break;
+                case 1:
+                    final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>> e = base.augmentation.entrySet().iterator().next();
+                    this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>singletonMap(e.getKey(), e.getValue());
+                break;
+            default :
+                this.augmentation = new HashMap<>(base.augmentation);
+            }
         }
 
         @Override
index 9d150c2631c6fc5d75f4e01f29f5f4a9a656d4b3..143ba80477228c1bd88bb57f79af3fe085b41406 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.control
 import java.util.Collections;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
 import java.util.HashMap;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
@@ -31,8 +32,12 @@ public class RpcRegistryBuilder implements Builder <org.opendaylight.yang.gen.v1
         this._name = base.getName();
         this._type = base.getType();
         if (base instanceof RpcRegistryImpl) {
-            RpcRegistryImpl _impl = (RpcRegistryImpl) base;
-            this.augmentation = new HashMap<>(_impl.augmentation);
+            RpcRegistryImpl impl = (RpcRegistryImpl) base;
+            this.augmentation = new HashMap<>(impl.augmentation);
+        } else if (base instanceof AugmentationHolder) {
+            @SuppressWarnings("unchecked")
+            AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>) base;
+            this.augmentation = new HashMap<>(casted.augmentations());
         }
     }
 
@@ -117,17 +122,17 @@ public class RpcRegistryBuilder implements Builder <org.opendaylight.yang.gen.v1
         private RpcRegistryImpl(RpcRegistryBuilder base) {
             this._name = base.getName();
             this._type = base.getType();
-                switch (base.augmentation.size()) {
-                case 0:
-                    this.augmentation = Collections.emptyMap();
-                    break;
-                    case 1:
-                        final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e = base.augmentation.entrySet().iterator().next();
-                        this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>singletonMap(e.getKey(), e.getValue());
-                    break;
-                default :
-                    this.augmentation = new HashMap<>(base.augmentation);
-                }
+            switch (base.augmentation.size()) {
+            case 0:
+                this.augmentation = Collections.emptyMap();
+                break;
+                case 1:
+                    final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e = base.augmentation.entrySet().iterator().next();
+                    this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>singletonMap(e.getKey(), e.getValue());
+                break;
+            default :
+                this.augmentation = new HashMap<>(base.augmentation);
+            }
         }
 
         @Override
index f351eaa69dc646ccd73df473035a7b13499c9d05..1e8487b99de05bbfbdbd85142117b7840f933590 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.control
 import java.util.Collections;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
 import java.util.HashMap;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
@@ -23,8 +24,12 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
 
     public AltoProviderImplBuilder(AltoProviderImpl base) {
         if (base instanceof AltoProviderImplImpl) {
-            AltoProviderImplImpl _impl = (AltoProviderImplImpl) base;
-            this.augmentation = new HashMap<>(_impl.augmentation);
+            AltoProviderImplImpl impl = (AltoProviderImplImpl) base;
+            this.augmentation = new HashMap<>(impl.augmentation);
+        } else if (base instanceof AugmentationHolder) {
+            @SuppressWarnings("unchecked")
+            AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>) base;
+            this.augmentation = new HashMap<>(casted.augmentations());
         }
     }
 
@@ -66,17 +71,17 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
         private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> augmentation = new HashMap<>();
 
         private AltoProviderImplImpl(AltoProviderImplBuilder base) {
-                switch (base.augmentation.size()) {
-                case 0:
-                    this.augmentation = Collections.emptyMap();
-                    break;
-                    case 1:
-                        final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
-                        this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
-                    break;
-                default :
-                    this.augmentation = new HashMap<>(base.augmentation);
-                }
+            switch (base.augmentation.size()) {
+            case 0:
+                this.augmentation = Collections.emptyMap();
+                break;
+                case 1:
+                    final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
+                    this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
+                break;
+            default :
+                this.augmentation = new HashMap<>(base.augmentation);
+            }
         }
 
         
index aa4d73947fd107e9045f78ad39433919a9288f58..5ba04437c407c1c6f65b9ec0decab014c611ed0d 100644 (file)
@@ -1,29 +1,29 @@
 package org.opendaylight.alto.services.api.rfc7285;
 
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
 
 public interface CostMapService {
 
-    public CostMap getCostMap(String id);
+    public RFC7285CostMap getCostMap(String id);
 
-    public CostMap getCostMap(VersionTag vtag);
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag);
 
-    public CostMap getCostMap(String id, CostType type);
+    public RFC7285CostMap getCostMap(String id, RFC7285CostType type);
 
-    public CostMap getCostMap(VersionTag vtag, CostType type);
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type);
 
-    public CostMap getCostMap(String id, CostMap.Filter filter);
+    public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter);
 
-    public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter);
+    public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
 
-    public Boolean supportCostType(String id, CostType type);
+    public Boolean supportCostType(String id, RFC7285CostType type);
 
-    public Boolean supportCostType(VersionTag vtag, CostType type);
+    public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type);
 
-    public Boolean validateCostMapFilter(String id, CostMap.Filter filter);
+    public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter);
 
-    public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter);
+    public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
 
 }
index b9d1b9f63494199be82f7513d0ce0908631f04e7..2383b9b739d2e8c191231cfbeda49b5b29df388a 100644 (file)
@@ -1,12 +1,13 @@
 package org.opendaylight.alto.services.api.rfc7285;
 
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
 
 public interface EndpointCostService {
 
-    public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request);
+    public CostResponse getEndpointCost(String id, CostRequest request);
 
-    public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request);
+    public CostResponse getEndpointCost(RFC7285VersionTag vtag, CostRequest request);
 
 }
index 1b2cf660c02568f36c08c37ae441adb357906105..cc9e70a528635e7a801017a4de0d9b4142ad0f2c 100644 (file)
@@ -1,12 +1,13 @@
 package org.opendaylight.alto.services.api.rfc7285;
 
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyRequest;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyResponse;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
 
 public interface EndpointPropertyService {
 
-    public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request);
+    public PropertyResponse getEndpointProperty(String id, PropertyRequest request);
 
-    public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request);
+    public PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, PropertyRequest request);
 
 }
index 767efe669d591e9d6a2bc28862311205a68d2549..be2ee62b5da36d7af519949c53da8ac5cd195887 100644 (file)
@@ -1,11 +1,11 @@
 package org.opendaylight.alto.services.api.rfc7285;
 
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
 
 public interface IRDService {
 
-    public IRD getDefaultIRD();
+    public RFC7285IRD getDefaultIRD();
 
-    public IRD getIRD(String id);
+    public RFC7285IRD getIRD(String id);
 
 }
index 2c83f3877fcbf06e13496a15d37d1124a2585917..2fbfbf3f6ddde979c245c1695e8ed13f7fbe9c04 100644 (file)
@@ -1,22 +1,22 @@
 package org.opendaylight.alto.services.api.rfc7285;
 
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
 
 public interface NetworkMapService {
 
-    public NetworkMap getDefaultNetworkMap();
+    public RFC7285NetworkMap getDefaultNetworkMap();
 
-    public NetworkMap getNetworkMap(String id);
+    public RFC7285NetworkMap getNetworkMap(String id);
 
-    public NetworkMap getNetworkMap(VersionTag vtag);
+    public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag);
 
-    public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter);
+    public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter);
 
-    public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter);
+    public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
 
-    public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter);
+    public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter);
 
-    public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter);
+    public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
 
 }
diff --git a/pom.xml b/pom.xml
index 33403b660e2efef287ee8899ea698969bb549356..069f19e7d23d9eb71bdd888f55aec6a3cfa424fc 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
     <module>alto-commons</module>
     <module>alto-manager</module>
     <module>alto-services/api</module>
-    <module>alto-services/ext</module>
+    <module>alto-extensions</module>
     <!-- <module>alto-karaf</module> -->
     <module>alto-northbound</module>
   </modules>