version number visible

This commit is contained in:
Jörg Henke
2021-01-16 15:50:48 +01:00
parent ec68448200
commit 71bb01e05c
7 changed files with 151 additions and 98 deletions

View File

@ -1,5 +1,8 @@
package de.jottyfan.timetrack.modules;
import java.io.InputStream;
import java.util.Properties;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
@ -59,6 +62,25 @@ public class SessionControl {
}
}
/**
* get the version from the mainfest file
*
* @return the version
*/
public String getVersion() {
FacesContext facesContext = FacesContext.getCurrentInstance();
try (InputStream is = facesContext.getExternalContext().getResourceAsStream("META-INF/MANIFEST.MF")){
// from servletcontext
Properties attributes = new Properties();
attributes.load(is);
return attributes.getProperty("Implementation-Version", "no Implementation-Version attribute found in MANIFEST");
} catch (Exception e) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on loading the version from the Manifest file", e.getMessage());
FacesContext.getCurrentInstance().addMessage(null, msg);
return "?";
}
}
/**
* @return the secretNew1
*/
@ -67,8 +89,7 @@ public class SessionControl {
}
/**
* @param secretNew1
* the secretNew1 to set
* @param secretNew1 the secretNew1 to set
*/
public void setSecretNew1(String secretNew1) {
this.secretNew1 = secretNew1;
@ -82,8 +103,7 @@ public class SessionControl {
}
/**
* @param secretNew2
* the secretNew2 to set
* @param secretNew2 the secretNew2 to set
*/
public void setSecretNew2(String secretNew2) {
this.secretNew2 = secretNew2;