Skip to content

Commit

Permalink
Package refactoring utils
Browse files Browse the repository at this point in the history
  • Loading branch information
autumoswitzerland committed Jul 14, 2024
1 parent e50b717 commit 6dc3d75
Show file tree
Hide file tree
Showing 76 changed files with 336 additions and 116 deletions.
1 change: 1 addition & 0 deletions cfg/beetroot_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ db_pw_encoded=no
# [WEB-CONTEXT-PATH] or use
# an absolute path.
#
#db_url_h2_non_keywords=TEST1,TEST2
db_url=jdbc:h2:./db/h2/db/test/beetroot;AUTO_SERVER=TRUE;IFEXISTS=TRUE
#db_url=jdbc:mariadb://localhost:3306/beetroot_test
#db_url=jdbc:postgresql://localhost:5432/beetroot
Expand Down
Binary file modified db/h2/db/test/beetroot.mv.db
Binary file not shown.
2 changes: 1 addition & 1 deletion gen/java/DeleteHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.handler.HandlerResponse;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

import ch.autumo.beetroot.handler.DefaultDeleteHandler;

Expand Down
2 changes: 1 addition & 1 deletion gen/java/IndexHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.handler.DefaultIndexHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* ##Entitynameplural## index handler.
Expand Down
2 changes: 1 addition & 1 deletion gen/java/ViewHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.handler.DefaultViewHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* ##Entitynameplural## view handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import ch.autumo.beetroot.logging.LoggingFactory;
import ch.autumo.beetroot.utils.UtilsException;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.web.Web;


/**
Expand Down
34 changes: 27 additions & 7 deletions src/main/java/ch/autumo/beetroot/BeetRootConfigurationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

import ch.autumo.beetroot.security.SecureApplication;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.OS;
import ch.autumo.beetroot.utils.Security;
import ch.autumo.beetroot.utils.security.Security;
import ch.autumo.beetroot.utils.systen.OS;


/**
Expand Down Expand Up @@ -612,19 +612,39 @@ public String[] getAppRoles() {

/**
* Get comma-separated values, e.g. 'a,b,c'.
* If the configuration is messed up an empty
* array is returned. No warning if key is missing.
*
* @param key key
* @return values
*/
public String[] getSepValuesNoWarn(String key) {
String v1 = generalProps.getProperty(key);
if (v1 == null || v1.length() == 0) {
return new String[0];
}
String v2[] = v1.split(",");
String res[] = new String[v2.length];
for (int j = 0; j < v2.length; j++) {
res[j] = v2[j].trim();
}
return res;
}

