initial commit
diff --git a/src/main/java/org.onosproject.xran/rest/CellWebResource.java b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
new file mode 100644
index 0000000..a2b0eac
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.entities.RnibCell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Cell web resource.
+ */
+@Path("cell")
+public class CellWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(CellWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @return test
+     */
+    @GET
+    @Path("{cellid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getCell(@PathParam("cellid") String eciHex) {
+        log.debug("GET CELLID {}", eciHex);
+
+        RnibCell cell = get(XranStore.class).getCell(eciHex);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (cell != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(cell.toString());
+                rootNode.put("cell", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @param stream test
+     * @return test
+     */
+    @Patch
+    @Path("{cellid}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response patchCell(@PathParam("cellid") String eciHex, InputStream stream) {
+        log.debug("PATCH CELLID {}", eciHex);
+
+        boolean b = false;
+
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            JsonNode rrmConf = jsonTree.get("RRMConf");
+            if (rrmConf != null) {
+                b = get(XranStore.class).modifyCellRrmConf(eciHex, rrmConf);
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
new file mode 100644
index 0000000..65772f0
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.entities.RnibLink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Link web resource.
+ */
+@Path("links")
+public class LinkWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(LinkWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @param ue     test
+     * @return test
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getLinksBetween(@DefaultValue("") @QueryParam("cell") String eciHex,
+                             @DefaultValue("-1") @QueryParam("ue") long ue) {
+        log.debug("GET LINKS CELL {} AND UE {}", eciHex, ue);
+
+        List<RnibLink> list = Lists.newArrayList();
+        if (!eciHex.isEmpty() && ue != -1) {
+            RnibLink link = get(XranStore.class).getLinkBetweenCellIdUeId(eciHex, ue);
+            if (link != null) {
+                list.add(link);
+            }
+        } else if (!eciHex.isEmpty()) {
+            list.addAll(get(XranStore.class).getLinksByCellId(eciHex));
+        } else if (ue != -1) {
+            list.addAll(get(XranStore.class).getLinksByUeId(ue));
+        } else {
+            list.addAll(get(XranStore.class).getLinks());
+        }
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        try {
+            JsonNode jsonNode = mapper().readTree(list.toString());
+            rootNode.put("links", jsonNode);
+        } catch (IOException e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param src    test
+     * @param dst    test
+     * @param stream test
+     * @return test
+     */
+    @Patch
+    @Path("{src},{dst}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    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);
+
+            JsonNode type = jsonTree.get("type");
+            if (type != null) {
+
+            }
+
+            JsonNode trafficpercent = jsonTree.get("trafficpercent");
+            if (trafficpercent != null) {
+
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param src    test
+     * @param dst    test
+     * @param stream test
+     * @return test
+     */
+    @POST
+    @Path("{src},{dst}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response postLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) {
+        log.debug("POST LINKS FROM {} to {}", src, dst);
+
+        boolean b = false;
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            JsonNode type = jsonTree.get("type");
+
+            if (type != null) {
+                b = get(XranStore.class).createLinkBetweenCellIdUeId(src, dst, type.asText());
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/NodeWebResource.java b/src/main/java/org.onosproject.xran/rest/NodeWebResource.java
new file mode 100644
index 0000000..1a70ccc
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/NodeWebResource.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibUe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Node web resource.
+ */
+@Path("nodes")
+public class NodeWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(NodeWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param type test
+     * @return test
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNodes(@DefaultValue("") @QueryParam("type") String type) {
+        log.debug("GET NODES " + type);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        try {
+            if (StringUtils.isBlank(type)) {
+                List<Object> nodes = get(XranStore.class).getNodes();
+
+                JsonNode jsonNode = mapper().readTree(nodes.get(0).toString());
+                JsonNode jsonNode2 = mapper().readTree(nodes.get(1).toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("cells", jsonNode);
+                arrayNode.put("ues", jsonNode2);
+            } else if (type.equals("cell")) {
+                List<RnibCell> cellNodes = get(XranStore.class).getCellNodes();
+                JsonNode jsonNode = mapper().readTree(cellNodes.toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("cells", jsonNode);
+            } else if (type.equals("ue")) {
+                List<RnibUe> ueNodes = get(XranStore.class).getUeNodes();
+                JsonNode jsonNode = mapper().readTree(ueNodes.toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("ues", jsonNode);
+            }
+        } catch (IOException e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param nodeid test
+     * @return test
+     */
+    @GET
+    @Path("{nodeid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNodeid(@PathParam("nodeid") String nodeid) {
+        log.debug("GET NODEID {}", nodeid);
+
+        Object node = get(XranStore.class).getByNodeId(nodeid);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (node != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(node.toString());
+                rootNode.put("node", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/SliceWebResource.java b/src/main/java/org.onosproject.xran/rest/SliceWebResource.java
new file mode 100644
index 0000000..2fe8385
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/SliceWebResource.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.entities.RnibSlice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Slice web resource.
+ */
+@Path("slice")
+public class SliceWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(SliceWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param sliceid test
+     * @return test
+     */
+    @GET
+    @Path("{sliceid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSlice(@PathParam("sliceid") long sliceid) {
+        log.debug("GET SLICE {}", sliceid);
+
+        RnibSlice slice = get(XranStore.class).getSlice(sliceid);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (slice != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(slice.toString());
+                rootNode.put("slice", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param stream test
+     * @return test
+     */
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response postSlice(InputStream stream) {
+        log.debug("POST SLICE");
+
+        boolean b = false;
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            b = get(XranStore.class).createSlice(jsonTree);
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/XranWebApplication.java b/src/main/java/org.onosproject.xran/rest/XranWebApplication.java
new file mode 100644
index 0000000..30f584b
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/XranWebApplication.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.xran.rest;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * Sample REST API web application.
+ */
+public class XranWebApplication extends AbstractWebApplication {
+    @Override
+    public Set<Class<?>> getClasses() {
+        return getClasses(
+                LinkWebResource.class,
+                NodeWebResource.class,
+                CellWebResource.class,
+                SliceWebResource.class);
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/rest/package-info.java b/src/main/java/org.onosproject.xran/rest/package-info.java
new file mode 100644
index 0000000..16f0c2f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+
+/**
+ * Created by dimitris on 7/20/17.
+ */
+package org.onosproject.xran.rest;
\ No newline at end of file