diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$ new file mode 100644 index 0000000..d4d7d1e --- /dev/null +++ b/.idea/$PRODUCT_WORKSPACE_FILE$ @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + 1.8 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore index 5c98b42..f22d961 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,2 +1,4 @@ # Default ignored files +/workspace.xml +# Default ignored files /workspace.xml \ No newline at end of file diff --git a/.idea/artifacts/WasteinformationServer.xml b/.idea/artifacts/WasteinformationServer.xml new file mode 100644 index 0000000..99a538f --- /dev/null +++ b/.idea/artifacts/WasteinformationServer.xml @@ -0,0 +1,11 @@ + + + $PROJECT_DIR$/out/artifacts/WasteinformationServer + + + + + + + + \ No newline at end of file diff --git a/UniquedeviceID-tcp19216864151883/.lck b/UniquedeviceID-tcp19216864151883/.lck deleted file mode 100644 index e69de29..0000000 diff --git a/UniquedeviceID-tcp19216865151883/.lck b/UniquedeviceID-tcp19216865151883/.lck deleted file mode 100644 index e69de29..0000000 diff --git a/WasteInformationServer.iml b/WasteInformationServer.iml index 8bd06b5..5c65772 100644 --- a/WasteInformationServer.iml +++ b/WasteInformationServer.iml @@ -4,6 +4,7 @@ + diff --git a/lib/mysql-connector-java-5.1.44-bin.jar b/lib/mysql-connector-java-5.1.44-bin.jar old mode 100755 new mode 100644 index 2f2e32d..cf69f4d Binary files a/lib/mysql-connector-java-5.1.44-bin.jar and b/lib/mysql-connector-java-5.1.44-bin.jar differ diff --git a/lib/org.eclipse.paho.client.mqttv3-1.2.1.jar b/lib/org.eclipse.paho.client.mqttv3-1.2.1.jar index fe62073..e017483 100644 Binary files a/lib/org.eclipse.paho.client.mqttv3-1.2.1.jar and b/lib/org.eclipse.paho.client.mqttv3-1.2.1.jar differ diff --git a/wwwroot/css/general.css b/resources/wwwroot/css/general.css similarity index 100% rename from wwwroot/css/general.css rename to resources/wwwroot/css/general.css diff --git a/wwwroot/css/index.css b/resources/wwwroot/css/index.css similarity index 100% rename from wwwroot/css/index.css rename to resources/wwwroot/css/index.css diff --git a/wwwroot/css/profile.css b/resources/wwwroot/css/profile.css similarity index 100% rename from wwwroot/css/profile.css rename to resources/wwwroot/css/profile.css diff --git a/wwwroot/css/register.css b/resources/wwwroot/css/register.css similarity index 100% rename from wwwroot/css/register.css rename to resources/wwwroot/css/register.css diff --git a/wwwroot/css/settings.css b/resources/wwwroot/css/settings.css similarity index 100% rename from wwwroot/css/settings.css rename to resources/wwwroot/css/settings.css diff --git a/wwwroot/index.html b/resources/wwwroot/index.html similarity index 100% rename from wwwroot/index.html rename to resources/wwwroot/index.html diff --git a/wwwroot/js/index.js b/resources/wwwroot/js/index.js similarity index 100% rename from wwwroot/js/index.js rename to resources/wwwroot/js/index.js diff --git a/wwwroot/js/profile.js b/resources/wwwroot/js/profile.js similarity index 100% rename from wwwroot/js/profile.js rename to resources/wwwroot/js/profile.js diff --git a/wwwroot/js/register.js b/resources/wwwroot/js/register.js similarity index 100% rename from wwwroot/js/register.js rename to resources/wwwroot/js/register.js diff --git a/wwwroot/js/settings.js b/resources/wwwroot/js/settings.js similarity index 100% rename from wwwroot/js/settings.js rename to resources/wwwroot/js/settings.js diff --git a/wwwroot/lib/bootstrap.min.css b/resources/wwwroot/lib/bootstrap.min.css similarity index 100% rename from wwwroot/lib/bootstrap.min.css rename to resources/wwwroot/lib/bootstrap.min.css diff --git a/wwwroot/lib/bootstrap.min.js b/resources/wwwroot/lib/bootstrap.min.js similarity index 100% rename from wwwroot/lib/bootstrap.min.js rename to resources/wwwroot/lib/bootstrap.min.js diff --git a/wwwroot/lib/jquery.min.js b/resources/wwwroot/lib/jquery.min.js similarity index 100% rename from wwwroot/lib/jquery.min.js rename to resources/wwwroot/lib/jquery.min.js diff --git a/wwwroot/lib/popper.min.js b/resources/wwwroot/lib/popper.min.js similarity index 100% rename from wwwroot/lib/popper.min.js rename to resources/wwwroot/lib/popper.min.js diff --git a/wwwroot/profile.html b/resources/wwwroot/profile.html similarity index 100% rename from wwwroot/profile.html rename to resources/wwwroot/profile.html diff --git a/wwwroot/register.html b/resources/wwwroot/register.html similarity index 100% rename from wwwroot/register.html rename to resources/wwwroot/register.html diff --git a/wwwroot/rsc/login.jpg b/resources/wwwroot/rsc/login.jpg similarity index 100% rename from wwwroot/rsc/login.jpg rename to resources/wwwroot/rsc/login.jpg diff --git a/wwwroot/rsc/login2.jpg b/resources/wwwroot/rsc/login2.jpg similarity index 100% rename from wwwroot/rsc/login2.jpg rename to resources/wwwroot/rsc/login2.jpg diff --git a/wwwroot/settings.html b/resources/wwwroot/settings.html similarity index 100% rename from wwwroot/settings.html rename to resources/wwwroot/settings.html diff --git a/src/com/wasteinformationserver/db/jdcb.java b/src/com/wasteinformationserver/db/jdcb.java index 20617d3..3d73113 100644 --- a/src/com/wasteinformationserver/db/jdcb.java +++ b/src/com/wasteinformationserver/db/jdcb.java @@ -1,8 +1,6 @@ package com.wasteinformationserver.db; import com.wasteinformationserver.basicutils.Log; -import com.wasteinformationserver.db.Database; -import com.wasteinformationserver.db.MySQLConnector; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/src/com/wasteinformationserver/main.java b/src/com/wasteinformationserver/main.java index 3e53e36..8f2bfbc 100644 --- a/src/com/wasteinformationserver/main.java +++ b/src/com/wasteinformationserver/main.java @@ -1,6 +1,8 @@ package com.wasteinformationserver; +import com.wasteinformationserver.basicutils.Log; import com.wasteinformationserver.mqtt.*; +import com.wasteinformationserver.website.Webserver; public class main { public static void main(String[] args) { @@ -10,7 +12,7 @@ public class main { D.printList(); */ - /* Runtime.getRuntime().addShutdownHook(new Thread(() -> { + Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { Thread.sleep(200); Log.warning("Shutting down ..."); @@ -24,10 +26,11 @@ public class main { Thread mythread = new Thread(() -> new Webserver().startserver()); mythread.start(); - Log.message("thread started");*/ + Log.message("thread started"); - mqtt m = new mqtt(); - m.notifymessage(); +// mqtt m = new mqtt(); +// m.notifymessage(); +// m.getDatabasedata(); } } diff --git a/src/com/wasteinformationserver/website/CheckLoginState.java b/src/com/wasteinformationserver/website/CheckLoginState.java index 8021dba..0f299a1 100644 --- a/src/com/wasteinformationserver/website/CheckLoginState.java +++ b/src/com/wasteinformationserver/website/CheckLoginState.java @@ -1,7 +1,6 @@ package com.wasteinformationserver.website; import com.wasteinformationserver.basicutils.Log; -import com.wasteinformationserver.db.PostRequest; import java.util.HashMap; diff --git a/src/com/wasteinformationserver/website/LoginRequest.java b/src/com/wasteinformationserver/website/LoginRequest.java index 44aac5c..93b0fea 100644 --- a/src/com/wasteinformationserver/website/LoginRequest.java +++ b/src/com/wasteinformationserver/website/LoginRequest.java @@ -1,6 +1,5 @@ package com.wasteinformationserver.website; -import com.wasteinformationserver.db.PostRequest; import com.wasteinformationserver.db.jdcb; import java.sql.ResultSet; diff --git a/src/com/wasteinformationserver/website/MainPage.java b/src/com/wasteinformationserver/website/MainPage.java index c727ab8..3597c4c 100644 --- a/src/com/wasteinformationserver/website/MainPage.java +++ b/src/com/wasteinformationserver/website/MainPage.java @@ -5,11 +5,10 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.wasteinformationserver.basicutils.Log; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; +import java.awt.*; +import java.io.*; import java.net.URI; +import java.net.URL; public class MainPage implements HttpHandler { @Override @@ -25,9 +24,13 @@ public class MainPage implements HttpHandler { } Log.message("looking for: " + root + path); - File file = new File(root + path).getCanonicalFile(); - if (!file.isFile()) { +// File file = new File(getClass().getResource("/wwwroot"+path).getFile()).getCanonicalFile(); + InputStream fs = getClass().getResourceAsStream("/wwwroot"+path); + +// File file = new File(root + path).getCanonicalFile(); + + if (fs.available() < 1) { // Object does not exist or is not a file: reject with 404 error. String response = "404 (Not Found)\n"; t.sendResponseHeaders(404, response.length()); @@ -45,7 +48,7 @@ public class MainPage implements HttpHandler { t.sendResponseHeaders(200, 0); OutputStream os = t.getResponseBody(); - FileInputStream fs = new FileInputStream(file); +// FileInputStream fs = new FileInputStream(file); final byte[] buffer = new byte[0x10000]; int count; while ((count = fs.read(buffer)) >= 0) { diff --git a/src/com/wasteinformationserver/db/PostRequest.java b/src/com/wasteinformationserver/website/PostRequest.java similarity index 96% rename from src/com/wasteinformationserver/db/PostRequest.java rename to src/com/wasteinformationserver/website/PostRequest.java index 35331d1..9ad4e46 100644 --- a/src/com/wasteinformationserver/db/PostRequest.java +++ b/src/com/wasteinformationserver/website/PostRequest.java @@ -1,4 +1,4 @@ -package com.wasteinformationserver.db; +package com.wasteinformationserver.website; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; diff --git a/src/com/wasteinformationserver/website/RegisterRequest.java b/src/com/wasteinformationserver/website/RegisterRequest.java index dc00441..ff36055 100644 --- a/src/com/wasteinformationserver/website/RegisterRequest.java +++ b/src/com/wasteinformationserver/website/RegisterRequest.java @@ -1,6 +1,5 @@ package com.wasteinformationserver.website; -import com.wasteinformationserver.db.PostRequest; import com.wasteinformationserver.db.jdcb; import java.util.HashMap; diff --git a/src/com/wasteinformationserver/website/Webserver.java b/src/com/wasteinformationserver/website/Webserver.java index fd052da..3180afb 100644 --- a/src/com/wasteinformationserver/website/Webserver.java +++ b/src/com/wasteinformationserver/website/Webserver.java @@ -4,7 +4,6 @@ import com.sun.net.httpserver.HttpServer; import com.wasteinformationserver.basicutils.Log; import java.io.IOException; - import java.net.InetSocketAddress; @@ -28,6 +27,4 @@ public class Webserver { Log.info("Server available at http://127.0.0.1:8000 now"); } - - }