summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/App.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-08 19:39:35 +0200
committerSimon Rettberg2015-07-08 19:39:35 +0200
commit8d6cd17c330388aa13fd7c39802c7400d85f972c (patch)
tree5f2c5856f58b1454e24dc16fad10751dfe9d087b /dozentenmodul/src/main/java/App.java
parentoops (diff)
downloadtutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.gz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.xz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.zip
[client] Redo package structure, add comments/TODOs, rename GUI classes
Diffstat (limited to 'dozentenmodul/src/main/java/App.java')
-rw-r--r--dozentenmodul/src/main/java/App.java117
1 files changed, 0 insertions, 117 deletions
diff --git a/dozentenmodul/src/main/java/App.java b/dozentenmodul/src/main/java/App.java
deleted file mode 100644
index 688ba81f..00000000
--- a/dozentenmodul/src/main/java/App.java
+++ /dev/null
@@ -1,117 +0,0 @@
-import gui.GuiManager;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.spi.LoggingEvent;
-
-import config.Config;
-import config.ConfigProxy;
-
-public class App {
-
- // Logger
- private final static Logger LOGGER = Logger.getLogger(App.class);
-
- private static void setupLogger() {
-
- // path to the log file
- final String logFilePath = Config.getPath() + System.getProperty("file.separator") + "bwSuite.log";
-
- // check if we had an old log file
- 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");
- FileUtils.forceDelete(oldFile);
- logFile.renameTo(oldFile);
- FileUtils.forceDelete(logFile);
- } catch (Exception e) {
- LOGGER.error("Could not move '" + logFilePath + "' to '" + logFilePath + ".old'", e);
- }
- }
-
- // add file appender to global logger
- FileAppender fa = null;
- try {
- fa = new FileAppender(new PatternLayout("%d [%F:%M] %m%n"), logFilePath);
- // All classes should log to file, configure global file appender.
- } catch (IOException e) {
- e.printStackTrace();
- BasicConfigurator.configure();
- return;
- }
-
- final FileAppender ffa = fa;
- final Pattern re = Pattern.compile("authorization:(\\w|\\+|/|\\s)+", Pattern.CASE_INSENSITIVE
- | Pattern.MULTILINE);
-
- AppenderSkeleton ap = new AppenderSkeleton() {
-
- @Override
- public boolean requiresLayout() {
- return ffa.requiresLayout();
- }
-
- @Override
- public void close() {
- ffa.close();
- }
-
- @Override
- protected void append(LoggingEvent event) {
- String s = event.getRenderedMessage();
- if (s.contains("uthorization")) {
- Matcher m = re.matcher(s);
- if (!m.find()) {
- LOGGER.warn("Could not match pattern!");
- } else {
- s = m.replaceAll("Authorization: ***********");
- LOGGER.info("Patched log message");
- }
- }
- ffa.append(new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(),
- event.getTimeStamp(), event.getLevel(), s, event.getThreadName(),
- event.getThrowableInformation(), event.getNDC(), event.getLocationInformation(),
- event.getProperties()));
- }
- };
-
- BasicConfigurator.configure(ap);
- LOGGER.info("Starting logging to: " + logFilePath);
- }
-
- public static void main(final String[] args) {
-
- // Pruefe und Erzeuge gegebenfalls Config
- try {
- Config.init();
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
-
- setupLogger();
-
- // initialise the proxy settings
- try {
- ConfigProxy.init();
- } catch (IOException e) {
- LOGGER.error("IOException when trying to initialise the proxy, see trace: ", e);
- }
-
- // start the GUI
- GuiManager.initGui();
-
- }
-}