diff --git a/.idea/misc.xml b/.idea/misc.xml index 588f4f9..71286c2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,10 @@ - + + + \ No newline at end of file diff --git a/src/java/com/wasteinformationserver/main.java b/src/java/com/wasteinformationserver/main.java index b43b53b..b76f2fd 100644 --- a/src/java/com/wasteinformationserver/main.java +++ b/src/java/com/wasteinformationserver/main.java @@ -13,39 +13,39 @@ public class main { Log.setLevel(Log.DEBUG); - Runtime.getRuntime().addShutdownHook(new Thread(() -> { + Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { Thread.sleep(200); Log.warning("Shutting down ..."); //shutdown routine - } catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } })); - //initial connect to db + //initial connect to db Log.message("initial login to db"); - new Thread(() -> { - try { - JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation","192.168.65.15",3306); - } catch (IOException e) { - //e.printStackTrace(); - Log.error("no connection to db"); - } - }).start(); + new Thread(() -> { + try { + JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306); + } catch (IOException e) { + //e.printStackTrace(); + Log.error("no connection to db"); + } + }).start(); - //startup web server + //startup web server Thread mythread = new Thread(() -> new Webserver().startserver()); mythread.start(); //startup mqtt service Log.message("starting mqtt service"); - try{ + try { mqtt m = new mqtt(); m.notifymessage(); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/java/com/wasteinformationserver/mqtt/mqtt.java b/src/java/com/wasteinformationserver/mqtt/mqtt.java index 8253fe2..3dc547e 100644 --- a/src/java/com/wasteinformationserver/mqtt/mqtt.java +++ b/src/java/com/wasteinformationserver/mqtt/mqtt.java @@ -33,7 +33,7 @@ public class mqtt { client.connect(connOpts); } catch (MqttException e) { - e.printStackTrace(); + Log.error("Connection to the ESB was failes"); } mqttreceiver mr = new mqttreceiver(client); @@ -56,7 +56,7 @@ public class mqtt { try { Database = JDCB.getInstance(); } catch (IOException e) { - //e.printStackTrace(); + Log.error("No Connection to the databank"); } //new JDCB("placeuser", "eaL956R6yFItQVBl", "wasteinformation"); ResultSet result = Database.executeQuery(message); @@ -77,23 +77,22 @@ public class mqtt { String tempyearnew = yearsplit[1]; String newDate = parts[2] + "." + parts[1] + ".20" + tempyearnew; String[] partstwo = date.split(" "); - String Datetomorrow=nexDayDate(); + String Datetomorrow = nexDayDate(); int abholtag; - if (partstwo[0].contains(newDate)||partstwo[0].contains(Datetomorrow)) { + if (partstwo[0].contains(newDate) || partstwo[0].contains(Datetomorrow)) { abholtag = 1; transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag); - }else { - abholtag=0; + } else { + abholtag = 0; transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag); } } } } catch (SQLException e) { - System.out.println("Exception"); - e.printStackTrace(); + Log.error("No data from databank"); } } @@ -116,12 +115,9 @@ public class mqtt { c.add(Calendar.DATE, 1); Date currentDatePlusOne = c.getTime(); - String temp=dateFormat.format(currentDatePlusOne); - String split[]=temp.split("/"); - String newDate=split[2]+"."+split[1]+"."+split[0]; + String temp = dateFormat.format(currentDatePlusOne); + String split[] = temp.split("/"); + String newDate = split[2] + "." + split[1] + "." + split[0]; return newDate; - - - } } \ No newline at end of file diff --git a/src/java/com/wasteinformationserver/mqtt/mqttreceiver.java b/src/java/com/wasteinformationserver/mqtt/mqttreceiver.java index cca19b0..7a8a64a 100644 --- a/src/java/com/wasteinformationserver/mqtt/mqttreceiver.java +++ b/src/java/com/wasteinformationserver/mqtt/mqttreceiver.java @@ -24,15 +24,15 @@ public class mqttreceiver { public String getmessage() { try { - client.setCallback(new MqttCallback() { + client.setCallback(new MqttCallback() { @Override public void connectionLost(Throwable throwable) { -Log.error("connection lost"); + Log.error("connection lost"); } @Override public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { - message =new String(mqttMessage.getPayload()); + message = new String(mqttMessage.getPayload()); notifylisteners(message); } @@ -45,7 +45,7 @@ Log.error("connection lost"); client.subscribe("TopicIn"); Log.debug("subscribed topic"); } catch (MqttException e) { - e.printStackTrace(); + Log.error("Connection to the ESB was failed"); } return message; } diff --git a/src/java/com/wasteinformationserver/mqtt/mqtttransmitter.java b/src/java/com/wasteinformationserver/mqtt/mqtttransmitter.java index daf2d21..fdfaa94 100644 --- a/src/java/com/wasteinformationserver/mqtt/mqtttransmitter.java +++ b/src/java/com/wasteinformationserver/mqtt/mqtttransmitter.java @@ -12,7 +12,7 @@ public class mqtttransmitter { MqttClient client; public mqtttransmitter(MqttClient client) { - this.client=client; + this.client = client; } public void sendmessage(String temp) { @@ -36,7 +36,6 @@ public class mqtttransmitter { Log.debug("loc " + me.getLocalizedMessage()); Log.debug("cause " + me.getCause()); Log.debug("excep " + me); - me.printStackTrace(); } } } \ No newline at end of file