some name and warning fixings

This commit is contained in:
lukas-heiligenbrunner 2020-01-20 18:20:37 +01:00
parent 81e79c1e67
commit c590b612b5
6 changed files with 18 additions and 23 deletions

View File

@ -32,7 +32,7 @@ dependencies {
task run (type: JavaExec){
description = "Secure algorythm testing"
main = 'com.wasteinformationserver.main'
main = 'com.wasteinformationserver.Main'
classpath = sourceSets.main.runtimeClasspath
}

View File

@ -8,7 +8,7 @@ import com.wasteinformationserver.website.Webserver;
import java.io.IOException;
public class main {
public class Main {
public static void main(String[] args) {
Log.setLevel(Log.DEBUG);
Info.init();
@ -32,8 +32,8 @@ public class main {
//initial connect to db
Log.message("initial login to db");
try {
//JDBC.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306);
JDBC.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
JDBC.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306);
//JDBC.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
} catch (IOException e) {
//e.printStackTrace();
Log.error("no connection to db");

View File

@ -21,7 +21,7 @@ public class MqttService {
try {
db = JDBC.getInstance();
} catch (IOException e) {
e.printStackTrace();
Log.error("no connetion to db");
}
}

View File

@ -57,8 +57,9 @@ public class MainPage implements HttpHandler {
} else {
// Object exists and is a file: accept with response code 200.
String mime = "text/html";
if (path.substring(path.length() - 3).equals(".js")) mime = "application/javascript";
if (path.substring(path.length() - 3).equals("css")) mime = "text/css";
final String s = path.substring(path.length() - 3);
if (s.equals(".js")) mime = "application/javascript";
if (s.equals("css")) mime = "text/css";
Headers h = t.getResponseHeaders();
h.set("Content-Type", mime);

View File

@ -15,7 +15,7 @@ public class DeviceRequest extends PostRequest {
JDBC jdbc = null;
try {
jdbc = jdbc.getInstance();
jdbc = JDBC.getInstance();
} catch (IOException e) {
e.printStackTrace();
}
@ -37,7 +37,7 @@ public class DeviceRequest extends PostRequest {
int deviceid = setunconfigured.getInt("DeviceID");
int cityid = setunconfigured.getInt("CityID");
sb.append("{\"deviceid\":\"" + deviceid + "\",\"cityid\":\"" + cityid + "\"}");
sb.append("{\"deviceid\":\"").append(deviceid).append("\",\"cityid\":\"").append(cityid).append("\"}");
if (!(setunconfigured.isLast() && configsize == 0)) {
sb.append(",");
@ -55,7 +55,7 @@ public class DeviceRequest extends PostRequest {
String wastetype = setconfigured.getString("wastetype");
String zone = setconfigured.getString("zone");
sb.append("{\"deviceid\":\"" + deviceid + "\",\"cityid\":\"" + cityid + "\",\"devicename\":\"" + devicename + "\",\"devicelocation\":\"" + devicelocation + "\",\"cityname\":\"" + cityname + "\",\"wastetype\":\"" + wastetype + "\",\"zone\":\"" + zone + "\"}");
sb.append("{\"deviceid\":\"").append(deviceid).append("\",\"cityid\":\"").append(cityid).append("\",\"devicename\":\"").append(devicename).append("\",\"devicelocation\":\"").append(devicelocation).append("\",\"cityname\":\"").append(cityname).append("\",\"wastetype\":\"").append(wastetype).append("\",\"zone\":\"").append(zone).append("\"}");
if (!setconfigured.isLast()) {
sb.append(",");
@ -74,13 +74,11 @@ public class DeviceRequest extends PostRequest {
try {
String prev = "";
while (setunconfigured.next()) {
if (prev.equals(setunconfigured.getString("name"))) {
} else {
if (!prev.equals(setunconfigured.getString("name"))) {
if (!setunconfigured.isFirst()) {
sb.append(",");
}
sb.append("\"" + setunconfigured.getString("name") + "\":\"" + setunconfigured.getString("name") + "\"");
sb.append("\"").append(setunconfigured.getString("name")).append("\":\"").append(setunconfigured.getString("name")).append("\"");
}
prev = setunconfigured.getString("name");
}
@ -97,10 +95,8 @@ public class DeviceRequest extends PostRequest {
try {
int prev = 42;
while (setunconfigured.next()) {
if (prev == setunconfigured.getInt("zone")) {
} else {
sb.append("\"" + setunconfigured.getInt("zone") + "\":\"" + setunconfigured.getInt("zone") + "\"");
if (prev != setunconfigured.getInt("zone")) {
sb.append("\"").append(setunconfigured.getInt("zone")).append("\":\"").append(setunconfigured.getInt("zone")).append("\"");
if (!setunconfigured.isLast()) {
sb.append(",");
}
@ -119,9 +115,7 @@ public class DeviceRequest extends PostRequest {
try {
String prev = "42";
while (setunconfigured.next()) {
if (prev == setunconfigured.getString("wastetype")) {
} else {
if (!prev.equals(setunconfigured.getString("wastetype"))) {
sb.append("\"" + setunconfigured.getString("wastetype") + "\":\"" + setunconfigured.getString("wastetype") + "\"");
if (!setunconfigured.isLast()) {
sb.append(",");
@ -151,7 +145,7 @@ public class DeviceRequest extends PostRequest {
break;
case "deleteDevice":
try {
int res = jdbc.executeUpdate("DELETE FROM devices WHERE `DeviceID`='" + params.get("id") + "'");
jdbc.executeUpdate("DELETE FROM devices WHERE `DeviceID`='" + params.get("id") + "'");
} catch (SQLException e) {
e.printStackTrace();
}

View File

@ -24,7 +24,7 @@ public class RegisterRequest extends PostRequest {
}
//new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
try {
int s = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('" + params.get("username") + "', '" + params.get("firstname") + "', '" + params.get("lastname") + "', '" + passhash + "', '" + params.get("email") + "', current_timestamp());");
myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('" + params.get("username") + "', '" + params.get("firstname") + "', '" + params.get("lastname") + "', '" + passhash + "', '" + params.get("email") + "', current_timestamp());");
} catch (SQLException e) {
e.printStackTrace();
}