From 6dc3d757c70451ae2ed8c3a5fc28d40194d22c19 Mon Sep 17 00:00:00 2001 From: Michael Gasche Date: Sun, 14 Jul 2024 06:16:26 +0200 Subject: [PATCH] Package refactoring utils --- cfg/beetroot_test.cfg | 1 + db/h2/db/test/beetroot.mv.db | Bin 36864 -> 36864 bytes gen/java/DeleteHandler.java | 2 +- gen/java/IndexHandler.java | 2 +- gen/java/ViewHandler.java | 2 +- .../beetroot/AbstractBeetRootServlet.java | 2 +- .../BeetRootConfigurationManager.java | 34 ++++- .../beetroot/BeetRootDatabaseManager.java | 6 +- .../ch/autumo/beetroot/BeetRootWebServer.java | 12 +- .../ch/autumo/beetroot/LanguageManager.java | 2 +- src/main/java/ch/autumo/beetroot/Model.java | 10 +- src/main/java/ch/autumo/beetroot/Session.java | 4 +- .../ch/autumo/beetroot/cache/FileCache.java | 2 +- .../ch/autumo/beetroot/crud/EventHandler.java | 2 +- .../autumo/beetroot/handler/BaseHandler.java | 10 +- .../beetroot/handler/DefaultAddHandler.java | 8 +- .../handler/DefaultDeleteHandler.java | 2 +- .../beetroot/handler/DefaultEditHandler.java | 6 +- .../beetroot/handler/DefaultIndexHandler.java | 8 +- .../handler/DefaultRESTIndexHandler.java | 4 +- .../beetroot/handler/DefaultViewHandler.java | 6 +- .../handler/ExampleDownloadHandler.java | 2 +- .../properties/PropertiesIndexHandler.java | 2 +- .../properties/PropertiesViewHandler.java | 2 +- .../handler/roles/RolesIndexHandler.java | 2 +- .../handler/roles/RolesViewHandler.java | 2 +- .../beetroot/handler/system/LogHandler.java | 2 +- .../handler/tasks/TasksIndexHandler.java | 4 +- .../handler/tasks/TasksViewHandler.java | 4 +- .../beetroot/handler/users/ChangeHandler.java | 4 +- .../handler/users/ExtUsersEditHandler.java | 2 +- .../handler/users/ExtUsersIndexHandler.java | 4 +- .../handler/users/ExtUsersViewHandler.java | 4 +- .../handler/users/NewQRCodeHandler.java | 4 +- .../beetroot/handler/users/ResetHandler.java | 4 +- .../handler/users/SettingsHandler.java | 2 +- .../handler/users/UsersAddHandler.java | 2 +- .../handler/users/UsersIndexHandler.java | 4 +- .../handler/users/UsersViewHandler.java | 6 +- .../beetroot/mailing/AbstractMailer.java | 2 +- .../ch/autumo/beetroot/plant/Fertilizer.java | 6 +- .../java/ch/autumo/beetroot/plant/Plant.java | 4 +- .../ch/autumo/beetroot/server/BaseServer.java | 8 +- .../communication/ClientCommunicator.java | 2 +- .../communication/ClientFileTransfer.java | 2 +- .../server/communication/FileTransfer.java | 2 +- .../beetroot/server/message/ClientAnswer.java | 2 +- .../server/message/ServerCommand.java | 2 +- .../message/file/PingUploadRequest.java | 2 +- .../java/ch/autumo/beetroot/utils/Helper.java | 2 + .../beetroot/utils/{ => bean}/BeanField.java | 2 +- .../utils/{ => bean}/BeanProcessor.java | 3 +- .../beetroot/utils/{ => bean}/Beans.java | 2 +- .../beetroot/utils/bean/package-info.java | 4 + .../beetroot/utils/{ => common}/Colors.java | 2 +- .../utils/{ => common}/LowerCaseList.java | 2 +- .../beetroot/utils/{ => common}/MIME.java | 2 +- .../beetroot/utils/{ => common}/Time.java | 2 +- .../beetroot/utils/common/package-info.java | 4 + .../beetroot/utils/{ => database}/DB.java | 4 +- .../utils/{ => database}/DBField.java | 2 +- .../autumo/beetroot/utils/database/H2Url.java | 129 ++++++++++++++++++ .../beetroot/utils/database/package-info.java | 4 + .../autumo/beetroot/utils/package-info.java | 2 +- .../beetroot/utils/security/PWEncoder.java | 3 +- .../beetroot/utils/{ => security}/SSL.java | 2 +- .../utils/{ => security}/Security.java | 4 +- .../beetroot/utils/security/package-info.java | 3 +- .../utils/{ => systen}/GUIDGenerator.java | 2 +- .../beetroot/utils/{ => systen}/OS.java | 2 +- .../beetroot/utils/systen/package-info.java | 4 + .../beetroot/utils/{ => web}/TwoFA.java | 4 +- .../autumo/beetroot/utils/{ => web}/Web.java | 5 +- .../beetroot/utils/web/package-info.java | 4 + .../ch/autumo/beetroot/DBManagerTest.java | 2 +- .../ch/autumo/beetroot/general/H2UrlTest.java | 38 ++++++ 76 files changed, 336 insertions(+), 116 deletions(-) rename src/main/java/ch/autumo/beetroot/utils/{ => bean}/BeanField.java (98%) rename src/main/java/ch/autumo/beetroot/utils/{ => bean}/BeanProcessor.java (99%) rename src/main/java/ch/autumo/beetroot/utils/{ => bean}/Beans.java (99%) create mode 100644 src/main/java/ch/autumo/beetroot/utils/bean/package-info.java rename src/main/java/ch/autumo/beetroot/utils/{ => common}/Colors.java (99%) rename src/main/java/ch/autumo/beetroot/utils/{ => common}/LowerCaseList.java (97%) rename src/main/java/ch/autumo/beetroot/utils/{ => common}/MIME.java (98%) rename src/main/java/ch/autumo/beetroot/utils/{ => common}/Time.java (99%) create mode 100644 src/main/java/ch/autumo/beetroot/utils/common/package-info.java rename src/main/java/ch/autumo/beetroot/utils/{ => database}/DB.java (99%) rename src/main/java/ch/autumo/beetroot/utils/{ => database}/DBField.java (98%) create mode 100644 src/main/java/ch/autumo/beetroot/utils/database/H2Url.java create mode 100644 src/main/java/ch/autumo/beetroot/utils/database/package-info.java rename src/main/java/ch/autumo/beetroot/utils/{ => security}/SSL.java (99%) rename src/main/java/ch/autumo/beetroot/utils/{ => security}/Security.java (98%) rename src/main/java/ch/autumo/beetroot/utils/{ => systen}/GUIDGenerator.java (99%) rename src/main/java/ch/autumo/beetroot/utils/{ => systen}/OS.java (99%) create mode 100644 src/main/java/ch/autumo/beetroot/utils/systen/package-info.java rename src/main/java/ch/autumo/beetroot/utils/{ => web}/TwoFA.java (97%) rename src/main/java/ch/autumo/beetroot/utils/{ => web}/Web.java (98%) create mode 100644 src/main/java/ch/autumo/beetroot/utils/web/package-info.java create mode 100644 src/test/java/ch/autumo/beetroot/general/H2UrlTest.java diff --git a/cfg/beetroot_test.cfg b/cfg/beetroot_test.cfg index 24dfcc0e..79bb56bf 100644 --- a/cfg/beetroot_test.cfg +++ b/cfg/beetroot_test.cfg @@ -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 diff --git a/db/h2/db/test/beetroot.mv.db b/db/h2/db/test/beetroot.mv.db index be204132a76a2356babefc1db6018c26238cfaa7..e75d02246252e082faa7ba2cda759212534ef5a9 100644 GIT binary patch delta 2795 zcmeHJO-K|`9N)KUyJ}k&rPO7|3QC=H-h9tMXaq({W+0w@J3E_O?)Y7|S}dWcD0|0( zl=LD&*f-7k_JDRc8(2sxZ&s3e1AJHUab`}%qNf8q%I`p5d)pf{&QdtdUSDY{-Uk`+~vZ7~E zf=qvinO*+WZ5&q>3Wa7Xo=3tVDB>3lry`%HTi;y!7{N>Fli~6Q7&X>al1DuPNxd54uqV^h(_;-N5(9_jx#>k~kIkNSatn3YMcf(^xOF+7c-yg!|<>}~u6?vNaI~4`0 z2vmdu<3zTiAc;|tv|kJo^)!rg=`e;qko|ch|$8SaeQ_27U delta 2745 zcmeH}O-vM59KdG=`K$;=fsl~wf+j{7b!Ogsv$K0Bv@|WUDm5WkJvpC<;sOfxR=2cV zYMToGLl5PEk)}zLCgPk-TH~Sd*raDqCOy@}#*d2!jBmc)JPo_}5fcyYVR!z!v+w=i z|NZ{IH{}(nydquRCFT})D?4(sH|fsWr`&S|!_ifO?54GuA6pj7O-rqt-f}(LkcGyP zRyZ*7ar*`L-1&*AQh_*Fo}MTTPR*5O3kt0DAAy?#_2RGo?SY$hBK8+PdnAf~!^P3| zZmrQiHCH;bpE#)YtU0}3tq%XdBfE_d9E~f-gOE%ujvSz$cVrAXm*U{rpalZ8kgs?7^XtANAO=!hVkNd_-br> z9^27urjyK8WpKm|4wq36w9aH{_Gtu(R+*$!$zri=O-|Wo3Yg0r zb4XYOVZ-vmU0m<~po7Hs6M51t6;zq-SAi}GGM{Huf`c{Dh;2+%Dm%{&PPm!}qi)M) zn*>2vtzD~^1XY7udk@#$ztVs2#u#Ld7R5y{dpjEG4T2#3Quo;Z@bpzl5`9ockBEPT z3?ar4uEJ0wiWASn@_bLSySESRO(;mtPS+3bFIv4{x_yi0>1}F3YB2SbZ(@C=UiUfd9W~i^=Y+NOo{gG!w2( zNOhP3dYG_cx4)wI`#x3tCkvNE|J(70fe5y2EP~Ti1Ot%>{%!6OvQz{+blYP)qp&NL cU1=3}>(ZM)e5CO4JhA6d%S&Ocp^pjA03fkM@c;k- diff --git a/gen/java/DeleteHandler.java b/gen/java/DeleteHandler.java index db0c6cf0..1aaa339b 100644 --- a/gen/java/DeleteHandler.java +++ b/gen/java/DeleteHandler.java @@ -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; diff --git a/gen/java/IndexHandler.java b/gen/java/IndexHandler.java index 5e52968a..82108462 100644 --- a/gen/java/IndexHandler.java +++ b/gen/java/IndexHandler.java @@ -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. diff --git a/gen/java/ViewHandler.java b/gen/java/ViewHandler.java index f3ca24fe..be002795 100644 --- a/gen/java/ViewHandler.java +++ b/gen/java/ViewHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/AbstractBeetRootServlet.java b/src/main/java/ch/autumo/beetroot/AbstractBeetRootServlet.java index bac0a316..56f1da0c 100644 --- a/src/main/java/ch/autumo/beetroot/AbstractBeetRootServlet.java +++ b/src/main/java/ch/autumo/beetroot/AbstractBeetRootServlet.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/BeetRootConfigurationManager.java b/src/main/java/ch/autumo/beetroot/BeetRootConfigurationManager.java index 78d45f56..44452709 100644 --- a/src/main/java/ch/autumo/beetroot/BeetRootConfigurationManager.java +++ b/src/main/java/ch/autumo/beetroot/BeetRootConfigurationManager.java @@ -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; /** @@ -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++) { diff --git a/src/main/java/ch/autumo/beetroot/BeetRootDatabaseManager.java b/src/main/java/ch/autumo/beetroot/BeetRootDatabaseManager.java index 7f22bbd3..2366bfb2 100644 --- a/src/main/java/ch/autumo/beetroot/BeetRootDatabaseManager.java +++ b/src/main/java/ch/autumo/beetroot/BeetRootDatabaseManager.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/BeetRootWebServer.java b/src/main/java/ch/autumo/beetroot/BeetRootWebServer.java index be40e012..39c2266c 100644 --- a/src/main/java/ch/autumo/beetroot/BeetRootWebServer.java +++ b/src/main/java/ch/autumo/beetroot/BeetRootWebServer.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/LanguageManager.java b/src/main/java/ch/autumo/beetroot/LanguageManager.java index 459be971..b25a4dbf 100644 --- a/src/main/java/ch/autumo/beetroot/LanguageManager.java +++ b/src/main/java/ch/autumo/beetroot/LanguageManager.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/Model.java b/src/main/java/ch/autumo/beetroot/Model.java index dfbd0e68..1cc9d0c7 100644 --- a/src/main/java/ch/autumo/beetroot/Model.java +++ b/src/main/java/ch/autumo/beetroot/Model.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/Session.java b/src/main/java/ch/autumo/beetroot/Session.java index 5aeb71b5..17ddf2de 100644 --- a/src/main/java/ch/autumo/beetroot/Session.java +++ b/src/main/java/ch/autumo/beetroot/Session.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/cache/FileCache.java b/src/main/java/ch/autumo/beetroot/cache/FileCache.java index 7d433a1e..486fd21e 100644 --- a/src/main/java/ch/autumo/beetroot/cache/FileCache.java +++ b/src/main/java/ch/autumo/beetroot/cache/FileCache.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/crud/EventHandler.java b/src/main/java/ch/autumo/beetroot/crud/EventHandler.java index 364258b4..73558cd9 100644 --- a/src/main/java/ch/autumo/beetroot/crud/EventHandler.java +++ b/src/main/java/ch/autumo/beetroot/crud/EventHandler.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/handler/BaseHandler.java b/src/main/java/ch/autumo/beetroot/handler/BaseHandler.java index 01e1d455..e57bd1b2 100644 --- a/src/main/java/ch/autumo/beetroot/handler/BaseHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/BaseHandler.java @@ -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; diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultAddHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultAddHandler.java index ef641a90..12649db8 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultAddHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultAddHandler.java @@ -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/<entity>/add.html' templates. diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultDeleteHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultDeleteHandler.java index e4abe6bc..73e7c309 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultDeleteHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultDeleteHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultEditHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultEditHandler.java index fffa8939..9a53b550 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultEditHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultEditHandler.java @@ -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/<entity>/edit.html' templates. diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultIndexHandler.java index 5bd54b63..6741769e 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultIndexHandler.java @@ -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/<entity>/index.html' templates. diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultRESTIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultRESTIndexHandler.java index 9e3b1b33..6d877cb9 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultRESTIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultRESTIndexHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/DefaultViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/DefaultViewHandler.java index 44c17e64..de5aa60f 100644 --- a/src/main/java/ch/autumo/beetroot/handler/DefaultViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/DefaultViewHandler.java @@ -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/<entity>/view.html' templates. diff --git a/src/main/java/ch/autumo/beetroot/handler/ExampleDownloadHandler.java b/src/main/java/ch/autumo/beetroot/handler/ExampleDownloadHandler.java index 76e89503..cbcdc139 100644 --- a/src/main/java/ch/autumo/beetroot/handler/ExampleDownloadHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/ExampleDownloadHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesIndexHandler.java index 0260161e..a52b4160 100644 --- a/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesIndexHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesViewHandler.java index c321eed0..4a749370 100644 --- a/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/properties/PropertiesViewHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/roles/RolesIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/roles/RolesIndexHandler.java index 28c380dc..4994e36e 100644 --- a/src/main/java/ch/autumo/beetroot/handler/roles/RolesIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/roles/RolesIndexHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/roles/RolesViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/roles/RolesViewHandler.java index fc045978..7b93feaa 100644 --- a/src/main/java/ch/autumo/beetroot/handler/roles/RolesViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/roles/RolesViewHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/system/LogHandler.java b/src/main/java/ch/autumo/beetroot/handler/system/LogHandler.java index 8abd8674..c433f967 100644 --- a/src/main/java/ch/autumo/beetroot/handler/system/LogHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/system/LogHandler.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/handler/tasks/TasksIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/tasks/TasksIndexHandler.java index 3b7a1ee6..5db70215 100644 --- a/src/main/java/ch/autumo/beetroot/handler/tasks/TasksIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/tasks/TasksIndexHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/tasks/TasksViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/tasks/TasksViewHandler.java index ed861c47..df20d7ad 100644 --- a/src/main/java/ch/autumo/beetroot/handler/tasks/TasksViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/tasks/TasksViewHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/ChangeHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/ChangeHandler.java index bc582a7e..85cf1443 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/ChangeHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/ChangeHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersEditHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersEditHandler.java index 32cf1a44..296f8495 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersEditHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersEditHandler.java @@ -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; /** diff --git a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersIndexHandler.java index 8df58411..cd42f952 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersIndexHandler.java @@ -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. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersViewHandler.java index 4decf5b8..196c12eb 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/ExtUsersViewHandler.java @@ -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 view handler for extended roles. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/NewQRCodeHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/NewQRCodeHandler.java index 08c54a21..de0f1330 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/NewQRCodeHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/NewQRCodeHandler.java @@ -21,8 +21,8 @@ import ch.autumo.beetroot.Session; import ch.autumo.beetroot.handler.BaseHandler; import ch.autumo.beetroot.handler.HandlerResponse; -import ch.autumo.beetroot.utils.DB; -import ch.autumo.beetroot.utils.TwoFA; +import ch.autumo.beetroot.utils.database.DB; +import ch.autumo.beetroot.utils.web.TwoFA; /** * New QR Code handler. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/ResetHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/ResetHandler.java index 23382f2b..b1e8d410 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/ResetHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/ResetHandler.java @@ -35,8 +35,8 @@ import ch.autumo.beetroot.handler.BaseHandler; import ch.autumo.beetroot.handler.HandlerResponse; import ch.autumo.beetroot.mailing.MailerFactory; -import ch.autumo.beetroot.utils.GUIDGenerator; -import ch.autumo.beetroot.utils.Time; +import ch.autumo.beetroot.utils.common.Time; +import ch.autumo.beetroot.utils.systen.GUIDGenerator; /** * Default login handler. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/SettingsHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/SettingsHandler.java index 4cabded1..5c176008 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/SettingsHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/SettingsHandler.java @@ -21,7 +21,7 @@ import ch.autumo.beetroot.Session; import ch.autumo.beetroot.handler.HandlerResponse; import ch.autumo.beetroot.handler.NoContentAndConfigHandler; -import ch.autumo.beetroot.utils.DB; +import ch.autumo.beetroot.utils.database.DB; /** * Settings handler. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/UsersAddHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/UsersAddHandler.java index b7d8f813..9f834e5f 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/UsersAddHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/UsersAddHandler.java @@ -29,7 +29,7 @@ import ch.autumo.beetroot.Session; import ch.autumo.beetroot.handler.DefaultAddHandler; import ch.autumo.beetroot.handler.HandlerResponse; -import ch.autumo.beetroot.utils.TwoFA; +import ch.autumo.beetroot.utils.web.TwoFA; /** * Users add handler. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/UsersIndexHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/UsersIndexHandler.java index fb5f7107..1508c801 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/UsersIndexHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/UsersIndexHandler.java @@ -24,8 +24,8 @@ import ch.autumo.beetroot.LanguageManager; 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; /** * Users index handler. diff --git a/src/main/java/ch/autumo/beetroot/handler/users/UsersViewHandler.java b/src/main/java/ch/autumo/beetroot/handler/users/UsersViewHandler.java index efd9138c..290ac847 100644 --- a/src/main/java/ch/autumo/beetroot/handler/users/UsersViewHandler.java +++ b/src/main/java/ch/autumo/beetroot/handler/users/UsersViewHandler.java @@ -29,11 +29,11 @@ import ch.autumo.beetroot.Session; import ch.autumo.beetroot.SessionManager; import ch.autumo.beetroot.handler.DefaultViewHandler; -import ch.autumo.beetroot.utils.DB; import ch.autumo.beetroot.utils.Helper; -import ch.autumo.beetroot.utils.Time; -import ch.autumo.beetroot.utils.TwoFA; import ch.autumo.beetroot.utils.UtilsException; +import ch.autumo.beetroot.utils.common.Time; +import ch.autumo.beetroot.utils.database.DB; +import ch.autumo.beetroot.utils.web.TwoFA; /** * Users view handler. diff --git a/src/main/java/ch/autumo/beetroot/mailing/AbstractMailer.java b/src/main/java/ch/autumo/beetroot/mailing/AbstractMailer.java index 152e7f7a..afd0392b 100644 --- a/src/main/java/ch/autumo/beetroot/mailing/AbstractMailer.java +++ b/src/main/java/ch/autumo/beetroot/mailing/AbstractMailer.java @@ -40,7 +40,7 @@ import ch.autumo.beetroot.LanguageManager; import ch.autumo.beetroot.Session; import ch.autumo.beetroot.security.SecureApplicationHolder; -import ch.autumo.beetroot.utils.Web; +import ch.autumo.beetroot.utils.web.Web; /** * Abstract mailer class. diff --git a/src/main/java/ch/autumo/beetroot/plant/Fertilizer.java b/src/main/java/ch/autumo/beetroot/plant/Fertilizer.java index 29461a0f..71a42475 100644 --- a/src/main/java/ch/autumo/beetroot/plant/Fertilizer.java +++ b/src/main/java/ch/autumo/beetroot/plant/Fertilizer.java @@ -34,9 +34,9 @@ import java.util.Set; import ch.autumo.beetroot.BeetRootDatabaseManager; -import ch.autumo.beetroot.utils.Beans; -import ch.autumo.beetroot.utils.DBField; -import ch.autumo.beetroot.utils.OS; +import ch.autumo.beetroot.utils.bean.Beans; +import ch.autumo.beetroot.utils.database.DBField; +import ch.autumo.beetroot.utils.systen.OS; /** * Fertilizer for plant. diff --git a/src/main/java/ch/autumo/beetroot/plant/Plant.java b/src/main/java/ch/autumo/beetroot/plant/Plant.java index 551abfbb..c1ce8c92 100644 --- a/src/main/java/ch/autumo/beetroot/plant/Plant.java +++ b/src/main/java/ch/autumo/beetroot/plant/Plant.java @@ -40,9 +40,9 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.BeetRootDatabaseManager; import ch.autumo.beetroot.Constants; -import ch.autumo.beetroot.utils.Colors; import ch.autumo.beetroot.utils.Helper; -import ch.autumo.beetroot.utils.OS; +import ch.autumo.beetroot.utils.common.Colors; +import ch.autumo.beetroot.utils.systen.OS; /** * PLANT - beetRoot CRUD Generator. diff --git a/src/main/java/ch/autumo/beetroot/server/BaseServer.java b/src/main/java/ch/autumo/beetroot/server/BaseServer.java index effab1d1..6da3f3d8 100644 --- a/src/main/java/ch/autumo/beetroot/server/BaseServer.java +++ b/src/main/java/ch/autumo/beetroot/server/BaseServer.java @@ -60,12 +60,12 @@ import ch.autumo.beetroot.transport.DefaultServerSocketFactory; import ch.autumo.beetroot.transport.SecureServerSocketFactory; import ch.autumo.beetroot.transport.ServerSocketFactory; -import ch.autumo.beetroot.utils.Colors; import ch.autumo.beetroot.utils.Helper; -import ch.autumo.beetroot.utils.OS; -import ch.autumo.beetroot.utils.SSL; import ch.autumo.beetroot.utils.UtilsException; -import ch.autumo.beetroot.utils.Web; +import ch.autumo.beetroot.utils.common.Colors; +import ch.autumo.beetroot.utils.security.SSL; +import ch.autumo.beetroot.utils.systen.OS; +import ch.autumo.beetroot.utils.web.Web; /** * Base server. diff --git a/src/main/java/ch/autumo/beetroot/server/communication/ClientCommunicator.java b/src/main/java/ch/autumo/beetroot/server/communication/ClientCommunicator.java index 9a2a3755..773e1db6 100644 --- a/src/main/java/ch/autumo/beetroot/server/communication/ClientCommunicator.java +++ b/src/main/java/ch/autumo/beetroot/server/communication/ClientCommunicator.java @@ -48,7 +48,7 @@ import ch.autumo.beetroot.transport.DefaultSocketFactory; import ch.autumo.beetroot.transport.SecureSocketFactory; import ch.autumo.beetroot.transport.SocketFactory; -import ch.autumo.beetroot.utils.SSL; +import ch.autumo.beetroot.utils.security.SSL; /** diff --git a/src/main/java/ch/autumo/beetroot/server/communication/ClientFileTransfer.java b/src/main/java/ch/autumo/beetroot/server/communication/ClientFileTransfer.java index d59dd8b4..ad5613ed 100644 --- a/src/main/java/ch/autumo/beetroot/server/communication/ClientFileTransfer.java +++ b/src/main/java/ch/autumo/beetroot/server/communication/ClientFileTransfer.java @@ -37,7 +37,7 @@ import ch.autumo.beetroot.transport.DefaultSocketFactory; import ch.autumo.beetroot.transport.SecureSocketFactory; import ch.autumo.beetroot.transport.SocketFactory; -import ch.autumo.beetroot.utils.SSL; +import ch.autumo.beetroot.utils.security.SSL; /** diff --git a/src/main/java/ch/autumo/beetroot/server/communication/FileTransfer.java b/src/main/java/ch/autumo/beetroot/server/communication/FileTransfer.java index 9cd84fa3..22f8199f 100644 --- a/src/main/java/ch/autumo/beetroot/server/communication/FileTransfer.java +++ b/src/main/java/ch/autumo/beetroot/server/communication/FileTransfer.java @@ -30,7 +30,7 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.Constants; import ch.autumo.beetroot.server.action.Download; -import ch.autumo.beetroot.utils.OS; +import ch.autumo.beetroot.utils.systen.OS; /** * Client/Server file transfer. diff --git a/src/main/java/ch/autumo/beetroot/server/message/ClientAnswer.java b/src/main/java/ch/autumo/beetroot/server/message/ClientAnswer.java index 41ac5ed7..f6ad2e9f 100644 --- a/src/main/java/ch/autumo/beetroot/server/message/ClientAnswer.java +++ b/src/main/java/ch/autumo/beetroot/server/message/ClientAnswer.java @@ -22,7 +22,7 @@ import org.json.JSONObject; import ch.autumo.beetroot.security.SecureApplicationHolder; -import ch.autumo.beetroot.utils.Security; +import ch.autumo.beetroot.utils.security.Security; /** * Client answer. diff --git a/src/main/java/ch/autumo/beetroot/server/message/ServerCommand.java b/src/main/java/ch/autumo/beetroot/server/message/ServerCommand.java index 60eae8c2..90065459 100644 --- a/src/main/java/ch/autumo/beetroot/server/message/ServerCommand.java +++ b/src/main/java/ch/autumo/beetroot/server/message/ServerCommand.java @@ -24,7 +24,7 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.Constants; import ch.autumo.beetroot.security.SecureApplicationHolder; -import ch.autumo.beetroot.utils.Security; +import ch.autumo.beetroot.utils.security.Security; /** * Secure server command. diff --git a/src/main/java/ch/autumo/beetroot/server/message/file/PingUploadRequest.java b/src/main/java/ch/autumo/beetroot/server/message/file/PingUploadRequest.java index dabefcae..e2cdbdbf 100644 --- a/src/main/java/ch/autumo/beetroot/server/message/file/PingUploadRequest.java +++ b/src/main/java/ch/autumo/beetroot/server/message/file/PingUploadRequest.java @@ -19,7 +19,7 @@ import java.io.IOException; -import ch.autumo.beetroot.utils.OS; +import ch.autumo.beetroot.utils.systen.OS; /** * Ping upload request. diff --git a/src/main/java/ch/autumo/beetroot/utils/Helper.java b/src/main/java/ch/autumo/beetroot/utils/Helper.java index 072243df..2d0922e5 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Helper.java +++ b/src/main/java/ch/autumo/beetroot/utils/Helper.java @@ -20,6 +20,8 @@ import com.diogonunes.jcolor.Ansi; import com.diogonunes.jcolor.Attribute; +import ch.autumo.beetroot.utils.systen.OS; + /** * Helper methods. */ diff --git a/src/main/java/ch/autumo/beetroot/utils/BeanField.java b/src/main/java/ch/autumo/beetroot/utils/bean/BeanField.java similarity index 98% rename from src/main/java/ch/autumo/beetroot/utils/BeanField.java rename to src/main/java/ch/autumo/beetroot/utils/bean/BeanField.java index 4480eba0..d856d26d 100644 --- a/src/main/java/ch/autumo/beetroot/utils/BeanField.java +++ b/src/main/java/ch/autumo/beetroot/utils/bean/BeanField.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.bean; import java.lang.reflect.Method; diff --git a/src/main/java/ch/autumo/beetroot/utils/BeanProcessor.java b/src/main/java/ch/autumo/beetroot/utils/bean/BeanProcessor.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/BeanProcessor.java rename to src/main/java/ch/autumo/beetroot/utils/bean/BeanProcessor.java index 1d671960..0b18c32a 100644 --- a/src/main/java/ch/autumo/beetroot/utils/BeanProcessor.java +++ b/src/main/java/ch/autumo/beetroot/utils/bean/BeanProcessor.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.bean; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory; import ch.autumo.beetroot.Entity; +import ch.autumo.beetroot.utils.database.DB; /** * This bean processor operates with bean fields that hold information of diff --git a/src/main/java/ch/autumo/beetroot/utils/Beans.java b/src/main/java/ch/autumo/beetroot/utils/bean/Beans.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/Beans.java rename to src/main/java/ch/autumo/beetroot/utils/bean/Beans.java index bc5b5a69..1056685b 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Beans.java +++ b/src/main/java/ch/autumo/beetroot/utils/bean/Beans.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.bean; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/src/main/java/ch/autumo/beetroot/utils/bean/package-info.java b/src/main/java/ch/autumo/beetroot/utils/bean/package-info.java new file mode 100644 index 00000000..d6abac10 --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/bean/package-info.java @@ -0,0 +1,4 @@ +/** + * Bean processing. + */ +package ch.autumo.beetroot.utils.bean; diff --git a/src/main/java/ch/autumo/beetroot/utils/Colors.java b/src/main/java/ch/autumo/beetroot/utils/common/Colors.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/Colors.java rename to src/main/java/ch/autumo/beetroot/utils/common/Colors.java index fe661f6d..a7b9c2c9 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Colors.java +++ b/src/main/java/ch/autumo/beetroot/utils/common/Colors.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.common; import com.diogonunes.jcolor.Ansi; import com.diogonunes.jcolor.Attribute; diff --git a/src/main/java/ch/autumo/beetroot/utils/LowerCaseList.java b/src/main/java/ch/autumo/beetroot/utils/common/LowerCaseList.java similarity index 97% rename from src/main/java/ch/autumo/beetroot/utils/LowerCaseList.java rename to src/main/java/ch/autumo/beetroot/utils/common/LowerCaseList.java index c865e2e4..09a67fd6 100644 --- a/src/main/java/ch/autumo/beetroot/utils/LowerCaseList.java +++ b/src/main/java/ch/autumo/beetroot/utils/common/LowerCaseList.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.common; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ch/autumo/beetroot/utils/MIME.java b/src/main/java/ch/autumo/beetroot/utils/common/MIME.java similarity index 98% rename from src/main/java/ch/autumo/beetroot/utils/MIME.java rename to src/main/java/ch/autumo/beetroot/utils/common/MIME.java index b69172ae..6d112ff7 100644 --- a/src/main/java/ch/autumo/beetroot/utils/MIME.java +++ b/src/main/java/ch/autumo/beetroot/utils/common/MIME.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.common; import java.util.List; diff --git a/src/main/java/ch/autumo/beetroot/utils/Time.java b/src/main/java/ch/autumo/beetroot/utils/common/Time.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/Time.java rename to src/main/java/ch/autumo/beetroot/utils/common/Time.java index b7b06a2a..16785c7a 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Time.java +++ b/src/main/java/ch/autumo/beetroot/utils/common/Time.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.common; import java.sql.Timestamp; import java.time.Instant; diff --git a/src/main/java/ch/autumo/beetroot/utils/common/package-info.java b/src/main/java/ch/autumo/beetroot/utils/common/package-info.java new file mode 100644 index 00000000..2e962cea --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/common/package-info.java @@ -0,0 +1,4 @@ +/** + * Common utilities and classes. + */ +package ch.autumo.beetroot.utils.common; diff --git a/src/main/java/ch/autumo/beetroot/utils/DB.java b/src/main/java/ch/autumo/beetroot/utils/database/DB.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/DB.java rename to src/main/java/ch/autumo/beetroot/utils/database/DB.java index 8fa0469d..f4a6eec5 100644 --- a/src/main/java/ch/autumo/beetroot/utils/DB.java +++ b/src/main/java/ch/autumo/beetroot/utils/database/DB.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.database; import java.sql.Connection; import java.sql.PreparedStatement; @@ -38,6 +38,8 @@ import ch.autumo.beetroot.Entity; import ch.autumo.beetroot.Model; import ch.autumo.beetroot.Session; +import ch.autumo.beetroot.utils.bean.Beans; +import ch.autumo.beetroot.utils.web.Web; /** diff --git a/src/main/java/ch/autumo/beetroot/utils/DBField.java b/src/main/java/ch/autumo/beetroot/utils/database/DBField.java similarity index 98% rename from src/main/java/ch/autumo/beetroot/utils/DBField.java rename to src/main/java/ch/autumo/beetroot/utils/database/DBField.java index 7f35b400..e0618851 100644 --- a/src/main/java/ch/autumo/beetroot/utils/DBField.java +++ b/src/main/java/ch/autumo/beetroot/utils/database/DBField.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.database; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/ch/autumo/beetroot/utils/database/H2Url.java b/src/main/java/ch/autumo/beetroot/utils/database/H2Url.java new file mode 100644 index 00000000..779cb0a6 --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/database/H2Url.java @@ -0,0 +1,129 @@ +/** + * + * Copyright (c) 2024 autumo Ltd. Switzerland, Michael Gasche + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package ch.autumo.beetroot.utils.database; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import ch.autumo.beetroot.BeetRootConfigurationManager; +import ch.autumo.beetroot.utils.UtilsException; + +/** + * H2 database URl for further processing. + */ +public final class H2Url { + + /** The H2 URL separator separates the URL from the features. */ + public static final String URL_SEPARATOR = ";"; + + /** MODE feature with default value. */ + public static final Map.Entry FEAT_MODE = Map.entry("MODE", "MySQL"); + /** FEAT_DATABASE_TO_LOWER feature with default value. */ + public static final Map.Entry FEAT_DATABASE_TO_LOWER = Map.entry("DATABASE_TO_LOWER", "TRUE"); + /** FEAT_CASE_INSENSITIVE_IDENTIFIERS feature with default value. */ + public static final Map.Entry FEAT_CASE_INSENSITIVE_IDENTIFIERS = Map.entry("FEAT_CASE_INSENSITIVE_IDENTIFIERS", "TRUE"); + /** NON_KEYWORDS feature with default value. */ + public static final Map.Entry NON_KEYWORDS = Map.entry("NON_KEYWORDS", "SECOND,MINUTE,DAY,MONTH,YEAR"); + + private static Map defaultFeatures = new HashMap<>(); + static { + defaultFeatures.put(FEAT_MODE.getKey(), FEAT_MODE.getValue()); + defaultFeatures.put(FEAT_DATABASE_TO_LOWER.getKey(), FEAT_DATABASE_TO_LOWER.getValue()); + defaultFeatures.put(FEAT_CASE_INSENSITIVE_IDENTIFIERS.getKey(), FEAT_CASE_INSENSITIVE_IDENTIFIERS.getValue()); + defaultFeatures.put(NON_KEYWORDS.getKey(), NON_KEYWORDS.getValue()); + } + + private String originalUrl = null; + private String urlNoFeatures = null; + private String url = null; + + + /** + * Constructor with original URL as configured. + * + * @param originalUrl originalUrl + * @throws UtilsException exception when the H2 URL cannot be created + */ + public H2Url(String originalUrl) throws UtilsException { + this.originalUrl= originalUrl; + this.enrichUrl(); + } + + private void enrichUrl() throws UtilsException { + + final String parts[] = this.originalUrl.split(URL_SEPARATOR, 2); + if (parts.length == 0) + throw new UtilsException("H2 URL is malformed! URL: '" + this.originalUrl + "'."); + + urlNoFeatures = parts[0].trim(); + if (parts.length == 2) { + final String features[] = parts[1].split(URL_SEPARATOR); + for (int i = 0; i < features.length; i++) { + final String kv[] = features[i].split("="); + if (kv.length != 2) + throw new UtilsException("H2 URL feature is malformed! Option: '" + Arrays.toString(kv) + "'."); + // Overwrite features if matching in default map + defaultFeatures.put(kv[0].trim(), kv[1].trim()); + } + } + + // Undocumented configuration, if available it overwrites the default keyword values for NON_KEYWORDS + final String nonKeywords[] = BeetRootConfigurationManager.getInstance().getSepValues("db_url_h2_non_keywords"); + final int len = nonKeywords.length; + if (len > 0) { + String s = ""; + for (int i = 0; i < len; i++) { + if (i + 1 == len) + s += nonKeywords[i]; + else + s += nonKeywords[i] + ","; + } + defaultFeatures.put(NON_KEYWORDS.getKey(), s); + } + + // Create new URL + final StringBuilder newUrl = new StringBuilder(); + newUrl.append(urlNoFeatures); + for (Map.Entry entry : defaultFeatures.entrySet()) { + newUrl.append(URL_SEPARATOR); + newUrl.append(entry.getKey() + "=" + entry.getValue()); + } + + this.url = newUrl.toString(); + } + + /** + * Get new enriched H2 URL. + * + * @return new H2 URL + */ + public String getUrl() { + return this.url; + } + + /** + * Get H2 URL without any features. + * + * @return new H2 URL without features + */ + public String getUrlNoFeatures() { + return this.urlNoFeatures; + } + +} diff --git a/src/main/java/ch/autumo/beetroot/utils/database/package-info.java b/src/main/java/ch/autumo/beetroot/utils/database/package-info.java new file mode 100644 index 00000000..a585f4dc --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/database/package-info.java @@ -0,0 +1,4 @@ +/** + * Database access and tools. + */ +package ch.autumo.beetroot.utils.database; diff --git a/src/main/java/ch/autumo/beetroot/utils/package-info.java b/src/main/java/ch/autumo/beetroot/utils/package-info.java index 6066ace4..8b40d409 100644 --- a/src/main/java/ch/autumo/beetroot/utils/package-info.java +++ b/src/main/java/ch/autumo/beetroot/utils/package-info.java @@ -1,7 +1,7 @@ /** * beetRoot's utilities: *
    - *
  • Bean Processor
  • + *
  • Bean processing
  • *
  • ANIS colors
  • *
  • Database helper methods
  • *
  • GUID generator
  • diff --git a/src/main/java/ch/autumo/beetroot/utils/security/PWEncoder.java b/src/main/java/ch/autumo/beetroot/utils/security/PWEncoder.java index 245644ba..2ae04399 100644 --- a/src/main/java/ch/autumo/beetroot/utils/security/PWEncoder.java +++ b/src/main/java/ch/autumo/beetroot/utils/security/PWEncoder.java @@ -22,10 +22,9 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.security.SecureApplication; import ch.autumo.beetroot.security.SecureApplicationHolder; -import ch.autumo.beetroot.utils.Colors; -import ch.autumo.beetroot.utils.Security; import ch.autumo.beetroot.utils.Helper; import ch.autumo.beetroot.utils.UtilsException; +import ch.autumo.beetroot.utils.common.Colors; /** * Encoder for passwords. diff --git a/src/main/java/ch/autumo/beetroot/utils/SSL.java b/src/main/java/ch/autumo/beetroot/utils/security/SSL.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/SSL.java rename to src/main/java/ch/autumo/beetroot/utils/security/SSL.java index 50dced18..8b425181 100644 --- a/src/main/java/ch/autumo/beetroot/utils/SSL.java +++ b/src/main/java/ch/autumo/beetroot/utils/security/SSL.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.security; import java.io.File; import java.io.FileInputStream; diff --git a/src/main/java/ch/autumo/beetroot/utils/Security.java b/src/main/java/ch/autumo/beetroot/utils/security/Security.java similarity index 98% rename from src/main/java/ch/autumo/beetroot/utils/Security.java rename to src/main/java/ch/autumo/beetroot/utils/security/Security.java index 1664487d..2b583826 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Security.java +++ b/src/main/java/ch/autumo/beetroot/utils/security/Security.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.security; import java.lang.reflect.Constructor; import java.security.MessageDigest; @@ -37,6 +37,8 @@ import ch.autumo.beetroot.Constants; import ch.autumo.beetroot.security.SecureApplication; import ch.autumo.beetroot.security.password.PasswordHashProvider; +import ch.autumo.beetroot.utils.UtilsException; +import ch.autumo.beetroot.utils.systen.GUIDGenerator; /** diff --git a/src/main/java/ch/autumo/beetroot/utils/security/package-info.java b/src/main/java/ch/autumo/beetroot/utils/security/package-info.java index 214316ac..c7da8930 100644 --- a/src/main/java/ch/autumo/beetroot/utils/security/package-info.java +++ b/src/main/java/ch/autumo/beetroot/utils/security/package-info.java @@ -1,4 +1,5 @@ /** - * Secure socket components for SSL communication. + * Security; password encoder console tool and + * secure socket components for SSL communication. */ package ch.autumo.beetroot.utils.security; diff --git a/src/main/java/ch/autumo/beetroot/utils/GUIDGenerator.java b/src/main/java/ch/autumo/beetroot/utils/systen/GUIDGenerator.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/GUIDGenerator.java rename to src/main/java/ch/autumo/beetroot/utils/systen/GUIDGenerator.java index 3e7e1f74..726ddea3 100644 --- a/src/main/java/ch/autumo/beetroot/utils/GUIDGenerator.java +++ b/src/main/java/ch/autumo/beetroot/utils/systen/GUIDGenerator.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.systen; import java.net.InetAddress; import java.net.NetworkInterface; diff --git a/src/main/java/ch/autumo/beetroot/utils/OS.java b/src/main/java/ch/autumo/beetroot/utils/systen/OS.java similarity index 99% rename from src/main/java/ch/autumo/beetroot/utils/OS.java rename to src/main/java/ch/autumo/beetroot/utils/systen/OS.java index fb092bfa..b7d280c5 100644 --- a/src/main/java/ch/autumo/beetroot/utils/OS.java +++ b/src/main/java/ch/autumo/beetroot/utils/systen/OS.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.systen; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/ch/autumo/beetroot/utils/systen/package-info.java b/src/main/java/ch/autumo/beetroot/utils/systen/package-info.java new file mode 100644 index 00000000..941d4cd8 --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/systen/package-info.java @@ -0,0 +1,4 @@ +/** + * System tools. + */ +package ch.autumo.beetroot.utils.systen; diff --git a/src/main/java/ch/autumo/beetroot/utils/TwoFA.java b/src/main/java/ch/autumo/beetroot/utils/web/TwoFA.java similarity index 97% rename from src/main/java/ch/autumo/beetroot/utils/TwoFA.java rename to src/main/java/ch/autumo/beetroot/utils/web/TwoFA.java index 088b0f42..014f247b 100644 --- a/src/main/java/ch/autumo/beetroot/utils/TwoFA.java +++ b/src/main/java/ch/autumo/beetroot/utils/web/TwoFA.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.web; import java.io.File; import java.io.FileOutputStream; @@ -34,6 +34,8 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.Constants; +import ch.autumo.beetroot.utils.UtilsException; +import ch.autumo.beetroot.utils.systen.OS; import de.taimos.totp.TOTP; /** diff --git a/src/main/java/ch/autumo/beetroot/utils/Web.java b/src/main/java/ch/autumo/beetroot/utils/web/Web.java similarity index 98% rename from src/main/java/ch/autumo/beetroot/utils/Web.java rename to src/main/java/ch/autumo/beetroot/utils/web/Web.java index de613ea8..a651ae9d 100644 --- a/src/main/java/ch/autumo/beetroot/utils/Web.java +++ b/src/main/java/ch/autumo/beetroot/utils/web/Web.java @@ -15,7 +15,7 @@ * limitations under the License. * */ -package ch.autumo.beetroot.utils; +package ch.autumo.beetroot.utils.web; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; @@ -47,6 +47,9 @@ import ch.autumo.beetroot.BeetRootConfigurationManager; import ch.autumo.beetroot.BeetRootDatabaseManager; import ch.autumo.beetroot.Constants; +import ch.autumo.beetroot.utils.Helper; +import ch.autumo.beetroot.utils.database.DB; +import ch.autumo.beetroot.utils.security.SSL; /** diff --git a/src/main/java/ch/autumo/beetroot/utils/web/package-info.java b/src/main/java/ch/autumo/beetroot/utils/web/package-info.java new file mode 100644 index 00000000..3044ddd7 --- /dev/null +++ b/src/main/java/ch/autumo/beetroot/utils/web/package-info.java @@ -0,0 +1,4 @@ +/** + * Web tools. + */ +package ch.autumo.beetroot.utils.web; diff --git a/src/test/java/ch/autumo/beetroot/DBManagerTest.java b/src/test/java/ch/autumo/beetroot/DBManagerTest.java index 267c098c..ae262f26 100644 --- a/src/test/java/ch/autumo/beetroot/DBManagerTest.java +++ b/src/test/java/ch/autumo/beetroot/DBManagerTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import ch.autumo.beetroot.models.ModelTest; -import ch.autumo.beetroot.utils.DBField; +import ch.autumo.beetroot.utils.database.DBField; /** diff --git a/src/test/java/ch/autumo/beetroot/general/H2UrlTest.java b/src/test/java/ch/autumo/beetroot/general/H2UrlTest.java new file mode 100644 index 00000000..6dd67d1d --- /dev/null +++ b/src/test/java/ch/autumo/beetroot/general/H2UrlTest.java @@ -0,0 +1,38 @@ +package ch.autumo.beetroot.general; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import ch.autumo.beetroot.BeetRootConfigurationManager; +import ch.autumo.beetroot.utils.database.H2Url; + +public class H2UrlTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + BeetRootConfigurationManager.getInstance().initialize("cfg/beetroot_test.cfg"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() throws Exception { + System.out.println(" 1:" + new H2Url("jdbc:h2:/Users/Mike/Downloads/test/test;MODE=MySQL;DATABASE_TO_LOWER=TRUE;NON_KEYWORDS=SECOND,MINUTE,DAY,MONTH,YEAR").getUrl()); + System.out.println(" 2:" + new H2Url("jdbc:h2:/Users/Mike/Downloads/test/test;DATABASE_TO_LOWER=TRUE").getUrl()); + System.out.println(" 3:" + new H2Url("jdbc:h2:/Users/Mike/Downloads/test/test").getUrl()); + } + +}