/**
   * 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);
    }
  }
  /**
   * Creates a new path.
   *
   * @param stream pce path from json
   * @return status of the request
   */
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response setupPath(InputStream stream) {
    log.debug("Setup path.");
    try {
      ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
      JsonNode port = jsonTree.get("path");
      PcePath path = codec(PcePath.class).decode((ObjectNode) port, this);

      DeviceId srcDevice = DeviceId.deviceId(path.source());
      DeviceId dstDevice = DeviceId.deviceId(path.destination());
      LspType lspType = path.lspType();
      List<Constraint> listConstrnt = new LinkedList<Constraint>();

      // add cost
      // TODO: need to uncomment below lines once Bandwidth and Cost constraint classes are ready
      // CostConstraint.Type costType =
      // CostConstraint.Type.values()[Integer.valueOf(path.constraint().cost())];
      // listConstrnt.add(CostConstraint.of(costType));

      // add bandwidth. Data rate unit is in BPS.
      // listConstrnt.add(LocalBandwidthConstraint.of(Double.valueOf(path.constraint().bandwidth()),
      // DataRateUnit
      //        .valueOf("BPS")));

      Boolean issuccess =
          nullIsNotFound(
              get(PceService.class)
                  .setupPath(srcDevice, dstDevice, path.name(), listConstrnt, lspType),
              PCE_SETUP_PATH_FAILED);
      return Response.status(OK).entity(issuccess.toString()).build();
    } catch (IOException e) {
      log.error("Exception while creating path {}.", e.toString());
      throw new IllegalArgumentException(e);
    }
  }