Enhance the detection of meter table supportability in meter GUI
Change-Id: I9925cf8e4ede51f0c7e627ec93b800e146aefbe7
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/MeterViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/MeterViewMessageHandler.java
index d3ba9c5..550d572 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/MeterViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/MeterViewMessageHandler.java
@@ -34,6 +34,7 @@
import org.onosproject.ui.table.cell.NumberFormatter;
import java.util.Collection;
+import java.util.Set;
/**
* Message handler for meter view related messages.
@@ -46,6 +47,10 @@
private static final String PROTOCOL = "protocol";
private static final String OF_10 = "OF_10";
+ private static final String OF_11 = "OF_11";
+ private static final String OF_12 = "OF_12";
+ private static final Set<String> UNSUPPORTED_PROTOCOLS =
+ ImmutableSet.of(OF_10, OF_11, OF_12);
private static final String ID = "id";
private static final String APP_ID = "app_id";
@@ -63,11 +68,6 @@
return ImmutableSet.of(new MeterDataRequest());
}
- private static String deviceProtocol(Device device) {
- String protocol = device.annotations().value(PROTOCOL);
- return protocol != null ? protocol : "";
- }
-
// handler for meter table requests
private final class MeterDataRequest extends TableRequestHandler {
@@ -90,8 +90,7 @@
DeviceService ds = get(DeviceService.class);
Device dev = ds.getDevice(DeviceId.deviceId(uri));
- // TODO: replace with a less brittle solution...
- if (deviceProtocol(dev).equals(OF_10)) {
+ if (meterNotSupported(dev)) {
return NOT_SUPPORT_MESSAGE;
}
}
@@ -129,6 +128,11 @@
.cell(BANDS, m.bands());
}
+ private boolean meterNotSupported(Device dev) {
+ String protocol = dev.annotations().value(PROTOCOL);
+ return UNSUPPORTED_PROTOCOLS.contains(protocol);
+ }
+
private final class BandFormatter implements CellFormatter {
private static final String BREAK = "<br>";