happy holiday and everything is in progress
[alto.git] / alto-northbound / src / main / java / org / opendaylight / alto / northbound / AltoNorthbound.java
1 /*
2  * Copyright (c) 2015 Yale University and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.alto.northbound;
9
10 import javax.ws.rs.GET;
11 import javax.ws.rs.Path;
12 import javax.ws.rs.PathParam;
13 import javax.ws.rs.Produces;
14 import javax.ws.rs.core.Response;
15
16 import org.opendaylight.alto.commons.types.mapper.JSONMapper;
17 import org.opendaylight.alto.commons.types.rfc7285.MediaType;
18 import org.opendaylight.alto.services.AltoService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.IRD;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
22
23 @Path("/")
24 public class AltoNorthbound {
25   private AltoService altoService = new AltoService();
26   private JSONMapper mapper = new JSONMapper();
27   
28   @GET
29   @Produces({ MediaType.ALTO_DIRECTORY, MediaType.ALTO_ERROR })
30   public Response retrieveIRD() {
31     try {
32       IRD ird = altoService.getIRD();
33       return Response.ok(ird, MediaType.ALTO_DIRECTORY).build();
34     } catch (Exception e) {
35     }
36     return Response.ok("", MediaType.ALTO_ERROR).build();
37   }
38
39   @Path("/networkmap/{networkmap_id}")
40   @GET
41   @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
42   public Response retrieveNetworkMap(
43       @PathParam(value = "networkmap_id") String nmap_id) {
44     NetworkMap networkMap = altoService.getNetworkMap(new ResourceId(nmap_id));
45     try {
46       return Response.ok("", MediaType.ALTO_NETWORKMAP).build();
47     } catch (Exception e) { 
48       return Response.ok("", MediaType.ALTO_ERROR).build();
49     }
50   }
51 }