protected final HostService hostService;
// code omitted ...
// Returns host details response.
protected ObjectNode hostDetails(HostId hostId, long sid) {
Host host = hostService.getHost(hostId);
Annotations annot = host.annotations();
String type = annot.value(AnnotationKeys.TYPE);
String name = annot.value(AnnotationKeys.NAME);
String vlan = host.vlan().toString();
return envelope("showDetails", sid,
json(isNullOrEmpty(name) ? hostId.toString() : name,
isNullOrEmpty(type) ? "endstation" : type,
new Prop("MAC", host.mac().toString()),
new Prop("IP", host.ipAddresses().toString().replaceAll("[\\[\\]]", "")),
new Prop("VLAN", vlan.equals("-1") ? "none" : vlan),
new Separator(),
new Prop("Latitude", annot.value(AnnotationKeys.LATITUDE)),
new Prop("Longitude", annot.value(AnnotationKeys.LONGITUDE))));
}