Fixed bug in Flows REST API for handling flows with no app ID
Change-Id: I67dc2bd7a1f5df71f29b16bed70922eba8cbae27
Showing
1 changed file
with
7 additions
and
3 deletions
| ... | @@ -15,15 +15,15 @@ | ... | @@ -15,15 +15,15 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.codec.impl; | 16 | package org.onosproject.codec.impl; |
| 17 | 17 | ||
| 18 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 18 | import org.onosproject.codec.CodecContext; | 19 | import org.onosproject.codec.CodecContext; |
| 19 | import org.onosproject.codec.JsonCodec; | 20 | import org.onosproject.codec.JsonCodec; |
| 21 | +import org.onosproject.core.ApplicationId; | ||
| 20 | import org.onosproject.core.CoreService; | 22 | import org.onosproject.core.CoreService; |
| 21 | import org.onosproject.net.flow.FlowEntry; | 23 | import org.onosproject.net.flow.FlowEntry; |
| 22 | import org.onosproject.net.flow.TrafficSelector; | 24 | import org.onosproject.net.flow.TrafficSelector; |
| 23 | import org.onosproject.net.flow.TrafficTreatment; | 25 | import org.onosproject.net.flow.TrafficTreatment; |
| 24 | 26 | ||
| 25 | -import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 26 | - | ||
| 27 | import static com.google.common.base.Preconditions.checkNotNull; | 27 | import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| ... | @@ -37,10 +37,14 @@ public final class FlowEntryCodec extends JsonCodec<FlowEntry> { | ... | @@ -37,10 +37,14 @@ public final class FlowEntryCodec extends JsonCodec<FlowEntry> { |
| 37 | 37 | ||
| 38 | CoreService service = context.getService(CoreService.class); | 38 | CoreService service = context.getService(CoreService.class); |
| 39 | 39 | ||
| 40 | + ApplicationId appId = service.getAppId(flowEntry.appId()); | ||
| 41 | + | ||
| 42 | + String strAppId = (appId == null) ? "<none>" : appId.name(); | ||
| 43 | + | ||
| 40 | final ObjectNode result = context.mapper().createObjectNode() | 44 | final ObjectNode result = context.mapper().createObjectNode() |
| 41 | .put("id", Long.toString(flowEntry.id().value())) | 45 | .put("id", Long.toString(flowEntry.id().value())) |
| 42 | .put("tableId", flowEntry.tableId()) | 46 | .put("tableId", flowEntry.tableId()) |
| 43 | - .put("appId", service.getAppId(flowEntry.appId()).name()) | 47 | + .put("appId", strAppId) |
| 44 | .put("groupId", flowEntry.groupId().id()) | 48 | .put("groupId", flowEntry.groupId().id()) |
| 45 | .put("priority", flowEntry.priority()) | 49 | .put("priority", flowEntry.priority()) |
| 46 | .put("timeout", flowEntry.timeout()) | 50 | .put("timeout", flowEntry.timeout()) | ... | ... |
-
Please register or login to post a comment