Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/VersionService.java @ 971:ad8c859cfdca
Get version from pom.xml instead of hard coded.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 07 Jun 2016 12:03:36 +0200 |
parents | 5bdd1631a451 |
children |
comparison
equal
deleted
inserted
replaced
970:3a2ed18fe13c | 971:ad8c859cfdca |
---|---|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | 5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
6 * the documentation coming with IMIS-Labordaten-Application for details. | 6 * the documentation coming with IMIS-Labordaten-Application for details. |
7 */ | 7 */ |
8 package de.intevation.lada.rest; | 8 package de.intevation.lada.rest; |
9 | 9 |
10 import java.util.ResourceBundle; | |
11 import java.util.MissingResourceException; | |
12 | |
13 import javax.inject.Inject; | |
10 import javax.enterprise.context.RequestScoped; | 14 import javax.enterprise.context.RequestScoped; |
11 import javax.servlet.http.HttpServletRequest; | 15 import javax.servlet.http.HttpServletRequest; |
12 import javax.ws.rs.GET; | 16 import javax.ws.rs.GET; |
13 import javax.ws.rs.Path; | 17 import javax.ws.rs.Path; |
14 import javax.ws.rs.Produces; | 18 import javax.ws.rs.Produces; |
15 import javax.ws.rs.core.Context; | 19 import javax.ws.rs.core.Context; |
16 import javax.ws.rs.core.HttpHeaders; | 20 import javax.ws.rs.core.HttpHeaders; |
17 import javax.ws.rs.core.MediaType; | 21 import javax.ws.rs.core.MediaType; |
18 import javax.ws.rs.core.UriInfo; | 22 import javax.ws.rs.core.UriInfo; |
23 | |
24 import org.apache.log4j.Logger; | |
19 | 25 |
20 import de.intevation.lada.util.rest.Response; | 26 import de.intevation.lada.util.rest.Response; |
21 | 27 |
22 /** | 28 /** |
23 * REST service returning the server version. | 29 * REST service returning the server version. |
44 */ | 50 */ |
45 @Path("rest/version") | 51 @Path("rest/version") |
46 @RequestScoped | 52 @RequestScoped |
47 public class VersionService { | 53 public class VersionService { |
48 | 54 |
49 private static final String VERSION = "2.2.0"; | 55 @Inject |
56 private Logger logger; | |
50 | 57 |
51 /** | 58 /** |
52 * Get server Version. | 59 * Get server Version. |
53 * <p> | 60 * <p> |
54 * Example: http://example.com/version | 61 * Example: http://example.com/version |
61 public Response get( | 68 public Response get( |
62 @Context HttpHeaders headers, | 69 @Context HttpHeaders headers, |
63 @Context HttpServletRequest request, | 70 @Context HttpServletRequest request, |
64 @Context UriInfo info | 71 @Context UriInfo info |
65 ) { | 72 ) { |
66 return new Response(true, 200, VERSION); | 73 String version = "unknown"; |
74 try { | |
75 version = ResourceBundle.getBundle("lada").getString("version"); | |
76 return new Response(true, 200, version); | |
77 } | |
78 catch (MissingResourceException mre) { | |
79 logger.error(mre); | |
80 } | |
81 return new Response(false, 200, version); | |
67 } | 82 } |
68 } | 83 } |