Jian Li
Committed by Gerrit Code Review

Treat null as NOT FOUND for application and applicationId

Change-Id: Ieaf65770b0057c85cef47e1904efbc93709ff06b
...@@ -35,12 +35,17 @@ import javax.ws.rs.core.Response; ...@@ -35,12 +35,17 @@ import javax.ws.rs.core.Response;
35 import java.io.InputStream; 35 import java.io.InputStream;
36 import java.util.Set; 36 import java.util.Set;
37 37
38 +import static org.onlab.util.Tools.nullIsNotFound;
39 +
38 /** 40 /**
39 * Manage inventory of applications. 41 * Manage inventory of applications.
40 */ 42 */
41 @Path("applications") 43 @Path("applications")
42 public class ApplicationsWebResource extends AbstractWebResource { 44 public class ApplicationsWebResource extends AbstractWebResource {
43 45
46 + private static final String APP_ID_NOT_FOUND = "Application ID is not found";
47 + private static final String APP_NOT_FOUND = "Application is not found";
48 +
44 /** 49 /**
45 * Get all installed applications. 50 * Get all installed applications.
46 * Returns array of all installed applications. 51 * Returns array of all installed applications.
...@@ -210,11 +215,12 @@ public class ApplicationsWebResource extends AbstractWebResource { ...@@ -210,11 +215,12 @@ public class ApplicationsWebResource extends AbstractWebResource {
210 } 215 }
211 216
212 private Response response(ApplicationAdminService service, ApplicationId appId) { 217 private Response response(ApplicationAdminService service, ApplicationId appId) {
213 - Application app = service.getApplication(appId); 218 + Application app = nullIsNotFound(service.getApplication(appId), APP_NOT_FOUND);
214 return ok(codec(Application.class).encode(app, this)).build(); 219 return ok(codec(Application.class).encode(app, this)).build();
215 } 220 }
216 221
217 private Response response(ApplicationId appId) { 222 private Response response(ApplicationId appId) {
218 - return ok(codec(ApplicationId.class).encode(appId, this)).build(); 223 + ApplicationId checkedAppId = nullIsNotFound(appId, APP_ID_NOT_FOUND);
224 + return ok(codec(ApplicationId.class).encode(checkedAppId, this)).build();
219 } 225 }
220 } 226 }
......