webadmin/src/wa/server/WAConstants.java

58 lines
1.6 KiB
Java
Raw Normal View History

2015-04-09 21:22:47 +00:00
package wa.server;
2015-07-15 12:58:30 +00:00
import zutil.db.DBConnection;
2015-04-09 21:22:47 +00:00
import zutil.osal.OSAbstractionLayer;
import zutil.osal.OSAbstractionLayer.OSType;
2016-03-04 17:55:30 +01:00
import java.io.File;
2015-04-09 21:22:47 +00:00
public class WAConstants {
2015-07-15 12:58:30 +00:00
public static final String DB_FILE_NAME = "webadmin.db";
2015-04-09 21:22:47 +00:00
public static final String DB_TABLE_PREFIX = "wa";
2015-07-15 12:58:30 +00:00
public static DBConnection db;
2015-06-02 15:48:21 +00:00
public static final String WA_ROOT_PATH_LINUX = "/";
public static final String WA_ROOT_PATH_WINDOWS = "C:\\webadmin\\";
public static final String WA_BASE_CONFIG_PATH = "etc/webadmin/";
private static final File configPath;
2015-04-09 21:22:47 +00:00
public static final String WA_SSL_CERT = "cert/server.crt";
public static final String WA_SSL_KEY = "cert/server.key";
public static final String WA_CONFIG_BOUNDARY = "---- WebAdmin Configuration ----";
static{
OSAbstractionLayer os = OSAbstractionLayer.getInstance();
2015-07-15 12:58:30 +00:00
2015-04-09 21:22:47 +00:00
if(os.getOSType() == OSType.Linux){
2015-06-02 15:48:21 +00:00
configPath = new File(WA_ROOT_PATH_LINUX + WA_BASE_CONFIG_PATH);
2015-04-09 21:22:47 +00:00
}
else if(os.getOSType() == OSType.Windows){
2015-06-02 15:48:21 +00:00
configPath = new File(WA_ROOT_PATH_WINDOWS + WA_BASE_CONFIG_PATH);
2015-04-09 21:22:47 +00:00
}
2015-06-02 15:48:21 +00:00
else {
configPath = null;
}
2015-07-15 12:58:30 +00:00
if(configPath != null){
try {
db = new DBConnection(DBConnection.DBMS.SQLite, configPath.getAbsolutePath() + DB_FILE_NAME);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
2015-04-09 21:22:47 +00:00
}
public static File getConfigFile(String name){
2015-06-02 15:48:21 +00:00
return new File(configPath, name);
2015-04-09 21:22:47 +00:00
}
2015-07-15 12:58:30 +00:00
public static DBConnection getDB(){
return db;
}
2015-04-09 21:22:47 +00:00
}