Mercurial > lada > lada-server
changeset 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 | 3a2ed18fe13c |
children | 2f816d251a0d |
files | pom.xml src/main/java/de/intevation/lada/rest/VersionService.java src/main/resources/lada.properties |
diffstat | 3 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pom.xml Mon Jun 06 15:15:12 2016 +0200 +++ b/pom.xml Tue Jun 07 12:03:36 2016 +0200 @@ -169,6 +169,12 @@ <activeByDefault>true</activeByDefault> </activation> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId>
--- a/src/main/java/de/intevation/lada/rest/VersionService.java Mon Jun 06 15:15:12 2016 +0200 +++ b/src/main/java/de/intevation/lada/rest/VersionService.java Tue Jun 07 12:03:36 2016 +0200 @@ -7,6 +7,10 @@ */ package de.intevation.lada.rest; +import java.util.ResourceBundle; +import java.util.MissingResourceException; + +import javax.inject.Inject; import javax.enterprise.context.RequestScoped; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; @@ -17,6 +21,8 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import org.apache.log4j.Logger; + import de.intevation.lada.util.rest.Response; /** @@ -46,7 +52,8 @@ @RequestScoped public class VersionService { - private static final String VERSION = "2.2.0"; + @Inject + private Logger logger; /** * Get server Version. @@ -63,6 +70,14 @@ @Context HttpServletRequest request, @Context UriInfo info ) { - return new Response(true, 200, VERSION); + String version = "unknown"; + try { + version = ResourceBundle.getBundle("lada").getString("version"); + return new Response(true, 200, version); + } + catch (MissingResourceException mre) { + logger.error(mre); + } + return new Response(false, 200, version); } }