2323
2424package com .iemr .admin .controller .version ;
2525
26- import java .util .Map ;
2726import java .util .Map ;
2827import org .slf4j .Logger ;
2928import org .slf4j .LoggerFactory ;
3029import org .springframework .http .ResponseEntity ;
3130import org .springframework .web .bind .annotation .GetMapping ;
32- import org .springframework .http .ResponseEntity ;
33- import org .springframework .web .bind .annotation .GetMapping ;
3431import org .springframework .web .bind .annotation .RestController ;
3532import io .swagger .v3 .oas .annotations .Operation ;
3633import java .io .IOException ;
@@ -46,14 +43,7 @@ public class VersionController {
4643 private final Logger logger = LoggerFactory .getLogger (this .getClass ().getSimpleName ());
4744
4845 private static final String UNKNOWN_VALUE = "unknown" ;
49- private final Logger logger = LoggerFactory .getLogger (this .getClass ().getSimpleName ());
5046
51- private static final String UNKNOWN_VALUE = "unknown" ;
52-
53- @ Operation (summary = "Get version information" )
54- @ GetMapping (value = "/version" , produces = MediaType .APPLICATION_JSON_VALUE )
55- public ResponseEntity <Map <String , String >> versionInformation () {
56- Map <String , String > response = new LinkedHashMap <>();
5747 @ Operation (summary = "Get version information" )
5848 @ GetMapping (value = "/version" , produces = MediaType .APPLICATION_JSON_VALUE )
5949 public ResponseEntity <Map <String , String >> versionInformation () {
@@ -65,34 +55,17 @@ public ResponseEntity<Map<String, String>> versionInformation() {
6555 response .put ("version" , gitProperties .getProperty ("git.build.version" , UNKNOWN_VALUE ));
6656 response .put ("branch" , gitProperties .getProperty ("git.branch" , UNKNOWN_VALUE ));
6757 response .put ("commitHash" , gitProperties .getProperty ("git.commit.id.abbrev" , UNKNOWN_VALUE ));
68- Properties gitProperties = loadGitProperties ();
69- response .put ("buildTimestamp" , gitProperties .getProperty ("git.build.time" , UNKNOWN_VALUE ));
70- response .put ("version" , gitProperties .getProperty ("git.build.version" , UNKNOWN_VALUE ));
71- response .put ("branch" , gitProperties .getProperty ("git.branch" , UNKNOWN_VALUE ));
72- response .put ("commitHash" , gitProperties .getProperty ("git.commit.id.abbrev" , UNKNOWN_VALUE ));
7358 } catch (Exception e ) {
7459 logger .error ("Failed to load version information" , e );
7560 response .put ("buildTimestamp" , UNKNOWN_VALUE );
7661 response .put ("version" , UNKNOWN_VALUE );
7762 response .put ("branch" , UNKNOWN_VALUE );
7863 response .put ("commitHash" , UNKNOWN_VALUE );
79- logger .error ("Failed to load version information" , e );
80- response .put ("buildTimestamp" , UNKNOWN_VALUE );
81- response .put ("version" , UNKNOWN_VALUE );
82- response .put ("branch" , UNKNOWN_VALUE );
83- response .put ("commitHash" , UNKNOWN_VALUE );
8464 }
8565 logger .info ("version Controller End" );
8666 return ResponseEntity .ok (response );
87- return ResponseEntity .ok (response );
8867 }
8968
90- private Properties loadGitProperties () throws IOException {
91- Properties properties = new Properties ();
92- try (InputStream input = getClass ().getClassLoader ()
93- .getResourceAsStream ("git.properties" )) {
94- if (input != null ) {
95- properties .load (input );
9669 private Properties loadGitProperties () throws IOException {
9770 Properties properties = new Properties ();
9871 try (InputStream input = getClass ().getClassLoader ()
@@ -102,6 +75,5 @@ private Properties loadGitProperties() throws IOException {
10275 }
10376 }
10477 return properties ;
105- return properties ;
10678 }
10779}
0 commit comments