summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorManuel Bentele2021-07-02 15:32:14 +0200
committerManuel Bentele2021-07-02 15:32:14 +0200
commit9c79bfe28db1f3f6ec6801d04a5f4b5226650b20 (patch)
tree2c98b818ba84253566e825336cea2f01b062a183 /dozentenmodul
parent[client] Make launchData a byte array; this is opaque data (diff)
downloadtutor-module-9c79bfe28db1f3f6ec6801d04a5f4b5226650b20.tar.gz
tutor-module-9c79bfe28db1f3f6ec6801d04a5f4b5226650b20.tar.xz
tutor-module-9c79bfe28db1f3f6ec6801d04a5f4b5226650b20.zip
[client] Refactor printing of app information from MANIFEST.MF
Diffstat (limited to 'dozentenmodul')
-rwxr-xr-xdozentenmodul/pom.xml13
-rwxr-xr-xdozentenmodul/src/main/java/org/openslx/dozmod/App.java20
-rwxr-xr-xdozentenmodul/src/main/java/org/openslx/dozmod/Config.java4
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ClientVersion.java50
4 files changed, 14 insertions, 73 deletions
diff --git a/dozentenmodul/pom.xml b/dozentenmodul/pom.xml
index 027520e7..d19d2995 100755
--- a/dozentenmodul/pom.xml
+++ b/dozentenmodul/pom.xml
@@ -15,7 +15,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.class>org.openslx.dozmod.App</main.class>
- <maven.build.timestamp.format>yyyy.MM.dd HH:mm</maven.build.timestamp.format>
</properties>
<repositories>
@@ -58,14 +57,16 @@
<phase>package</phase>
<goals>
<goal>create</goal>
- <goal>create-timestamp</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
- <timestampPropertyName>revision.timestamp</timestampPropertyName>
+ <timezone>UTC</timezone>
+ <timestampPropertyName>build.time</timestampPropertyName>
+ <scmBranchPropertyName>revision.branch</scmBranchPropertyName>
+ <buildNumberPropertyName>revision.version</buildNumberPropertyName>
</configuration>
</plugin>
<plugin>
@@ -109,9 +110,9 @@
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
- <Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
- <Build-Revision>${buildNumber}</Build-Revision>
- <Build-Revision-Timestamp>${revision.timestamp}</Build-Revision-Timestamp>
+ <Build-Timestamp>${build.time}</Build-Timestamp>
+ <Revision-Branch>${revision.branch}</Revision-Branch>
+ <Revision-Version>${revision.version}</Revision-Version>
</manifestEntries>
</archive>
<descriptorRefs>
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
index 7e13be8d..fb1f4c86 100755
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
@@ -36,9 +36,9 @@ import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.Language;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.util.ClientVersion;
-import org.openslx.dozmod.util.FormatHelper;
import org.openslx.dozmod.util.ProxyConfigurator;
import org.openslx.thrifthelper.ThriftManager;
+import org.openslx.util.AppUtil;
import org.openslx.util.Util;
public class App {
@@ -67,7 +67,6 @@ public class App {
final File logFile = new File(logFilePath);
if (logFile.exists() && !logFile.isDirectory()) {
// we have one, rename it to 'bwSuite.log.old'
- LOGGER.info("renaming old log file");
try {
File oldFile = new File(logFilePath + ".old");
oldFile.delete();
@@ -129,20 +128,6 @@ public class App {
return logFilePath;
}
-
- public static void logHeader(String logFilePath)
- {
- LOGGER.info("Starting logging to: " + logFilePath);
- LOGGER.info(Branding.getApplicationName() + " Version: " + ClientVersion.getLocalRevision());
- LOGGER.info(" " + FormatHelper.longDate(ClientVersion.getLocalRevTimestamp()));
- LOGGER.info("os.name: " + System.getProperty("os.name"));
- LOGGER.info("java.specification.vendor: " + System.getProperty("java.specification.vendor"));
- LOGGER.info("java.specification.name: " + System.getProperty("java.specification.name"));
- LOGGER.info("java.specification.version: " + System.getProperty("java.specification.version"));
- LOGGER.info("java.version: " + System.getProperty("java.version"));
- LOGGER.info("java.vm.version: " + System.getProperty("java.vm.version"));
- LOGGER.info("java.runtime.version: " + System.getProperty("java.runtime.version"));
- }
public static void main(final String[] args) throws InvocationTargetException, InterruptedException
{
@@ -176,7 +161,8 @@ public class App {
}
final String logFilePath = setupFileLogger();
- logHeader(logFilePath);
+ AppUtil.logHeader(LOGGER, Branding.getApplicationName(), App.class.getPackage().getImplementationVersion());
+ LOGGER.info("Starting logging to " + logFilePath);
// Setting the locale
if (!setPreferredLanguage()) {
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
index a0e41689..d3a561c9 100755
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
@@ -67,8 +67,6 @@ public class Config {
String configPath = null;
// Determine OS
- String osName = System.getProperty("os.name").toLowerCase();
- LOGGER.info("Machine's OS: " + osName);
if (OsHelper.isWindows()) {
// Windows machine. Use the environment variable 'APPDATA' which
// should point to a path similar to:
@@ -96,7 +94,7 @@ public class Config {
// Check if the directory exists.
if (!configFile.getParentFile().exists()) {
- LOGGER.info("Folder " + configFile.getParentFile() + " does not exist, creating it.");
+ LOGGER.debug("Folder " + configFile.getParentFile() + " does not exist, creating it.");
// Does not, create it
if (!configFile.getParentFile().mkdirs()) {
throw new IOException("Could not create '" + configFile.getParentFile() + "'.");
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ClientVersion.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ClientVersion.java
index e7eb31c3..0ac740b2 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ClientVersion.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ClientVersion.java
@@ -7,8 +7,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
@@ -16,6 +14,7 @@ import org.apache.log4j.Logger;
import org.openslx.dozmod.App;
import org.openslx.dozmod.Branding;
import org.openslx.sat.thrift.version.Version;
+import org.openslx.util.AppUtil;
import org.openslx.util.Json;
public class ClientVersion {
@@ -100,51 +99,8 @@ public class ClientVersion {
* into the fields 'localRevision' and 'localRevisionTime'
*/
private static void loadLocalVersion() {
- Class<ClientVersion> clazz = ClientVersion.class;
- String className = clazz.getSimpleName() + ".class";
- String classPath = clazz.getResource(className).toString();
- if (!classPath.startsWith("jar")) {
- // Class not from JAR
- return;
- }
- String manifestPath = classPath.replaceAll("![^!]*$", "") + "!/META-INF/MANIFEST.MF";
- Manifest manifest = null;
- try (InputStream stream = new URL(manifestPath).openStream()) {
- manifest = new Manifest(stream);
- } catch (Exception e) {
- if (manifest == null) {
- LOGGER.error("Could not open MANIFEST", e);
- return;
- }
- }
- Attributes attributes = manifest.getMainAttributes();
- // if attr are null, then we couldn't open the jar's MANIFEST
- // since we are probably not in a jar context, just do nothing
- if (attributes == null)
- return;
- String manifestRev = null;
- String manifestRevTime = null;
- try {
- manifestRev = attributes.getValue("Build-Revision");
- } catch (Exception e) {
- LOGGER.warn("Error while reading revision: ", e);
- }
- try {
- manifestRevTime = attributes.getValue("Build-Revision-Timestamp");
- } catch (Exception e) {
- LOGGER.warn("Error while reading timestamp: ", e);
- }
- if (manifestRev != null) {
- localRevision = manifestRev;
- }
- if (manifestRevTime != null) {
- try {
- // hax since we get milliseconds not seconds
- localRevisionTime = Long.valueOf(manifestRevTime) / 1000L;
- } catch (NumberFormatException e) {
- LOGGER.warn("Build timestamp is not a number!", e);
- }
- }
+ localRevision = AppUtil.getRevisionVersion();
+ localRevisionTime = AppUtil.getBuildTimestamp();
}
/**