-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemLogAnalyzerApp.java
More file actions
87 lines (64 loc) · 2.56 KB
/
SystemLogAnalyzerApp.java
File metadata and controls
87 lines (64 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.project.system_log_analyzer;
import com.project.system_log_analyzer.config.SpringConfig;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class SystemLogAnalyzerApp extends Application {
private boolean app_Log = false;
private AnnotationConfigApplicationContext springContext;
private static Boolean elevatedFlag = false; // Admin permissions
@Override
public void init() {
springContext = new AnnotationConfigApplicationContext(SpringConfig.class);
if (app_Log) { // debug app.log in main directory
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream("app.log", true), true);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
System.setOut(out);
System.setErr(out);
}
}
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/view/WelcomeView.fxml"));
loader.setControllerFactory(springContext::getBean);
boolean elevated = getParameters().getRaw().contains("--elevated");
elevatedFlag = elevated; // Admin profile checker
System.out.println("ARGS = " + getParameters().getRaw()); // Admin permission check to debug file
com.project.system_log_analyzer.config.appConfig cfg = springContext.getBean(com.project.system_log_analyzer.config.appConfig.class);
if (elevated) {
cfg.setCsvSecurity(true);
}
try {
cfg.setCsvSecurity(elevated);
IO.println("Elevated mode: " + elevated);
} catch (Exception e) {
System.err.println("Could not set elevated flag in appConfig: " + e.getMessage());
}
Parent root = loader.load();
SpringConfig.APP_READY = true;
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle("System Log Analyzer");
primaryStage.show();
}
@Override
public void stop() {
springContext.close();
}
public static boolean isElevated() {
return Boolean.TRUE.equals(elevatedFlag);
}
public static void main(String[] args) {
launch(args);
}
}