added HO and RRMConf NB api
diff --git a/src/main/java/org.onosproject.xran/rest/CellWebResource.java b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
index a2b0eac..336f67a 100644
--- a/src/main/java/org.onosproject.xran/rest/CellWebResource.java
+++ b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
@@ -21,6 +21,9 @@
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.xran.XranStore;
import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
+import org.onosproject.xran.controller.XranController;
import org.onosproject.xran.entities.RnibCell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +37,8 @@
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Optional;
+import java.util.concurrent.SynchronousQueue;
/**
* Cell web resource.
@@ -79,7 +84,7 @@
* test.
*
* @param eciHex test
- * @param stream test
+ * @param stream test (body of request)
* @return test
*/
@Patch
@@ -88,22 +93,29 @@
public Response patchCell(@PathParam("cellid") String eciHex, InputStream stream) {
log.debug("PATCH CELLID {}", eciHex);
- boolean b = false;
+ boolean b;
+
+ RnibCell cell = get(XranStore.class).getCell(eciHex);
+ // Check if a cell with that ECI exists. If it does, then modify its contents.
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode rrmConf = jsonTree.get("RRMConf");
if (rrmConf != null) {
- b = get(XranStore.class).modifyCellRrmConf(eciHex, rrmConf);
+ final SynchronousQueue<String>[] queue = new SynchronousQueue[1];
+ b = get(XranStore.class).modifyCellRrmConf(cell, rrmConf);
+ if (b) {
+ queue[0] = get(XranController.class).sendModifiedRRMConf(cell);
+ return Response.ok().entity(queue[0].take()).build();
+ }
}
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
e.printStackTrace();
+ return Response.serverError().entity(ExceptionUtils.getFullStackTrace(e)).build();
}
-
-
- return ok(b).build();
+ return Response.noContent().build();
}
}
diff --git a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
index 65772f0..370755f 100644
--- a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
+++ b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
@@ -22,7 +22,9 @@
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.xran.XranStore;
import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.controller.XranController;
import org.onosproject.xran.entities.RnibLink;
+import org.openmuc.jasn1.ber.types.BerInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +41,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.SynchronousQueue;
/**
* Link web resource.
@@ -103,25 +107,48 @@
public Response patchLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) {
log.debug("Patch LINKS FROM {} to {}", src, dst);
- boolean b = false;
try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+ RnibLink link = get(XranStore.class).getLinkBetweenCellIdUeId(src, dst);
+ if (link != null) {
- JsonNode type = jsonTree.get("type");
- if (type != null) {
+ ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
- }
+ JsonNode type = jsonTree.get("type");
+ if (type != null) {
+ final SynchronousQueue<String>[] queue = new SynchronousQueue[1];
+ RnibLink.Type linkType = RnibLink.Type.getEnum(type.asText());
+ if (linkType.equals(RnibLink.Type.SERVING_PRIMARY)) {
+ List<RnibLink> linksByUeId = get(XranStore.class).getLinksByUeId(dst);
+ Optional<RnibLink> primary = linksByUeId.stream()
+ .filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY))
+ .findFirst();
+ if (primary.isPresent()) {
+ queue[0] = get(XranController.class).sendHORequest(link, primary.get());
+ return Response.ok().entity(queue[0].take()).build();
+ }
+ }
+ }
- JsonNode trafficpercent = jsonTree.get("trafficpercent");
- if (trafficpercent != null) {
-
+ JsonNode trafficpercent = jsonTree.get("trafficpercent");
+ if (trafficpercent != null) {
+ JsonNode jsonNode = trafficpercent.get("traffic-percent-dl");
+ if (jsonNode != null) {
+ link.getTrafficPercent().setTrafficPercentDl(new BerInteger(jsonNode.asInt()));
+ }
+ jsonNode = trafficpercent.get("traffic-percent-ul");
+ if (jsonNode != null) {
+ link.getTrafficPercent().setTrafficPercentUl(new BerInteger(jsonNode.asInt()));
+ }
+ return Response.ok().build();
+ }
}
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
e.printStackTrace();
+ return Response.serverError().entity(ExceptionUtils.getFullStackTrace(e)).build();
}
- return ok(b).build();
+ return Response.noContent().build();
}
/**