2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
7 * Modifications Copyright (C) 2019 IBM.
8 * ===================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=============================================
22 * ====================================================================
25 package org.onap.music.rest;
29 import javax.servlet.http.HttpServletResponse;
30 import javax.ws.rs.GET;
31 import javax.ws.rs.Path;
32 import javax.ws.rs.Produces;
33 import javax.ws.rs.core.Context;
34 import javax.ws.rs.core.MediaType;
36 import org.onap.music.response.jsonobjects.JsonResponse;
37 import org.onap.music.eelf.logging.EELFLoggerDelegate;
38 import org.onap.music.main.MusicUtil;
39 import org.onap.music.main.ResultType;
41 import io.swagger.annotations.Api;
42 import io.swagger.annotations.ApiOperation;
45 @Path("/v{version: [0-9]+}/version")
46 @Api(value="Version Api")
47 public class RestMusicVersionAPI {
49 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class);
50 private static final String MUSIC_KEY = "MUSIC:";
52 * Get the version of MUSIC.
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).
62 setMusicVersion(MUSIC_KEY + MusicUtil.getVersion()).toMap();
66 * Get the version of MUSIC.
71 @ApiOperation(value = "Get Version", response = Map.class)
72 @Produces(MediaType.APPLICATION_JSON)
73 public Map<String,Object> build(@Context HttpServletResponse response) {
74 logger.info("Replying to request for MUSIC build with MUSIC:" + MusicUtil.getBuild());
75 response.addHeader("X-latestVersion",MusicUtil.getVersion());
76 return new JsonResponse(ResultType.SUCCESS)
77 .setMusicBuild(MUSIC_KEY + MusicUtil.getBuild())
78 .setMusicVersion(MUSIC_KEY + MusicUtil.getVersion()).toMap();