ONOS-7034
app-install should give error code 400 if dependencies are missing
Change-Id: I742c0d6c67125112ce2d4a3bf44715a29b4c5a8a
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 3a4eb5c..2f46933 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
@@ -17,6 +17,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.app.ApplicationAdminService;
+import org.onosproject.app.ApplicationException;
import org.onosproject.core.Application;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -108,7 +109,7 @@
if (activate) {
service.activate(app.id());
}
- } catch (IOException ex) {
+ } catch (IOException | ApplicationException ex) {
throw new IllegalArgumentException(ex);
}
return ok(codec(Application.class).encode(app, this)).build();
@@ -130,10 +131,16 @@
@DefaultValue("false") boolean activate,
InputStream stream) {
ApplicationAdminService service = get(ApplicationAdminService.class);
- Application app = service.install(stream);
- if (activate) {
- service.activate(app.id());
+ Application app;
+ try {
+ app = service.install(stream);
+ if (activate) {
+ service.activate(app.id());
+ }
+ } catch (ApplicationException ex) {
+ throw new IllegalArgumentException(ex);
}
+
return ok(codec(Application.class).encode(app, this)).build();
}