/** * Update details of a specified path id. * * @param id path id * @param stream pce path from json * @return 200 OK, 404 if given identifier does not exist */ @PUT @Path("{path_id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response updatePath(@PathParam("path_id") String id, final InputStream stream) { log.debug("Update path by identifier {}.", id); try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode pathNode = jsonTree.get("path"); PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this); // Assign cost List<Constraint> constrntList = new LinkedList<Constraint>(); // TODO: need to uncomment below lines once CostConstraint class is ready if (path.costConstraint() != null) { // CostConstraint.Type costType = CostConstraint.Type.values()[path.constraint().cost()]; // constrntList.add(CostConstraint.of(costType)); } // Assign bandwidth. Data rate unit is in BPS. if (path.bandwidthConstraint() != null) { // TODO: need to uncomment below lines once BandwidthConstraint class is ready // constrntList.add(LocalBandwidthConstraint // .of(path.constraint().bandwidth(), DataRateUnit.valueOf("BPS"))); } Boolean result = nullIsNotFound( get(PceService.class).updatePath(TunnelId.valueOf(id), constrntList), PCE_PATH_NOT_FOUND); return Response.status(OK).entity(result.toString()).build(); } catch (IOException e) { log.error("Update path failed because of exception {}.", e.toString()); throw new IllegalArgumentException(e); } }