Simon Hunt
Committed by Gerrit Code Review

CORD Subscriber GUI - Added CDN function. Added backend boolean to filter out 'i…

…nternet' when talking to XOS.

Change-Id: I076b9966c38589636968eef3dcaa203ba57f4eba
......@@ -59,11 +59,14 @@ public class XosManager {
String uriFmt = subId(subscriberId) + "services/%s/%s";
Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions();
for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) {
// only process the functions that have a real back-end on XOS
if (xfd.backend()) {
String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd));
String result = xosUtils.putRest(uri);
// TODO: convert JSON result to object and check (if we care)
}
}
}
/**
* Configure XOS with new setting for given user and function, for the
......
......@@ -26,30 +26,45 @@ public enum XosFunctionDescriptor {
*/
INTERNET("internet",
"Internet",
"Basic internet connectivity."),
"Basic internet connectivity.",
false),
/**
* Firewall function.
*/
FIREWALL("firewall",
"Firewall",
"Normal firewall protection."),
"Normal firewall protection.",
true),
/**
* URL Filtering function (parental controls).
*/
URL_FILTER("url_filter",
"Parental Control",
"Variable levels of URL filtering.");
"Variable levels of URL filtering.",
true),
/**
* Content Distribution function.
*/
CDN("cdn",
"CDN",
"Content Distribution Network service.",
true);
private final String id;
private final String displayName;
private final String description;
private final boolean backend;
XosFunctionDescriptor(String id, String displayName, String description) {
XosFunctionDescriptor(String id, String displayName, String description,
boolean backend) {
this.id = id;
this.displayName = displayName;
this.description = description;
this.backend = backend;
}
/**
......@@ -79,4 +94,13 @@ public enum XosFunctionDescriptor {
return description;
}
/**
* Returns true if this function is supported by the XOS backend.
*
* @return true if backend function exists
*/
public boolean backend() {
return backend;
}
}
......
......@@ -19,8 +19,7 @@ package org.onosproject.cord.gui.model;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.onosproject.cord.gui.model.XosFunctionDescriptor.*;
/**
......@@ -30,7 +29,7 @@ public class XosFunctionDescriptorTest {
@Test
public void numberOfFunctions() {
assertEquals("unexpected constant count", 3, values().length);
assertEquals("unexpected constant count", 4, values().length);
}
@Test
......@@ -38,6 +37,7 @@ public class XosFunctionDescriptorTest {
assertEquals("wrong id", "internet", INTERNET.id());
assertEquals("wrong display", "Internet", INTERNET.displayName());
assertTrue("wrong desc", INTERNET.description().startsWith("Basic"));
assertFalse("wrong backend", INTERNET.backend());
}
@Test
......@@ -45,12 +45,22 @@ public class XosFunctionDescriptorTest {
assertEquals("wrong id", "firewall", FIREWALL.id());
assertEquals("wrong display", "Firewall", FIREWALL.displayName());
assertTrue("wrong desc", FIREWALL.description().startsWith("Normal"));
assertTrue("wrong backend", FIREWALL.backend());
}
@Test
public void urlFiltering() {
public void urlFilter() {
assertEquals("wrong id", "url_filter", URL_FILTER.id());
assertEquals("wrong display", "Parental Control", URL_FILTER.displayName());
assertTrue("wrong desc", URL_FILTER.description().startsWith("Variable"));
assertTrue("wrong backend", URL_FILTER.backend());
}
@Test
public void cdn() {
assertEquals("wrong id", "cdn", CDN.id());
assertEquals("wrong display", "CDN", CDN.displayName());
assertTrue("wrong desc", CDN.description().startsWith("Content"));
assertTrue("wrong backend", CDN.backend());
}
}
......