Priyanka B
Committed by Gerrit Code Review

[ONOS-4986] [ONOS-4985] Json defect fix

Change-Id: I50876404fa75ca0dd9d30ab255ae800430147fae
......@@ -47,7 +47,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand {
@Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).",
required = false, multiValued = false)
int cost = -1;
Integer cost = null;
@Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
+ "Data rate unit is in Bps.", required = false, multiValued = false)
......@@ -66,7 +66,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand {
}
// Cost validation
if (cost != -1) {
if (cost != null) {
if ((cost < 1) || (cost > 2)) {
error("The cost attribute value is either IGP cost(1) or TE cost(2).");
return;
......
......@@ -508,7 +508,7 @@ public class PceManager implements PceService {
}
if (existingBwValue != null) {
if (bwConstraintValue == 0 && bwConstraint != null) {
if (bwConstraint == null) {
bwConstraintValue = existingBwValue.bps();
}
//If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
......
......@@ -101,6 +101,9 @@ public class PcePathWebResource extends AbstractWebResource {
Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)),
PCE_PATH_NOT_FOUND);
PcePath path = DefaultPcePath.builder().of(tunnel).build();
if (path == null) {
return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
}
ObjectNode result = mapper().createObjectNode();
result.set("path", codec(PcePath.class).encode(path, this));
return ok(result.toString()).build();
......@@ -175,6 +178,9 @@ public class PcePathWebResource extends AbstractWebResource {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode pathNode = jsonTree.get("path");
PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this);
if (path == null) {
return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
}
List<Constraint> constrntList = new LinkedList<Constraint>();
// Assign bandwidth
if (path.bandwidthConstraint() != null) {
......