Wu wenbin
Committed by Gerrit Code Review

ONOS-4512 fix bug to get and delete

Change-Id: I952085be7548830b660e133cf1c59fcdf98e8f69
......@@ -18,6 +18,7 @@ package org.onosproject.vtnweb.resources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
......@@ -45,6 +46,7 @@ public class ClassifierWebResource extends AbstractWebResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getClassifiers() {
ObjectNode result = mapper().createObjectNode();
......
......@@ -75,6 +75,7 @@ public class FloatingIpWebResource extends AbstractWebResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listFloatingIps() {
Collection<FloatingIp> floatingIps = get(FloatingIpService.class)
.getFloatingIps();
......@@ -87,6 +88,7 @@ public class FloatingIpWebResource extends AbstractWebResource {
@GET
@Path("{floatingIpUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getFloatingIp(@PathParam("floatingIpUUID") String id,
@QueryParam("fields") List<String> fields) {
......
......@@ -59,6 +59,7 @@ public class FlowClassifierWebResource extends AbstractWebResource {
* @return 200 OK
*/
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getFlowClassifiers() {
Iterable<FlowClassifier> flowClassifiers = get(FlowClassifierService.class).getFlowClassifiers();
......@@ -81,6 +82,7 @@ public class FlowClassifierWebResource extends AbstractWebResource {
*/
@GET
@Path("{flow_id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getFlowClassifier(@PathParam("flow_id") String id) {
FlowClassifier flowClassifier = nullIsNotFound(get(FlowClassifierService.class)
......@@ -154,6 +156,8 @@ public class FlowClassifierWebResource extends AbstractWebResource {
*/
@Path("{flow_id}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteFlowClassifier(@PathParam("flow_id") String id) {
log.debug("Deletes flow classifier by identifier {}.", id);
FlowClassifierId flowClassifierId = FlowClassifierId.of(id);
......
......@@ -62,6 +62,7 @@ public class PortChainWebResource extends AbstractWebResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortChains() {
Iterable<PortChain> portChains = get(PortChainService.class).getPortChains();
ObjectNode result = mapper().createObjectNode();
......@@ -83,6 +84,7 @@ public class PortChainWebResource extends AbstractWebResource {
@GET
@Path("{chain_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortPain(@PathParam("chain_id") String id) {
PortChain portChain = nullIsNotFound(get(PortChainService.class).getPortChain(PortChainId.of(id)),
......@@ -150,6 +152,8 @@ public class PortChainWebResource extends AbstractWebResource {
*/
@Path("{chain_id}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deletePortPain(@PathParam("chain_id") String id) {
log.debug("Deletes port chain by identifier {}.", id);
PortChainId portChainId = PortChainId.of(id);
......
......@@ -64,6 +64,7 @@ public class PortPairGroupWebResource extends AbstractWebResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortPairGroups() {
Iterable<PortPairGroup> portPairGroups = get(PortPairGroupService.class).getPortPairGroups();
ObjectNode result = mapper().createObjectNode();
......@@ -85,6 +86,7 @@ public class PortPairGroupWebResource extends AbstractWebResource {
@GET
@Path("{group_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortPairGroup(@PathParam("group_id") String id) {
PortPairGroup portPairGroup = nullIsNotFound(get(PortPairGroupService.class)
.getPortPairGroup(PortPairGroupId.of(id)),
......@@ -157,6 +159,8 @@ public class PortPairGroupWebResource extends AbstractWebResource {
*/
@Path("{group_id}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deletePortPairGroup(@PathParam("group_id") String id) {
log.debug("Deletes port pair group by identifier {}.", id);
PortPairGroupId portPairGroupId = PortPairGroupId.of(id);
......
......@@ -62,6 +62,7 @@ public class PortPairWebResource extends AbstractWebResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortPairs() {
Iterable<PortPair> portPairs = get(PortPairService.class).getPortPairs();
ObjectNode result = mapper().createObjectNode();
......@@ -83,6 +84,7 @@ public class PortPairWebResource extends AbstractWebResource {
@GET
@Path("{pair_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPortPair(@PathParam("pair_id") String id) {
PortPair portPair = nullIsNotFound(get(PortPairService.class).getPortPair(PortPairId.of(id)),
PORT_PAIR_NOT_FOUND);
......@@ -149,6 +151,8 @@ public class PortPairWebResource extends AbstractWebResource {
*/
@Path("{pair_id}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response deletePortPair(@PathParam("pair_id") String id) {
PortPairId portPairId = PortPairId.of(id);
......
......@@ -83,6 +83,7 @@ public class RouterWebResource extends AbstractWebResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listRouters() {
Collection<Router> routers = get(RouterService.class).getRouters();
ObjectNode result = new ObjectMapper().createObjectNode();
......@@ -93,6 +94,7 @@ public class RouterWebResource extends AbstractWebResource {
@GET
@Path("{routerUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getRouter(@PathParam("routerUUID") String id,
@QueryParam("fields") List<String> fields) {
......
......@@ -75,6 +75,7 @@ public class SubnetWebResource extends AbstractWebResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listSubnets() {
Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
ObjectNode result = new ObjectMapper().createObjectNode();
......@@ -85,6 +86,7 @@ public class SubnetWebResource extends AbstractWebResource {
@GET
@Path("{subnetUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getSubnet(@PathParam("subnetUUID") String id) {
if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
......
......@@ -77,7 +77,8 @@ public class TenantNetworkWebResource extends AbstractWebResource {
.newConcurrentMap();
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getNetworks(@QueryParam("id") String queryId,
@QueryParam("name") String queryName,
@QueryParam("admin_state_up") String queryadminStateUp,
......@@ -144,7 +145,8 @@ public class TenantNetworkWebResource extends AbstractWebResource {
@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getNetwork(@PathParam("id") String id) {
if (!get(TenantNetworkService.class).exists(TenantNetworkId
......
......@@ -80,7 +80,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
.getLogger(VirtualPortService.class);
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getPorts() {
Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
.getPorts();
......@@ -91,7 +92,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getportsById(@PathParam("id") String id) {
if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
......