Changes Listed below:
[music.git] / src / main / java / org / onap / music / rest / RestMusicVersionAPI.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2017 AT&T Intellectual Property
6  * ===================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  * 
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  * 
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22
23 package org.onap.music.rest;
24
25 import java.util.Map;
26
27 import javax.servlet.http.HttpServletResponse;
28 import javax.ws.rs.GET;
29 import javax.ws.rs.Path;
30 import javax.ws.rs.Produces;
31 import javax.ws.rs.core.Context;
32 import javax.ws.rs.core.MediaType;
33
34 import org.onap.music.response.jsonobjects.JsonResponse;
35 import org.onap.music.eelf.logging.EELFLoggerDelegate;
36 import org.onap.music.main.MusicUtil;
37 import org.onap.music.main.ResultType;
38
39 import com.att.eelf.configuration.EELFLogger;
40 import com.att.eelf.configuration.EELFManager;
41
42 import io.swagger.annotations.Api;
43 import io.swagger.annotations.ApiOperation;
44
45
46 @Path("/v{version: [0-9]+}/version")
47 @Api(value="Version Api")
48 public class RestMusicVersionAPI {
49
50     private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class);
51
52     /**
53      * Get the version of MUSIC.
54      * @return
55      */
56     @GET
57     @ApiOperation(value = "Get Version", response = Map.class)
58     @Produces(MediaType.APPLICATION_JSON)
59     public Map<String,Object> version(@Context HttpServletResponse response) {
60         logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion());
61         response.addHeader("X-latestVersion",MusicUtil.getVersion());
62         return new JsonResponse(ResultType.SUCCESS).
63             setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap();
64     }
65
66     /**
67      * Get the version of MUSIC.
68      * @return
69      */
70     @GET
71     @Path("/build")
72     @ApiOperation(value = "Get Version", response = Map.class)
73     @Produces(MediaType.APPLICATION_JSON)
74     public Map<String,Object> build(@Context HttpServletResponse response) {
75         logger.info("Replying to request for MUSIC build with MUSIC:" + MusicUtil.getBuild());
76         response.addHeader("X-latestVersion",MusicUtil.getVersion());
77         return new JsonResponse(ResultType.SUCCESS)
78             .setMusicBuild("MUSIC:" + MusicUtil.getBuild())
79             .setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap();
80     }
81
82
83 }