[ODTN] Add read/create/delete ConnectivityService RPC
- RPC: get service interface point
- RPC: get connectivity service list
- RPC: get connectivity service detail
- RPC: create connectivity service
- RPC: delete connectivity service
- Filter method of TAPI resolver for both Node / NEP
- Change condition for sip to odtn-port-type
- Use odtn-port-type in path-computation mock
- Create CEP at topology discovery
- Add sample path calculator
- Add connection-id based path selection
Change-Id: I2f08aacb3dd14b6b3c59a64a349e50abb495f70b
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNepRef.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNepRef.java
index 12df8cb..e5fcf2d 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNepRef.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNepRef.java
@@ -20,6 +20,9 @@
import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.Node;
import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.Topology;
+/**
+ * TAPI Nep reference class which has a factory method using DCS modelObject.
+ */
public final class DcsBasedTapiNepRef extends TapiNepRef {
private DcsBasedTapiNepRef(Topology topology, Node node, OwnedNodeEdgePoint nep) {
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNodeRef.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNodeRef.java
index cfc38e2..b6260a7 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNodeRef.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/DcsBasedTapiNodeRef.java
@@ -19,6 +19,9 @@
import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.Node;
import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.Topology;
+/**
+ * TAPI Node reference class which has a factory method using DCS modelObject.
+ */
public final class DcsBasedTapiNodeRef extends TapiNodeRef {
private DcsBasedTapiNodeRef(Topology topology, Node node) {
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepHandler.java
new file mode 100644
index 0000000..b49de0c
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepHandler.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.ceplist.DefaultConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectionendpoint.DefaultParentNodeEdgePoint;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.node.DefaultOwnedNodeEdgePoint;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.node.OwnedNodeEdgePointKeys;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.DefaultNode;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.NodeKeys;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.DefaultTopology;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.TopologyKeys;
+import org.onosproject.yang.model.ModelObjectId;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
+
+/**
+ * Utility class to deal with TAPI CEP with DCS.
+ */
+public final class TapiCepHandler extends TapiObjectHandler<DefaultConnectionEndPoint> {
+
+ private Uuid topologyUuid;
+ private Uuid nodeUuid;
+ private Uuid nepUuid;
+
+ private TapiCepHandler() {
+ obj = new DefaultConnectionEndPoint();
+ setId();
+ }
+
+ public static TapiCepHandler create() {
+ return new TapiCepHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ checkNotNull(topologyUuid);
+ checkNotNull(nodeUuid);
+ checkNotNull(nodeUuid);
+
+ TopologyKeys topologyKey = new TopologyKeys();
+ topologyKey.uuid(topologyUuid);
+
+ NodeKeys nodeKey = new NodeKeys();
+ nodeKey.uuid(nodeUuid);
+
+ OwnedNodeEdgePointKeys nepKey = new OwnedNodeEdgePointKeys();
+ nepKey.uuid(nepUuid);
+
+ return ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .addChild(DefaultTopology.class, topologyKey)
+ .addChild(DefaultNode.class, nodeKey)
+ .addChild(DefaultOwnedNodeEdgePoint.class, nepKey)
+ .build();
+ }
+
+ public TapiCepHandler setTopologyUuid(Uuid topologyUuid) {
+ this.topologyUuid = topologyUuid;
+ return this;
+ }
+
+ public TapiCepHandler setNodeUuid(Uuid nodeUuid) {
+ this.nodeUuid = nodeUuid;
+ return this;
+ }
+
+ public TapiCepHandler setNepUuid(Uuid nepUuid) {
+ this.nepUuid = nepUuid;
+ return this;
+ }
+
+ public TapiCepHandler setParentNep() {
+ checkNotNull(topologyUuid);
+ checkNotNull(nodeUuid);
+ checkNotNull(nepUuid);
+
+ DefaultParentNodeEdgePoint parentNep = new DefaultParentNodeEdgePoint();
+ parentNep.topologyId(topologyUuid);
+ parentNep.nodeId(nodeUuid);
+ parentNep.ownedNodeEdgePointId(nepUuid);
+ obj.addToParentNodeEdgePoint(parentNep);
+
+ return this;
+ }
+
+ public TapiCepHandler setParentNep(TapiNepRef nepRef) {
+ topologyUuid = Uuid.fromString(nepRef.getTopologyId());
+ nodeUuid = Uuid.fromString(nepRef.getNodeId());
+ nepUuid = Uuid.fromString(nepRef.getNepId());
+
+ setParentNep();
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepPair.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepPair.java
new file mode 100644
index 0000000..f283bf3
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepPair.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Objects;
+import java.util.stream.Stream;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * TAPI CepRef pair class for representation of endpoints of single connection.
+ */
+public final class TapiCepPair {
+
+ private TapiCepRef left;
+ private TapiCepRef right;
+
+ private TapiCepPair() {
+ }
+
+ public static TapiCepPair create(TapiCepRef left, TapiCepRef right) {
+ TapiCepPair self = new TapiCepPair();
+ self.left = left;
+ self.right = right;
+ return self;
+ }
+
+ public TapiCepRef left() {
+ return left;
+ }
+
+ public TapiCepRef right() {
+ return right;
+ }
+
+ public TapiNepPair getTapiNepPair() {
+ return TapiNepPair.create(left.getNepRef(), right.getNepRef());
+ }
+
+ public TapiCepPair invert() {
+ return TapiCepPair.create(right, left);
+ }
+
+ public boolean isSameNode() {
+ return left.getTopologyId().equals(right.getTopologyId()) && left.getNodeId().equals(right.getNodeId());
+ }
+
+ public Stream<TapiCepRef> stream() {
+ return Stream.of(left, right);
+ }
+
+ public String toString() {
+ return toStringHelper(getClass())
+ .add("left", left)
+ .add("right", right)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TapiCepPair)) {
+ return false;
+ }
+ TapiCepPair that = (TapiCepPair) o;
+ return Objects.equals(left, that.left) &&
+ Objects.equals(right, that.right);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(left, right);
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRef.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRef.java
new file mode 100644
index 0000000..15e3ecc
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRef.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Objects;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * TAPI Cep reference class.
+ * <p>
+ * TAPI reference class should be used in ODTN ServiceApplication
+ * in order to make independent ServiceApplication implementation from DCS.
+ */
+public final class TapiCepRef {
+
+ protected final Logger log = getLogger(getClass());
+
+ private final UUID topologyId;
+ private final UUID nodeId;
+ private final UUID nepId;
+ private final UUID cepId;
+
+ private TapiCepRef(String topologyId, String nodeId, String nepId, String cepId) {
+ this.topologyId = UUID.fromString(topologyId);
+ this.nodeId = UUID.fromString(nodeId);
+ this.nepId = UUID.fromString(nepId);
+ this.cepId = UUID.fromString(cepId);
+ }
+
+ public static TapiCepRef create(String topologyId, String nodeId, String nepId, String cepId) {
+ return new TapiCepRef(topologyId, nodeId, nepId, cepId);
+ }
+
+ public static TapiCepRef create(TapiNepRef nepRef, String cepId) {
+ return new TapiCepRef(nepRef.getTopologyId(), nepRef.getNodeId(), nepRef.getNepId(), cepId);
+ }
+
+ public String getTopologyId() {
+ return topologyId.toString();
+ }
+
+ public String getNodeId() {
+ return nodeId.toString();
+ }
+
+ public String getNepId() {
+ return nepId.toString();
+ }
+
+ public String getCepId() {
+ return cepId.toString();
+ }
+
+ public TapiNepRef getNepRef() {
+ return new TapiNepRef(topologyId.toString(), nodeId.toString(), nepId.toString());
+ }
+
+ public String toString() {
+ return toStringHelper(getClass())
+ .add("topologyId", topologyId)
+ .add("nodeId", nodeId)
+ .add("nepId", nepId)
+ .add("cepId", cepId)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TapiCepRef)) {
+ return false;
+ }
+ TapiCepRef that = (TapiCepRef) o;
+ return Objects.equals(topologyId, that.topologyId) &&
+ Objects.equals(nodeId, that.nodeId) &&
+ Objects.equals(nepId, that.nepId) &&
+ Objects.equals(cepId, that.cepId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(topologyId, nodeId, nepId, cepId);
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRefHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRefHandler.java
new file mode 100644
index 0000000..38acd75
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCepRefHandler.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.ceplist.ConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.DefaultConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectionendpoint.ParentNodeEdgePoint;
+import org.onosproject.yang.model.ModelObjectId;
+
+/**
+ * Utility class to deal with TAPI CepRef with DCS.
+ */
+public final class TapiCepRefHandler extends TapiObjectHandler<DefaultConnectionEndPoint> {
+
+ private TapiCepRefHandler() {
+ obj = new DefaultConnectionEndPoint();
+ }
+
+ public static TapiCepRefHandler create() {
+ return new TapiCepRefHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return (Uuid) obj.connectionEndPointId();
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {}
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return null;
+ }
+
+ public TapiCepRefHandler setCep(TapiCepRef cepRef) {
+ obj.topologyId(cepRef.getTopologyId());
+ obj.nodeId(cepRef.getNodeId());
+ obj.ownedNodeEdgePointId(cepRef.getNepId());
+ obj.connectionEndPointId(cepRef.getCepId());
+ return this;
+ }
+
+ public TapiCepRefHandler setCep(ConnectionEndPoint cep) {
+ obj.connectionEndPointId(cep.uuid());
+ ParentNodeEdgePoint parentNep = cep.parentNodeEdgePoint().get(0);
+ obj.topologyId(parentNep.topologyId());
+ obj.nodeId(parentNep.nodeId());
+ obj.ownedNodeEdgePointId(parentNep.ownedNodeEdgePointId());
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnection.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnection.java
new file mode 100644
index 0000000..f81ec1a
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnection.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+public final class TapiConnection {
+
+ private TapiCepPair ceps;
+ private List<TapiConnection> lowerConnections = new ArrayList<>();
+
+ private TapiConnection(TapiCepPair ceps) {
+ this.ceps = ceps;
+ }
+
+ public static TapiConnection create(TapiCepPair ceps) {
+ return new TapiConnection(ceps);
+ }
+
+ public static TapiConnection create(TapiCepRef left, TapiCepRef right) {
+ TapiCepPair cepPair = TapiCepPair.create(left, right);
+ return new TapiConnection(cepPair);
+ }
+
+ public TapiCepPair getCeps() {
+ return ceps;
+ }
+
+ public List<TapiConnection> getLowerConnections() {
+ return lowerConnections;
+ }
+
+ public TapiConnection addLowerConnection(TapiConnection lowerConnection) {
+ this.lowerConnections.add(lowerConnection);
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("ceps", ceps)
+ .add("lowerConnection", lowerConnections)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TapiConnection)) {
+ return false;
+ }
+ TapiConnection that = (TapiConnection) o;
+ return Objects.equals(ceps, that.ceps) &&
+ Objects.equals(lowerConnections, that.lowerConnections);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ceps, lowerConnections);
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectionHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectionHandler.java
new file mode 100644
index 0000000..b3d6f3e
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectionHandler.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.ConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.DefaultConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.DefaultLowerConnection;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.DefaultRoute;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.LowerConnection;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectionKeys;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.DefaultConnection;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ModelObjectId;
+
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
+
+/**
+ * Utility class to deal with TAPI Connection with DCS.
+ */
+public final class TapiConnectionHandler extends TapiObjectHandler<DefaultConnection> {
+
+ private TapiConnectionHandler() {
+ obj = new DefaultConnection();
+ setId();
+ }
+
+ public static TapiConnectionHandler create() {
+ return new TapiConnectionHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder().addChild(DefaultContext.class).build();
+ }
+
+ @Override
+ public ModelObjectData getChildModelObjectData() {
+
+ ConnectionKeys key = new ConnectionKeys();
+ key.uuid(getId());
+
+ DefaultConnectionEndPoint mObj = new DefaultConnectionEndPoint();
+
+ ModelObjectId mId = ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .addChild(DefaultConnection.class, key)
+ .build();
+
+ return DefaultModelObjectData.builder()
+ .addModelObject(mObj)
+ .identifier(mId)
+ .build();
+ }
+
+ public TapiConnectionHandler addCep(ConnectionEndPoint cep) {
+ obj.addToConnectionEndPoint(cep);
+ return this;
+ }
+
+ public TapiConnectionHandler addLowerConnection(DefaultConnection connection) {
+ DefaultLowerConnection lowerConnection = new DefaultLowerConnection();
+ lowerConnection.connectionId(connection.uuid());
+ obj.addToLowerConnection(lowerConnection);
+ return this;
+ }
+
+ public TapiConnectionHandler addRoute(DefaultRoute route) {
+ obj.addToRoute(route);
+ return this;
+ }
+
+ public List<TapiConnectionHandler> getLowerConnections() {
+
+ try {
+ return obj.lowerConnection().stream()
+ .map(LowerConnection::connectionId)
+ .map(id -> {
+ TapiConnectionHandler handler = new TapiConnectionHandler();
+ handler.setId(Uuid.fromString(id.toString()));
+ return handler;
+ }).collect(Collectors.toList());
+ } catch (NullPointerException e) {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectivityServiceHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectivityServiceHandler.java
new file mode 100644
index 0000000..89ac48e
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiConnectivityServiceHandler.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityServiceKeys;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.DefaultConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityservice.DefaultConnection;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityservice.EndPoint;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ModelObjectId;
+
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
+
+/**
+ * Utility class to deal with TAPI ConnectivityService with DCS.
+ */
+public final class TapiConnectivityServiceHandler extends TapiObjectHandler<DefaultConnectivityService> {
+
+ private TapiConnectivityServiceHandler() {
+ obj = new DefaultConnectivityService();
+ setId();
+ }
+
+ public static TapiConnectivityServiceHandler create() {
+ return new TapiConnectivityServiceHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder().addChild(DefaultContext.class).build();
+ }
+
+ @Override
+ public ModelObjectData getChildModelObjectData() {
+
+ ConnectivityServiceKeys key = new ConnectivityServiceKeys();
+ key.uuid(getId());
+
+ DefaultConnection mObj = new DefaultConnection();
+
+ ModelObjectId mId = ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .addChild(DefaultConnectivityService.class, key)
+ .build();
+
+ return DefaultModelObjectData.builder()
+ .addModelObject(mObj)
+ .identifier(mId)
+ .build();
+ }
+
+ public TapiConnectivityServiceHandler addSep(EndPoint sep) {
+ obj.addToEndPoint(sep);
+ return this;
+ }
+
+ public TapiConnectivityServiceHandler addConnection(Uuid connectionUuid) {
+ DefaultConnection connection = new DefaultConnection();
+ connection.connectionId(connectionUuid.toString());
+ obj.addToConnection(connection);
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextBuilder.java
deleted file mode 100644
index 720d436..0000000
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.odtn.utils.tapi;
-
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
-import org.onosproject.yang.model.ModelObjectId;
-
-/**
- * Utility builder class for TAPI context creation with DCS.
- */
-public final class TapiContextBuilder extends TapiInstanceBuilder {
-
- private DefaultContext context;
-
- private TapiContextBuilder(DefaultContext context) {
- this.context = context;
- }
-
- public static TapiContextBuilder builder(DefaultContext context) {
- return new TapiContextBuilder(context);
- }
-
- @Override
- public ModelObjectId getModelObjectId() {
- return ModelObjectId.builder().build();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public DefaultContext getModelObject() {
- return context;
- }
-
- @Override
- public Uuid getUuid() {
- return null;
- }
-}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextHandler.java
new file mode 100644
index 0000000..ff8e24d
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiContextHandler.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.DefaultConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.context.DefaultAugmentedTapiCommonContext;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.DefaultTopology;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ModelObjectId;
+
+/**
+ * Utility class to deal with TAPI Context with DCS.
+ */
+public final class TapiContextHandler extends TapiObjectHandler<DefaultContext> {
+
+ private TapiContextHandler() {
+ obj = new DefaultContext();
+ }
+
+ public static TapiContextHandler create() {
+ return new TapiContextHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return null;
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder().build();
+ }
+
+ @Override
+ public ModelObjectData getChildModelObjectData() {
+
+ ModelObjectId mId = ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .build();
+
+ DefaultTopology mObj = new DefaultTopology();
+
+ return DefaultModelObjectData.builder()
+ .addModelObject(mObj)
+ .identifier(mId)
+ .build();
+ }
+
+ public List<TapiConnectivityServiceHandler> getConnectivityServices() {
+
+ DefaultAugmentedTapiCommonContext augmentedContext = obj.augmentation(DefaultAugmentedTapiCommonContext.class);
+ try {
+ return augmentedContext.connectivityService().stream()
+ .map(connectivityService -> {
+ TapiConnectivityServiceHandler handler = TapiConnectivityServiceHandler.create();
+ handler.setModelObject((DefaultConnectivityService) connectivityService);
+ return handler;
+ }).collect(Collectors.toList());
+ } catch (NullPointerException e) {
+ return Collections.emptyList();
+ }
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityInputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityInputHandler.java
new file mode 100644
index 0000000..1a182b8
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityInputHandler.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.createconnectivityservice.CreateConnectivityServiceInput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.createconnectivityservice.DefaultCreateConnectivityServiceInput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.createconnectivityservice.createconnectivityserviceinput.EndPoint;
+
+/**
+ * Utility class to deal with TAPI RPC input with DCS.
+ */
+public final class TapiCreateConnectivityInputHandler
+ extends TapiRpcInputHandler<DefaultCreateConnectivityServiceInput> {
+
+ public List<EndPoint> getEndPoints() {
+ List<EndPoint> eps = CreateConnectivityServiceInput.class.cast(obj).endPoint();
+ if (eps == null) {
+ return Collections.emptyList();
+ }
+ return eps;
+ }
+
+ public List<String> getSips() {
+ return getEndPoints().stream()
+ .map(ep -> ep.serviceInterfacePoint().serviceInterfacePointId().toString())
+ .collect(Collectors.toList());
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityOutputHandler.java
new file mode 100644
index 0000000..f503072
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiCreateConnectivityOutputHandler.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.createconnectivityservice.DefaultCreateConnectivityServiceOutput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.createconnectivityservice.createconnectivityserviceoutput.DefaultService;
+
+/**
+ * Utility class to deal with TAPI RPC output with DCS.
+ */
+public final class TapiCreateConnectivityOutputHandler
+ extends TapiRpcOutputHandler<DefaultCreateConnectivityServiceOutput> {
+
+ private TapiCreateConnectivityOutputHandler() {
+ obj = new DefaultCreateConnectivityServiceOutput();
+ }
+
+ public static TapiCreateConnectivityOutputHandler create() {
+ return new TapiCreateConnectivityOutputHandler();
+ }
+
+ public TapiCreateConnectivityOutputHandler addService(ConnectivityService res) {
+ DefaultService rpcOutputService = new DefaultService();
+ rpcOutputService.uuid(res.uuid());
+ res.connection().forEach(rpcOutputService::addToConnection);
+ res.endPoint().forEach(rpcOutputService::addToEndPoint);
+ obj.service(rpcOutputService);
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityInputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityInputHandler.java
new file mode 100644
index 0000000..75d854e
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityInputHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.UUID;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.deleteconnectivityservice.DefaultDeleteConnectivityServiceInput;
+
+/**
+ * Utility class to deal with TAPI RPC input with DCS.
+ */
+public final class TapiDeleteConnectivityInputHandler
+ extends TapiRpcInputHandler<DefaultDeleteConnectivityServiceInput> {
+
+ public Uuid getId() {
+ String idOrName = obj.serviceIdOrName();
+ UUID uuid = UUID.fromString(idOrName);
+ return Uuid.fromString(uuid.toString());
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityOutputHandler.java
new file mode 100644
index 0000000..34186a4
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiDeleteConnectivityOutputHandler.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.deleteconnectivityservice.DefaultDeleteConnectivityServiceOutput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.deleteconnectivityservice.deleteconnectivityserviceoutput.DefaultService;
+
+/**
+ * Utility class to deal with TAPI RPC output with DCS.
+ */
+public final class TapiDeleteConnectivityOutputHandler
+ extends TapiRpcOutputHandler<DefaultDeleteConnectivityServiceOutput> {
+
+ private TapiDeleteConnectivityOutputHandler() {
+ obj = new DefaultDeleteConnectivityServiceOutput();
+ }
+
+ public static TapiDeleteConnectivityOutputHandler create() {
+ return new TapiDeleteConnectivityOutputHandler();
+ }
+
+ public TapiDeleteConnectivityOutputHandler addService(ConnectivityService res) {
+ log.info("Output service: {}", res);
+ DefaultService rpcOutputService = new DefaultService();
+ rpcOutputService.uuid(res.uuid());
+ obj.service(rpcOutputService);
+ return this;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsInputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsInputHandler.java
new file mode 100644
index 0000000..ca01812
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsInputHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.UUID;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.getconnectivityservicedetails.DefaultGetConnectivityServiceDetailsInput;
+
+/**
+ * Utility class to deal with TAPI RPC input with DCS.
+ */
+public final class TapiGetConnectivityDetailsInputHandler
+ extends TapiRpcInputHandler<DefaultGetConnectivityServiceDetailsInput> {
+
+ public Uuid getId() {
+ String idOrName = obj.serviceIdOrName();
+ UUID uuid = UUID.fromString(idOrName);
+ return Uuid.fromString(uuid.toString());
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsOutputHandler.java
new file mode 100644
index 0000000..1d7b02d
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityDetailsOutputHandler.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.getconnectivityservicedetails.DefaultGetConnectivityServiceDetailsOutput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.getconnectivityservicedetails.getconnectivityservicedetailsoutput.DefaultService;
+
+/**
+ * Utility class to deal with TAPI RPC output with DCS.
+ */
+public final class TapiGetConnectivityDetailsOutputHandler
+ extends TapiRpcOutputHandler<DefaultGetConnectivityServiceDetailsOutput> {
+
+ private TapiGetConnectivityDetailsOutputHandler() {
+ obj = new DefaultGetConnectivityServiceDetailsOutput();
+ }
+
+ public static TapiGetConnectivityDetailsOutputHandler create() {
+ return new TapiGetConnectivityDetailsOutputHandler();
+ }
+
+ public TapiGetConnectivityDetailsOutputHandler addService(ConnectivityService res) {
+ DefaultService rpcOutputService = new DefaultService();
+ rpcOutputService.uuid(res.uuid());
+ res.connection().forEach(rpcOutputService::addToConnection);
+ res.endPoint().forEach(rpcOutputService::addToEndPoint);
+ obj.service(rpcOutputService);
+ return this;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityListOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityListOutputHandler.java
new file mode 100644
index 0000000..99bc678
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetConnectivityListOutputHandler.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityService;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.getconnectivityservicelist.DefaultGetConnectivityServiceListOutput;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.getconnectivityservicelist.getconnectivityservicelistoutput.DefaultService;
+
+/**
+ * Utility class to deal with TAPI RPC output with DCS.
+ */
+public final class TapiGetConnectivityListOutputHandler
+ extends TapiRpcOutputHandler<DefaultGetConnectivityServiceListOutput> {
+
+ private TapiGetConnectivityListOutputHandler() {
+ obj = new DefaultGetConnectivityServiceListOutput();
+ }
+
+ public static TapiGetConnectivityListOutputHandler create() {
+ return new TapiGetConnectivityListOutputHandler();
+ }
+
+ public TapiGetConnectivityListOutputHandler addService(ConnectivityService res) {
+ DefaultService rpcOutputService = new DefaultService();
+ rpcOutputService.uuid(res.uuid());
+ res.connection().forEach(rpcOutputService::addToConnection);
+ res.endPoint().forEach(rpcOutputService::addToEndPoint);
+ obj.addToService(rpcOutputService);
+ return this;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetSipListOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetSipListOutputHandler.java
new file mode 100644
index 0000000..95143d6
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGetSipListOutputHandler.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.getserviceinterfacepointlist.DefaultGetServiceInterfacePointListOutput;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.getserviceinterfacepointlist.getserviceinterfacepointlistoutput.DefaultSip;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.getserviceinterfacepointlist.getserviceinterfacepointlistoutput.Sip;
+
+/**
+ * Utility class to deal with TAPI RPC output with DCS.
+ */
+public final class TapiGetSipListOutputHandler
+ extends TapiRpcOutputHandler<DefaultGetServiceInterfacePointListOutput> {
+
+ private TapiGetSipListOutputHandler() {
+ obj = new DefaultGetServiceInterfacePointListOutput();
+ }
+
+ public static TapiGetSipListOutputHandler create() {
+ return new TapiGetSipListOutputHandler();
+ }
+
+ public TapiGetSipListOutputHandler addSip(Uuid sipId) {
+ Sip sip = new DefaultSip();
+ sip.uuid(sipId);
+ obj.addToSip(sip);
+ return this;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGlobalClassUtil.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGlobalClassUtil.java
index 2af7fed..200c623 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGlobalClassUtil.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiGlobalClassUtil.java
@@ -25,35 +25,35 @@
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.UUID;
import org.slf4j.Logger;
+
import static org.slf4j.LoggerFactory.getLogger;
/**
* Utility methods dealing with TAPI modelObject which includes global class grouping.
- *
+ * <p>
* <p> tapi-common@2018-03-07.yang
* grouping global-class {
- * leaf uuid {
- * type uuid;
- * }
- * list name {
- * key 'value-name';
- * uses name-and-value;
- * }
+ * leaf uuid {
+ * type uuid;
* }
- *
+ * list name {
+ * key 'value-name';
+ * uses name-and-value;
+ * }
+ * }
+ * <p>
* grouping name-and-value {
- * leaf value-name {
- * type string;
- * description "The name of the value. The value need not have a name.";
- * }
- * leaf value {
- * type string;
- * description "The value";
- * }
- * description "A scoped name-value pair";
+ * leaf value-name {
+ * type string;
+ * description "The name of the value. The value need not have a name.";
+ * }
+ * leaf value {
+ * type string;
+ * description "The value";
+ * }
+ * description "A scoped name-value pair";
* }
* </p>
*/
@@ -65,14 +65,13 @@
}
/**
- * Generate and set Uuid for the ModelObject.
- * @param obj ModelObject
- * @param <T> type of ModelObject
- * @return generated uuid
+ * Set uuid for the ModelObject.
+ *
+ * @param obj ModelObject
+ * @param uuid Uuid
+ * @param <T> Type of ModelObject
*/
- public static <T extends ModelObject> Uuid setUuid(T obj) {
- Uuid uuid = Uuid.of(UUID.randomUUID().toString());
-
+ public static <T extends ModelObject> void setUuid(T obj, Uuid uuid) {
@SuppressWarnings("unchecked")
Class<T> cls = (Class<T>) obj.getClass();
try {
@@ -81,15 +80,35 @@
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.error("Exception thrown", e);
}
+ }
+
+ /**
+ * Get uuid for the ModelObject.
+ *
+ * @param obj ModelObject
+ * @param <T> Type of ModelObject
+ * @return Uuid
+ */
+ public static <T extends ModelObject> Uuid getUuid(T obj) {
+ Uuid uuid = null;
+ @SuppressWarnings("unchecked")
+ Class<T> cls = (Class<T>) obj.getClass();
+ try {
+ Method method = cls.getMethod("uuid");
+ uuid = (Uuid) method.invoke(obj);
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ log.error("Exception thrown", e);
+ }
return uuid;
}
/**
* Add key-value to the ModelObject as "name-and-value" list.
+ *
* @param obj ModelObject
- * @param kvs key-value map
- * @param <T> type of ModelObject
+ * @param kvs Key-value map
+ * @param <T> Type of ModelObject
*/
public static <T extends ModelObject> void addNameList(T obj, Map<String, String> kvs) {
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiInstanceBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiInstanceBuilder.java
deleted file mode 100644
index dc4fd10..0000000
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiInstanceBuilder.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.odtn.utils.tapi;
-
-import java.util.List;
-import org.onlab.util.XmlString;
-import org.onosproject.config.DynamicConfigService;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultModelObjectData;
-import org.onosproject.yang.model.ModelConverter;
-import org.onosproject.yang.model.ModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-import org.onosproject.yang.model.ResourceData;
-
-import static org.onlab.osgi.DefaultServiceDirectory.getService;
-import static org.onosproject.odtn.utils.YangToolUtil.toCharSequence;
-import static org.onosproject.odtn.utils.YangToolUtil.toCompositeData;
-import static org.onosproject.odtn.utils.YangToolUtil.toXmlCompositeStream;
-
-import org.onosproject.yang.model.ResourceId;
-import org.slf4j.Logger;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Utility builder class for TAPI modelobject creation with DCS.
- */
-public abstract class TapiInstanceBuilder {
-
- public static final String ONOS_CP = "onos-cp";
-
- public static final String DEVICE_ID = "device-id";
-
- public static final String ODTN_PORT_TYPE = "odtn-port-type";
-
- private final Logger log = getLogger(getClass());
-
- private ModelConverter modelConverter;
- private DynamicConfigService dcs;
-
- /**
- * Generate DCS modelObjectData.
- *
- * @return ModelObjectId of build target
- */
- public abstract ModelObjectId getModelObjectId();
-
- /**
- * Get modelObject instance.
- *
- * @param <T> build target class
- * @return ModelObject of build target
- */
- public abstract <T extends ModelObject> T getModelObject();
-
- /**
- * Get modelObject uuid.
- *
- * @return Uuid of build target
- */
- public abstract Uuid getUuid();
-
- /**
- * Get modelObjectData instance.
- *
- * @return ModelObjectData of build target
- */
- public ModelObjectData getModelObjectData() {
- ModelObject obj = getModelObject();
- ModelObjectId objId = getModelObjectId();
-
- return DefaultModelObjectData.builder()
- .addModelObject(obj)
- .identifier(objId)
- .build();
- }
-
- /**
- * Add built modelObject to Dcs store.
- */
- public void build() {
- dcs = getService(DynamicConfigService.class);
- modelConverter = getService(ModelConverter.class);
- addModelObjectDataToDcs(getModelObjectData());
- }
-
- private void addModelObjectDataToDcs(ModelObjectData input) {
-
- ResourceData rnode = modelConverter.createDataNode(input);
-
- // for debug
- CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(rnode)));
- log.info("XML:\n{}", XmlString.prettifyXml(strNode));
-
- addResourceDataToDcs(rnode);
- }
-
- private void addResourceDataToDcs(ResourceData input) {
- addResourceDataToDcs(input, input.resourceId());
- }
-
- private void addResourceDataToDcs(ResourceData input, ResourceId rid) {
- if (input == null || input.dataNodes() == null) {
- return;
- }
- List<DataNode> dataNodes = input.dataNodes();
- for (DataNode node : dataNodes) {
- dcs.createNode(rid, node);
- }
- }
-
-}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkHandler.java
similarity index 71%
rename from apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkBuilder.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkHandler.java
index 31107ae..2af1cb1 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkBuilder.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLinkHandler.java
@@ -24,40 +24,39 @@
import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.TopologyKeys;
import org.onosproject.yang.model.ModelObjectId;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
/**
- * Utility builder class for TAPI link creation with DCS.
+ * Utility class to deal with TAPI Link with DCS.
*/
-public final class TapiLinkBuilder extends TapiInstanceBuilder {
+public final class TapiLinkHandler extends TapiObjectHandler<DefaultLink> {
private Uuid topologyUuid;
- private DefaultLink link = new DefaultLink();
- private TapiLinkBuilder() {
- setUuid(link);
+ private TapiLinkHandler() {
+ obj = new DefaultLink();
+ setId();
}
- public static TapiLinkBuilder builder() {
- return new TapiLinkBuilder();
- }
-
- public TapiLinkBuilder setTopologyUuid(Uuid topologyUuid) {
- this.topologyUuid = topologyUuid;
- return this;
- }
-
- public TapiLinkBuilder addNep(TapiNepRef nepRef) {
- DefaultNodeEdgePoint nep = new DefaultNodeEdgePoint();
- nep.topologyId(nepRef.getTopologyId());
- nep.nodeId(nepRef.getNodeId());
- nep.ownedNodeEdgePointId(nepRef.getNepId());
- link.addToNodeEdgePoint(nep);
- return this;
+ public static TapiLinkHandler create() {
+ return new TapiLinkHandler();
}
@Override
- public ModelObjectId getModelObjectId() {
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ checkNotNull(topologyUuid);
TopologyKeys topologyKey = new TopologyKeys();
topologyKey.uuid(topologyUuid);
@@ -67,15 +66,18 @@
.build();
}
- @Override
- @SuppressWarnings("unchecked")
- public DefaultLink getModelObject() {
- return link;
+ public TapiLinkHandler setTopologyUuid(Uuid topologyUuid) {
+ this.topologyUuid = topologyUuid;
+ return this;
}
- @Override
- public Uuid getUuid() {
- return link.uuid();
+ public TapiLinkHandler addNep(TapiNepRef nepRef) {
+ DefaultNodeEdgePoint nep = new DefaultNodeEdgePoint();
+ nep.topologyId(nepRef.getTopologyId());
+ nep.nodeId(nepRef.getNodeId());
+ nep.ownedNodeEdgePointId(nepRef.getNepId());
+ obj.addToNodeEdgePoint(nep);
+ return this;
}
}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLocalClassUtil.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLocalClassUtil.java
new file mode 100644
index 0000000..f593d20
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiLocalClassUtil.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.globalclass.DefaultName;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.globalclass.Name;
+import org.onosproject.yang.model.ModelObject;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Utility methods dealing with TAPI modelObject which includes local class grouping.
+ * <p>
+ * <p> tapi-common@2018-03-07.yang
+ * grouping local-class {
+ * leaf local-id {
+ * type string;
+ * }
+ * list name {
+ * key 'value-name';
+ * uses name-and-value;
+ * }
+ * }
+ * <p>
+ * grouping name-and-value {
+ * leaf value-name {
+ * type string;
+ * description "The name of the value. The value need not have a name.";
+ * }
+ * leaf value {
+ * type string;
+ * description "The value";
+ * }
+ * description "A scoped name-value pair";
+ * }
+ * </p>
+ */
+public final class TapiLocalClassUtil {
+
+ private static final Logger log = getLogger(TapiLocalClassUtil.class);
+
+ private TapiLocalClassUtil() {
+ }
+
+ /**
+ * Set local-id for the ModelObject.
+ *
+ * @param obj ModelObject
+ * @param localId LocalId
+ * @param <T> Type of ModelObject
+ */
+ public static <T extends ModelObject> void setLocalId(T obj, String localId) {
+ @SuppressWarnings("unchecked")
+ Class<T> cls = (Class<T>) obj.getClass();
+ try {
+ Method method = cls.getMethod("localId", String.class);
+ method.invoke(obj, localId);
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ log.error("Exception thrown", e);
+ }
+ }
+
+ /**
+ * Get local-id for the ModelObject.
+ *
+ * @param obj ModelObject
+ * @param <T> Type of ModelObject
+ * @return Local-id
+ */
+ public static <T extends ModelObject> String getLocalId(T obj) {
+ String localId = null;
+ @SuppressWarnings("unchecked")
+ Class<T> cls = (Class<T>) obj.getClass();
+ try {
+ Method method = cls.getMethod("localId");
+ localId = (String) method.invoke(obj);
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ log.error("Exception thrown", e);
+ }
+
+ return localId;
+ }
+
+ /**
+ * Add key-value to the ModelObject as "name-and-value" list.
+ *
+ * @param obj ModelObject
+ * @param kvs Key-value map
+ * @param <T> Type of ModelObject
+ */
+ public static <T extends ModelObject> void addNameList(T obj, Map<String, String> kvs) {
+
+ @SuppressWarnings("unchecked")
+ Class<T> cls = (Class<T>) obj.getClass();
+ try {
+ Method method = cls.getMethod("addToName", Name.class);
+
+ for (Entry<String, String> kv : kvs.entrySet()) {
+ DefaultName prop = new DefaultName();
+ prop.valueName(kv.getKey());
+ prop.value(kv.getValue());
+ method.invoke(obj, prop);
+ }
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ log.error("Exception thrown", e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepBuilder.java
deleted file mode 100644
index 1148511..0000000
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepBuilder.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.odtn.utils.tapi;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.onosproject.net.ConnectPoint;
-
-import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.addNameList;
-import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
-
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.node.DefaultOwnedNodeEdgePoint;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.nodeedgepoint.DefaultMappedServiceInterfacePoint;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.DefaultNode;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.NodeKeys;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.DefaultTopology;
-import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.TopologyKeys;
-import org.onosproject.yang.model.ModelObjectId;
-
-/**
- * Utility builder class for TAPI nep creation with DCS.
- */
-public final class TapiNepBuilder extends TapiInstanceBuilder {
-
- private Uuid topologyUuid;
- private Uuid nodeUuid;
- private DefaultOwnedNodeEdgePoint nep = new DefaultOwnedNodeEdgePoint();
- private ConnectPoint cp;
- private Map<String, String> kvs = new HashMap<>();
-
- private TapiNepBuilder() {
- setUuid(nep);
- }
-
- public static TapiNepBuilder builder() {
- return new TapiNepBuilder();
- }
-
- public TapiNepBuilder setTopologyUuid(Uuid topologyUuid) {
- this.topologyUuid = topologyUuid;
- return this;
- }
-
- public TapiNepBuilder setNodeUuid(Uuid nodeUuid) {
- this.nodeUuid = nodeUuid;
- return this;
- }
-
- public TapiNepBuilder setConnectPoint(ConnectPoint cp) {
- kvs.put(ONOS_CP, cp.toString());
- addNameList(nep, kvs);
- return this;
- }
-
- public TapiNepBuilder addSip(Uuid sipUuid) {
- DefaultMappedServiceInterfacePoint mappedSip = new DefaultMappedServiceInterfacePoint();
- mappedSip.serviceInterfacePointId(sipUuid);
- nep.addToMappedServiceInterfacePoint(mappedSip);
- return this;
- }
-
- public ConnectPoint getConnectPoint() {
- return cp;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public DefaultOwnedNodeEdgePoint getModelObject() {
- return nep;
- }
-
- @Override
- public Uuid getUuid() {
- return nep.uuid();
- }
-
- @Override
- public ModelObjectId getModelObjectId() {
- TopologyKeys topologyKey = new TopologyKeys();
- topologyKey.uuid(topologyUuid);
-
- NodeKeys nodeKey = new NodeKeys();
- nodeKey.uuid(nodeUuid);
-
- return ModelObjectId.builder()
- .addChild(DefaultContext.class)
- .addChild(DefaultTopology.class, topologyKey)
- .addChild(DefaultNode.class, nodeKey)
- .build();
- }
-
-}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepHandler.java
new file mode 100644
index 0000000..2934b3e
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepHandler.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.onosproject.net.ConnectPoint;
+
+import static org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.addNameList;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
+
+import org.onosproject.net.Port;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.ceplist.DefaultConnectionEndPoint;
+
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.context.topology.node.ownednodeedgepoint.DefaultAugmentedTapiTopologyOwnedNodeEdgePoint;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.node.DefaultOwnedNodeEdgePoint;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.nodeedgepoint.DefaultMappedServiceInterfacePoint;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.DefaultNode;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topology.NodeKeys;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.DefaultTopology;
+import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.TopologyKeys;
+import org.onosproject.yang.model.ModelObjectId;
+
+/**
+ * Utility class to deal with TAPI NEP with DCS.
+ */
+public final class TapiNepHandler extends TapiObjectHandler<DefaultOwnedNodeEdgePoint> {
+
+ private Uuid topologyUuid;
+ private Uuid nodeUuid;
+
+ private ConnectPoint cp;
+ private Map<String, String> kvs = new HashMap<>();
+
+ private TapiNepHandler() {
+ obj = new DefaultOwnedNodeEdgePoint();
+ setId();
+ }
+
+ public static TapiNepHandler create() {
+ return new TapiNepHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ TopologyKeys topologyKey = new TopologyKeys();
+ topologyKey.uuid(topologyUuid);
+
+ NodeKeys nodeKey = new NodeKeys();
+ nodeKey.uuid(nodeUuid);
+
+ return ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .addChild(DefaultTopology.class, topologyKey)
+ .addChild(DefaultNode.class, nodeKey)
+ .build();
+ }
+
+ public TapiNepHandler setTopologyUuid(Uuid topologyUuid) {
+ this.topologyUuid = topologyUuid;
+ return this;
+ }
+
+ public TapiNepHandler setNodeUuid(Uuid nodeUuid) {
+ this.nodeUuid = nodeUuid;
+ return this;
+ }
+
+ public TapiNepHandler setPort(Port port) {
+ ConnectPoint cp = new ConnectPoint(port.element().id(), port.number());
+ kvs.put(ODTN_PORT_TYPE, port.annotations().value(ODTN_PORT_TYPE));
+ kvs.put(CONNECTION_ID, port.annotations().value(CONNECTION_ID));
+ addNameList(obj, kvs);
+ return setConnectPoint(cp);
+ }
+
+ public TapiNepHandler setConnectPoint(ConnectPoint cp) {
+ kvs.put(ONOS_CP, cp.toString());
+ addNameList(obj, kvs);
+ return this;
+ }
+
+ public TapiNepHandler addSip(Uuid sipUuid) {
+ DefaultMappedServiceInterfacePoint mappedSip = new DefaultMappedServiceInterfacePoint();
+ mappedSip.serviceInterfacePointId(sipUuid);
+ obj.addToMappedServiceInterfacePoint(mappedSip);
+ return this;
+ }
+
+ public TapiNepHandler addCep(DefaultConnectionEndPoint cep) {
+ DefaultAugmentedTapiTopologyOwnedNodeEdgePoint augmentNep =
+ new DefaultAugmentedTapiTopologyOwnedNodeEdgePoint();
+ augmentNep.addToConnectionEndPoint(cep);
+ obj.addAugmentation(augmentNep);
+ return this;
+ }
+
+ public ConnectPoint getConnectPoint() {
+ return cp;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepPair.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepPair.java
new file mode 100644
index 0000000..a442586
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepPair.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.Objects;
+import java.util.stream.Stream;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * TAPI NepRef pair class for representation of endpoints of single connection.
+ */
+public class TapiNepPair {
+
+ private TapiNepRef left;
+ private TapiNepRef right;
+
+ public TapiNepPair() {
+ }
+
+ public static TapiNepPair create(TapiNepRef left, TapiNepRef right) {
+ TapiNepPair self = new TapiNepPair();
+ self.left = left;
+ self.right = right;
+ return self;
+ }
+
+ public TapiNepRef left() {
+ return left;
+ }
+
+ public TapiNepRef right() {
+ return right;
+ }
+
+ public TapiNepPair invert() {
+ return TapiNepPair.create(right, left);
+ }
+
+ public boolean isSameNode() {
+ return left.getTopologyId().equals(right.getTopologyId()) && left.getNodeId().equals(right.getNodeId());
+ }
+
+ public Stream<TapiNepRef> stream() {
+ return Stream.of(left, right);
+ }
+
+ public String toString() {
+ return toStringHelper(getClass())
+ .add("left", left)
+ .add("right", right)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TapiNepPair)) {
+ return false;
+ }
+ TapiNepPair that = (TapiNepPair) o;
+ return Objects.equals(left, that.left) &&
+ Objects.equals(right, that.right);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(left, right);
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepRef.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepRef.java
index d837362..af4d299 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepRef.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNepRef.java
@@ -16,21 +16,48 @@
package org.onosproject.odtn.utils.tapi;
+import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import java.util.UUID;
+import java.util.stream.Collectors;
import org.onosproject.net.ConnectPoint;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.hash;
+import static org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID;
+import static org.onosproject.odtn.utils.tapi.TapiObjectHandler.ODTN_PORT_TYPE;
+import static org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID;
+import org.onosproject.net.DeviceId;
+import org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery;
+import org.slf4j.Logger;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * TAPI Nep reference class.
+ *
+ * TAPI reference class should be used in ODTN ServiceApplication
+ * in order to make independent ServiceApplication implementation from DCS.
+ */
public class TapiNepRef {
+ protected final Logger log = getLogger(getClass());
+
private final UUID topologyId;
private final UUID nodeId;
private final UUID nepId;
+
+ // Annotations to be used for reference of related TAPI objects.
private UUID sipId = null;
+ private List<UUID> cepIds = Collections.emptyList();
+
+ // Annotations to be used for OpenConfig configuration.
private ConnectPoint cp = null;
+ private OdtnDeviceDescriptionDiscovery.OdtnPortType portType = null;
+ private String connectionId = null;
TapiNepRef(String topologyId, String nodeId, String nepId) {
this.topologyId = UUID.fromString(topologyId);
@@ -60,27 +87,89 @@
.orElse(null);
}
+ public List<String> getCepIds() {
+ return cepIds.stream().map(UUID::toString).collect(Collectors.toList());
+ }
+
+ public OdtnDeviceDescriptionDiscovery.OdtnPortType getPortType() {
+ return portType;
+ }
+
public ConnectPoint getConnectPoint() {
return cp;
}
+ public String getConnectionId() {
+ return connectionId;
+ }
+
+
public TapiNepRef setSipId(String sipId) {
this.sipId = UUID.fromString(sipId);
return this;
}
+ public TapiNepRef setCepIds(List<String> cepIds) {
+ this.cepIds = cepIds.stream().map(UUID::fromString).collect(Collectors.toList());
+ return this;
+ }
+
+ public TapiNepRef setPortType(String portType) {
+ this.portType = Optional.ofNullable(portType)
+ .map(OdtnDeviceDescriptionDiscovery.OdtnPortType::fromValue)
+ .orElse(null);
+ return this;
+ }
+
public TapiNepRef setConnectPoint(ConnectPoint cp) {
this.cp = cp;
return this;
}
+ public TapiNepRef setConnectionId(String connectionId) {
+ this.connectionId = connectionId;
+ return this;
+ }
+
+ /**
+ * Check if this Nep matches input filter condition.
+ *
+ * @param key Filter key
+ * @param value Filter value
+ * @return If match or not
+ */
+ public boolean is(String key, String value) {
+ checkNotNull(key);
+ checkNotNull(value);
+ switch (key) {
+ case DEVICE_ID:
+ return value.equals(
+ Optional.ofNullable(cp)
+ .map(ConnectPoint::deviceId)
+ .map(DeviceId::toString)
+ .orElse(null));
+ case ODTN_PORT_TYPE:
+ return value.equals(
+ Optional.ofNullable(portType)
+ .map(OdtnDeviceDescriptionDiscovery.OdtnPortType::value)
+ .orElse(null));
+ case CONNECTION_ID:
+ return value.equals(connectionId);
+ default:
+ log.warn("Unknown key: {}", key);
+ return true;
+ }
+ }
+
public String toString() {
return toStringHelper(getClass())
-// .add("topologyId", topologyId)
+ .add("topologyId", topologyId)
.add("nodeId", nodeId)
.add("nepId", nepId)
.add("sipId", sipId)
.add("connectPoint", cp)
+ .add("portType", portType)
+ .add("connectionId", connectionId)
.toString();
}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeHandler.java
similarity index 69%
rename from apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeBuilder.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeHandler.java
index 21e812c..1d897ad 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeBuilder.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeHandler.java
@@ -18,7 +18,10 @@
import java.util.HashMap;
import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.addNameList;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
import org.onosproject.net.DeviceId;
@@ -31,51 +34,35 @@
import org.onosproject.yang.model.ModelObjectId;
/**
- * Utility builder class for TAPI node creation with DCS.
+ * Utility class to deal with TAPI Node with DCS.
*/
-public final class TapiNodeBuilder extends TapiInstanceBuilder {
+public final class TapiNodeHandler extends TapiObjectHandler<DefaultNode> {
private Uuid topologyUuid;
- private DefaultNode node = new DefaultNode();
- private TapiNodeBuilder() {
- setUuid(node);
+ private TapiNodeHandler() {
+ obj = new DefaultNode();
+ setId();
}
- public static TapiNodeBuilder builder() {
- return new TapiNodeBuilder();
- }
-
- public TapiNodeBuilder setTopologyUuid(Uuid topologyUuid) {
- this.topologyUuid = topologyUuid;
- return this;
- }
-
- public TapiNodeBuilder addNep(OwnedNodeEdgePoint nep) {
- node.addToOwnedNodeEdgePoint(nep);
- return this;
- }
-
- public TapiNodeBuilder setDeviceId(DeviceId deviceId) {
- Map<String, String> kvs = new HashMap<>();
- kvs.put(DEVICE_ID, deviceId.toString());
- addNameList(node, kvs);
- return this;
+ public static TapiNodeHandler create() {
+ return new TapiNodeHandler();
}
@Override
- @SuppressWarnings("unchecked")
- public DefaultNode getModelObject() {
- return node;
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
}
@Override
- public Uuid getUuid() {
- return node.uuid();
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
}
@Override
- public ModelObjectId getModelObjectId() {
+ public ModelObjectId getParentModelObjectId() {
+ checkNotNull(topologyUuid);
+
TopologyKeys topologyKey = new TopologyKeys();
topologyKey.uuid(topologyUuid);
return ModelObjectId.builder()
@@ -84,4 +71,21 @@
.build();
}
+ public TapiNodeHandler setTopologyUuid(Uuid topologyUuid) {
+ this.topologyUuid = topologyUuid;
+ return this;
+ }
+
+ public TapiNodeHandler addNep(OwnedNodeEdgePoint nep) {
+ obj.addToOwnedNodeEdgePoint(nep);
+ return this;
+ }
+
+ public TapiNodeHandler setDeviceId(DeviceId deviceId) {
+ Map<String, String> kvs = new HashMap<>();
+ kvs.put(DEVICE_ID, deviceId.toString());
+ addNameList(obj, kvs);
+ return this;
+ }
+
}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeRef.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeRef.java
index ae2a968..8db2005 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeRef.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiNodeRef.java
@@ -21,10 +21,23 @@
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.hash;
+import static org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID;
+import org.slf4j.Logger;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * TAPI Node reference class.
+ *
+ * TAPI reference class should be used in ODTN ServiceApplication
+ * in order to make independent ServiceApplication implementation from DCS.
+ */
public class TapiNodeRef {
+ protected final Logger log = getLogger(getClass());
+
private final UUID topologyId;
private final UUID nodeId;
private DeviceId deviceId;
@@ -51,9 +64,30 @@
return this;
}
+ /**
+ * Check if this Node matches input filter condition.
+ *
+ * @param key Filter key
+ * @param value Filter value
+ * @return If match or not
+ */
+ public boolean is(String key, String value) {
+ checkNotNull(value);
+ switch (key) {
+ case DEVICE_ID:
+ if (deviceId == null) {
+ return false;
+ }
+ return value.equals(deviceId.toString());
+ default:
+ log.warn("Unknown key: {}", key);
+ return true;
+ }
+ }
+
public String toString() {
return toStringHelper(getClass())
-// .add("topologyId", topologyId)
+ .add("topologyId", topologyId)
.add("nodeId", nodeId)
.add("deviceId", deviceId)
.toString();
@@ -77,4 +111,5 @@
return hash(topologyId, nodeId);
}
-}
+
+}
\ No newline at end of file
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiObjectHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiObjectHandler.java
new file mode 100644
index 0000000..05cbc57
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiObjectHandler.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.List;
+import java.util.UUID;
+import org.apache.commons.lang.NotImplementedException;
+import org.onlab.util.XmlString;
+import org.onosproject.config.DynamicConfigService;
+import org.onosproject.config.Filter;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.DefaultResourceData;
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ModelObjectId;
+import org.onosproject.yang.model.ResourceData;
+
+import static org.onlab.osgi.DefaultServiceDirectory.getService;
+import static org.onosproject.odtn.utils.YangToolUtil.toCharSequence;
+import static org.onosproject.odtn.utils.YangToolUtil.toCompositeData;
+import static org.onosproject.odtn.utils.YangToolUtil.toXmlCompositeStream;
+
+import org.onosproject.yang.model.ResourceId;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Utility abstract class to deal with TAPI ModelObject with DCS.
+ *
+ * @param <T> modelObject to be dealt with
+ */
+public abstract class TapiObjectHandler<T extends ModelObject> {
+
+ public static final String ONOS_CP = "onos-cp";
+ public static final String DEVICE_ID = "device-id";
+ public static final String ODTN_PORT_TYPE = "odtn-port-type";
+
+ protected final Logger log = getLogger(getClass());
+
+ protected ModelConverter modelConverter;
+ protected DynamicConfigService dcs;
+
+ protected T obj;
+
+ /**
+ * Get modelObject uuid.
+ *
+ * @return Uuid
+ */
+ public Uuid getId() {
+ return getIdDetail();
+ }
+
+ /**
+ * Generate and set modelObject uuid.
+ */
+ public void setId() {
+ Uuid uuid = Uuid.of(UUID.randomUUID().toString());
+ setIdDetail(uuid);
+ }
+
+ /**
+ * Set modelObject uuid.
+ *
+ * @param uuid Uuid
+ */
+ public void setId(Uuid uuid) {
+ setIdDetail(uuid);
+ }
+
+ /**
+ * Get modelObject uuid, to be implemented in sub classes.
+ *
+ * @return Uuid
+ */
+ protected abstract Uuid getIdDetail();
+
+ /**
+ * Set modelObject uuid, to be implemented in sub classes.
+ *
+ * @param uuid Uuid
+ */
+ protected abstract void setIdDetail(Uuid uuid);
+
+ /**
+ * Generate DCS modelObjectId for parent node.
+ *
+ * @return ModelObjectId of parent node
+ */
+ public abstract ModelObjectId getParentModelObjectId();
+
+ /**
+ * Get modelObject instance.
+ *
+ * @return ModelObject of target node
+ */
+ public T getModelObject() {
+ return obj;
+ }
+
+ /**
+ * Set modelObject instance.
+ *
+ * @param newObj ModelObject to be set
+ */
+ public void setModelObject(T newObj) {
+ obj = newObj;
+ }
+
+ /**
+ * Get modelObjectData instance.
+ *
+ * @return ModelObjectData of target node
+ */
+ public ModelObjectData getModelObjectData() {
+ ModelObject obj = getModelObject();
+ ModelObjectId objId = getParentModelObjectId();
+
+ return DefaultModelObjectData.builder()
+ .addModelObject(obj)
+ .identifier(objId)
+ .build();
+ }
+
+ /**
+ * Get modelObjectData instance for child node.
+ * <p>
+ * This modelObjectData is needed for read / update / delete operation
+ * to extract ResourceId of this modelObject itself.
+ * It's just workaround, fix in DCS needed.
+ *
+ * @return ModelObjectData of build target
+ */
+ public ModelObjectData getChildModelObjectData() {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * Get DataNode instance.
+ *
+ * @return DataNode of target node
+ */
+ public DataNode getDataNode() {
+ ResourceData rData = toResourceData(getModelObjectData());
+ if (rData.dataNodes().size() > 1) {
+ throw new RuntimeException("Multiple dataNode found.");
+ }
+ return rData.dataNodes().get(0);
+ }
+
+ /**
+ * Read modelObject from Dcs store.
+ *
+ * @return ModelObject
+ */
+ public T read() {
+ return readOnDcs();
+ }
+
+ /**
+ * Add modelObject to Dcs store.
+ */
+ public void add() {
+ createOnDcs();
+ }
+
+ /**
+ * Delete modelObject from Dcs store.
+ */
+ public void remove() {
+ deleteOnDcs();
+ }
+
+ private void dcsSetup() {
+ dcs = getService(DynamicConfigService.class);
+ modelConverter = getService(ModelConverter.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ private T readOnDcs() {
+ dcsSetup();
+ ResourceData rData1 = toResourceData(getChildModelObjectData());
+ ResourceData rData2 = toResourceData(getModelObjectData());
+ DataNode rNode = dcs.readNode(rData1.resourceId(), Filter.builder().build());
+ obj = toModelObject(rNode, rData2.resourceId());
+ return obj;
+ }
+
+ private void createOnDcs() {
+ dcsSetup();
+ ResourceData rData = toResourceData(getModelObjectData());
+ addResourceDataToDcs(rData, rData.resourceId());
+ }
+
+ private void deleteOnDcs() {
+ dcsSetup();
+ ResourceData rData = toResourceData(getChildModelObjectData());
+ dcs.deleteNode(rData.resourceId());
+ }
+
+ private void addResourceDataToDcs(ResourceData input, ResourceId rid) {
+ if (input == null || input.dataNodes() == null) {
+ return;
+ }
+ List<DataNode> dataNodes = input.dataNodes();
+ for (DataNode node : dataNodes) {
+ dcs.createNode(rid, node);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected T toModelObject(DataNode rNode, ResourceId rId) {
+ dcsSetup();
+ ResourceData rData = toResourceData(rNode, rId);
+ ModelObjectData modelObjectData = modelConverter.createModel(rData);
+ if (modelObjectData.modelObjects().size() > 1) {
+ throw new RuntimeException("Multiple modelObject found.");
+ }
+ return (T) modelObjectData.modelObjects().get(0);
+ }
+
+ private ResourceData toResourceData(DataNode rNode, ResourceId rId) {
+ return DefaultResourceData.builder()
+ .addDataNode(rNode)
+ .resourceId(rId)
+ .build();
+ }
+
+ private ResourceData toResourceData(ModelObjectData data) {
+ dcsSetup();
+ ResourceData rData = modelConverter.createDataNode(data);
+
+ // for debug
+ CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(rData)));
+ log.info("XML:\n{}", XmlString.prettifyXml(strNode));
+
+ return rData;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRouteHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRouteHandler.java
new file mode 100644
index 0000000..7482979
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRouteHandler.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connection.DefaultRoute;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectionKeys;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.DefaultConnection;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.route.ConnectionEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.route.DefaultConnectionEndPoint;
+import org.onosproject.yang.model.ModelObjectId;
+
+import static org.onosproject.odtn.utils.tapi.TapiLocalClassUtil.getLocalId;
+import static org.onosproject.odtn.utils.tapi.TapiLocalClassUtil.setLocalId;
+
+/**
+ * Utility class to deal with TAPI Route with DCS.
+ */
+public final class TapiRouteHandler extends TapiObjectHandler<DefaultRoute> {
+
+ private Uuid connectionId;
+
+ private TapiRouteHandler() {
+ obj = new DefaultRoute();
+ setId();
+ }
+
+ public static TapiRouteHandler create() {
+ return new TapiRouteHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return Uuid.fromString(getLocalId(obj));
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setLocalId(obj, uuid.toString());
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ ConnectionKeys connectionKeys = new ConnectionKeys();
+ connectionKeys.uuid(connectionId);
+
+ return ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .addChild(DefaultConnection.class, connectionKeys)
+ .build();
+ }
+
+ public TapiRouteHandler addCep(TapiCepRef cepRef) {
+ DefaultConnectionEndPoint cep = new DefaultConnectionEndPoint();
+ cep.topologyId(cepRef.getTopologyId());
+ cep.nodeId(cepRef.getNodeId());
+ cep.ownedNodeEdgePointId(cepRef.getNepId());
+ cep.connectionEndPointId(cepRef.getCepId());
+
+ obj.addToConnectionEndPoint(cep);
+ return this;
+ }
+
+ public TapiCepRef getRouteStart() {
+ ConnectionEndPoint cep = obj.connectionEndPoint().get(0);
+ return TapiCepRef.create(cep.topologyId().toString(), cep.nodeId().toString(),
+ cep.ownedNodeEdgePointId().toString(), cep.connectionEndPointId().toString());
+ }
+
+ public TapiCepRef getRouteEnd() {
+ ConnectionEndPoint cep = obj.connectionEndPoint().get(obj.connectionEndPoint().size() - 1);
+ return TapiCepRef.create(cep.topologyId().toString(), cep.nodeId().toString(),
+ cep.ownedNodeEdgePointId().toString(), cep.connectionEndPointId().toString());
+ }
+
+ public TapiRouteHandler setConnectionId(Uuid connectionId) {
+ this.connectionId = connectionId;
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcInputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcInputHandler.java
new file mode 100644
index 0000000..9112f34
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcInputHandler.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectId;
+import org.onosproject.yang.model.RpcInput;
+
+/**
+ * Utility abstract class to deal with TAPI RPC input with DCS.
+ *
+ * @param <T> RPCInput modelObject to be dealt with
+ */
+public abstract class TapiRpcInputHandler<T extends ModelObject> extends TapiObjectHandler<T> {
+
+ // Uuid getter is not needed for RPC input
+ @Override
+ protected Uuid getIdDetail() {
+ return null;
+ }
+
+ // Uuid getter is not needed for RPC input
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ }
+
+ // Root modelObjectId must be used
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder().build();
+ }
+
+ // Cannot set InputRpc modelObject into DCS
+ @Override
+ public final void add() {
+ }
+
+ // Cannot remove InputRpc modelObject into DCS
+ @Override
+ public final void remove() {
+ }
+
+ /**
+ * Set RPCInput modelObject.
+ *
+ * @param input Tapi RpcInput modelObject
+ */
+ public void setRpcInput(RpcInput input) {
+ obj = toModelObject(input.data(), input.id());
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcOutputHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcOutputHandler.java
new file mode 100644
index 0000000..aa2c890
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiRpcOutputHandler.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectId;
+
+/**
+ * Utility abstract class to deal with TAPI RPC output with DCS.
+ *
+ * @param <T> RpcOutput modelObject to be dealt with
+ */
+public abstract class TapiRpcOutputHandler<T extends ModelObject> extends TapiObjectHandler<T> {
+
+ // Uuid getter is not needed for RPC output
+ @Override
+ protected Uuid getIdDetail() {
+ return null;
+ }
+
+ // Uuid setter is not needed for RPC output
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ }
+
+ // Root modelObjectId must be used
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder().build();
+ }
+
+
+ // Cannot add OutputRpc modelObject into DCS.
+ @Override
+ public final void add() {
+ }
+
+ // Cannot delete OutputRpc modelObject into DCS.
+ @Override
+ public final void remove() {
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSepHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSepHandler.java
new file mode 100644
index 0000000..35e01e0
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSepHandler.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityservice.DefaultEndPoint;
+import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityserviceendpoint.DefaultServiceInterfacePoint;
+import org.onosproject.yang.model.ModelObjectId;
+
+import static org.onosproject.odtn.utils.tapi.TapiLocalClassUtil.getLocalId;
+import static org.onosproject.odtn.utils.tapi.TapiLocalClassUtil.setLocalId;
+
+/**
+ * Utility class to deal with TAPI SEP with DCS.
+ */
+public final class TapiSepHandler extends TapiObjectHandler<DefaultEndPoint> {
+
+ private TapiSepHandler() {
+ obj = new DefaultEndPoint();
+ setId();
+ }
+
+ public static TapiSepHandler create() {
+ return new TapiSepHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return Uuid.fromString(getLocalId(obj));
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setLocalId(obj, uuid.toString());
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return null;
+ }
+
+ public TapiSepHandler setSip(String sipId) {
+ DefaultServiceInterfacePoint sip = new DefaultServiceInterfacePoint();
+ sip.serviceInterfacePointId(sipId);
+ obj.serviceInterfacePoint(sip);
+ return this;
+ }
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipBuilder.java
deleted file mode 100644
index 5e24b33..0000000
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipBuilder.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.odtn.utils.tapi;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.onosproject.net.ConnectPoint;
-
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.LayerProtocolName;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
-
-import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.addNameList;
-import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
-import static org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.layerprotocolname.LayerProtocolNameEnum.DSR;
-import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.tapicontext.DefaultServiceInterfacePoint;
-import org.onosproject.yang.model.ModelObjectId;
-
-/**
- * Utility builder class for TAPI sip creation with DCS.
- */
-public final class TapiSipBuilder extends TapiInstanceBuilder {
-
- private DefaultServiceInterfacePoint sip = new DefaultServiceInterfacePoint();
-
- private TapiSipBuilder() {
- setUuid(sip);
- }
-
- public static TapiSipBuilder builder() {
- return new TapiSipBuilder();
- }
-
- /**
- * Check this builder dealing with port for SIP or not.
- * @param cp onos connectPoint
- * @return Is this builder for SIP or not
- */
- public static boolean isSip(ConnectPoint cp) {
- // FIXME modify this method to appropriate way
- return cp.toString().contains("TRANSCEIVER");
- }
-
- public TapiSipBuilder setConnectPoint(ConnectPoint cp) {
- if (!isSip(cp)) {
- throw new IllegalStateException("Not allowed to use this port as SIP.");
- }
- Map<String, String> kvs = new HashMap<>();
- kvs.put(ONOS_CP, cp.toString());
- addNameList(sip, kvs);
- sip.addToLayerProtocolName(LayerProtocolName.of(DSR));
- return this;
- }
-
- @Override
- public ModelObjectId getModelObjectId() {
- return ModelObjectId.builder()
- .addChild(DefaultContext.class)
- .build();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public DefaultServiceInterfacePoint getModelObject() {
- return sip;
- }
-
- @Override
- public Uuid getUuid() {
- return sip.uuid();
- }
-}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipHandler.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipHandler.java
new file mode 100644
index 0000000..34b3896
--- /dev/null
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiSipHandler.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.odtn.utils.tapi;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.onosproject.net.ConnectPoint;
+
+import org.onosproject.net.Port;
+import org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.LayerProtocolName;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
+
+import static org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.PORT_TYPE;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.addNameList;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
+import static org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.layerprotocolname.LayerProtocolNameEnum.DSR;
+import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.tapicontext.DefaultServiceInterfacePoint;
+import org.onosproject.yang.model.ModelObjectId;
+
+/**
+ * Utility class to deal with TAPI SIP with DCS.
+ */
+public final class TapiSipHandler extends TapiObjectHandler<DefaultServiceInterfacePoint> {
+
+ private TapiSipHandler() {
+ obj = new DefaultServiceInterfacePoint();
+ setId();
+ }
+
+ public static TapiSipHandler create() {
+ return new TapiSipHandler();
+ }
+
+ @Override
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
+ return ModelObjectId.builder()
+ .addChild(DefaultContext.class)
+ .build();
+ }
+
+ /**
+ * Check this handler dealing with port for SIP or not.
+ * @param port onos port object
+ * @return is this handler for SIP or not
+ */
+ public static boolean isSip(Port port) {
+ // FIXME modify this method to appropriate way
+ String portType = port.annotations().value(PORT_TYPE);
+ OdtnDeviceDescriptionDiscovery.OdtnPortType odtnPortType
+ = OdtnDeviceDescriptionDiscovery.OdtnPortType.fromValue(portType);
+ return odtnPortType.value().equals(OdtnDeviceDescriptionDiscovery.OdtnPortType.CLIENT.value());
+ }
+
+ public TapiSipHandler setPort(Port port) {
+ if (!isSip(port)) {
+ throw new IllegalStateException("Not allowed to use this port as SIP.");
+ }
+ ConnectPoint cp = new ConnectPoint(port.element().id(), port.number());
+ return setConnectPoint(cp);
+ }
+
+ public TapiSipHandler setConnectPoint(ConnectPoint cp) {
+ Map<String, String> kvs = new HashMap<>();
+ kvs.put(ONOS_CP, cp.toString());
+ addNameList(obj, kvs);
+ obj.addToLayerProtocolName(LayerProtocolName.of(DSR));
+ return this;
+ }
+
+}
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyBuilder.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyHandler.java
similarity index 67%
rename from apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyBuilder.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyHandler.java
index 4c96133..2d81e80 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyBuilder.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/tapi/TapiTopologyHandler.java
@@ -16,6 +16,7 @@
package org.onosproject.odtn.utils.tapi;
+import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
@@ -25,40 +26,34 @@
import org.onosproject.yang.model.ModelObjectId;
/**
- * Utility builder class for TAPI topology creation with DCS.
+ * Utility class to deal with TAPI Topology with DCS.
*/
-public final class TapiTopologyBuilder extends TapiInstanceBuilder {
+public final class TapiTopologyHandler extends TapiObjectHandler<DefaultTopology> {
- private DefaultTopology topology;
-
- private TapiTopologyBuilder(DefaultTopology topology) {
- this.topology = topology;
- setUuid(this.topology);
+ private TapiTopologyHandler() {
+ obj = new DefaultTopology();
+ setId();
}
- public static TapiTopologyBuilder builder(DefaultTopology topology) {
- return new TapiTopologyBuilder(topology);
+ public static TapiTopologyHandler create() {
+ return new TapiTopologyHandler();
}
-
@Override
- public ModelObjectId getModelObjectId() {
+ protected Uuid getIdDetail() {
+ return getUuid(obj);
+ }
+ @Override
+ protected void setIdDetail(Uuid uuid) {
+ setUuid(obj, uuid);
+ }
+
+ @Override
+ public ModelObjectId getParentModelObjectId() {
DefaultAugmentedTapiCommonContext topologyContext = new DefaultAugmentedTapiCommonContext();
- topologyContext.addToTopology(topology);
+ topologyContext.addToTopology(obj);
return ModelObjectId.builder().addChild(DefaultContext.class).build();
}
-
- @Override
- @SuppressWarnings("unchecked")
- public DefaultTopology getModelObject() {
- return topology;
- }
-
- @Override
- public Uuid getUuid() {
- return topology.uuid();
- }
-
}