/** * Creates and installs a new forwarding objective for the specified device. * * @param appId application identifier * @param deviceId device identifier * @param stream forwarding objective JSON * @return status of the request - CREATED if the JSON is correct, BAD_REQUEST if the JSON is * invalid * @onos.rsModel ForwardingObjective */ @POST @Path("{deviceId}/forward") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createForwardingObjective( @QueryParam("appId") String appId, @PathParam("deviceId") String deviceId, InputStream stream) { try { UriBuilder locationBuilder = null; ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); if (validateDeviceId(deviceId, jsonTree)) { if (appId != null) { jsonTree.put("appId", appId); } DeviceId did = DeviceId.deviceId(deviceId); ForwardingObjective forwardingObjective = codec(ForwardingObjective.class).decode(jsonTree, this); flowObjectiveService.forward(did, forwardingObjective); locationBuilder = uriInfo .getBaseUriBuilder() .path("flowobjectives") .path(did.toString()) .path("forward") .path(Integer.toString(forwardingObjective.id())); } return Response.created(locationBuilder.build()).build(); } catch (IOException e) { throw new IllegalArgumentException(e); } }