Thomas Vachuska
Committed by Gerrit Code Review

GUI -- Fixed application upload/install functionality.

Change-Id: I5b02ff7470bda46b76bc067b64514204b474fb97
......@@ -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>
......
......@@ -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>
......
......@@ -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.*,
......
/*
* 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();
}
}
......@@ -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>
......
......@@ -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>
......
......@@ -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);
......