Thomas Vachuska
Committed by Gerrit Code Review

GUI -- Fixed application upload/install functionality.

Change-Id: I5b02ff7470bda46b76bc067b64514204b474fb97
...@@ -75,6 +75,8 @@ ...@@ -75,6 +75,8 @@
75 <bundle>mvn:com.sun.jersey/jersey-core/1.19</bundle> 75 <bundle>mvn:com.sun.jersey/jersey-core/1.19</bundle>
76 <bundle>mvn:com.sun.jersey/jersey-server/1.19</bundle> 76 <bundle>mvn:com.sun.jersey/jersey-server/1.19</bundle>
77 <bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle> 77 <bundle>mvn:com.sun.jersey/jersey-servlet/1.19</bundle>
78 + <bundle>mvn:com.sun.jersey.contribs/jersey-multipart/1.19</bundle>
79 + <bundle>mvn:org.jvnet.mimepull/mimepull/1.9.3</bundle>
78 <bundle>mvn:javax.ws.rs/jsr311-api/1.1.1</bundle> 80 <bundle>mvn:javax.ws.rs/jsr311-api/1.1.1</bundle>
79 </feature> 81 </feature>
80 82
......
...@@ -211,6 +211,12 @@ ...@@ -211,6 +211,12 @@
211 <scope>provided</scope> 211 <scope>provided</scope>
212 </dependency> 212 </dependency>
213 <dependency> 213 <dependency>
214 + <groupId>com.sun.jersey.contribs</groupId>
215 + <artifactId>jersey-multipart</artifactId>
216 + <version>${jersey.version}</version>
217 + <scope>provided</scope>
218 + </dependency>
219 + <dependency>
214 <groupId>com.sun.jersey.jersey-test-framework</groupId> 220 <groupId>com.sun.jersey.jersey-test-framework</groupId>
215 <artifactId>jersey-test-framework-core</artifactId> 221 <artifactId>jersey-test-framework-core</artifactId>
216 <version>${jersey.version}</version> 222 <version>${jersey.version}</version>
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
52 <scope>test</scope> 52 <scope>test</scope>
53 <classifier>tests</classifier> 53 <classifier>tests</classifier>
54 </dependency> 54 </dependency>
55 + <dependency>
56 + <groupId>com.sun.jersey.contribs</groupId>
57 + <artifactId>jersey-multipart</artifactId>
58 + </dependency>
55 </dependencies> 59 </dependencies>
56 60
57 <build> 61 <build>
...@@ -81,6 +85,9 @@ ...@@ -81,6 +85,9 @@
81 com.sun.jersey.api, 85 com.sun.jersey.api,
82 com.sun.jersey.spi.container.servlet, 86 com.sun.jersey.spi.container.servlet,
83 com.sun.jersey.server.impl.container.servlet, 87 com.sun.jersey.server.impl.container.servlet,
88 + com.sun.jersey.multipart,
89 + com.sun.jersey.core.header,
90 + org.jvnet.mimepull,
84 com.fasterxml.jackson.databind, 91 com.fasterxml.jackson.databind,
85 com.fasterxml.jackson.databind.node, 92 com.fasterxml.jackson.databind.node,
86 com.google.common.base.*, 93 com.google.common.base.*,
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.ui.impl;
17 +
18 +import com.sun.jersey.multipart.FormDataParam;
19 +import org.onlab.rest.BaseResource;
20 +import org.onosproject.app.ApplicationAdminService;
21 +import org.onosproject.core.Application;
22 +
23 +import javax.ws.rs.Consumes;
24 +import javax.ws.rs.POST;
25 +import javax.ws.rs.Path;
26 +import javax.ws.rs.core.MediaType;
27 +import javax.ws.rs.core.Response;
28 +import java.io.IOException;
29 +import java.io.InputStream;
30 +
31 +/**
32 + * Application upload resource.
33 + */
34 +@Path("applications")
35 +public class ApplicationResource extends BaseResource {
36 +
37 + @Path("upload")
38 + @POST
39 + @Consumes(MediaType.MULTIPART_FORM_DATA)
40 + public Response upload(@FormDataParam("file") InputStream stream) throws IOException {
41 + Application app = get(ApplicationAdminService.class).install(stream);
42 + return Response.ok(app.toString()).build();
43 + }
44 +
45 +}
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
139 <param-name>com.sun.jersey.config.property.classnames</param-name> 139 <param-name>com.sun.jersey.config.property.classnames</param-name>
140 <param-value> 140 <param-value>
141 org.onosproject.ui.impl.TopologyResource, 141 org.onosproject.ui.impl.TopologyResource,
142 + org.onosproject.ui.impl.ApplicationResource
142 </param-value> 143 </param-value>
143 </init-param> 144 </init-param>
144 <load-on-startup>1</load-on-startup> 145 <load-on-startup>1</load-on-startup>
......
...@@ -13,10 +13,13 @@ ...@@ -13,10 +13,13 @@
13 <div id="app-uninstall" icon icon-size="36" icon-id="minus"></div> 13 <div id="app-uninstall" icon icon-size="36" icon-id="minus"></div>
14 </div> 14 </div>
15 15
16 - <form id="app-form" method="POST" action="/onos/v1/applications/upload" enctype="multipart/form-data" style="display:none"> 16 + <form id="app-form" method="POST" action="rs/applications/upload"
17 - <input type="file" id="file" accept=".oar"> 17 + target="app-form-response" enctype="multipart/form-data" style="display:none">
18 + <input type="file" name="file" id="file" size="50" accept=".oar">
18 <button type="submit" id="app-upload">Upload</button> 19 <button type="submit" id="app-upload">Upload</button>
19 </form> 20 </form>
21 + <iframe id="app-form-response" name="app-form-response"
22 + src="" width="0" height="0" style="visibility:hidden;display:none"></iframe>
20 </div> 23 </div>
21 24
22 <div class="summary-list" onos-fixed-header> 25 <div class="summary-list" onos-fixed-header>
......
...@@ -51,6 +51,11 @@ ...@@ -51,6 +51,11 @@
51 $scope.sortCallback(); 51 $scope.sortCallback();
52 }; 52 };
53 53
54 + document.getElementById('app-form-response').onload = function () {
55 + document.getElementById('app-form').reset();
56 + $scope.refresh();
57 + }
58 +
54 function appAction(action) { 59 function appAction(action) {
55 if (selection) { 60 if (selection) {
56 $log.debug('Initiating uninstall of', selection); 61 $log.debug('Initiating uninstall of', selection);
......