Revert "Fix for ONOS-5417:Issue with Creating Flows using POST flows REST API"
This reverts commit dba61119d17fcffa67026d1cf7e450fc7fb2a2ec.
This breaks compatibility with the existing API where users can POST a flow without specifying an app ID.
Change-Id: I50b4be3cb018a2d5a5fe61153d6c491df49122e2
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
index e9f88ba..fa5c3c7 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
@@ -116,14 +116,13 @@
@Produces(MediaType.APPLICATION_JSON)
public Response createFlows(@QueryParam("appId") String appId, InputStream stream) {
try {
- final ApplicationService appService = get(ApplicationService.class);
- final ApplicationId idInstant = nullIsNotFound(appService.getId(appId), APP_ID_NOT_FOUND);
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
ArrayNode flowsArray = nullIsIllegal((ArrayNode) jsonTree.get(FLOWS),
FLOW_ARRAY_REQUIRED);
- flowsArray.forEach(flowJson -> ((ObjectNode) flowJson).put("appId", idInstant.name()));
-
+ if (appId != null) {
+ flowsArray.forEach(flowJson -> ((ObjectNode) flowJson).put("appId", appId));
+ }
List<FlowRule> rules = codec(FlowRule.class).decode(flowsArray, this);
@@ -254,8 +253,6 @@
@QueryParam("appId") String appId,
InputStream stream) {
try {
- final ApplicationService appService = get(ApplicationService.class);
- final ApplicationId idInstant = nullIsNotFound(appService.getId(appId), APP_ID_NOT_FOUND);
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
if (specifiedDeviceId != null &&
@@ -265,7 +262,9 @@
}
jsonTree.put("deviceId", deviceId);
- jsonTree.put("appId", idInstant.name());
+ if (appId != null) {
+ jsonTree.put("appId", appId);
+ }
FlowRule rule = codec(FlowRule.class).decode(jsonTree, this);
service.applyFlowRules(rule);