"Invalid Switch DPID: must be a 64-bit quantity, expressed in " +
"hex as AA:BB:CC:DD:EE:FF:00:11";
@Get("json")
public Iterator<SwitchJsonSerializerWrapper> retrieve() {
IFloodlightProviderService floodlightProvider =
(IFloodlightProviderService)getContext().getAttributes().
get(IFloodlightProviderService.class.getCanonicalName());
Long switchDPID = null;
Form form = getQuery();
String dpid = form.getFirstValue("dpid", true);
if (dpid != null) {
try {
switchDPID = HexString.toLong(dpid);
} catch (Exception e) {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, DPID_ERROR);
return null;
}
}
if (switchDPID != null) {
IOFSwitch sw =
floodlightProvider.getSwitch(switchDPID);
if (sw != null) {
SwitchJsonSerializerWrapper wrappedSw =
new SwitchJsonSerializerWrapper(sw);
return Collections.singleton(wrappedSw).iterator();
}
return Collections.<SwitchJsonSerializerWrapper>emptySet().iterator();
}
final String dpidStartsWith =
form.getFirstValue("dpid__startswith", true);
Iterator<IOFSwitch> iofSwitchIter =
floodlightProvider.getAllSwitchMap().values().iterator();
Iterator<SwitchJsonSerializerWrapper> switer =
new SwitchJsonSerializerWrapperIterator(iofSwitchIter);
if (dpidStartsWith != null) {
return new FilterIterator<SwitchJsonSerializerWrapper>(switer) {
@Override