Committed by
Yuta HIGUCHI
Fixing codec usage.
Change-Id: I9101296a7ec4d4b13bf11df3e49e17afad79405e (cherry picked from commit 8683e016)
Showing
1 changed file
with
12 additions
and
15 deletions
| ... | @@ -15,23 +15,21 @@ | ... | @@ -15,23 +15,21 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.rest; | 16 | package org.onosproject.rest; |
| 17 | 17 | ||
| 18 | -import javax.ws.rs.GET; | 18 | +import com.fasterxml.jackson.databind.node.ArrayNode; |
| 19 | -import javax.ws.rs.Path; | 19 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
| 20 | -import javax.ws.rs.PathParam; | ||
| 21 | -import javax.ws.rs.Produces; | ||
| 22 | -import javax.ws.rs.core.MediaType; | ||
| 23 | -import javax.ws.rs.core.Response; | ||
| 24 | - | ||
| 25 | import org.onlab.util.ItemNotFoundException; | 20 | import org.onlab.util.ItemNotFoundException; |
| 26 | -import org.onosproject.codec.impl.FlowEntryCodec; | ||
| 27 | import org.onosproject.net.Device; | 21 | import org.onosproject.net.Device; |
| 28 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
| 29 | import org.onosproject.net.device.DeviceService; | 23 | import org.onosproject.net.device.DeviceService; |
| 30 | import org.onosproject.net.flow.FlowEntry; | 24 | import org.onosproject.net.flow.FlowEntry; |
| 31 | import org.onosproject.net.flow.FlowRuleService; | 25 | import org.onosproject.net.flow.FlowRuleService; |
| 32 | 26 | ||
| 33 | -import com.fasterxml.jackson.databind.node.ArrayNode; | 27 | +import javax.ws.rs.GET; |
| 34 | -import com.fasterxml.jackson.databind.node.ObjectNode; | 28 | +import javax.ws.rs.Path; |
| 29 | +import javax.ws.rs.PathParam; | ||
| 30 | +import javax.ws.rs.Produces; | ||
| 31 | +import javax.ws.rs.core.MediaType; | ||
| 32 | +import javax.ws.rs.core.Response; | ||
| 35 | 33 | ||
| 36 | /** | 34 | /** |
| 37 | * REST resource for interacting with the inventory of flows. | 35 | * REST resource for interacting with the inventory of flows. |
| ... | @@ -44,7 +42,6 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -44,7 +42,6 @@ public class FlowsWebResource extends AbstractWebResource { |
| 44 | final FlowRuleService service = get(FlowRuleService.class); | 42 | final FlowRuleService service = get(FlowRuleService.class); |
| 45 | final ObjectNode root = mapper().createObjectNode(); | 43 | final ObjectNode root = mapper().createObjectNode(); |
| 46 | final ArrayNode flowsNode = root.putArray("flows"); | 44 | final ArrayNode flowsNode = root.putArray("flows"); |
| 47 | - final FlowEntryCodec flowEntryCodec = new FlowEntryCodec(); | ||
| 48 | 45 | ||
| 49 | /** | 46 | /** |
| 50 | * Gets an array containing all the intents in the system. | 47 | * Gets an array containing all the intents in the system. |
| ... | @@ -60,7 +57,7 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -60,7 +57,7 @@ public class FlowsWebResource extends AbstractWebResource { |
| 60 | final Iterable<FlowEntry> deviceEntries = service.getFlowEntries(device.id()); | 57 | final Iterable<FlowEntry> deviceEntries = service.getFlowEntries(device.id()); |
| 61 | if (deviceEntries != null) { | 58 | if (deviceEntries != null) { |
| 62 | for (final FlowEntry entry : deviceEntries) { | 59 | for (final FlowEntry entry : deviceEntries) { |
| 63 | - flowsNode.add(flowEntryCodec.encode(entry, this)); | 60 | + flowsNode.add(codec(FlowEntry.class).encode(entry, this)); |
| 64 | } | 61 | } |
| 65 | } | 62 | } |
| 66 | } | 63 | } |
| ... | @@ -85,7 +82,7 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -85,7 +82,7 @@ public class FlowsWebResource extends AbstractWebResource { |
| 85 | throw new ItemNotFoundException(DEVICE_NOT_FOUND); | 82 | throw new ItemNotFoundException(DEVICE_NOT_FOUND); |
| 86 | } | 83 | } |
| 87 | for (final FlowEntry entry : deviceEntries) { | 84 | for (final FlowEntry entry : deviceEntries) { |
| 88 | - flowsNode.add(flowEntryCodec.encode(entry, this)); | 85 | + flowsNode.add(codec(FlowEntry.class).encode(entry, this)); |
| 89 | } | 86 | } |
| 90 | return ok(root).build(); | 87 | return ok(root).build(); |
| 91 | } | 88 | } |
| ... | @@ -94,7 +91,7 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -94,7 +91,7 @@ public class FlowsWebResource extends AbstractWebResource { |
| 94 | * Gets the flows for a device, where the device is specified by Id. | 91 | * Gets the flows for a device, where the device is specified by Id. |
| 95 | * | 92 | * |
| 96 | * @param deviceId Id of device to look up | 93 | * @param deviceId Id of device to look up |
| 97 | - * @param flowId Id of flow to look up | 94 | + * @param flowId Id of flow to look up |
| 98 | * @return flow data as an array | 95 | * @return flow data as an array |
| 99 | */ | 96 | */ |
| 100 | @GET | 97 | @GET |
| ... | @@ -110,7 +107,7 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -110,7 +107,7 @@ public class FlowsWebResource extends AbstractWebResource { |
| 110 | } | 107 | } |
| 111 | for (final FlowEntry entry : deviceEntries) { | 108 | for (final FlowEntry entry : deviceEntries) { |
| 112 | if (entry.id().value() == flowId) { | 109 | if (entry.id().value() == flowId) { |
| 113 | - flowsNode.add(flowEntryCodec.encode(entry, this)); | 110 | + flowsNode.add(codec(FlowEntry.class).encode(entry, this)); |
| 114 | } | 111 | } |
| 115 | } | 112 | } |
| 116 | return ok(root).build(); | 113 | return ok(root).build(); | ... | ... |
-
Please register or login to post a comment