Skip to content

Commit 1dd3c30

Browse files
authored
Merge pull request #249 from Dokyeongyun/ft-220515-exceptionHandling
Ft 220515 exception handling
2 parents 011424b + 2263196 commit 1dd3c30

File tree

20 files changed

+635
-1082
lines changed

20 files changed

+635
-1082
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package root.core.domain.exceptions;
2+
3+
public class PropertyNotFoundException extends Exception {
4+
private static final long serialVersionUID = 196259383529491976L;
5+
6+
public PropertyNotFoundException(String message) {
7+
super(message);
8+
}
9+
}

Core/src/main/java/root/core/repository/constracts/PropertyRepository.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,32 @@
88
import root.common.database.implement.JdbcConnectionInfo;
99
import root.common.server.implement.AlertLogCommand;
1010
import root.common.server.implement.JschConnectionInfo;
11+
import root.core.domain.exceptions.PropertyNotFoundException;
12+
import root.core.domain.exceptions.PropertyNotLoadedException;
1113

1214
public interface PropertyRepository {
1315

1416
boolean isFileExist(String filePath);
1517

16-
PropertiesConfiguration getConfiguration(String config);
18+
PropertiesConfiguration getConfiguration(String config) throws PropertyNotLoadedException;
1719

1820
void save(String filePath, PropertiesConfiguration config);
1921

2022
void saveDBConnectionInfo(String filePath, Map<String, JdbcConnectionInfo> config);
2123

2224
void saveServerConnectionInfo(String filePath, Map<String, JschConnectionInfo> config);
2325

24-
void saveCommonConfig(Map<String, Object> values);
26+
void saveCommonConfig(Map<String, Object> values) throws PropertyNotLoadedException;
2527

26-
void saveCommonConfig(String key, String value);
28+
void saveCommonConfig(String key, String value) throws PropertyNotLoadedException;
2729

28-
void loadCombinedConfiguration();
30+
void loadCombinedConfiguration() throws PropertyNotFoundException;
2931

3032
void loadConnectionInfoConfig(String filePath);
3133

3234
void loadMonitoringInfoConfig(String filePath);
3335

34-
String[] getConnectionInfoFileNames();
36+
String[] getConnectionInfoFileNames() throws PropertyNotFoundException;
3537

3638
String getCommonResource(String key);
3739

Core/src/main/java/root/core/service/contracts/PropertyService.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import root.core.domain.enums.MonitoringType;
1111
import root.core.domain.enums.RoundingDigits;
1212
import root.core.domain.enums.UsageUIType;
13+
import root.core.domain.exceptions.PropertyNotFoundException;
14+
import root.core.domain.exceptions.PropertyNotLoadedException;
1315
import root.utils.UnitUtils.FileSize;
1416

1517
public interface PropertyService {
@@ -25,8 +27,9 @@ public interface PropertyService {
2527
* 모니터링 접속정보 설정파일의 경로를 반환한다.
2628
*
2729
* @return
30+
* @throws PropertyNotFoundException
2831
*/
29-
List<String> getConnectionInfoList();
32+
List<String> getConnectionInfoList() throws PropertyNotFoundException;
3033

3134
/**
3235
* 최근 사용된 접속정보 설정파일의 경로를 반환한다.
@@ -65,13 +68,13 @@ public interface PropertyService {
6568
*/
6669
List<MonitoringYN> getServerMonitoringYnList(String presetConfigFileName);
6770

68-
Map<String, String> getMonitoringPresetMap();
71+
Map<String, String> getMonitoringPresetMap() throws PropertyNotLoadedException;
6972

70-
List<String> getMonitoringPresetFilePathList();
73+
List<String> getMonitoringPresetFilePathList() throws PropertyNotLoadedException;
7174

72-
List<String> getMonitoringPresetNameList();
75+
List<String> getMonitoringPresetNameList() throws PropertyNotLoadedException;
7376

74-
String getMonitoringPresetFilePath(String presetName);
77+
String getMonitoringPresetFilePath(String presetName) throws PropertyNotLoadedException;
7578

7679
List<String> getMonitoringDBNameList();
7780

@@ -122,30 +125,32 @@ public interface PropertyService {
122125
* @param key 설정정보 키
123126
* @param value 설정정보 값
124127
*/
125-
void saveCommonConfig(String key, String value);
128+
void saveCommonConfig(String key, String value) throws PropertyNotLoadedException;
126129

127130
/**
128131
* 최근 사용한 접속정보 설정정보를 저장한다.
129132
*
130133
* @param filePath
134+
* @throws PropertyNotLoadedException
131135
*/
132-
void saveLastUseConnectionInfoSetting(String filePath);
136+
void saveLastUseConnectionInfoSetting(String filePath) throws PropertyNotLoadedException;
133137

134138
/**
135139
* 접속정보 설정을 추가한다.
136140
*
137141
* @param filePath
138142
* @return
143+
* @throws PropertyNotLoadedException
139144
*/
140-
String addConnectionInfoSetting(String filePath);
145+
String addConnectionInfoSetting(String filePath) throws PropertyNotLoadedException;
141146

142147
/**
143148
* 모니터링여부 Preset 설정을 추가한다.
144149
*
145150
* @param connInfoSetting
146151
* @param presetName
147152
*/
148-
void addMonitoringPreset(String connInfoSetting, String presetName);
153+
void addMonitoringPreset(String connInfoSetting, String presetName) throws PropertyNotLoadedException;
149154

150155
/**
151156
* 모니터링여부 Preset 설정을 저장한다.

DBMonitoringWindowApp/src/main/java/root/applications/ConsoleApp.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import root.common.server.implement.JschServer;
1818
import root.core.batch.DBCheckBatch;
1919
import root.core.batch.ServerCheckBatch;
20+
import root.core.domain.exceptions.PropertyNotLoadedException;
2021
import root.core.repository.constracts.DBCheckRepository;
2122
import root.core.repository.constracts.PropertyRepository;
2223
import root.core.repository.constracts.ServerMonitoringRepository;
@@ -98,8 +99,13 @@ public static void main(String[] args) throws IOException {
9899
while (true) {
99100
System.out.println(String.format("사용하실 모니터링여부 설정을 선택해주세요."));
100101

101-
List<String> presetNames = propService.getMonitoringPresetNameList();
102-
if (presetNames.size() == 0) {
102+
List<String> presetNames = null;
103+
try {
104+
presetNames = propService.getMonitoringPresetNameList();
105+
} catch (PropertyNotLoadedException e) {
106+
e.printStackTrace();
107+
}
108+
if (presetNames == null || presetNames.size() == 0) {
103109
System.out.println("모니터링여부 설정파일이 존재하지 않습니다. 프로그램을 종료합니다.");
104110
return;
105111
}

DBMonitoringWindowApp/src/main/java/root/applications/Program.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import javafx.application.Application;
44
import javafx.scene.Parent;
55
import javafx.scene.Scene;
6+
import javafx.scene.control.Alert.AlertType;
67
import javafx.stage.Stage;
78
import lombok.extern.slf4j.Slf4j;
9+
import root.core.domain.exceptions.PropertyNotFoundException;
810
import root.core.repository.constracts.PropertyRepository;
911
import root.javafx.Controller.HomeController;
1012
import root.javafx.Controller.LeftMenuController;
1113
import root.javafx.DI.DependencyInjection;
14+
import root.javafx.utils.AlertUtils;
1215
import root.repository.implement.PropertyRepositoryImpl;
1316

1417
@Slf4j
@@ -26,7 +29,12 @@ public void start(Stage primaryStage) throws Exception {
2629
setUpDependecyInjector();
2730

2831
// configuration load
29-
propRepo.loadCombinedConfiguration();
32+
try {
33+
propRepo.loadCombinedConfiguration();
34+
} catch (PropertyNotFoundException e) {
35+
AlertUtils.showAlert(AlertType.ERROR, "설정 파일 Load", "설정 파일 읽기에 실패했습니다. 설정파일을 확인해주세요.");
36+
return;
37+
}
3038

3139
// fxml load
3240
System.setProperty("prism.lcdtext", "false"); // 안티앨리어싱 (Font 부드럽게)

DBMonitoringWindowApp/src/main/java/root/javafx/Controller/AlertLogMonitoringMenuController.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import root.common.server.implement.ServerOS;
3636
import root.core.domain.AlertLog;
3737
import root.core.domain.Log;
38+
import root.core.domain.exceptions.PropertyNotFoundException;
3839
import root.core.repository.constracts.ServerMonitoringRepository;
3940
import root.core.service.contracts.PropertyService;
4041
import root.core.usecase.constracts.ServerMonitoringUsecase;
@@ -107,18 +108,25 @@ public AlertLogMonitoringMenuController() {
107108
public void initialize(URL location, ResourceBundle resources) {
108109

109110
// 접속정보 설정 프로퍼티 파일
110-
List<String> connInfoFiles = propService.getConnectionInfoList();
111-
if (connInfoFiles != null && connInfoFiles.size() != 0) {
112-
// Connection Info ComboBox
113-
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
114-
runConnInfoFileComboBox.getSelectionModel().selectFirst();
115-
116-
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
117-
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
118-
if (lastUseConnInfoFilePath != null) {
119-
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
111+
List<String> connInfoFiles;
112+
try {
113+
connInfoFiles = propService.getConnectionInfoList();
114+
if (connInfoFiles != null && connInfoFiles.size() != 0) {
115+
// Connection Info ComboBox
116+
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
117+
runConnInfoFileComboBox.getSelectionModel().selectFirst();
118+
119+
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
120+
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
121+
if (lastUseConnInfoFilePath != null) {
122+
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
123+
}
124+
} else {
125+
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
126+
return;
120127
}
121-
} else {
128+
} catch (PropertyNotFoundException e) {
129+
log.error(e.getMessage());
122130
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
123131
return;
124132
}

DBMonitoringWindowApp/src/main/java/root/javafx/Controller/HistoryMenuController.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javafx.fxml.Initializable;
1212
import javafx.scene.control.Alert.AlertType;
1313
import javafx.scene.layout.AnchorPane;
14+
import lombok.extern.slf4j.Slf4j;
1415
import root.common.database.implement.JdbcConnectionInfo;
1516
import root.common.database.implement.JdbcDatabase;
1617
import root.common.server.implement.JschConnectionInfo;
@@ -20,6 +21,7 @@
2021
import root.core.domain.MonitoringResult;
2122
import root.core.domain.OSDiskUsage;
2223
import root.core.domain.TableSpaceUsage;
24+
import root.core.domain.exceptions.PropertyNotFoundException;
2325
import root.core.repository.constracts.DBCheckRepository;
2426
import root.core.repository.constracts.ServerMonitoringRepository;
2527
import root.core.service.contracts.PropertyService;
@@ -34,6 +36,7 @@
3436
import root.repository.implement.ReportFileRepo;
3537
import root.service.implement.FilePropertyService;
3638

39+
@Slf4j
3740
public class HistoryMenuController implements Initializable {
3841

3942
/* Dependency Injection */
@@ -76,18 +79,25 @@ public HistoryMenuController() {
7679
public void initialize(URL location, ResourceBundle resources) {
7780

7881
// 접속정보 설정 프로퍼티 파일
79-
List<String> connInfoFiles = propService.getConnectionInfoList();
80-
if (connInfoFiles != null && connInfoFiles.size() != 0) {
81-
// Connection Info ComboBox
82-
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
83-
runConnInfoFileComboBox.getSelectionModel().selectFirst();
84-
85-
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
86-
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
87-
if (lastUseConnInfoFilePath != null) {
88-
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
82+
List<String> connInfoFiles;
83+
try {
84+
connInfoFiles = propService.getConnectionInfoList();
85+
if (connInfoFiles != null && connInfoFiles.size() != 0) {
86+
// Connection Info ComboBox
87+
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
88+
runConnInfoFileComboBox.getSelectionModel().selectFirst();
89+
90+
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
91+
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
92+
if (lastUseConnInfoFilePath != null) {
93+
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
94+
}
95+
} else {
96+
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 DB/Server 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
97+
return;
8998
}
90-
} else {
99+
} catch (PropertyNotFoundException e) {
100+
log.error(e.getMessage());
91101
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 DB/Server 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
92102
return;
93103
}

0 commit comments

Comments
 (0)