GUI -- Fixed application upload/install functionality.
Change-Id: I5b02ff7470bda46b76bc067b64514204b474fb97
diff --git a/features/features.xml b/features/features.xml
index 594dc69..ac06664 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -75,6 +75,8 @@
<bundle>mvn:com.sun.jersey/jersey-core/1.19</bundle>
<bundle>mvn:com.sun.jersey/jersey-server/1.19</bundle>
<bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle>
+ <bundle>mvn:com.sun.jersey.contribs/jersey-multipart/1.19</bundle>
+ <bundle>mvn:org.jvnet.mimepull/mimepull/1.9.3</bundle>
<bundle>mvn:javax.ws.rs/jsr311-api/1.1.1</bundle>
</feature>
diff --git a/pom.xml b/pom.xml
index 3feb61a..a000472 100644
--- a/pom.xml
+++ b/pom.xml
@@ -211,6 +211,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId>
+ <version>${jersey.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>${jersey.version}</version>
diff --git a/web/gui/pom.xml b/web/gui/pom.xml
index 9747b3e..65f4f58 100644
--- a/web/gui/pom.xml
+++ b/web/gui/pom.xml
@@ -52,6 +52,10 @@
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -81,6 +85,9 @@
com.sun.jersey.api,
com.sun.jersey.spi.container.servlet,
com.sun.jersey.server.impl.container.servlet,
+ com.sun.jersey.multipart,
+ com.sun.jersey.core.header,
+ org.jvnet.mimepull,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
com.google.common.base.*,
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/ApplicationResource.java b/web/gui/src/main/java/org/onosproject/ui/impl/ApplicationResource.java
new file mode 100644
index 0000000..c4b4c88
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/ApplicationResource.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ui.impl;
+
+import com.sun.jersey.multipart.FormDataParam;
+import org.onlab.rest.BaseResource;
+import org.onosproject.app.ApplicationAdminService;
+import org.onosproject.core.Application;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Application upload resource.
+ */
+@Path("applications")
+public class ApplicationResource extends BaseResource {
+
+ @Path("upload")
+ @POST
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ public Response upload(@FormDataParam("file") InputStream stream) throws IOException {
+ Application app = get(ApplicationAdminService.class).install(stream);
+ return Response.ok(app.toString()).build();
+ }
+
+}
diff --git a/web/gui/src/main/webapp/WEB-INF/web.xml b/web/gui/src/main/webapp/WEB-INF/web.xml
index f83fbad..ace06db 100644
--- a/web/gui/src/main/webapp/WEB-INF/web.xml
+++ b/web/gui/src/main/webapp/WEB-INF/web.xml
@@ -139,6 +139,7 @@
<param-name>com.sun.jersey.config.property.classnames</param-name>
<param-value>
org.onosproject.ui.impl.TopologyResource,
+ org.onosproject.ui.impl.ApplicationResource
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
diff --git a/web/gui/src/main/webapp/app/view/app/app.html b/web/gui/src/main/webapp/app/view/app/app.html
index c57da76..b3cc209 100644
--- a/web/gui/src/main/webapp/app/view/app/app.html
+++ b/web/gui/src/main/webapp/app/view/app/app.html
@@ -13,10 +13,13 @@
<div id="app-uninstall" icon icon-size="36" icon-id="minus"></div>
</div>
- <form id="app-form" method="POST" action="/onos/v1/applications/upload" enctype="multipart/form-data" style="display:none">
- <input type="file" id="file" accept=".oar">
+ <form id="app-form" method="POST" action="rs/applications/upload"
+ target="app-form-response" enctype="multipart/form-data" style="display:none">
+ <input type="file" name="file" id="file" size="50" accept=".oar">
<button type="submit" id="app-upload">Upload</button>
</form>
+ <iframe id="app-form-response" name="app-form-response"
+ src="" width="0" height="0" style="visibility:hidden;display:none"></iframe>
</div>
<div class="summary-list" onos-fixed-header>
diff --git a/web/gui/src/main/webapp/app/view/app/app.js b/web/gui/src/main/webapp/app/view/app/app.js
index 674407b..cacd5e0 100644
--- a/web/gui/src/main/webapp/app/view/app/app.js
+++ b/web/gui/src/main/webapp/app/view/app/app.js
@@ -51,6 +51,11 @@
$scope.sortCallback();
};
+ document.getElementById('app-form-response').onload = function () {
+ document.getElementById('app-form').reset();
+ $scope.refresh();
+ }
+
function appAction(action) {
if (selection) {
$log.debug('Initiating uninstall of', selection);