2424import java .util .Comparator ;
2525import java .util .Properties ;
2626
27- import de .doubleslash .keeptime .REST_API .controller .ApiPort ;
2827import de .doubleslash .keeptime .model .Authorities ;
2928import de .doubleslash .keeptime .model .User ;
3029import de .doubleslash .keeptime .model .repos .AuthoritiesRepository ;
@@ -254,14 +253,17 @@ private void initialize() {
254253 LOG .info ("Save clicked" );
255254
256255 //*******************************************************************************
257-
256+ // String authPortValue = authPort.getText();
257+ // propertyWrite("server.port",authPortValue);
258258 Properties properties = new Properties ();
259259 try {
260260 properties .load (getClass ().getClassLoader ().getResourceAsStream (propertiesFilePath ));
261261
262262 String authPortValue = authPort .getText ();
263263
264264 properties .setProperty ("server.port" , authPortValue );
265+ // properties.setProperty("spring.main.web-application-type", "none");
266+
265267System .err .println (authPortValue );
266268 FileOutputStream outputStream = new FileOutputStream (propertiesFilePath );
267269 properties .store (outputStream , null );
@@ -283,37 +285,9 @@ private void initialize() {
283285
284286 if (selectedRadioButton == radioApiOff ) {
285287 handleApiOff ();
286- System .out .println ("#########" );
287288 } else if (selectedRadioButton == radioApiOn ) {
288289 handleApiOn ();
289- System .out .println ("---------" );
290-
291-
292-
293290 }
294- /*
295-
296-
297-
298-
299-
300-
301-
302- User user = new User();
303- Authorities authorities = new Authorities();
304- userRepository.deleteAll();
305- authoritiesRepository.deleteAll();
306- user.setUserName(username);
307- user.setPassword("{noop}" + password);
308- user.setEnabled(true);
309-
310- authorities.setUserName(username);
311- authorities.setAuthority("ROLE_USER");
312-
313- userRepository.save(user);
314- authoritiesRepository.save(authorities);*/
315-
316- //*******************************************************************************
317291
318292 if (OS .isLinux ()) {
319293 if (hoverBackgroundColor .getValue ().getOpacity () < 0.5 ) {
@@ -386,11 +360,16 @@ private void initialize() {
386360 }
387361
388362 private void handleApiOff () {
363+ propertyWrite ("spring.main.web-application-type" , "none" );
364+
389365
390366 System .out .println ("API ist ausgeschaltet" );
391367 }
392368
393369 private void handleApiOn () {
370+
371+
372+
394373 // Hier den Code ausführen, der bei Auswahl von "On" ausgeführt werden soll
395374 username = authName .getText ();
396375 password = authPassword .getText ();
@@ -409,6 +388,8 @@ private void handleApiOn() {
409388 userRepository .save (user );
410389 authoritiesRepository .save (authorities );
411390 System .out .println ("API ist eingeschaltet und Benutzer erstellt." );
391+ propertyWrite ("spring.main.web-application-type" , "" );
392+
412393 }
413394
414395 private static void setRegionSvg (Region region , double requiredWidth , double requiredHeight , RESOURCE resource ) {
@@ -666,5 +647,16 @@ private void showLicense(final Licenses license) {
666647 }
667648 }
668649
669-
650+ private void propertyWrite (String key ,String value ){
651+ Properties properties = new Properties ();
652+ try {
653+ properties .load (getClass ().getClassLoader ().getResourceAsStream (propertiesFilePath ));
654+ properties .setProperty (key , value );
655+ FileOutputStream outputStream = new FileOutputStream (propertiesFilePath );
656+ properties .store (outputStream , null );
657+ outputStream .close ();
658+ } catch (IOException e ) {
659+ e .printStackTrace ();
660+ }
661+ }
670662}
0 commit comments