blob: c4b4c888b422bd6e879faa4b6516dea314482e6a [file] [log] [blame]
Thomas Vachuska530e52a2015-05-06 19:51:32 -07001/*
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 */
16package org.onosproject.ui.impl;
17
18import com.sun.jersey.multipart.FormDataParam;
19import org.onlab.rest.BaseResource;
20import org.onosproject.app.ApplicationAdminService;
21import org.onosproject.core.Application;
22
23import javax.ws.rs.Consumes;
24import javax.ws.rs.POST;
25import javax.ws.rs.Path;
26import javax.ws.rs.core.MediaType;
27import javax.ws.rs.core.Response;
28import java.io.IOException;
29import java.io.InputStream;
30
31/**
32 * Application upload resource.
33 */
34@Path("applications")
35public 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}