diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-06 07:15:03 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-08 10:55:21 -0800 |
commit | 76dc892491948adae5e5e62cf94448967e8d865b (patch) | |
tree | 7a33ef05cc583946db21edad627060f280a53549 /framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject | |
parent | d333c63fdec8b064184b0a26f8d777f267577fde (diff) |
Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2
Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject')
5 files changed, 137 insertions, 81 deletions
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java index 08e37f96..4fd3fa48 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java @@ -36,12 +36,10 @@ import org.onosproject.rest.AbstractWebResource; import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; -import org.onosproject.vtnweb.web.FlowClassifierCodec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -64,11 +62,11 @@ public class FlowClassifierWebResource extends AbstractWebResource { @Produces(MediaType.APPLICATION_JSON) public Response getFlowClassifiers() { Iterable<FlowClassifier> flowClassifiers = get(FlowClassifierService.class).getFlowClassifiers(); - ObjectNode result = new ObjectMapper().createObjectNode(); + ObjectNode result = mapper().createObjectNode(); ArrayNode flowClassifierEntry = result.putArray("flow_classifiers"); if (flowClassifiers != null) { for (final FlowClassifier flowClassifier : flowClassifiers) { - flowClassifierEntry.add(new FlowClassifierCodec().encode(flowClassifier, this)); + flowClassifierEntry.add(codec(FlowClassifier.class).encode(flowClassifier, this)); } } return ok(result.toString()).build(); @@ -85,11 +83,11 @@ public class FlowClassifierWebResource extends AbstractWebResource { @Path("{flow_id}") @Produces(MediaType.APPLICATION_JSON) public Response getFlowClassifier(@PathParam("flow_id") String id) { - FlowClassifier flowClassifier = nullIsNotFound( - get(FlowClassifierService.class).getFlowClassifier(FlowClassifierId.of(id)), FLOW_CLASSIFIER_NOT_FOUND); + FlowClassifier flowClassifier = nullIsNotFound(get(FlowClassifierService.class) + .getFlowClassifier(FlowClassifierId.of(id)), FLOW_CLASSIFIER_NOT_FOUND); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("flow_classifier", new FlowClassifierCodec().encode(flowClassifier, this)); + ObjectNode result = mapper().createObjectNode(); + result.set("flow_classifier", codec(FlowClassifier.class).encode(flowClassifier, this)); return ok(result.toString()).build(); } @@ -107,13 +105,12 @@ public class FlowClassifierWebResource extends AbstractWebResource { @Produces(MediaType.APPLICATION_JSON) public Response createFlowClassifier(InputStream stream) { try { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream); + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode flow = jsonTree.get("flow_classifier"); - FlowClassifier flowClassifier = new FlowClassifierCodec().decode((ObjectNode) flow, this); + FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this); Boolean issuccess = nullIsNotFound(get(FlowClassifierService.class).createFlowClassifier(flowClassifier), - FLOW_CLASSIFIER_NOT_FOUND); + FLOW_CLASSIFIER_NOT_FOUND); return Response.status(OK).entity(issuccess.toString()).build(); } catch (IOException ex) { log.error("Exception while creating flow classifier {}.", ex.toString()); @@ -139,9 +136,9 @@ public class FlowClassifierWebResource extends AbstractWebResource { JsonNode jsonTree = mapper().readTree(stream); JsonNode flow = jsonTree.get("flow_classifier"); - FlowClassifier flowClassifier = new FlowClassifierCodec().decode((ObjectNode) flow, this); + FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this); Boolean result = nullIsNotFound(get(FlowClassifierService.class).updateFlowClassifier(flowClassifier), - FLOW_CLASSIFIER_NOT_FOUND); + FLOW_CLASSIFIER_NOT_FOUND); return Response.status(OK).entity(result.toString()).build(); } catch (IOException e) { log.error("Update flow classifier failed because of exception {}.", e.toString()); @@ -161,7 +158,7 @@ public class FlowClassifierWebResource extends AbstractWebResource { log.debug("Deletes flow classifier by identifier {}.", id); FlowClassifierId flowClassifierId = FlowClassifierId.of(id); Boolean issuccess = nullIsNotFound(get(FlowClassifierService.class).removeFlowClassifier(flowClassifierId), - FLOW_CLASSIFIER_NOT_FOUND); + FLOW_CLASSIFIER_NOT_FOUND); } } diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java index db12bcc7..e7b908b7 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java @@ -15,7 +15,6 @@ */ package org.onosproject.vtnweb.resources; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.onlab.util.Tools.nullIsNotFound; @@ -37,11 +36,11 @@ import org.onosproject.rest.AbstractWebResource; import org.onosproject.vtnrsc.PortChain; import org.onosproject.vtnrsc.PortChainId; import org.onosproject.vtnrsc.portchain.PortChainService; -import org.onosproject.vtnweb.web.PortChainCodec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; /** @@ -52,7 +51,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; public class PortChainWebResource extends AbstractWebResource { private final Logger log = LoggerFactory.getLogger(PortChainWebResource.class); - private final PortChainService service = get(PortChainService.class); public static final String PORT_CHAIN_NOT_FOUND = "Port chain not found"; public static final String PORT_CHAIN_ID_EXIST = "Port chain exists"; public static final String PORT_CHAIN_ID_NOT_EXIST = "Port chain does not exist with identifier"; @@ -65,10 +63,15 @@ public class PortChainWebResource extends AbstractWebResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getPortChains() { - Iterable<PortChain> portChains = service.getPortChains(); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("port_chains", new PortChainCodec().encode(portChains, this)); - return ok(result).build(); + Iterable<PortChain> portChains = get(PortChainService.class).getPortChains(); + ObjectNode result = mapper().createObjectNode(); + ArrayNode portChainEntry = result.putArray("port_chains"); + if (portChains != null) { + for (final PortChain portChain : portChains) { + portChainEntry.add(codec(PortChain.class).encode(portChain, this)); + } + } + return ok(result.toString()).build(); } /** @@ -82,14 +85,11 @@ public class PortChainWebResource extends AbstractWebResource { @Produces(MediaType.APPLICATION_JSON) public Response getPortPain(@PathParam("chain_id") String id) { - if (!service.exists(PortChainId.of(id))) { - return Response.status(NOT_FOUND).entity(PORT_CHAIN_NOT_FOUND).build(); - } - PortChain portChain = nullIsNotFound(service.getPortChain(PortChainId.of(id)), + PortChain portChain = nullIsNotFound(get(PortChainService.class).getPortChain(PortChainId.of(id)), PORT_CHAIN_NOT_FOUND); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("port_chain", new PortChainCodec().encode(portChain, this)); - return ok(result).build(); + ObjectNode result = mapper().createObjectNode(); + result.set("port_chain", codec(PortChain.class).encode(portChain, this)); + return ok(result.toString()).build(); } /** @@ -105,8 +105,10 @@ public class PortChainWebResource extends AbstractWebResource { public Response createPortChain(InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); - PortChain portChain = codec(PortChain.class).decode(jsonTree, this); - Boolean issuccess = nullIsNotFound(service.createPortChain(portChain), PORT_CHAIN_NOT_FOUND); + JsonNode port = jsonTree.get("port_chain"); + PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this); + Boolean issuccess = nullIsNotFound(get(PortChainService.class).createPortChain(portChain), + PORT_CHAIN_NOT_FOUND); return Response.status(OK).entity(issuccess.toString()).build(); } catch (IOException e) { log.error("Exception while creating port chain {}.", e.toString()); @@ -129,8 +131,10 @@ public class PortChainWebResource extends AbstractWebResource { final InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); - PortChain portChain = codec(PortChain.class).decode(jsonTree, this); - Boolean result = nullIsNotFound(service.updatePortChain(portChain), PORT_CHAIN_NOT_FOUND); + JsonNode port = jsonTree.get("port_chain"); + PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this); + Boolean result = nullIsNotFound(get(PortChainService.class).updatePortChain(portChain), + PORT_CHAIN_NOT_FOUND); return Response.status(OK).entity(result.toString()).build(); } catch (IOException e) { log.error("Update port chain failed because of exception {}.", e.toString()); @@ -149,7 +153,8 @@ public class PortChainWebResource extends AbstractWebResource { log.debug("Deletes port chain by identifier {}.", id); PortChainId portChainId = PortChainId.of(id); - Boolean issuccess = nullIsNotFound(service.removePortChain(portChainId), PORT_CHAIN_NOT_FOUND); + Boolean issuccess = nullIsNotFound(get(PortChainService.class).removePortChain(portChainId), + PORT_CHAIN_NOT_FOUND); if (!issuccess) { log.debug("Port Chain identifier {} does not exist", id); } diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java index 69daad37..dc5328a2 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java @@ -16,7 +16,6 @@ package org.onosproject.vtnweb.resources; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.onlab.util.Tools.nullIsNotFound; @@ -38,11 +37,12 @@ import org.onosproject.rest.AbstractWebResource; import org.onosproject.vtnrsc.PortPairGroup; import org.onosproject.vtnrsc.PortPairGroupId; import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; -import org.onosproject.vtnweb.web.PortPairGroupCodec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; /** @@ -53,7 +53,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; public class PortPairGroupWebResource extends AbstractWebResource { private final Logger log = LoggerFactory.getLogger(PortPairGroupWebResource.class); - private final PortPairGroupService service = get(PortPairGroupService.class); public static final String PORT_PAIR_GROUP_NOT_FOUND = "Port pair group not found"; public static final String PORT_PAIR_GROUP_ID_EXIST = "Port pair group exists"; public static final String PORT_PAIR_GROUP_ID_NOT_EXIST = "Port pair group does not exist with identifier"; @@ -66,10 +65,15 @@ public class PortPairGroupWebResource extends AbstractWebResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getPortPairGroups() { - Iterable<PortPairGroup> portPairGroups = service.getPortPairGroups(); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("port_pair_groups", new PortPairGroupCodec().encode(portPairGroups, this)); - return ok(result).build(); + Iterable<PortPairGroup> portPairGroups = get(PortPairGroupService.class).getPortPairGroups(); + ObjectNode result = mapper().createObjectNode(); + ArrayNode portPairGroupEntry = result.putArray("port_pair_groups"); + if (portPairGroups != null) { + for (final PortPairGroup portPairGroup : portPairGroups) { + portPairGroupEntry.add(codec(PortPairGroup.class).encode(portPairGroup, this)); + } + } + return ok(result.toString()).build(); } /** @@ -82,17 +86,13 @@ public class PortPairGroupWebResource extends AbstractWebResource { @Path("{group_id}") @Produces(MediaType.APPLICATION_JSON) public Response getPortPairGroup(@PathParam("group_id") String id) { - - if (!service.exists(PortPairGroupId.of(id))) { - return Response.status(NOT_FOUND) - .entity(PORT_PAIR_GROUP_NOT_FOUND).build(); - } - PortPairGroup portPairGroup = nullIsNotFound(service.getPortPairGroup(PortPairGroupId.of(id)), + PortPairGroup portPairGroup = nullIsNotFound(get(PortPairGroupService.class) + .getPortPairGroup(PortPairGroupId.of(id)), PORT_PAIR_GROUP_NOT_FOUND); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("port_pair_group", new PortPairGroupCodec().encode(portPairGroup, this)); - return ok(result).build(); + ObjectNode result = mapper().createObjectNode(); + result.set("port_pair_group", codec(PortPairGroup.class).encode(portPairGroup, this)); + return ok(result.toString()).build(); } /** @@ -108,10 +108,12 @@ public class PortPairGroupWebResource extends AbstractWebResource { public Response createPortPairGroup(InputStream stream) { try { - ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream); + JsonNode port = jsonTree.get("port_pair_group"); - PortPairGroup portPairGroup = codec(PortPairGroup.class).decode(jsonTree, this); - Boolean issuccess = nullIsNotFound(service.createPortPairGroup(portPairGroup), + PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this); + Boolean issuccess = nullIsNotFound(get(PortPairGroupService.class).createPortPairGroup(portPairGroup), PORT_PAIR_GROUP_NOT_FOUND); return Response.status(OK).entity(issuccess.toString()).build(); } catch (IOException e) { @@ -134,9 +136,12 @@ public class PortPairGroupWebResource extends AbstractWebResource { public Response updatePortPairGroup(@PathParam("group_id") String id, final InputStream stream) { try { - ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); - PortPairGroup portPairGroup = codec(PortPairGroup.class).decode(jsonTree, this); - Boolean isSuccess = nullIsNotFound(service.updatePortPairGroup(portPairGroup), PORT_PAIR_GROUP_NOT_FOUND); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream); + JsonNode port = jsonTree.get("port_pair_group"); + PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this); + Boolean isSuccess = nullIsNotFound(get(PortPairGroupService.class).updatePortPairGroup(portPairGroup), + PORT_PAIR_GROUP_NOT_FOUND); return Response.status(OK).entity(isSuccess.toString()).build(); } catch (IOException e) { log.error("Update port pair group failed because of exception {}.", e.toString()); @@ -154,7 +159,7 @@ public class PortPairGroupWebResource extends AbstractWebResource { public void deletePortPairGroup(@PathParam("group_id") String id) { log.debug("Deletes port pair group by identifier {}.", id); PortPairGroupId portPairGroupId = PortPairGroupId.of(id); - Boolean issuccess = nullIsNotFound(service.removePortPairGroup(portPairGroupId), + Boolean issuccess = nullIsNotFound(get(PortPairGroupService.class).removePortPairGroup(portPairGroupId), PORT_PAIR_GROUP_NOT_FOUND); if (!issuccess) { log.debug("Port pair group identifier {} does not exist", id); diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java index b9012898..4ed8ecd8 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java @@ -16,7 +16,6 @@ package org.onosproject.vtnweb.resources; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; import static javax.ws.rs.core.Response.Status.OK; import static org.onlab.util.Tools.nullIsNotFound; @@ -38,12 +37,10 @@ import org.onosproject.rest.AbstractWebResource; import org.onosproject.vtnrsc.PortPair; import org.onosproject.vtnrsc.PortPairId; import org.onosproject.vtnrsc.portpair.PortPairService; -import org.onosproject.vtnweb.web.PortPairCodec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -54,7 +51,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; public class PortPairWebResource extends AbstractWebResource { private final Logger log = LoggerFactory.getLogger(PortPairWebResource.class); - private final PortPairService service = get(PortPairService.class); public static final String PORT_PAIR_NOT_FOUND = "Port pair not found"; public static final String PORT_PAIR_ID_EXIST = "Port pair exists"; public static final String PORT_PAIR_ID_NOT_EXIST = "Port pair does not exist with identifier"; @@ -67,12 +63,12 @@ public class PortPairWebResource extends AbstractWebResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getPortPairs() { - Iterable<PortPair> portPairs = service.getPortPairs(); - ObjectNode result = new ObjectMapper().createObjectNode(); + Iterable<PortPair> portPairs = get(PortPairService.class).getPortPairs(); + ObjectNode result = mapper().createObjectNode(); ArrayNode portPairEntry = result.putArray("port_pairs"); if (portPairs != null) { for (final PortPair portPair : portPairs) { - portPairEntry.add(new PortPairCodec().encode(portPair, this)); + portPairEntry.add(codec(PortPair.class).encode(portPair, this)); } } return ok(result.toString()).build(); @@ -88,13 +84,10 @@ public class PortPairWebResource extends AbstractWebResource { @Path("{pair_id}") @Produces(MediaType.APPLICATION_JSON) public Response getPortPair(@PathParam("pair_id") String id) { - - if (!service.exists(PortPairId.of(id))) { - return Response.status(NOT_FOUND).entity(PORT_PAIR_NOT_FOUND).build(); - } - PortPair portPair = nullIsNotFound(service.getPortPair(PortPairId.of(id)), PORT_PAIR_NOT_FOUND); - ObjectNode result = new ObjectMapper().createObjectNode(); - result.set("port_pair", new PortPairCodec().encode(portPair, this)); + PortPair portPair = nullIsNotFound(get(PortPairService.class).getPortPair(PortPairId.of(id)), + PORT_PAIR_NOT_FOUND); + ObjectNode result = mapper().createObjectNode(); + result.set("port_pair", codec(PortPair.class).encode(portPair, this)); return ok(result.toString()).build(); } @@ -110,11 +103,11 @@ public class PortPairWebResource extends AbstractWebResource { @Produces(MediaType.APPLICATION_JSON) public Response createPortPair(InputStream stream) { try { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream); + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode port = jsonTree.get("port_pair"); - PortPair portPair = new PortPairCodec().decode((ObjectNode) port, this); - Boolean isSuccess = nullIsNotFound(service.createPortPair(portPair), PORT_PAIR_NOT_FOUND); + PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this); + Boolean isSuccess = nullIsNotFound(get(PortPairService.class).createPortPair(portPair), + PORT_PAIR_NOT_FOUND); return Response.status(OK).entity(isSuccess.toString()).build(); } catch (IOException e) { log.error("Exception while creating port pair {}.", e.toString()); @@ -136,11 +129,11 @@ public class PortPairWebResource extends AbstractWebResource { public Response updatePortPair(@PathParam("pair_id") String id, final InputStream stream) { try { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream); + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode port = jsonTree.get("port_pair"); - PortPair portPair = new PortPairCodec().decode((ObjectNode) port, this); - Boolean isSuccess = nullIsNotFound(service.updatePortPair(portPair), PORT_PAIR_NOT_FOUND); + PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this); + Boolean isSuccess = nullIsNotFound(get(PortPairService.class).updatePortPair(portPair), + PORT_PAIR_NOT_FOUND); return Response.status(OK).entity(isSuccess.toString()).build(); } catch (IOException e) { log.error("Update port pair failed because of exception {}.", e.toString()); @@ -158,7 +151,7 @@ public class PortPairWebResource extends AbstractWebResource { public void deletePortPair(@PathParam("pair_id") String id) { PortPairId portPairId = PortPairId.of(id); - Boolean isSuccess = nullIsNotFound(service.removePortPair(portPairId), PORT_PAIR_NOT_FOUND); + Boolean isSuccess = nullIsNotFound(get(PortPairService.class).removePortPair(portPairId), PORT_PAIR_NOT_FOUND); if (!isSuccess) { log.debug("Port pair identifier {} does not exist", id); } diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java new file mode 100644 index 00000000..e2defe59 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java @@ -0,0 +1,56 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.vtnweb.web; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onosproject.codec.CodecService; +import org.onosproject.vtnrsc.FlowClassifier; +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation of the JSON codec brokering service for VTN app. + */ +@Component(immediate = true) +public class VtnCodecRegistrator { + + private static Logger log = LoggerFactory.getLogger(VtnCodecRegistrator.class); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected CodecService codecService; + + @Activate + public void activate() { + codecService.registerCodec(PortPair.class, new PortPairCodec()); + codecService.registerCodec(PortPairGroup.class, new PortPairGroupCodec()); + codecService.registerCodec(FlowClassifier.class, new FlowClassifierCodec()); + codecService.registerCodec(PortChain.class, new PortChainCodec()); + + log.info("Started"); + } + + @Deactivate + public void deactivate() { + log.info("Stopped"); + } +} |