Compare commits
No commits in common. "eec6266e20a3ee3b2eb079ffbbdf164976234e0d" and "79aa1678b20472a43498e8894950d16c7e84694c" have entirely different histories.
eec6266e20
...
79aa1678b2
|
|
@ -1 +0,0 @@
|
|||
*.log
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -35,19 +35,19 @@ dist.jlink.dir=${dist.dir}/jlink
|
|||
dist.jlink.output=${dist.jlink.dir}/jNetLib
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.apache-commons-configuration2-2.9.0.jar=lib\\apache-commons-configuration2-2.9.0.jar
|
||||
file.reference.apache-commons-lang3-3.12.0.jar=lib\\apache-commons-lang3-3.12.0.jar
|
||||
file.reference.apache-commons-logging-1.2.jar=lib\\apache-commons-logging-1.2.jar
|
||||
file.reference.snmp4j-3.8.2.jar=lib\\snmp4j-3.8.2.jar
|
||||
file.reference.spring-security-crypto-5.8.0.jar=lib\\spring-security-crypto-5.8.0.jar
|
||||
file.reference.apache-commons-configuration2-2.9.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-configuration2-2.9.0.jar
|
||||
file.reference.apache-commons-lang3-3.12.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-lang3-3.12.0.jar
|
||||
file.reference.apache-commons-logging-1.2.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-logging-1.2.jar
|
||||
file.reference.argon2-jvm-nolibs-2.11.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\argon2-jvm-nolibs-2.11.jar
|
||||
file.reference.spring-security-crypto-5.8.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\spring-security-crypto-5.8.0.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.apache-commons-configuration2-2.9.0.jar}:\
|
||||
${file.reference.apache-commons-lang3-3.12.0.jar}:\
|
||||
${file.reference.apache-commons-logging-1.2.jar}:\
|
||||
${file.reference.spring-security-crypto-5.8.0.jar}:\
|
||||
${file.reference.snmp4j-3.8.2.jar}
|
||||
${file.reference.apache-commons-logging-1.2.jar}:\
|
||||
${file.reference.argon2-jvm-nolibs-2.11.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
|
|
|||
|
|
@ -50,12 +50,10 @@ public class Message implements Serializable {
|
|||
// C->S: klient odesila upravu serveru
|
||||
public static final int SERVER_CONFIG = 13;
|
||||
|
||||
// C->S: klient posila požadavek na restart serveru
|
||||
public static final int RESTART = 15;
|
||||
//S->C: server odesila seznam objektu
|
||||
public static final int OBJECT_LIST = 14;
|
||||
|
||||
|
||||
// C->S: klient se dotazuje na uptime server
|
||||
// S->C: server odesila uptim serveru
|
||||
public static final int UPTIME = 16;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,29 @@
|
|||
package jnet.lib;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
|
||||
public class PropertiesManager {
|
||||
|
||||
private PropertiesConfiguration config;
|
||||
private String file;
|
||||
private String filePath;
|
||||
|
||||
// Konstruktor pro inicializaci s cestou k souboru
|
||||
public PropertiesManager(String file) {
|
||||
this.file = file;
|
||||
public PropertiesManager(String filePath) {
|
||||
this.filePath = filePath;
|
||||
this.config = new PropertiesConfiguration();
|
||||
}
|
||||
|
||||
public void load() throws FileException, ConfigException {
|
||||
try (InputStream input = getClass().getClassLoader().getResourceAsStream(file)) {
|
||||
if (input == null) {
|
||||
throw new FileException("Soubor config.properties nebyl nalezen.");
|
||||
}
|
||||
config.read(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
try {
|
||||
// Načtení existující konfigurace, pokud soubor existuje
|
||||
config.read(new FileReader(filePath));
|
||||
} catch (ConfigurationException ex) {
|
||||
throw new ConfigException("Chyba konfigurace");
|
||||
} catch (IOException ex) {
|
||||
|
|
@ -44,7 +43,7 @@ public class PropertiesManager {
|
|||
|
||||
// Metoda pro uložení konfigurace do souboru
|
||||
public void save() {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
try (FileWriter writer = new FileWriter(filePath)) {
|
||||
// Použití FileWriter pro zápis do souboru
|
||||
config.write(writer);
|
||||
LogFile.printInfo("Konfigurace byla uspesne ulozena.");
|
||||
|
|
@ -91,7 +90,7 @@ public class PropertiesManager {
|
|||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ConfigException extends Exception {
|
||||
|
||||
public ConfigException(String message) {
|
||||
|
|
|
|||
|
|
@ -4,21 +4,23 @@ import jnet.lib.Status;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cucky
|
||||
*/
|
||||
public class Map implements Serializable {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private boolean lock;
|
||||
private ArrayList<MapObject> objects;
|
||||
//private ArrayList<MapObject> objects;
|
||||
private int status;
|
||||
|
||||
public Map(int id, String name, boolean lock, ArrayList<MapObject> objects) {
|
||||
public Map(int id, String name, boolean lock) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lock = lock;
|
||||
this.status = Status.NA;
|
||||
this.objects = objects;
|
||||
|
||||
}
|
||||
|
||||
public Map(String name) {
|
||||
|
|
@ -26,6 +28,8 @@ public class Map implements Serializable {
|
|||
this.lock = false;
|
||||
this.status = Status.NA;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
|
@ -51,36 +55,5 @@ public class Map implements Serializable {
|
|||
this.lock = lock;
|
||||
}
|
||||
|
||||
public ArrayList<MapObject> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
public void setObjects(ArrayList<MapObject> objects) {
|
||||
this.objects = objects;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
if (getObjects().isEmpty()) {
|
||||
return Status.NA;
|
||||
}
|
||||
|
||||
int status = Status.OK;
|
||||
|
||||
for (MapObject object : getObjects()) {
|
||||
int objectStatus = object.getStatus();
|
||||
|
||||
if (objectStatus == Status.OFFLINE) {
|
||||
return Status.OFFLINE; // Okamžitě vrátíme OFFLINE
|
||||
} else if (objectStatus == Status.WARNING) {
|
||||
status = Status.WARNING; // Možný downgrade na WARNING
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,28 +4,18 @@ import java.io.Serializable;
|
|||
|
||||
public class ServerConfig implements Serializable {
|
||||
|
||||
private int pingRepeat;
|
||||
private int pingAttempt;
|
||||
private int pingTimeout;
|
||||
private int instabilityAttempt;
|
||||
private int instabilityLimit;
|
||||
|
||||
public ServerConfig(int pingRepeat, int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
||||
this.pingRepeat = pingRepeat;
|
||||
public ServerConfig(int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
||||
this.pingAttempt = pingAttempt;
|
||||
this.pingTimeout = pingTimeout;
|
||||
this.instabilityAttempt = instabilityAttempt;
|
||||
this.instabilityLimit = instabilityLimit;
|
||||
}
|
||||
|
||||
public int getPingRepeat() {
|
||||
return pingRepeat;
|
||||
}
|
||||
|
||||
public void setPingRepeat(int pingRepeat) {
|
||||
this.pingRepeat = pingRepeat;
|
||||
}
|
||||
|
||||
public int getPingAttempt() {
|
||||
return pingAttempt;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue