@@ -66,11 +66,6 @@ public static PropertyRepository getInstance() {
6666
6767 /****************************************************************************/
6868
69- @ Override
70- public boolean isFileExist (String filePath ) {
71- return new File (filePath ).exists ();
72- }
73-
7469 /**
7570 * Configuration 객체를 반환한다. TODO 굳이 메서드를 Wrapping 해서 호출할 필요가 있을까..? Controller와
7671 * 의존성 제거목적으로 일단 이렇게 함..
@@ -87,12 +82,15 @@ public PropertiesConfiguration getConfiguration(String name) throws PropertyNotL
8782 throw new PropertyNotLoadedException ("monitoringConfig properties file is not loaded" );
8883 }
8984 return monitoringConfig ;
85+ } else if (name .equals ("commonConfig" ) || name .equals ("rememberConfig" )) {
86+ Configuration config = combinedConfig .getConfiguration (name );
87+ if (config == null ) {
88+ throw new PropertyNotLoadedException (name + " properties file is not loaded" );
89+ }
90+ return (PropertiesConfiguration ) config ;
9091 }
9192
92- if (combinedConfig == null ) {
93- throw new PropertyNotLoadedException ("combinedConfig properties file is not loaded" );
94- }
95- return (PropertiesConfiguration ) combinedConfig .getConfiguration (name );
93+ throw new PropertyNotLoadedException ("there is no properties file" );
9694 }
9795
9896 /**
@@ -137,9 +135,9 @@ public void save(String filePath, PropertiesConfiguration config) {
137135
138136 @ Override
139137 public void saveDBConnectionInfo (String filePath , Map <String , JdbcConnectionInfo > dbConfig ) {
138+ loadConnectionInfoConfig (filePath );
140139 PropertiesConfiguration config = connInfoConfig ;
141140
142- // TODO dbnames property..
143141 String dbNames = "" ;
144142 for (String dbName : dbConfig .keySet ()) {
145143 dbNames += dbName + "," ;
@@ -187,6 +185,7 @@ public void saveDBConnectionInfo(String filePath, Map<String, JdbcConnectionInfo
187185
188186 writer .writeln (layout .getCanonicalFooterCooment (true ));
189187 writer .flush ();
188+ writer .close ();
190189
191190 log .info ("[" + filePath + "] 파일 저장이 성공적으로 완료되었습니다." );
192191 } catch (Exception e ) {
@@ -197,9 +196,9 @@ public void saveDBConnectionInfo(String filePath, Map<String, JdbcConnectionInfo
197196
198197 @ Override
199198 public void saveServerConnectionInfo (String filePath , Map <String , JschConnectionInfo > serverConfig ) {
199+ loadConnectionInfoConfig (filePath );
200200 PropertiesConfiguration config = connInfoConfig ;
201201
202- // TODO servernames property..
203202 String serverNames = "" ;
204203 for (String serverName : serverConfig .keySet ()) {
205204 serverNames += serverName + "," ;
@@ -248,6 +247,7 @@ public void saveServerConnectionInfo(String filePath, Map<String, JschConnection
248247
249248 writer .writeln (layout .getCanonicalFooterCooment (true ));
250249 writer .flush ();
250+ writer .close ();
251251
252252 log .info ("[" + filePath + "] 파일 저장이 성공적으로 완료되었습니다." );
253253 } catch (Exception e ) {
@@ -289,7 +289,7 @@ private static PropertiesConfiguration load(String filePath) {
289289 try {
290290 return builder .getConfiguration ();
291291 } catch (ConfigurationException e ) {
292- e . printStackTrace ( );
292+ log . error ( e . getMessage () );
293293 return null ;
294294 }
295295 }
@@ -364,14 +364,6 @@ public String getCommonResource(String key) {
364364 return combinedConfig .getString (key );
365365 }
366366
367- /**
368- * commons.properties에서 값을 읽어 반환한다.
369- */
370- @ Override
371- public int getIntegerCommonResource (String key ) {
372- return combinedConfig .getInt (key );
373- }
374-
375367 /**
376368 * commons.properties에서 값을 읽어 반환한다.
377369 */
@@ -442,16 +434,6 @@ public Map<String, String> getMonitoringPresetMap() {
442434 return presetMap ;
443435 }
444436
445- /**
446- * 최근 사용한 Monitoring Preset 이름을 반환한다. 단, 최근 사용한 Preset이 없을 때, NULL을 반환한다.
447- *
448- * @return
449- */
450- @ Override
451- public String getLastUseMonitoringPresetName () {
452- return connInfoConfig .subset ("monitoring.setting.preset.lastuse" ).getString ("" );
453- }
454-
455437 /**
456438 * 최근 사용한 Monitoring Preset 이름을 반환한다. 단, 최근 사용한 Preset이 없을 때, NULL을 반환한다.
457439 *
@@ -461,7 +443,7 @@ public String getLastUseMonitoringPresetName() {
461443 @ Override
462444 public String getLastUseMonitoringPresetName (String filePath ) {
463445 load (filePath );
464- return connInfoConfig .subset ("monitoring.setting.preset.lastuse" ). getString ( " " );
446+ return connInfoConfig .getString ("monitoring.setting.preset.lastuse" );
465447 }
466448
467449 /**
@@ -480,11 +462,6 @@ public String[] getMonitoringServerNames() {
480462 return connInfoConfig .getStringArray ("servernames" );
481463 }
482464
483- @ Override
484- public boolean isMonitoringContent (String toggleId ) {
485- return monitoringConfig .containsKey (toggleId ) == false ? true : monitoringConfig .getBoolean (toggleId );
486- }
487-
488465 /**
489466 * 지정된 경로에 새로운 파일을 생성한다.
490467 *
@@ -519,7 +496,7 @@ public void createNewPropertiesFile(String filePath, String type) {
519496
520497 }
521498 } catch (IOException e ) {
522- e . printStackTrace ( );
499+ log . error ( e . getMessage () );
523500 }
524501 }
525502
@@ -554,6 +531,7 @@ public JschConnectionInfo getJschConnectionInfo(String serverName) {
554531 try {
555532 serverOS = ServerOS .valueOf (connInfoConfig .getString (serverName + ".server.os" ));
556533 } catch (Exception e ) {
534+ log .error (e .getMessage ());
557535 }
558536 String serverPort = connInfoConfig .getString (serverName + ".server.port" );
559537 String serverUserName = connInfoConfig .getString (serverName + ".server.username" );
0 commit comments