/**
* Get comma-separated values, e.g. 'a,b,c'.
* If no values are found an empty array
* is returned.
*
* @param key key
* @return values
*/
public String[] getSepValues(String key) {

String v1 = generalProps.getProperty(key);

if (v1 == null || v1.length() == 0) {

LOG.warn("There are no separated values (or fields configured) for key '" + key + "' !");
LOG.warn("There are no separated values (or fields configured) for key '{}'!", key);
return new String[0];
}

String v2[] = v1.split(",");
String res[] = new String[v2.length];
for (int j = 0; j < v2.length; j++) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ch/autumo/beetroot/BeetRootDatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import com.zaxxer.hikari.HikariDataSource;

import ch.autumo.beetroot.security.SecureApplicationHolder;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.DBField;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.OS;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.database.DBField;
import ch.autumo.beetroot.utils.systen.OS;

/**
* Database manager.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/ch/autumo/beetroot/BeetRootWebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
import ch.autumo.beetroot.server.message.ClientAnswer;
import ch.autumo.beetroot.server.message.ServerCommand;
import ch.autumo.beetroot.sms.MessengerFactory;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.MIME;
import ch.autumo.beetroot.utils.OS;
import ch.autumo.beetroot.utils.Security;
import ch.autumo.beetroot.utils.TwoFA;
import ch.autumo.beetroot.utils.UtilsException;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.common.MIME;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.security.Security;
import ch.autumo.beetroot.utils.systen.OS;
import ch.autumo.beetroot.utils.web.TwoFA;
import ch.autumo.beetroot.utils.web.Web;

/**
* autumo ifaceX web server and template engine.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/autumo/beetroot/LanguageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.web.Web;


/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ch/autumo/beetroot/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@

import ch.autumo.beetroot.annotations.Column;
import ch.autumo.beetroot.plant.Plant;
import ch.autumo.beetroot.utils.BeanField;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Security;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.UtilsException;
import ch.autumo.beetroot.utils.bean.BeanField;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.security.Security;


/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/autumo/beetroot/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import org.nanohttpd.protocols.http.content.CookieHandler;

import ch.autumo.beetroot.utils.GUIDGenerator;
import ch.autumo.beetroot.utils.LowerCaseList;
import ch.autumo.beetroot.utils.common.LowerCaseList;
import ch.autumo.beetroot.utils.systen.GUIDGenerator;

/**
* User session.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/autumo/beetroot/cache/FileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.slf4j.LoggerFactory;

import ch.autumo.beetroot.BeetRootConfigurationManager;
import ch.autumo.beetroot.utils.MIME;
import ch.autumo.beetroot.utils.common.MIME;

/**
* File cache.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/autumo/beetroot/crud/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.slf4j.LoggerFactory;

import ch.autumo.beetroot.Model;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;


/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ch/autumo/beetroot/handler/BaseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
import ch.autumo.beetroot.handler.roles.Role;
import ch.autumo.beetroot.handler.users.LogoutHandler;
import ch.autumo.beetroot.handler.usersroles.UserRole;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Security;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.security.Security;
import ch.autumo.beetroot.utils.web.Web;
import jakarta.activation.MimeType;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
import ch.autumo.beetroot.LanguageManager;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.crud.EventHandler;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.web.Web;

/**
* Default handler for 'web/html/&lt;entity&gt;/add.html' templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.LanguageManager;
import ch.autumo.beetroot.crud.EventHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* Default delete handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.LanguageManager;
import ch.autumo.beetroot.crud.EventHandler;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.web.Web;

/**
* Default handler for 'web/html/&lt;entity&gt;/edit.html' templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import ch.autumo.beetroot.LanguageManager;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.SessionManager;
import ch.autumo.beetroot.utils.BeanProcessor;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.bean.BeanProcessor;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.web.Web;

/**
* Default handler for 'web/html/&lt;entity&gt;/index.html' templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.Constants;
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.utils.BeanProcessor;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.bean.BeanProcessor;
import ch.autumo.beetroot.utils.bean.Beans;

/**
* Default JSON-REST handler for listing entities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.LanguageManager;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.utils.Beans;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Helper;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.bean.Beans;
import ch.autumo.beetroot.utils.database.DB;
import ch.autumo.beetroot.utils.web.Web;

/**
* Default handler for 'web/html/&lt;entity&gt;/view.html' templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import ch.autumo.beetroot.BeetRootConfigurationManager;
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.Constants;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.web.Web;

/**
* Default file download handler for 'web/html/files/view.html' templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.handler.DefaultIndexHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* Properties index handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.handler.DefaultViewHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* Properties view handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.handler.DefaultIndexHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* Roles index handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.handler.DefaultViewHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;

/**
* Roles view handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import ch.autumo.beetroot.logging.LogEventAppender;
import ch.autumo.beetroot.server.message.ClientAnswer;
import ch.autumo.beetroot.server.modules.log.LogFactory;
import ch.autumo.beetroot.utils.Web;
import ch.autumo.beetroot.utils.web.Web;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.Session;
import ch.autumo.beetroot.handler.DefaultIndexHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;

/**
* Tasks index handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import ch.autumo.beetroot.BeetRootHTTPSession;
import ch.autumo.beetroot.Entity;
import ch.autumo.beetroot.handler.DefaultViewHandler;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;

/**
* Tasks view handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import ch.autumo.beetroot.SessionManager;
import ch.autumo.beetroot.handler.BaseHandler;
import ch.autumo.beetroot.handler.HandlerResponse;
import ch.autumo.beetroot.utils.Security;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.security.Security;

/**
* Default login handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import ch.autumo.beetroot.handler.HandlerResponse;
import ch.autumo.beetroot.handler.roles.Role;
import ch.autumo.beetroot.handler.usersroles.UserRole;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.database.DB;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import ch.autumo.beetroot.Model;
import ch.autumo.beetroot.handler.roles.Role;
import ch.autumo.beetroot.handler.usersroles.UserRole;
import ch.autumo.beetroot.utils.DB;
import ch.autumo.beetroot.utils.Time;
import ch.autumo.beetroot.utils.common.Time;
import ch.autumo.beetroot.utils.database.DB;

/**
* Users edit handler for extended roles.
Expand Down
Loading

0 comments on commit 6dc3d75

Please sign in to comment.