code cleanup
deleted deadcode
This commit is contained in:
parent
b3fcd26964
commit
f4a00620a3
@ -40,7 +40,7 @@ task run (type: JavaExec){
|
||||
|
||||
task createProperties(dependsOn: processResources) {
|
||||
doLast {
|
||||
new File("$projectDir/src/resources/version.properties").withWriter { w ->
|
||||
new File("$projectDir/src/resources/version.prop").withWriter { w ->
|
||||
Properties p = new Properties()
|
||||
p['version'] = project.version.toString()
|
||||
p['buildtime'] = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())
|
||||
|
@ -1,105 +0,0 @@
|
||||
/**
|
||||
* dead code...
|
||||
*/
|
||||
package com.wasteinformationserver;
|
||||
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Dateget {
|
||||
private int index = 0;
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
ArrayList<String> listnew = new ArrayList<>();
|
||||
public String nextDate;
|
||||
|
||||
|
||||
public void getdata() {
|
||||
|
||||
GregorianCalendar now = new GregorianCalendar();
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||
String datum = df.format(now.getTime());
|
||||
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum=" + datum + "&bdatum=19.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
|
||||
Scanner scanner = new Scanner(new InputStreamReader(url.openStream()));
|
||||
|
||||
int n = 0;
|
||||
while (scanner.hasNext()) {
|
||||
String temp = scanner.next();
|
||||
addList(temp);
|
||||
}
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Filter();
|
||||
}
|
||||
|
||||
private void addList(String temp) {
|
||||
list.add(index, temp);
|
||||
}
|
||||
|
||||
public void printList() {
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
Log.Log.debug(list.get(n));
|
||||
}
|
||||
}
|
||||
|
||||
public void printListnew() {
|
||||
for (int n = 0; n < listnew.size(); n++) {
|
||||
Log.Log.debug(listnew.get(n));
|
||||
}
|
||||
}
|
||||
|
||||
private void Filter() {
|
||||
String temp = "href=\"/system/web/kalender.aspx?detailonr=225781954-6&menuonr=225781812\">Hausabfall";
|
||||
int counter = 0;
|
||||
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if (list.get(n).equals(temp)) {
|
||||
counter++;
|
||||
|
||||
if (counter == 4) {
|
||||
|
||||
int zaehler = 0;
|
||||
|
||||
for (int v = n; v < list.size(); v++) {
|
||||
listnew.add(zaehler, list.get(v));
|
||||
zaehler++;
|
||||
}
|
||||
|
||||
/* String string = "004-034556";
|
||||
String[] parts = string.split("-");
|
||||
String part1 = parts[0]; // 004
|
||||
String part2 = parts[1]; // 034556*/
|
||||
|
||||
splitter();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void splitter() {
|
||||
String temp = "</ul><h2>";
|
||||
|
||||
for (int n = 0; n < listnew.size(); n++) {
|
||||
|
||||
if (listnew.get(n).equals(temp)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -36,6 +36,7 @@ fun main() {
|
||||
Log.message("initial login to db")
|
||||
try {
|
||||
JDBC.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306)
|
||||
// todo make dynamic with settings page
|
||||
//JDBC.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
|
||||
} catch (e: IOException) { //e.printStackTrace();
|
||||
Log.error("no connection to db")
|
||||
@ -50,6 +51,6 @@ fun main() {
|
||||
//startup mqtt service
|
||||
Log.message("starting mqtt service")
|
||||
|
||||
val m = MqttService("mqtt.heili.eu", "1883")
|
||||
val m = MqttService("mqtt.heili.eu", "1883") // todo make dynamic with settings page
|
||||
m.startupService()
|
||||
}
|
@ -51,7 +51,7 @@ public class Info {
|
||||
starttime = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date());
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
URL url = Info.class.getResource("/version.properties");
|
||||
URL url = Info.class.getResource("/version.prop");
|
||||
|
||||
prop.load(url.openStream());
|
||||
version = (String) prop.get("version");
|
||||
@ -75,10 +75,10 @@ public class Info {
|
||||
long allocatedMemory = runtime.totalMemory();
|
||||
long freeMemory = runtime.freeMemory();
|
||||
|
||||
sb.append("free memory: " + format.format(freeMemory / 1024) + "\n");
|
||||
sb.append("allocated memory: " + format.format(allocatedMemory / 1024) + "\n");
|
||||
sb.append("max memory: " + format.format(maxMemory / 1024) + "\n");
|
||||
sb.append("total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + "\n");
|
||||
sb.append("free memory: ").append(format.format(freeMemory / 1024)).append("\n");
|
||||
sb.append("allocated memory: ").append(format.format(allocatedMemory / 1024)).append("\n");
|
||||
sb.append("max memory: ").append(format.format(maxMemory / 1024)).append("\n");
|
||||
sb.append("total free memory: ").append(format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024)).append("\n");
|
||||
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
|
@ -5,22 +5,22 @@ import java.util.*
|
||||
|
||||
class Log {
|
||||
companion object Log{
|
||||
val CRITICAL_ERROR = 6
|
||||
val ERROR = 5
|
||||
val WARNING = 4
|
||||
val INFO = 3
|
||||
val MESSAGE = 2
|
||||
val DEBUG = 1
|
||||
const val CRITICAL_ERROR = 6
|
||||
const val ERROR = 5
|
||||
const val WARNING = 4
|
||||
const val INFO = 3
|
||||
const val MESSAGE = 2
|
||||
const val DEBUG = 1
|
||||
|
||||
private val ANSI_RESET = "\u001B[0m"
|
||||
private val ANSI_BLACK = "\u001B[30m"
|
||||
private val ANSI_RED = "\u001B[31m"
|
||||
private val ANSI_GREEN = "\u001B[32m"
|
||||
private val ANSI_YELLOW = "\u001B[33m"
|
||||
private val ANSI_BLUE = "\u001B[34m"
|
||||
private val ANSI_PURPLE = "\u001B[35m"
|
||||
private val ANSI_CYAN = "\u001B[36m"
|
||||
private val ANSI_WHITE = "\u001B[37m"
|
||||
private const val ANSI_RESET = "\u001B[0m"
|
||||
private const val ANSI_BLACK = "\u001B[30m"
|
||||
private const val ANSI_RED = "\u001B[31m"
|
||||
private const val ANSI_GREEN = "\u001B[32m"
|
||||
private const val ANSI_YELLOW = "\u001B[33m"
|
||||
private const val ANSI_BLUE = "\u001B[34m"
|
||||
private const val ANSI_PURPLE = "\u001B[35m"
|
||||
private const val ANSI_CYAN = "\u001B[36m"
|
||||
private const val ANSI_WHITE = "\u001B[37m"
|
||||
|
||||
private var Loglevel = 0
|
||||
|
||||
@ -126,14 +126,14 @@ class Log {
|
||||
fun setLevel(level: Int) {
|
||||
Loglevel = level
|
||||
}
|
||||
private val colors = ArrayList(Arrays.asList("", "DEBUG", "MESSAGE", "INFO", "WARNING", "ERROR", "CRITICAL_ERROR"))
|
||||
|
||||
private val colors = ArrayList(listOf("", "DEBUG", "MESSAGE", "INFO", "WARNING", "ERROR", "CRITICAL_ERROR"))
|
||||
|
||||
|
||||
|
||||
private fun calcDate(millisecs: Long): String? {
|
||||
val date_format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
val resultdate = Date(millisecs)
|
||||
return date_format.format(resultdate)
|
||||
private fun calcDate(milliSecs: Long): String? {
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
val resultDate = Date(milliSecs)
|
||||
return dateFormat.format(resultDate)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.wasteinformationserver.db;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
abstract class Database {
|
||||
|
||||
protected String user;
|
||||
protected String password;
|
||||
|
||||
protected String host;
|
||||
protected int port;
|
||||
|
||||
protected String dbName;
|
||||
|
||||
public Database(String user, String password, String host, int port, String dbName) {
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public abstract Connection getConnection() throws SQLException;
|
||||
}
|
@ -3,10 +3,7 @@ package com.wasteinformationserver.db;
|
||||
import com.wasteinformationserver.basicutils.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
* basic connection class to a Database
|
||||
@ -25,6 +22,21 @@ public class JDBC {
|
||||
private static String ipc;
|
||||
private static int portc;
|
||||
|
||||
private JDBC(String username, String password, String dbname, String ip, int port) throws IOException {
|
||||
logintodb(username, password, dbname, ip, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* instance of JDBC driver
|
||||
*/
|
||||
static {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver").getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize database values
|
||||
* suggested on startup
|
||||
@ -45,10 +57,6 @@ public class JDBC {
|
||||
JDBC = new JDBC(username, password, dbname, ip, port);
|
||||
}
|
||||
|
||||
private JDBC(String username, String password, String dbname, String ip, int port) throws IOException {
|
||||
logintodb(username, password, dbname, ip, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* get instance of db object
|
||||
* logindata has to be set before!
|
||||
@ -67,22 +75,28 @@ public class JDBC {
|
||||
return JDBC;
|
||||
}
|
||||
|
||||
/**
|
||||
* initial login to db -- should be called only one time or for reconnect
|
||||
*
|
||||
* @param username username
|
||||
* @param password password
|
||||
* @param dbname Database name
|
||||
* @param ip Host or ip address
|
||||
* @param port Server port
|
||||
* @throws IOException thrown if no connection to db is possible.
|
||||
*/
|
||||
private static void logintodb(String username, String password, String dbname, String ip, int port) throws IOException {
|
||||
Database db = new MySQLConnector(
|
||||
username,
|
||||
password,
|
||||
ip,
|
||||
port,
|
||||
dbname);
|
||||
|
||||
try {
|
||||
conn = db.getConnection();
|
||||
DriverManager.setLoginTimeout(1);
|
||||
conn = DriverManager.getConnection(
|
||||
"jdbc:mysql://" + ip + ":" + port + "/" + dbname + "?useSSL=false&serverTimezone=CET",
|
||||
username,
|
||||
password);
|
||||
loggedin = true;
|
||||
} catch (SQLException e) {
|
||||
throw new IOException("No connection to database");
|
||||
// todo reconnect every 5mins or something
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,6 +128,11 @@ public class JDBC {
|
||||
return stmt.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* check if connection is still established
|
||||
*
|
||||
* @return connection state
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return loggedin;
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package com.wasteinformationserver.db;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
class MySQLConnector extends Database {
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver").getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public MySQLConnector(String user, String password, String host, int port, String dbName) {
|
||||
super(user, password, host, port, dbName);
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
DriverManager.setLoginTimeout(1);
|
||||
return DriverManager.getConnection(
|
||||
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false&serverTimezone=CET",
|
||||
user,
|
||||
password);
|
||||
}
|
||||
|
||||
}
|
@ -4,9 +4,9 @@ import com.wasteinformationserver.basicutils.Log.Log.debug
|
||||
import com.wasteinformationserver.basicutils.Log.Log.error
|
||||
import com.wasteinformationserver.basicutils.Log.Log.info
|
||||
import com.wasteinformationserver.basicutils.Log.Log.message
|
||||
import com.wasteinformationserver.basicutils.Log.Log.warning
|
||||
import com.wasteinformationserver.db.JDBC
|
||||
import org.eclipse.paho.client.mqttv3.*
|
||||
import java.io.IOException
|
||||
import java.sql.SQLException
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
@ -25,11 +25,7 @@ class MqttService(serverurl: String, port: String) {
|
||||
private var db: JDBC = JDBC.getInstance()
|
||||
|
||||
/**
|
||||
* init mqtt service
|
||||
* JDBC has to be inited before
|
||||
*
|
||||
* @param serverurl mqtt server ip or hostname
|
||||
* @param port mqtt server port
|
||||
* initial login to db
|
||||
*/
|
||||
init {
|
||||
connectToDb()
|
||||
@ -91,12 +87,19 @@ class MqttService(serverurl: String, port: String) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device is configured and zone infos are stored in db
|
||||
*
|
||||
* @param citywastezoneid zone/city id
|
||||
* @param deviceid device id
|
||||
*/
|
||||
private fun checkDatabase(citywastezoneid: Int, deviceid: Int) {
|
||||
var wastetype = -1
|
||||
val set2 = db.executeQuery("SELECT * FROM cities WHERE `id`='$citywastezoneid'")
|
||||
try {
|
||||
set2.last()
|
||||
if (set2.row != 1) { //error
|
||||
warning("multiple Rows with same city id found - DB Error")
|
||||
}
|
||||
else {
|
||||
val typ = set2.getString("wastetype")
|
||||
@ -136,8 +139,11 @@ class MqttService(serverurl: String, port: String) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* send a mqtt message to predefined topic
|
||||
*/
|
||||
private fun tramsmitMessage(temp: String) {
|
||||
debug("sending message >>>$temp")
|
||||
message("reply back to PCB: $temp")
|
||||
val message = MqttMessage(temp.toByteArray())
|
||||
message.qos = 2
|
||||
try {
|
||||
@ -147,16 +153,9 @@ class MqttService(serverurl: String, port: String) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTyp(number: Int): String? {
|
||||
return when (number) {
|
||||
1 -> "Plastic"
|
||||
2 -> "Metal"
|
||||
3 -> "Residual waste"
|
||||
4 -> "Biowaste"
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parse Type name to representing integer value
|
||||
*/
|
||||
private fun getIntTyp(temp: String): Int {
|
||||
return when (temp) {
|
||||
"Plastic" -> 1
|
||||
@ -167,6 +166,9 @@ class MqttService(serverurl: String, port: String) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* receives connection object and initial connection to db
|
||||
*/
|
||||
private fun connectToDb() {
|
||||
db = JDBC.getInstance()
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class HttpTools {
|
||||
* @param value input string
|
||||
* @return md5 hash
|
||||
*/
|
||||
fun StringToMD5(value: String): String {
|
||||
fun stringToMD5(value: String): String {
|
||||
return try {
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
val messageDigest = md.digest(value.toByteArray())
|
||||
|
@ -42,7 +42,7 @@ public class AdminRequests extends PostRequest {
|
||||
Log.Log.warning("not jar --> cant restart");
|
||||
|
||||
/* Build command: java -jar application.jar */
|
||||
final ArrayList<String> command = new ArrayList<String>();
|
||||
final ArrayList<String> command = new ArrayList<>();
|
||||
command.add(javaBin);
|
||||
command.add("-jar");
|
||||
command.add(currentJar.getPath());
|
||||
|
@ -74,7 +74,7 @@ class DeviceRequest : PostRequest() {
|
||||
var prev = ""
|
||||
while (deviceset.next()) {
|
||||
if (prev != deviceset.getString("name")) {
|
||||
if (!deviceset.isFirst()) {
|
||||
if (!deviceset.isFirst) {
|
||||
sb.append(",")
|
||||
}
|
||||
sb.append("\"").append(deviceset.getString("name")).append("\":\"").append(deviceset.getString("name")).append("\"")
|
||||
@ -99,7 +99,7 @@ class DeviceRequest : PostRequest() {
|
||||
while (deviceset.next()) {
|
||||
if (prev != deviceset.getInt("zone")) {
|
||||
sb.append("\"").append(deviceset.getInt("zone")).append("\":\"").append(deviceset.getInt("zone")).append("\"")
|
||||
if (!deviceset.isLast()) {
|
||||
if (!deviceset.isLast) {
|
||||
sb.append(",")
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ class DeviceRequest : PostRequest() {
|
||||
while (deviceset.next()) {
|
||||
if (prev != deviceset.getString("wastetype")) {
|
||||
sb.append("\"" + deviceset.getString("wastetype") + "\":\"" + deviceset.getString("wastetype") + "\"")
|
||||
if (!deviceset.isLast()) {
|
||||
if (!deviceset.isLast) {
|
||||
sb.append(",")
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ class DeviceRequest : PostRequest() {
|
||||
try {
|
||||
val device = jdbc.executeQuery("SELECT * FROM cities WHERE name='" + params["cityname"] + "' AND wastetype='" + params["wastetype"] + "' AND zone='" + params["zonename"] + "'")
|
||||
device.first()
|
||||
var cityid = device.getInt("id")
|
||||
val cityid = device.getInt("id")
|
||||
jdbc.executeUpdate("INSERT INTO `device_city` (`DeviceID`, `CityID`) VALUES ('" + params["deviceid"] + "', '" + cityid + "');")
|
||||
} catch (e: SQLException) {
|
||||
e.printStackTrace()
|
||||
|
@ -30,9 +30,7 @@ class NewDateRequest : PostRequest() {
|
||||
try {
|
||||
var prev = ""
|
||||
while (set.next()) {
|
||||
if (prev == set.getString("name")) {
|
||||
}
|
||||
else {
|
||||
if (prev != set.getString("name")) { // not same --> new element
|
||||
if (!set.isFirst) {
|
||||
sb.append(",")
|
||||
}
|
||||
@ -55,9 +53,7 @@ class NewDateRequest : PostRequest() {
|
||||
try {
|
||||
var prev = 42
|
||||
while (set.next()) {
|
||||
if (prev == set.getInt("zone")) {
|
||||
}
|
||||
else {
|
||||
if (prev != set.getInt("zone")) { // not same --> append next
|
||||
sb.append("{\"zone\":\"" + set.getInt("zone") + "\"}")
|
||||
if (!set.isLast) {
|
||||
sb.append(",")
|
||||
@ -79,9 +75,7 @@ class NewDateRequest : PostRequest() {
|
||||
try {
|
||||
var prev = "42"
|
||||
while (set.next()) {
|
||||
if (prev === set.getString("wastetype")) {
|
||||
}
|
||||
else {
|
||||
if (prev !== set.getString("wastetype")) {
|
||||
sb.append("{\"wastetype\":\"" + set.getString("wastetype") + "\"}")
|
||||
if (!set.isLast) {
|
||||
sb.append(",")
|
||||
|
@ -3,7 +3,7 @@ package com.wasteinformationserver.website.datarequests
|
||||
import com.wasteinformationserver.basicutils.Log
|
||||
import com.wasteinformationserver.basicutils.Log.Log.debug
|
||||
import com.wasteinformationserver.db.JDBC
|
||||
import com.wasteinformationserver.website.HttpTools.Companion.StringToMD5
|
||||
import com.wasteinformationserver.website.HttpTools.Companion.stringToMD5
|
||||
import com.wasteinformationserver.website.basicrequest.PostRequest
|
||||
import java.io.IOException
|
||||
import java.sql.SQLException
|
||||
@ -12,15 +12,16 @@ import java.util.*
|
||||
class RegisterRequest : PostRequest() {
|
||||
override fun request(params: HashMap<String, String>): String {
|
||||
debug(params.toString())
|
||||
val passhash = StringToMD5(params["password"]!!)
|
||||
var reply: StringBuilder = StringBuilder("{")
|
||||
val passhash = stringToMD5(params["password"]!!)
|
||||
val reply: StringBuilder = StringBuilder("{")
|
||||
try {
|
||||
var myjd: JDBC = JDBC.getInstance()
|
||||
val myjd: JDBC = JDBC.getInstance()
|
||||
|
||||
val status = myjd.executeUpdate("INSERT INTO `user` (`username`, `firstName`, `secondName`, `password`, `email`, `logindate`) VALUES ('" + params["username"] + "', '" + params["firstname"] + "', '" + params["lastname"] + "', '" + passhash + "', '" + params["email"] + "', current_timestamp());")
|
||||
if (status == 1) {
|
||||
reply.append("\"accept\": true")
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
reply.append("\"accept\": false")
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,14 @@ import java.util.*
|
||||
class UserInfoRequest : PostRequest() {
|
||||
override fun request(params: HashMap<String, String>): String {
|
||||
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
when (params.get("action")) {
|
||||
when (params["action"]) {
|
||||
"getlogins" -> {
|
||||
println("heyho")
|
||||
}
|
||||
""->{
|
||||
"" -> {
|
||||
//todo o
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
return "{}"
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.wasteinformationserver.basicutils.Log.Log.debug
|
||||
import com.wasteinformationserver.basicutils.Log.Log.error
|
||||
import com.wasteinformationserver.basicutils.Log.Log.message
|
||||
import com.wasteinformationserver.db.JDBC
|
||||
import com.wasteinformationserver.website.HttpTools.Companion.StringToMD5
|
||||
import com.wasteinformationserver.website.HttpTools.Companion.stringToMD5
|
||||
import com.wasteinformationserver.website.basicrequest.PostRequest
|
||||
import java.io.IOException
|
||||
import java.sql.SQLException
|
||||
@ -33,12 +33,13 @@ class LoginRequest : PostRequest() {
|
||||
try {
|
||||
s.last()
|
||||
if (s.row == 1) { //success
|
||||
if (StringToMD5(password!!) == s.getString("password")) {
|
||||
if (stringToMD5(password!!) == s.getString("password")) {
|
||||
debug("login success")
|
||||
LoginState.getObject().logIn()
|
||||
LoginState.getObject().setAccountData(username, s.getString("firstName"), s.getString("secondName"), s.getString("email"), s.getInt("permission"))
|
||||
response = "{\"accept\": true}"
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
debug("wrong password")
|
||||
}
|
||||
} else if (s.row == 0) { //user not found
|
||||
|
@ -5,7 +5,7 @@ package com.wasteinformationserver.website.datarequests.login;
|
||||
*/
|
||||
public class LoginState {
|
||||
|
||||
private static LoginState mythis = new LoginState();
|
||||
private static final LoginState mythis = new LoginState();
|
||||
|
||||
/**
|
||||
* get object
|
||||
|
Loading…
Reference in New Issue
Block a user