Docker update and POM fix
[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 package org.onap.music.rest;
23
24 import java.util.Map;
25
26 import javax.servlet.http.HttpServletResponse;
27 import javax.ws.rs.GET;
28 import javax.ws.rs.Path;
29 import javax.ws.rs.Produces;
30 import javax.ws.rs.core.Context;
31 import javax.ws.rs.core.MediaType;
32
33 import org.onap.music.response.jsonobjects.JsonResponse;
34 import org.onap.music.eelf.logging.EELFLoggerDelegate;
35 import org.onap.music.main.MusicUtil;
36 import org.onap.music.main.ResultType;
37
38 import com.att.eelf.configuration.EELFLogger;
39 import com.att.eelf.configuration.EELFManager;
40
41 import io.swagger.annotations.Api;
42 import io.swagger.annotations.ApiOperation;
43
44
45 @Path("/v{version: [0-9]+}/version")
46 @Api(value="Version Api")
47 public class RestMusicVersionAPI {
48
49         private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class);
50
51         /**
52          * Get the version of MUSIC
53          * @return
54          */
55         @GET
56         @ApiOperation(value = "Get Version", response = Map.class)
57         @Produces(MediaType.APPLICATION_JSON)
58         public Map<String,Object> version(@Context HttpServletResponse response) {
59                 logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion());
60                 response.addHeader("X-latestVersion",MusicUtil.getVersion());
61                 return new JsonResponse(ResultType.SUCCESS).setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap();
62         }
63 }