Treat null as NOT FOUND for application and applicationId
Change-Id: Ieaf65770b0057c85cef47e1904efbc93709ff06b
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
index ee6a6b5..8d0bc3e 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
@@ -35,12 +35,17 @@
import java.io.InputStream;
import java.util.Set;
+import static org.onlab.util.Tools.nullIsNotFound;
+
/**
* Manage inventory of applications.
*/
@Path("applications")
public class ApplicationsWebResource extends AbstractWebResource {
+ private static final String APP_ID_NOT_FOUND = "Application ID is not found";
+ private static final String APP_NOT_FOUND = "Application is not found";
+
/**
* Get all installed applications.
* Returns array of all installed applications.
@@ -210,11 +215,12 @@
}
private Response response(ApplicationAdminService service, ApplicationId appId) {
- Application app = service.getApplication(appId);
+ Application app = nullIsNotFound(service.getApplication(appId), APP_NOT_FOUND);
return ok(codec(Application.class).encode(app, this)).build();
}
private Response response(ApplicationId appId) {
- return ok(codec(ApplicationId.class).encode(appId, this)).build();
+ ApplicationId checkedAppId = nullIsNotFound(appId, APP_ID_NOT_FOUND);
+ return ok(codec(ApplicationId.class).encode(checkedAppId, this)).build();
}
}