Sonar fix- RestMusicVersionAPI.java
[music.git] / src / main / java / org / onap / music / rest / RestMusicVersionAPI.java
index b9754f6..8c86152 100644 (file)
@@ -3,6 +3,8 @@
  * org.onap.music
  * ===================================================================
  *  Copyright (c) 2017 AT&T Intellectual Property
+ *
+ *  Modifications Copyright (C) 2019 IBM.
  * ===================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -19,6 +21,7 @@
  * ============LICENSE_END=============================================
  * ====================================================================
  */
+
 package org.onap.music.rest;
 
 import java.util.Map;
@@ -43,18 +46,37 @@ import io.swagger.annotations.ApiOperation;
 @Api(value="Version Api")
 public class RestMusicVersionAPI {
 
-       private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class);
-
-       /**
-        * Get the version of MUSIC
-        * @return
-        */
-       @GET
-       @ApiOperation(value = "Get Version", response = Map.class)
-       @Produces(MediaType.APPLICATION_JSON)
-       public Map<String,Object> version(@Context HttpServletResponse response) {
-               logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion());
-               response.addHeader("X-latestVersion",MusicUtil.getVersion());
-               return new JsonResponse(ResultType.SUCCESS).setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap();
-       }
+    private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class);
+    private static final String MUSIC_KEY = "MUSIC:";
+    /**
+     * Get the version of MUSIC.
+     * @return
+     */
+    @GET
+    @ApiOperation(value = "Get Version", response = Map.class)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map<String,Object> version(@Context HttpServletResponse response) {
+        logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion());
+        response.addHeader("X-latestVersion",MusicUtil.getVersion());
+        return new JsonResponse(ResultType.SUCCESS).
+            setMusicVersion(MUSIC_KEY + MusicUtil.getVersion()).toMap();
+    }
+
+    /**
+     * Get the version of MUSIC.
+     * @return
+     */
+    @GET
+    @Path("/build")
+    @ApiOperation(value = "Get Version", response = Map.class)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map<String,Object> build(@Context HttpServletResponse response) {
+        logger.info("Replying to request for MUSIC build with MUSIC:" + MusicUtil.getBuild());
+        response.addHeader("X-latestVersion",MusicUtil.getVersion());
+        return new JsonResponse(ResultType.SUCCESS)
+            .setMusicBuild(MUSIC_KEY + MusicUtil.getBuild())
+            .setMusicVersion(MUSIC_KEY + MusicUtil.getVersion()).toMap();
+    }
+
+
 }
\ No newline at end of file