blob: f811044665107859e40050b4f9c41a4e8ef86448 [file] [log] [blame]
Thomas Vachuskaf7582552015-05-14 10:13:46 -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 */
16
17package org.onosproject.cord.gui;
18
19import javax.ws.rs.GET;
20import javax.ws.rs.Path;
Simon Hunt3e59c602015-05-18 15:29:42 -070021import javax.ws.rs.PathParam;
22import javax.ws.rs.Produces;
23import javax.ws.rs.core.MediaType;
Thomas Vachuskaf7582552015-05-14 10:13:46 -070024import javax.ws.rs.core.Response;
25
26/**
27 * Web resource to use as the GUI back-end and as a proxy to XOS REST API.
28 */
29@Path("")
30public class CordWebResource {
31
Simon Hunt3e59c602015-05-18 15:29:42 -070032 private Response fakeData(String which, String suffix) {
33 String path = "local/" + which + "-" + suffix + ".json";
34 String content = FakeUtils.slurp(path);
35 if (content == null) {
36 return Response.status(Response.Status.NOT_FOUND).build();
37 }
38 return Response.ok(content).build();
Thomas Vachuskaf7582552015-05-14 10:13:46 -070039 }
40
Simon Hunt8dd716a2015-05-14 18:51:52 -070041 @GET
Simon Hunt3e59c602015-05-18 15:29:42 -070042 @Produces(MediaType.APPLICATION_JSON)
43 @Path("dashboard/{suffix}")
44 public Response dashboard(@PathParam("suffix") String suffix) {
45 return fakeData("dashboard", suffix);
Simon Hunt8dd716a2015-05-14 18:51:52 -070046 }
Simon Hunt3e59c602015-05-18 15:29:42 -070047
48 @GET
49 @Produces(MediaType.APPLICATION_JSON)
50 @Path("bundle/{suffix}")
51 public Response bundle(@PathParam("suffix") String suffix) {
52 return fakeData("bundle", suffix);
53 }
54
55 @GET
56 @Produces(MediaType.APPLICATION_JSON)
57 @Path("users/{suffix}")
58 public Response users(@PathParam("suffix") String suffix) {
59 return fakeData("users", suffix);
60 }
61
Simon Hunta29c87b2015-05-21 09:56:19 -070062 @GET
63 @Produces(MediaType.APPLICATION_JSON)
64 @Path("dashboard")
65 public Response dashboard() {
66 // TODO:
67 return Response.ok().build();
68 }
69
Thomas Vachuskaf7582552015-05-14 10:13:46 -070070}