mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 12:16:13 +02:00
Upgrade fasterXML libraries for OS-9
Upgrade fasterXML to version 2.9.5 to address security vulnerability Wrap calls to treeRead(InputStream) to handle new behavior of null streams Change-Id: Id199cfacd0cf9e5371dc33de9f1e058c2e72eaa5
This commit is contained in:
parent
fca3c6abb5
commit
86ee5e8711
@ -42,6 +42,8 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage ACL rules.
|
||||
*/
|
||||
@ -141,7 +143,7 @@ public class AclWebResource extends AbstractWebResource {
|
||||
private AclRule jsonToRule(InputStream stream) {
|
||||
JsonNode node;
|
||||
try {
|
||||
node = mapper().readTree(stream);
|
||||
node = readTreeFromStream(mapper(), stream);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Unable to parse ACL request", e);
|
||||
}
|
||||
|
||||
@ -47,6 +47,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Layer 2 CFM Maintenance Association web resource.
|
||||
*/
|
||||
@ -143,7 +145,7 @@ public class MaWebResource extends AbstractWebResource {
|
||||
}
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonCodec<MaintenanceAssociation> maCodec =
|
||||
codec(MaintenanceAssociation.class);
|
||||
|
||||
|
||||
@ -43,6 +43,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Layer 2 CFM Maintenance Domain web resource.
|
||||
*/
|
||||
@ -136,7 +138,7 @@ public class MdWebResource extends AbstractWebResource {
|
||||
log.debug("POST called to Create MD");
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
MaintenanceDomain md = codec(MaintenanceDomain.class).decode((ObjectNode) cfg, this);
|
||||
|
||||
if (get(CfmMdService.class).createMaintenanceDomain(md)) {
|
||||
|
||||
@ -56,6 +56,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Layer 2 CFM Maintenance Association Endpoint (MEP) web resource.
|
||||
*/
|
||||
@ -186,7 +188,7 @@ public class MepWebResource extends AbstractWebResource {
|
||||
"MA " + mdName + "/" + maName + " not Found"));
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper(), input);
|
||||
JsonCodec<Mep> mepCodec = codec(Mep.class);
|
||||
|
||||
Mep mep = ((MepCodec) mepCodec).decode((ObjectNode) cfg, this, mdName, maName);
|
||||
@ -258,7 +260,7 @@ public class MepWebResource extends AbstractWebResource {
|
||||
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper(), input);
|
||||
JsonCodec<MepLbCreate> mepLbCreateCodec = codec(MepLbCreate.class);
|
||||
|
||||
MepLbCreate lbCreate = mepLbCreateCodec.decode((ObjectNode) cfg, this);
|
||||
@ -380,7 +382,7 @@ public class MepWebResource extends AbstractWebResource {
|
||||
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonCodec<MepLtCreate> mepLtCreateCodec = codec(MepLtCreate.class);
|
||||
|
||||
MepLtCreate ltCreate = mepLtCreateCodec.decode((ObjectNode) cfg, this);
|
||||
|
||||
@ -55,6 +55,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Layer 2 SOAM Delay Measurement web resource.
|
||||
*/
|
||||
@ -199,7 +201,7 @@ public class DmWebResource extends AbstractWebResource {
|
||||
}
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonCodec<DelayMeasurementCreate> dmCodec = codec(DelayMeasurementCreate.class);
|
||||
|
||||
DelayMeasurementCreate dm = dmCodec.decode((ObjectNode) cfg, this);
|
||||
|
||||
@ -53,6 +53,8 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Layer 2 SOAM Loss Measurement web resource.
|
||||
*/
|
||||
@ -197,7 +199,7 @@ public class LmWebResource extends AbstractWebResource {
|
||||
}
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonCodec<LossMeasurementCreate> lmCodec = codec(LossMeasurementCreate.class);
|
||||
|
||||
LossMeasurementCreate lm = lmCodec.decode((ObjectNode) cfg, this);
|
||||
|
||||
@ -46,6 +46,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsIllegal;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Collect system metrics.
|
||||
@ -90,7 +91,7 @@ public class SystemMetricsCollectorWebResource extends AbstractWebResource {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
ControlMetric cm;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
|
||||
if (jsonTree == null || !checkFields(jsonTree, CPU_FIELD_SET)) {
|
||||
return ok(root).build();
|
||||
@ -151,7 +152,7 @@ public class SystemMetricsCollectorWebResource extends AbstractWebResource {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
ControlMetric cm;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
|
||||
if (jsonTree == null || !checkFields(jsonTree, MEMORY_FIELD_SET)) {
|
||||
return ok(root).build();
|
||||
@ -206,7 +207,7 @@ public class SystemMetricsCollectorWebResource extends AbstractWebResource {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
ControlMetric cm;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
ArrayNode diskRes =
|
||||
jsonTree.get("disks") == null ?
|
||||
mapper().createArrayNode() : (ArrayNode) jsonTree.get("disks");
|
||||
@ -252,7 +253,7 @@ public class SystemMetricsCollectorWebResource extends AbstractWebResource {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
ControlMetric cm;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
|
||||
ArrayNode networkRes = jsonTree.get("networks") == null
|
||||
? mapper().createArrayNode() : (ArrayNode) jsonTree.get("networks");
|
||||
@ -315,7 +316,7 @@ public class SystemMetricsCollectorWebResource extends AbstractWebResource {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode numOfCores = jsonTree.get("numOfCores");
|
||||
JsonNode numOfCpus = jsonTree.get("numOfCpus");
|
||||
JsonNode cpuSpeed = jsonTree.get("cpuSpeed");
|
||||
|
||||
@ -38,6 +38,7 @@ import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.onosproject.dhcp.IpAssignment.AssignmentStatus.Option_Requested;
|
||||
|
||||
/**
|
||||
@ -118,7 +119,7 @@ public class DhcpWebResource extends AbstractWebResource {
|
||||
public Response setMapping(InputStream stream) {
|
||||
ObjectNode root = mapper().createObjectNode();
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode macID = jsonTree.get("mac");
|
||||
JsonNode ip = jsonTree.get("ip");
|
||||
if (macID != null && ip != null) {
|
||||
|
||||
@ -43,6 +43,7 @@ import org.onosproject.incubator.net.faultmanagement.alarm.AlarmService;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
@ -121,7 +122,7 @@ public class AlarmsWebResource extends AbstractWebResource {
|
||||
log.debug("PUT NEW ALARM at /{}", alarmIdPath);
|
||||
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
log.debug("jsonTree={}", jsonTree);
|
||||
|
||||
Alarm alarm = new AlarmCodec().decode(jsonTree, this);
|
||||
|
||||
@ -36,6 +36,7 @@ import java.io.InputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Rest Interfaces for subscribing/unsubscribing to event notifications.
|
||||
@ -140,7 +141,7 @@ public class EventExporterWebResource extends AbstractWebResource {
|
||||
throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode node = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode node = readTreeFromStream(mapper, input);
|
||||
checkNotNull(node, JSON_NOT_NULL);
|
||||
EventSubscriber codec = codec(EventSubscriber.class).decode(node, this);
|
||||
checkNotNull(codec, JSON_NOT_NULL);
|
||||
|
||||
@ -39,6 +39,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.*;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
|
||||
/**
|
||||
@ -117,7 +118,7 @@ public class OFAgentWebResource extends AbstractWebResource {
|
||||
public Response createOFAgent(InputStream stream) throws IOException {
|
||||
OFAgentAdminService adminService = get(OFAgentAdminService.class);
|
||||
|
||||
OFAgent ofAgent = (new OFAgentCodec()).decode((ObjectNode) mapper().readTree(stream), this);
|
||||
OFAgent ofAgent = (new OFAgentCodec()).decode(readTreeFromStream(mapper(), stream), this);
|
||||
if (ofAgent == null) {
|
||||
return Response.status(BAD_REQUEST)
|
||||
.entity(OFAGENT_NOT_CREATED).build();
|
||||
@ -141,7 +142,7 @@ public class OFAgentWebResource extends AbstractWebResource {
|
||||
public Response startOFAgent(InputStream stream) throws IOException {
|
||||
OFAgentAdminService adminService = get(OFAgentAdminService.class);
|
||||
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode networkId = jsonTree.get("networkId");
|
||||
|
||||
if (networkId == null) {
|
||||
@ -170,7 +171,7 @@ public class OFAgentWebResource extends AbstractWebResource {
|
||||
public Response updateOFAgent(InputStream stream) throws IOException {
|
||||
OFAgentAdminService adminService = get(OFAgentAdminService.class);
|
||||
|
||||
OFAgent ofAgent = (new OFAgentCodec()).decode((ObjectNode) mapper().readTree(stream), this);
|
||||
OFAgent ofAgent = (new OFAgentCodec()).decode(readTreeFromStream(mapper(), stream), this);
|
||||
|
||||
if (ofAgent == null) {
|
||||
return Response.status(NOT_FOUND)
|
||||
@ -199,7 +200,7 @@ public class OFAgentWebResource extends AbstractWebResource {
|
||||
public Response stopOFAgent(InputStream stream) throws IOException {
|
||||
|
||||
OFAgentAdminService adminService = get(OFAgentAdminService.class);
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode networkId = jsonTree.get("networkId");
|
||||
|
||||
if (get(OFAgentService.class).agent(NetworkId.networkId(networkId.asLong())) == null) {
|
||||
|
||||
@ -37,6 +37,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static javax.ws.rs.core.Response.status;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Handles REST API from monitoring server.
|
||||
@ -58,7 +59,7 @@ public class FlowTraceWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response flowTraceResponse(InputStream inputStream) throws IOException {
|
||||
try {
|
||||
JsonNode jsonNode = mapper().enable(SerializationFeature.INDENT_OUTPUT).readTree(inputStream);
|
||||
JsonNode jsonNode = readTreeFromStream(mapper().enable(SerializationFeature.INDENT_OUTPUT), inputStream);
|
||||
ObjectNode objectNode = jsonNode.deepCopy();
|
||||
|
||||
log.debug("FlowTraceResponse: {}", jsonNode.toString());
|
||||
|
||||
@ -44,6 +44,7 @@ import java.util.Set;
|
||||
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
|
||||
import static javax.ws.rs.core.Response.created;
|
||||
import static org.onlab.util.Tools.nullIsIllegal;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Handles REST API call of openstack node config.
|
||||
@ -158,7 +159,7 @@ public class OpenstackNodeWebResource extends AbstractWebResource {
|
||||
private Set<OpenstackNode> readNodeConfiguration(InputStream input) {
|
||||
Set<OpenstackNode> nodeSet = Sets.newHashSet();
|
||||
try {
|
||||
JsonNode jsonTree = mapper().enable(INDENT_OUTPUT).readTree(input);
|
||||
JsonNode jsonTree = readTreeFromStream(mapper().enable(INDENT_OUTPUT), input);
|
||||
ArrayNode nodes = (ArrayNode) jsonTree.path(NODES);
|
||||
nodes.forEach(node -> {
|
||||
try {
|
||||
|
||||
@ -47,8 +47,10 @@ import java.io.InputStream;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.onosproject.net.optical.util.OpticalIntentUtility.createOpticalIntent;
|
||||
|
||||
|
||||
/**
|
||||
* Query, submit and withdraw optical network intents.
|
||||
*/
|
||||
@ -91,7 +93,7 @@ public class OpticalIntentsWebResource extends AbstractWebResource {
|
||||
public Response createIntent(InputStream stream) {
|
||||
try {
|
||||
IntentService service = get(IntentService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode root = readTreeFromStream(mapper(), stream);
|
||||
Intent intent = decode(root);
|
||||
service.submit(intent);
|
||||
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
|
||||
|
||||
@ -17,6 +17,7 @@ package org.onosproject.pcerest;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.io.IOException;
|
||||
@ -130,7 +131,7 @@ public class PcePathWebResource extends AbstractWebResource {
|
||||
public Response setupPath(InputStream stream) {
|
||||
log.debug("Setup path.");
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode port = jsonTree.get("path");
|
||||
TunnelService tunnelService = get(TunnelService.class);
|
||||
PcePath path = codec(PcePath.class).decode((ObjectNode) port, this);
|
||||
@ -190,7 +191,7 @@ public class PcePathWebResource extends AbstractWebResource {
|
||||
final InputStream stream) {
|
||||
log.debug("Update path by identifier {}.", id);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode pathNode = jsonTree.get("path");
|
||||
PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this);
|
||||
if (path == null) {
|
||||
|
||||
@ -54,6 +54,8 @@ import java.util.Map.Entry;
|
||||
import org.slf4j.Logger;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage inventory of infrastructure devices with Power Config behaviour.
|
||||
*/
|
||||
@ -119,7 +121,7 @@ public class PowerConfigWebResource extends AbstractWebResource {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response setTargetPower(InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
decode(jsonTree);
|
||||
return Response.ok().build();
|
||||
} catch (IOException e) {
|
||||
|
||||
@ -46,6 +46,7 @@ import java.net.URI;
|
||||
import java.util.Optional;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.*;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Utilities used by the RESTCONF app.
|
||||
@ -78,7 +79,7 @@ public final class RestconfUtils {
|
||||
ObjectNode rootNode;
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
rootNode = (ObjectNode) mapper.readTree(inputStream);
|
||||
rootNode = readTreeFromStream(mapper, inputStream);
|
||||
} catch (IOException e) {
|
||||
throw new RestconfException("ERROR: InputStream failed to parse",
|
||||
e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR,
|
||||
|
||||
@ -39,6 +39,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsIllegal;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage the unicast routing information.
|
||||
@ -88,7 +89,7 @@ public class RouteServiceWebResource extends AbstractWebResource {
|
||||
public Response createRoute(InputStream route) {
|
||||
RouteAdminService service = get(RouteAdminService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(route);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), route);
|
||||
Route r = codec(Route.class).decode(jsonTree, this);
|
||||
service.update(Collections.singletonList(r));
|
||||
} catch (IOException ex) {
|
||||
@ -118,7 +119,7 @@ public class RouteServiceWebResource extends AbstractWebResource {
|
||||
public Response createRoutes(InputStream routesStream) {
|
||||
RouteAdminService service = get(RouteAdminService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(routesStream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), routesStream);
|
||||
ArrayNode routesArray = nullIsIllegal((ArrayNode) jsonTree.get(ROUTES),
|
||||
ROUTES_KEY_ERROR);
|
||||
List<Route> routes = codec(Route.class).decode(routesArray, this);
|
||||
@ -146,7 +147,7 @@ public class RouteServiceWebResource extends AbstractWebResource {
|
||||
public Response deleteRoute(InputStream route) {
|
||||
RouteAdminService service = get(RouteAdminService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(route);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), route);
|
||||
Route r = codec(Route.class).decode(jsonTree, this);
|
||||
service.withdraw(Collections.singletonList(r));
|
||||
} catch (IOException ex) {
|
||||
@ -168,7 +169,7 @@ public class RouteServiceWebResource extends AbstractWebResource {
|
||||
public Response deleteRoutes(InputStream routesStream) {
|
||||
RouteAdminService service = get(RouteAdminService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(routesStream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), routesStream);
|
||||
ArrayNode routesArray = nullIsIllegal((ArrayNode) jsonTree.get(ROUTES),
|
||||
ROUTES_KEY_ERROR);
|
||||
List<Route> routes = codec(Route.class).decode(routesArray, this);
|
||||
|
||||
@ -33,6 +33,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query, create and remove segment routing plicies.
|
||||
*/
|
||||
@ -69,7 +71,7 @@ public class PolicyWebResource extends AbstractWebResource {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response createPolicy(InputStream input) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode policyJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode policyJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
Policy policyInfo = POLICY_CODEC.decode(policyJson, this);
|
||||
|
||||
@ -92,7 +94,7 @@ public class PolicyWebResource extends AbstractWebResource {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response removePolicy(InputStream input) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode policyJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode policyJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
Policy policyInfo = POLICY_CODEC.decode(policyJson, this);
|
||||
// TODO: Check the result
|
||||
|
||||
@ -44,6 +44,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsIllegal;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query, create and remove pseudowires.
|
||||
@ -107,7 +108,7 @@ public class PseudowireWebResource extends AbstractWebResource {
|
||||
public Response createPseudowire(InputStream input) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode pseudowireJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode pseudowireJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
|
||||
DefaultL2TunnelDescription pseudowire = PSEUDOWIRE_CODEC.decode(pseudowireJson, this);
|
||||
@ -147,7 +148,7 @@ public class PseudowireWebResource extends AbstractWebResource {
|
||||
public Response createPseudowiresBulk(InputStream input) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode pseudowireJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode pseudowireJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
List<DefaultL2TunnelDescription> pseudowires;
|
||||
|
||||
@ -189,7 +190,7 @@ public class PseudowireWebResource extends AbstractWebResource {
|
||||
public Response removePseudowire(InputStream input) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode pseudowireJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode pseudowireJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
|
||||
Integer pseudowireId = PSEUDOWIRE_CODEC.decodeId(pseudowireJson);
|
||||
@ -229,7 +230,7 @@ public class PseudowireWebResource extends AbstractWebResource {
|
||||
public Response removePseudowiresBulk(InputStream input) throws IOException {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode pseudowireJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode pseudowireJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
|
||||
@ -33,6 +33,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query, create and remove segment routing tunnels.
|
||||
*/
|
||||
@ -69,7 +71,7 @@ public class TunnelWebResource extends AbstractWebResource {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response createTunnel(InputStream input) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode tunnelJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode tunnelJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
Tunnel tunnelInfo = TUNNEL_CODEC.decode(tunnelJson, this);
|
||||
srService.createTunnel(tunnelInfo);
|
||||
@ -88,7 +90,7 @@ public class TunnelWebResource extends AbstractWebResource {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response removeTunnel(InputStream input) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode tunnelJson = (ObjectNode) mapper.readTree(input);
|
||||
ObjectNode tunnelJson = readTreeFromStream(mapper, input);
|
||||
SegmentRoutingService srService = get(SegmentRoutingService.class);
|
||||
Tunnel tunnelInfo = TUNNEL_CODEC.decode(tunnelJson, this);
|
||||
srService.removeTunnel(tunnelInfo);
|
||||
|
||||
@ -60,6 +60,7 @@ import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
||||
import static javax.ws.rs.core.Response.Status.CONFLICT;
|
||||
import static javax.ws.rs.core.Response.Status.CREATED;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
@Path("floatingips")
|
||||
public class FloatingIpWebResource extends AbstractWebResource {
|
||||
@ -114,7 +115,7 @@ public class FloatingIpWebResource extends AbstractWebResource {
|
||||
public Response createFloatingIp(final InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
|
||||
Boolean result = nullIsNotFound((get(FloatingIpService.class)
|
||||
.createFloatingIps(floatingIps)),
|
||||
@ -137,7 +138,7 @@ public class FloatingIpWebResource extends AbstractWebResource {
|
||||
final InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
|
||||
Boolean result = nullIsNotFound(get(FloatingIpService.class)
|
||||
.updateFloatingIps(floatingIps), UPDATE_FAIL);
|
||||
|
||||
@ -17,6 +17,7 @@ package org.onosproject.vtnweb.resources;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -107,7 +108,7 @@ public class FlowClassifierWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response createFlowClassifier(InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode flow = jsonTree.get("flow_classifier");
|
||||
|
||||
FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
|
||||
@ -136,7 +137,7 @@ public class FlowClassifierWebResource extends AbstractWebResource {
|
||||
public Response updateFlowClassifier(@PathParam("flow_id") String id, final InputStream stream) {
|
||||
try {
|
||||
|
||||
JsonNode jsonTree = mapper().readTree(stream);
|
||||
JsonNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode flow = jsonTree.get("flow_classifier");
|
||||
FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
|
||||
Boolean result = nullIsNotFound(get(FlowClassifierService.class).updateFlowClassifier(flowClassifier),
|
||||
|
||||
@ -17,6 +17,7 @@ package org.onosproject.vtnweb.resources;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -106,7 +107,7 @@ public class PortChainWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response createPortChain(InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode port = jsonTree.get("port_chain");
|
||||
PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this);
|
||||
Boolean issuccess = nullIsNotFound(get(PortChainService.class).createPortChain(portChain),
|
||||
@ -132,7 +133,7 @@ public class PortChainWebResource extends AbstractWebResource {
|
||||
public Response updatePortPain(@PathParam("chain_id") String id,
|
||||
final InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode port = jsonTree.get("port_chain");
|
||||
PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this);
|
||||
Boolean result = nullIsNotFound(get(PortChainService.class).updatePortChain(portChain),
|
||||
|
||||
@ -18,6 +18,7 @@ package org.onosproject.vtnweb.resources;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -111,7 +112,7 @@ public class PortPairGroupWebResource extends AbstractWebResource {
|
||||
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper, stream);
|
||||
JsonNode port = jsonTree.get("port_pair_group");
|
||||
|
||||
PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this);
|
||||
@ -139,7 +140,7 @@ public class PortPairGroupWebResource extends AbstractWebResource {
|
||||
final InputStream stream) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper, stream);
|
||||
JsonNode port = jsonTree.get("port_pair_group");
|
||||
PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this);
|
||||
Boolean isSuccess = nullIsNotFound(get(PortPairGroupService.class).updatePortPairGroup(portPairGroup),
|
||||
|
||||
@ -18,6 +18,7 @@ package org.onosproject.vtnweb.resources;
|
||||
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -105,7 +106,7 @@ public class PortPairWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response createPortPair(InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode port = jsonTree.get("port_pair");
|
||||
PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this);
|
||||
Boolean isSuccess = nullIsNotFound(get(PortPairService.class).createPortPair(portPair),
|
||||
@ -131,7 +132,7 @@ public class PortPairWebResource extends AbstractWebResource {
|
||||
public Response updatePortPair(@PathParam("pair_id") String id,
|
||||
final InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode port = jsonTree.get("port_pair");
|
||||
PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this);
|
||||
Boolean isSuccess = nullIsNotFound(get(PortPairService.class).updatePortPair(portPair),
|
||||
|
||||
@ -68,6 +68,7 @@ import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
||||
import static javax.ws.rs.core.Response.Status.CONFLICT;
|
||||
import static javax.ws.rs.core.Response.Status.CREATED;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
@Path("routers")
|
||||
public class RouterWebResource extends AbstractWebResource {
|
||||
@ -121,7 +122,7 @@ public class RouterWebResource extends AbstractWebResource {
|
||||
public Response createRouter(final InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Collection<Router> routers = createOrUpdateByInputStream(subnode);
|
||||
|
||||
Boolean result = nullIsNotFound((get(RouterService.class)
|
||||
@ -144,7 +145,7 @@ public class RouterWebResource extends AbstractWebResource {
|
||||
final InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Collection<Router> routers = changeUpdateJsonToSub(subnode, id);
|
||||
Boolean result = nullIsNotFound(get(RouterService.class)
|
||||
.updateRouters(routers), UPDATE_FAIL);
|
||||
@ -184,7 +185,7 @@ public class RouterWebResource extends AbstractWebResource {
|
||||
}
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
if (!subnode.hasNonNull("id")) {
|
||||
throw new IllegalArgumentException("id should not be null");
|
||||
} else if (subnode.get("id").asText().isEmpty()) {
|
||||
@ -233,7 +234,7 @@ public class RouterWebResource extends AbstractWebResource {
|
||||
}
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
if (!subnode.hasNonNull("id")) {
|
||||
throw new IllegalArgumentException("id should not be null");
|
||||
} else if (subnode.get("id").asText().isEmpty()) {
|
||||
|
||||
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -109,7 +110,7 @@ public class SubnetWebResource extends AbstractWebResource {
|
||||
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
|
||||
Boolean result = nullIsNotFound((get(SubnetService.class)
|
||||
.createSubnets(subnets)),
|
||||
@ -134,7 +135,7 @@ public class SubnetWebResource extends AbstractWebResource {
|
||||
final InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode subnode = mapper.readTree(input);
|
||||
JsonNode subnode = readTreeFromStream(mapper, input);
|
||||
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
|
||||
Boolean result = nullIsNotFound(get(SubnetService.class)
|
||||
.updateSubnets(subnets), SUBNET_NOT_FOUND);
|
||||
|
||||
@ -58,6 +58,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* REST resource for interacting with the inventory of networks.
|
||||
@ -170,7 +171,7 @@ public class TenantNetworkWebResource extends AbstractWebResource {
|
||||
public Response createNetworks(InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonNode nodes = null;
|
||||
Iterable<TenantNetwork> networks = null;
|
||||
if (cfg.get("network") != null) {
|
||||
@ -207,7 +208,7 @@ public class TenantNetworkWebResource extends AbstractWebResource {
|
||||
public Response updateNetworks(@PathParam("id") String id, InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
JsonNode nodes = null;
|
||||
Iterable<TenantNetwork> networks = null;
|
||||
if (cfg.get("network") != null) {
|
||||
|
||||
@ -65,6 +65,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* REST resource for interacting with the inventory of infrastructure
|
||||
@ -113,7 +114,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
|
||||
public Response createPorts(InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
|
||||
Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
|
||||
.createPorts(vPorts), VPORT_NOT_FOUND);
|
||||
@ -162,7 +163,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
|
||||
public Response updatePorts(@PathParam("id") String id, InputStream input) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode cfg = mapper.readTree(input);
|
||||
JsonNode cfg = readTreeFromStream(mapper, input);
|
||||
Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
|
||||
Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
|
||||
.updatePorts(vPorts), VPORT_NOT_FOUND);
|
||||
|
||||
27
lib/BUCK
27
lib/BUCK
@ -1,4 +1,4 @@
|
||||
# ***** This file was auto-generated at Wed, 28 Feb 2018 18:29:16 GMT. Do not edit this file manually. *****
|
||||
# ***** This file was auto-generated at Mon, 2 Apr 2018 16:16:40 GMT. Do not edit this file manually. *****
|
||||
# ***** Use onos-lib-gen *****
|
||||
|
||||
pass_thru_pom(
|
||||
@ -522,28 +522,28 @@ remote_jar (
|
||||
|
||||
remote_jar (
|
||||
name = 'jackson-annotations',
|
||||
out = 'jackson-annotations-2.8.10.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-annotations:jar:2.8.10',
|
||||
sha1 = '5e924646d6f893bc9036939c5f2b4ecaee85e5da',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-annotations:2.8.10',
|
||||
out = 'jackson-annotations-2.9.5.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-annotations:jar:2.9.5',
|
||||
sha1 = '9056ec9db21c57d43219a84bb18c129ae51c6a5d',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-annotations:2.9.5',
|
||||
visibility = [ 'PUBLIC' ],
|
||||
)
|
||||
|
||||
remote_jar (
|
||||
name = 'jackson-core',
|
||||
out = 'jackson-core-2.8.10.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-core:jar:2.8.10',
|
||||
sha1 = 'eb21a035c66ad307e66ec8fce37f5d50fd62d039',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-core:2.8.10',
|
||||
out = 'jackson-core-2.9.5.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-core:jar:2.9.5',
|
||||
sha1 = 'a22ac51016944b06fd9ffbc9541c6e7ce5eea117',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-core:2.9.5',
|
||||
visibility = [ 'PUBLIC' ],
|
||||
)
|
||||
|
||||
remote_jar (
|
||||
name = 'jackson-databind',
|
||||
out = 'jackson-databind-2.8.10.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-databind:jar:2.8.10',
|
||||
sha1 = 'f7b83cb2bc4b88d53961e749e1ad32f49ef017b7',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-databind:2.8.10',
|
||||
out = 'jackson-databind-2.9.5.jar',
|
||||
url = 'mvn:com.fasterxml.jackson.core:jackson-databind:jar:2.9.5',
|
||||
sha1 = '3490508379d065fe3fcb80042b62f630f7588606',
|
||||
maven_coords = 'com.fasterxml.jackson.core:jackson-databind:2.9.5',
|
||||
visibility = [ 'PUBLIC' ],
|
||||
)
|
||||
|
||||
@ -1643,3 +1643,4 @@ remote_jar (
|
||||
maven_coords = 'org.gnu.inet:libidn:jar:NON-OSGI:1.15',
|
||||
visibility = [ 'PUBLIC' ],
|
||||
)
|
||||
|
||||
|
||||
@ -151,9 +151,9 @@
|
||||
"logging-interceptor": "mvn:com.squareup.okhttp3:logging-interceptor:3.9.1",
|
||||
"moshi": "mvn:com.squareup.moshi:moshi:1.4.0",
|
||||
"okio": "mvn:com.squareup.okio:okio:1.11.0",
|
||||
"jackson-annotations": "mvn:com.fasterxml.jackson.core:jackson-annotations:2.8.10",
|
||||
"jackson-core": "mvn:com.fasterxml.jackson.core:jackson-core:2.8.10",
|
||||
"jackson-databind": "mvn:com.fasterxml.jackson.core:jackson-databind:2.8.10",
|
||||
"jackson-annotations": "mvn:com.fasterxml.jackson.core:jackson-annotations:2.9.5",
|
||||
"jackson-core": "mvn:com.fasterxml.jackson.core:jackson-core:2.9.5",
|
||||
"jackson-databind": "mvn:com.fasterxml.jackson.core:jackson-databind:2.9.5",
|
||||
"javax.annotation-api": "mvn:javax.annotation:javax.annotation-api:1.2",
|
||||
"javax.inject": "mvn:org.glassfish.hk2.external:javax.inject:2.5.0-b42",
|
||||
"javax.ws.rs-api": "mvn:javax.ws.rs:javax.ws.rs-api:2.1",
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
<karaf.version>3.0.8</karaf.version>
|
||||
<jersey.version>2.26</jersey.version>
|
||||
<jetty.version>9.2.21.v20170120</jetty.version>
|
||||
<jackson.version>2.8.10</jackson.version>
|
||||
<jackson.version>2.9.5</jackson.version>
|
||||
<slf4j.version>1.7.21</slf4j.version>
|
||||
<guava.version>22.0</guava.version>
|
||||
<commons.io.version>2.6</commons.io.version>
|
||||
|
||||
@ -50,6 +50,7 @@ import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
|
||||
@ -193,7 +194,7 @@ public class RestconfWebResource extends AbstractWebResource {
|
||||
URI uri = uriInfo.getRequestUri();
|
||||
|
||||
try {
|
||||
ObjectNode rootNode = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode rootNode = readTreeFromStream(mapper(), stream);
|
||||
|
||||
service.runPostOperationOnDataResource(uri, rootNode);
|
||||
return Response.created(uriInfo.getRequestUri()).build();
|
||||
@ -238,7 +239,7 @@ public class RestconfWebResource extends AbstractWebResource {
|
||||
@Context HttpServletRequest request) {
|
||||
URI uri = uriInfo.getRequestUri();
|
||||
try {
|
||||
ObjectNode inputNode = (ObjectNode) mapper().readTree(rpcInput);
|
||||
ObjectNode inputNode = readTreeFromStream(mapper(), rpcInput);
|
||||
CompletableFuture<RestconfRpcOutput> rpcFuture = service.runRpc(uri,
|
||||
inputNode,
|
||||
request.getRemoteAddr());
|
||||
@ -297,7 +298,7 @@ public class RestconfWebResource extends AbstractWebResource {
|
||||
URI uri = uriInfo.getRequestUri();
|
||||
|
||||
try {
|
||||
ObjectNode rootNode = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode rootNode = readTreeFromStream(mapper(), stream);
|
||||
|
||||
service.runPutOperationOnDataResource(uri, rootNode);
|
||||
return Response.created(uriInfo.getRequestUri()).build();
|
||||
@ -374,7 +375,7 @@ public class RestconfWebResource extends AbstractWebResource {
|
||||
URI uri = uriInfo.getRequestUri();
|
||||
|
||||
try {
|
||||
ObjectNode rootNode = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode rootNode = readTreeFromStream(mapper(), stream);
|
||||
|
||||
service.runPatchOperationOnDataResource(uri, rootNode);
|
||||
return Response.ok().build();
|
||||
|
||||
@ -26,6 +26,7 @@ import org.slf4j.Logger;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
|
||||
@ -50,7 +51,7 @@ public final class CodecTools {
|
||||
public static ObjectNode toJson(InputStream stream) {
|
||||
ObjectNode response = null;
|
||||
try {
|
||||
response = (ObjectNode) MAPPER.readTree(stream);
|
||||
response = readTreeFromStream(MAPPER, stream);
|
||||
} catch (IOException e) {
|
||||
log.error("Parse json string failed {}", e.getMessage());
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ COMPILE_DEPS = [
|
||||
'//lib:METRICS',
|
||||
'//lib:KRYO',
|
||||
'//lib:netty',
|
||||
'//lib:JACKSON',
|
||||
]
|
||||
|
||||
osgi_jar_with_tests(
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.onlab.util;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -24,6 +26,7 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
@ -75,6 +78,8 @@ public abstract class Tools {
|
||||
|
||||
private static Random random = new SecureRandom();
|
||||
|
||||
private static final String INPUT_JSON_CANNOT_BE_NULL = "Input JSON cannot be null";
|
||||
|
||||
/**
|
||||
* Returns a thread factory that produces threads named according to the
|
||||
* supplied name pattern.
|
||||
@ -217,6 +222,19 @@ public abstract class Tools {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to convert a mapper and an input stream into a JSON tree,
|
||||
* and be tolerant of a null tree being returned.
|
||||
*
|
||||
* @param mapper JSON object mapper
|
||||
* @param stream IO stream containing the JSON
|
||||
* @return object node for the given
|
||||
* @throws IOException if JSON parsing fails
|
||||
*/
|
||||
public static ObjectNode readTreeFromStream(ObjectMapper mapper, InputStream stream) throws IOException {
|
||||
return nullIsIllegal((ObjectNode) mapper.readTree(stream), INPUT_JSON_CANNOT_BE_NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string from hex to long.
|
||||
*
|
||||
|
||||
@ -39,6 +39,7 @@ import java.net.URL;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage inventory of applications.
|
||||
@ -96,7 +97,7 @@ public class ApplicationsWebResource extends AbstractWebResource {
|
||||
public Response installApp(InputStream raw) {
|
||||
Application app;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(raw);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), raw);
|
||||
URL url = new URL(jsonTree.get(URL).asText());
|
||||
boolean activate = false;
|
||||
if (jsonTree.has(ACTIVATE)) {
|
||||
|
||||
@ -38,6 +38,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage cluster of ONOS instances.
|
||||
@ -92,7 +93,7 @@ public class ClusterWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response formCluster(InputStream config) throws IOException {
|
||||
JsonCodec<ControllerNode> codec = codec(ControllerNode.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(config);
|
||||
ObjectNode root = readTreeFromStream(mapper(), config);
|
||||
|
||||
List<ControllerNode> nodes = codec.decode((ArrayNode) root.path("nodes"), this);
|
||||
JsonNode partitionSizeNode = root.get("partitionSize");
|
||||
|
||||
@ -39,6 +39,7 @@ import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage component configurations.
|
||||
@ -105,7 +106,7 @@ public class ComponentConfigWebResource extends AbstractWebResource {
|
||||
@DefaultValue("false") @QueryParam("preset") boolean preset,
|
||||
InputStream request) throws IOException {
|
||||
ComponentConfigService service = get(ComponentConfigService.class);
|
||||
ObjectNode props = (ObjectNode) mapper().readTree(request);
|
||||
ObjectNode props = readTreeFromStream(mapper(), request);
|
||||
List<String> errorMsgs = new ArrayList<String>();
|
||||
if (preset) {
|
||||
props.fieldNames().forEachRemaining(k -> {
|
||||
@ -151,7 +152,7 @@ public class ComponentConfigWebResource extends AbstractWebResource {
|
||||
public Response unsetConfigs(@PathParam("component") String component,
|
||||
InputStream request) throws IOException {
|
||||
ComponentConfigService service = get(ComponentConfigService.class);
|
||||
ObjectNode props = (ObjectNode) mapper().readTree(request);
|
||||
ObjectNode props = readTreeFromStream(mapper(), request);
|
||||
props.fieldNames().forEachRemaining(k -> service.unsetProperty(component, k));
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query and Manage Device Keys.
|
||||
@ -96,7 +97,7 @@ public class DeviceKeyWebResource extends AbstractWebResource {
|
||||
public Response addDeviceKey(InputStream stream) {
|
||||
try {
|
||||
DeviceKeyAdminService service = get(DeviceKeyAdminService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode root = readTreeFromStream(mapper(), stream);
|
||||
DeviceKey deviceKey = codec(DeviceKey.class).decode(root, this);
|
||||
service.addKey(deviceKey);
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
@ -292,7 +293,7 @@ public class DpisWebResource extends AbstractWebResource {
|
||||
ObjectNode result;
|
||||
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
log.debug("jsonTree={}", jsonTree);
|
||||
|
||||
DpiStatistics ds = codec(DpiStatistics.class).decode(jsonTree, this);
|
||||
|
||||
@ -39,6 +39,8 @@ import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage flow objectives.
|
||||
*/
|
||||
@ -74,7 +76,7 @@ public class FlowObjectiveWebResource extends AbstractWebResource {
|
||||
InputStream stream) {
|
||||
try {
|
||||
UriBuilder locationBuilder = null;
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
validateDeviceId(deviceId, jsonTree);
|
||||
|
||||
if (appId != null) {
|
||||
|
||||
@ -52,6 +52,7 @@ import java.util.stream.StreamSupport;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsIllegal;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query and program flow rules.
|
||||
@ -113,7 +114,7 @@ public class FlowsWebResource extends AbstractWebResource {
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response createFlows(@QueryParam("appId") String appId, InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
ArrayNode flowsArray = nullIsIllegal((ArrayNode) jsonTree.get(FLOWS),
|
||||
FLOW_ARRAY_REQUIRED);
|
||||
|
||||
@ -248,7 +249,7 @@ public class FlowsWebResource extends AbstractWebResource {
|
||||
@QueryParam("appId") String appId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
|
||||
if (specifiedDeviceId != null &&
|
||||
!specifiedDeviceId.asText().equals(deviceId)) {
|
||||
@ -312,7 +313,7 @@ public class FlowsWebResource extends AbstractWebResource {
|
||||
List<FlowEntry> rulesToRemove = new ArrayList<>();
|
||||
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
|
||||
JsonNode jsonFlows = jsonTree.get("flows");
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ import java.io.InputStream;
|
||||
|
||||
import org.onlab.util.HexString;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query and program group rules.
|
||||
@ -148,7 +149,7 @@ public class GroupsWebResource extends AbstractWebResource {
|
||||
InputStream stream) {
|
||||
try {
|
||||
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
|
||||
|
||||
if (specifiedDeviceId != null &&
|
||||
|
||||
@ -57,6 +57,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.onosproject.net.HostId.hostId;
|
||||
|
||||
/**
|
||||
@ -139,7 +140,7 @@ public class HostsWebResource extends AbstractWebResource {
|
||||
URI location;
|
||||
try {
|
||||
// Parse the input stream
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode root = readTreeFromStream(mapper(), stream);
|
||||
|
||||
HostProviderRegistry hostProviderRegistry = get(HostProviderRegistry.class);
|
||||
InternalHostProvider hostProvider = new InternalHostProvider();
|
||||
|
||||
@ -57,6 +57,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.onosproject.net.intent.IntentState.FAILED;
|
||||
import static org.onosproject.net.intent.IntentState.WITHDRAWN;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
@ -297,7 +298,7 @@ public class IntentsWebResource extends AbstractWebResource {
|
||||
public Response createIntent(InputStream stream) {
|
||||
try {
|
||||
IntentService service = get(IntentService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode root = readTreeFromStream(mapper(), stream);
|
||||
Intent intent = codec(Intent.class).decode(root, this);
|
||||
service.submit(intent);
|
||||
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
|
||||
|
||||
@ -40,6 +40,7 @@ import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage the mastership of ONOS instances.
|
||||
@ -190,7 +191,7 @@ public final class MastershipWebResource extends AbstractWebResource {
|
||||
public Response setRole(InputStream stream) {
|
||||
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode deviceIdJson = jsonTree.get(DEVICE_ID);
|
||||
JsonNode nodeIdJson = jsonTree.get(NODE_ID);
|
||||
MastershipRole role = codec(MastershipRole.class).decode(jsonTree, this);
|
||||
|
||||
@ -44,6 +44,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
@ -138,7 +139,7 @@ public class MetersWebResource extends AbstractWebResource {
|
||||
public Response createMeter(@PathParam("deviceId") String deviceId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
|
||||
|
||||
if ((specifiedDeviceId != null &&
|
||||
|
||||
@ -25,6 +25,7 @@ import org.onosproject.net.mcast.MulticastRouteService;
|
||||
import org.onosproject.rest.AbstractWebResource;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
@ -79,7 +80,7 @@ public class MulticastRouteWebResource extends AbstractWebResource {
|
||||
final String ingressStr = "ingress";
|
||||
MulticastRouteService service = get(MulticastRouteService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
McastRoute route = codec(McastRoute.class).decode(jsonTree, this);
|
||||
service.add(route);
|
||||
if (jsonTree.has(ingressStr)) {
|
||||
@ -110,7 +111,7 @@ public class MulticastRouteWebResource extends AbstractWebResource {
|
||||
public Response deleteRoute(InputStream stream) {
|
||||
MulticastRouteService service = get(MulticastRouteService.class);
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
McastRoute route = codec(McastRoute.class).decode(jsonTree, this);
|
||||
service.remove(route);
|
||||
} catch (IOException ex) {
|
||||
@ -141,7 +142,7 @@ public class MulticastRouteWebResource extends AbstractWebResource {
|
||||
try {
|
||||
McastRoute route = new McastRoute(IpAddress.valueOf(source), IpAddress.valueOf(group),
|
||||
McastRoute.Type.STATIC);
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
|
||||
jsonTree.path("sinks").forEach(node -> {
|
||||
ConnectPoint sink = ConnectPoint.deviceConnectPoint(node.asText());
|
||||
|
||||
@ -41,6 +41,7 @@ import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.emptyIsNotFound;
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manage network configurations.
|
||||
@ -207,7 +208,7 @@ public class NetworkConfigWebResource extends AbstractWebResource {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Response upload(InputStream request) throws IOException {
|
||||
NetworkConfigService service = get(NetworkConfigService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(request);
|
||||
ObjectNode root = readTreeFromStream(mapper(), request);
|
||||
List<String> errorMsgs = new ArrayList<String>();
|
||||
root.fieldNames()
|
||||
.forEachRemaining(sk -> {
|
||||
@ -241,7 +242,7 @@ public class NetworkConfigWebResource extends AbstractWebResource {
|
||||
public Response upload(@PathParam("subjectClassKey") String subjectClassKey,
|
||||
InputStream request) throws IOException {
|
||||
NetworkConfigService service = get(NetworkConfigService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(request);
|
||||
ObjectNode root = readTreeFromStream(mapper(), request);
|
||||
SubjectFactory subjectFactory =
|
||||
nullIsNotFound(service.getSubjectFactory(subjectClassKey),
|
||||
subjectClassNotValidErrorString(subjectClassKey));
|
||||
@ -269,7 +270,7 @@ public class NetworkConfigWebResource extends AbstractWebResource {
|
||||
@PathParam("subjectKey") String subjectKey,
|
||||
InputStream request) throws IOException {
|
||||
NetworkConfigService service = get(NetworkConfigService.class);
|
||||
ObjectNode root = (ObjectNode) mapper().readTree(request);
|
||||
ObjectNode root = readTreeFromStream(mapper(), request);
|
||||
SubjectFactory subjectFactory =
|
||||
nullIsNotFound(service.getSubjectFactory(subjectClassKey),
|
||||
subjectClassNotValidErrorString(subjectClassKey));
|
||||
@ -301,7 +302,7 @@ public class NetworkConfigWebResource extends AbstractWebResource {
|
||||
@PathParam("configKey") String configKey,
|
||||
InputStream request) throws IOException {
|
||||
NetworkConfigService service = get(NetworkConfigService.class);
|
||||
JsonNode root = mapper().readTree(request);
|
||||
JsonNode root = readTreeFromStream(mapper(), request);
|
||||
SubjectFactory subjectFactory =
|
||||
nullIsNotFound(service.getSubjectFactory(subjectClassKey),
|
||||
subjectClassNotValidErrorString(subjectClassKey));
|
||||
|
||||
@ -43,6 +43,7 @@ import java.net.URISyntaxException;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onlab.util.Tools.nullIsNotFound;
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Manages region and device membership.
|
||||
@ -119,7 +120,7 @@ public class RegionsWebResource extends AbstractWebResource {
|
||||
public Response createRegion(InputStream stream) {
|
||||
URI location;
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
final Region region = codec(Region.class).decode(jsonTree, this);
|
||||
final Region resultRegion = regionAdminService.createRegion(region.id(),
|
||||
region.name(), region.type(), region.masters());
|
||||
@ -146,7 +147,7 @@ public class RegionsWebResource extends AbstractWebResource {
|
||||
public Response updateRegion(@PathParam("regionId") String regionId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedRegionId = jsonTree.get("id");
|
||||
|
||||
if (specifiedRegionId != null &&
|
||||
@ -242,7 +243,7 @@ public class RegionsWebResource extends AbstractWebResource {
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<DeviceId> extractDeviceIds(InputStream stream) throws IOException {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode deviceIdsJson = jsonTree.get("deviceIds");
|
||||
|
||||
if (deviceIdsJson == null || deviceIdsJson.size() == 0) {
|
||||
|
||||
@ -38,6 +38,8 @@ import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query and manage tenants of virtual networks.
|
||||
*/
|
||||
@ -116,7 +118,7 @@ public class TenantWebResource extends AbstractWebResource {
|
||||
* @throws IOException if unable to parse the request
|
||||
*/
|
||||
private TenantId getTenantIdFromJsonStream(InputStream stream) throws IOException {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedTenantId = jsonTree.get("id");
|
||||
|
||||
if (specifiedTenantId == null) {
|
||||
|
||||
@ -51,6 +51,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
|
||||
/**
|
||||
* Query and Manage Virtual Network elements.
|
||||
*/
|
||||
@ -176,7 +178,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
public Response createVirtualDevice(@PathParam("networkId") long networkId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
final VirtualDevice vdevReq = codec(VirtualDevice.class).decode(jsonTree, this);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
if (specifiedNetworkId == null || specifiedNetworkId.asLong() != (networkId)) {
|
||||
@ -250,7 +252,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
@PathParam("deviceId") String virtDeviceId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
// final VirtualPort vportReq = codec(VirtualPort.class).decode(jsonTree, this);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
|
||||
@ -335,7 +337,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
public Response createVirtualLink(@PathParam("networkId") long networkId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
if (specifiedNetworkId == null || specifiedNetworkId.asLong() != (networkId)) {
|
||||
throw new IllegalArgumentException(INVALID_FIELD + "networkId");
|
||||
@ -368,7 +370,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
public Response removeVirtualLink(@PathParam("networkId") long networkId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
if (specifiedNetworkId != null &&
|
||||
specifiedNetworkId.asLong() != (networkId)) {
|
||||
@ -416,7 +418,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
public Response createVirtualHost(@PathParam("networkId") long networkId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
if (specifiedNetworkId == null || specifiedNetworkId.asLong() != (networkId)) {
|
||||
throw new IllegalArgumentException(INVALID_FIELD + "networkId");
|
||||
@ -450,7 +452,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
public Response removeVirtualHost(@PathParam("networkId") long networkId,
|
||||
InputStream stream) {
|
||||
try {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode specifiedNetworkId = jsonTree.get("networkId");
|
||||
if (specifiedNetworkId != null &&
|
||||
specifiedNetworkId.asLong() != (networkId)) {
|
||||
@ -474,7 +476,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* @throws IOException if unable to parse the request
|
||||
*/
|
||||
private JsonNode getFromJsonStream(InputStream stream, String jsonFieldName) throws IOException {
|
||||
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
|
||||
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
|
||||
JsonNode jsonNode = jsonTree.get(jsonFieldName);
|
||||
|
||||
if (jsonNode == null) {
|
||||
|
||||
@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.onlab.util.Tools.readTreeFromStream;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
@ -114,7 +115,7 @@ public class TopologyResource extends BaseResource {
|
||||
@Consumes("application/json")
|
||||
@Deprecated
|
||||
public Response setSprites(InputStream stream) throws IOException {
|
||||
JsonNode root = mapper.readTree(stream);
|
||||
JsonNode root = readTreeFromStream(mapper, stream);
|
||||
String name = root.path("defn_name").asText("sprites");
|
||||
get(SpriteService.class).put(name, root);
|
||||
return Response.ok().build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user