From ba83ce8996b0b2cdccc01ce1e1af761d1fc816c7 Mon Sep 17 00:00:00 2001 From: VogelT Date: Tue, 9 Dec 2025 09:19:30 +0100 Subject: [PATCH] Update --- pom.xml | 95 ++- src/main/java/META-INF/persistence.xml | 5 - src/main/java/de/tvo/database/DBHandler.java | 97 +-- .../database/tables/NLCONNECT/Nlconnect.java | 14 +- .../tables/NLCONNECT/NlconnectWorker.java | 40 + .../tvo/global/workplace/WorkplaceConfig.java | 511 ++++++++++++ .../java/de/tvo/log4j2/Log4j2Handler.java | 743 ++++++++++++++++++ .../java/de/tvo/mailer/MailAttachment.java | 65 ++ .../de/tvo/nanoleaf/enums/NanoTypeEnum.java | 14 + .../de/tvo/nanoleaf/oclasses/MatrixInfo.java | 33 + src/main/java/de/tvo/session/SessionTyp.java | 12 + src/main/java/de/tvo/session/SessionUtil.java | 416 ++++++++++ src/main/java/de/tvo/tools/Exceptions.java | 8 +- src/main/java/de/tvo/tools/NumericUtil.java | 248 ++++++ .../java/de/tvo/tools/SearchReplaceObj.java | 30 + src/main/java/de/tvo/tools/StringUtil.java | 198 ++++- src/main/java/de/tvo/tools/XMLUtils.java | 49 -- .../de/tvo/toolset/PropertiesHandler.java | 446 +++++++++++ .../toolset/PropertiesHandlerException.java | 41 + src/main/resources/META-INF/MARIADBNL.cfg.xml | 10 +- .../services/javax.xml.soap.MetaFactory | 1 - .../services/javax.xml.soap.SAAJMetaFactory | 1 - .../services/javax.xml.ws.spi.Provider | 1 - src/main/webapp/META-INF/context.xml | 22 - 24 files changed, 2919 insertions(+), 181 deletions(-) delete mode 100644 src/main/java/META-INF/persistence.xml create mode 100644 src/main/java/de/tvo/database/tables/NLCONNECT/NlconnectWorker.java create mode 100644 src/main/java/de/tvo/global/workplace/WorkplaceConfig.java create mode 100644 src/main/java/de/tvo/log4j2/Log4j2Handler.java create mode 100644 src/main/java/de/tvo/mailer/MailAttachment.java create mode 100644 src/main/java/de/tvo/nanoleaf/enums/NanoTypeEnum.java create mode 100644 src/main/java/de/tvo/nanoleaf/oclasses/MatrixInfo.java create mode 100644 src/main/java/de/tvo/session/SessionTyp.java create mode 100644 src/main/java/de/tvo/session/SessionUtil.java create mode 100644 src/main/java/de/tvo/tools/NumericUtil.java create mode 100644 src/main/java/de/tvo/tools/SearchReplaceObj.java delete mode 100644 src/main/java/de/tvo/tools/XMLUtils.java create mode 100644 src/main/java/de/tvo/toolset/PropertiesHandler.java create mode 100644 src/main/java/de/tvo/toolset/PropertiesHandlerException.java delete mode 100644 src/main/resources/META-INF/services/javax.xml.soap.MetaFactory delete mode 100644 src/main/resources/META-INF/services/javax.xml.soap.SAAJMetaFactory delete mode 100644 src/main/resources/META-INF/services/javax.xml.ws.spi.Provider diff --git a/pom.xml b/pom.xml index 227de71..8c234ee 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.tvo web_shared war - 0.0.1 + 1 web_shared Maven Webapp http://maven.apache.org @@ -27,7 +27,7 @@ - 20250128 + 20251117 UTF-8 @@ -47,6 +47,25 @@ log4j 1.2.17 + + jakarta.xml.bind + + jakarta.xml.bind-api + 3.0.0 + + + + jakarta.platform + + jakarta.jakartaee-api + 9.1.0 + provided + + + jakarta.xml.soap + jakarta.xml.soap-api + 3.0.1 + com.google.code.gson gson @@ -57,6 +76,7 @@ hibernate-core-jakarta 5.6.15.Final + org.apache.xmlbeans xmlbeans @@ -72,11 +92,13 @@ + org.mariadb.jdbc mariadb-java-client @@ -95,6 +117,33 @@ + + org.apache.commons + commons-lang3 + 3.11 + + + commons-io + commons-io + 2.11.0 + + + commons-codec + commons-codec + 1.16.1 + + + dnsjava + dnsjava + 3.5.2 + + org.owasp.esapi esapi @@ -110,6 +159,8 @@ + + diff --git a/src/main/java/META-INF/persistence.xml b/src/main/java/META-INF/persistence.xml deleted file mode 100644 index 6d320d8..0000000 --- a/src/main/java/META-INF/persistence.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/main/java/de/tvo/database/DBHandler.java b/src/main/java/de/tvo/database/DBHandler.java index f5792e4..9588a7a 100644 --- a/src/main/java/de/tvo/database/DBHandler.java +++ b/src/main/java/de/tvo/database/DBHandler.java @@ -23,7 +23,10 @@ import org.hibernate.cfg.Configuration; import org.hibernate.query.NativeQuery; import org.hibernate.query.Query; +import org.apache.logging.log4j.Level; import de.tvo.global.PreparedStatementData; +import de.tvo.log4j2.Log4j2Handler; +import de.tvo.log4j2.Log4j2Source; import de.tvo.reflection.MyObject; import de.tvo.tools.Exceptions; import de.tvo.tools.StringUtil; @@ -59,7 +62,9 @@ public class DBHandler { ex.printStackTrace(); } } + } + System.out.println("Sessionpool: " + SESSIONPOOLMAP.size()); } // ------------------------- PreparedStatement ----------------------- @@ -594,7 +599,7 @@ public class DBHandler { return jdbcUpdateWithFeedback(sqlString.toString()); } catch (Exception e) { - Exceptions.prettyPrintGeisException(e, true); + Exceptions.prettyPrintTvoException(e, true); } return 0; } @@ -765,7 +770,7 @@ public class DBHandler { */ private final Boolean DEBUG; - //Log4j2Handler log4j2Handler = null; + Log4j2Handler log4j2Handler = null; /** * enables logging @@ -782,7 +787,7 @@ public class DBHandler { return sessionFactory.openSession(); } catch (Throwable e) { - Exceptions.prettyPrintGeisException(e, true); + Exceptions.prettyPrintTvoException(e, true); return null; } } @@ -842,8 +847,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -907,8 +912,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -970,8 +975,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1033,8 +1038,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1123,8 +1128,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1214,8 +1219,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1266,8 +1271,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1317,8 +1322,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1357,8 +1362,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1397,8 +1402,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return null; } @@ -1437,16 +1442,16 @@ public class DBHandler { System.out.println("Persistance fehler"); e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1486,8 +1491,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } } finally { @@ -1526,8 +1531,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1564,8 +1569,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1600,8 +1605,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1638,8 +1643,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1695,8 +1700,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1731,8 +1736,8 @@ public class DBHandler { catch (Exception e) { e.printStackTrace(); if (LOG) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); } return false; } @@ -1764,8 +1769,8 @@ public class DBHandler { return q.list(); } catch (Exception e) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); return null; } finally { @@ -1796,8 +1801,8 @@ public class DBHandler { return MyObject.trimReflectiveObjectListString(q.list()); } catch (Exception e) { - //log4j2Handler.setUsername("System"); - //log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); + log4j2Handler.setUsername("System"); + log4j2Handler.log(Level.ERROR, Log4j2Source.DATABASE, e.getMessage(), e, null); return null; } finally { @@ -1921,7 +1926,7 @@ public class DBHandler { SCHEMA = schema; DEBUG = debug; LOG = log; - //log4j2Handler = new Log4j2Handler(this); + log4j2Handler = new Log4j2Handler(this); sessionFactory = SESSIONPOOLMAP.get(SCHEMA); } diff --git a/src/main/java/de/tvo/database/tables/NLCONNECT/Nlconnect.java b/src/main/java/de/tvo/database/tables/NLCONNECT/Nlconnect.java index e729b7b..e0433fe 100644 --- a/src/main/java/de/tvo/database/tables/NLCONNECT/Nlconnect.java +++ b/src/main/java/de/tvo/database/tables/NLCONNECT/Nlconnect.java @@ -3,11 +3,17 @@ package de.tvo.database.tables.NLCONNECT; import java.io.Serializable; import java.math.BigInteger; +import de.tvo.nanoleaf.enums.NanoTypeEnum; import jakarta.persistence.Column; +import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Table; +@Entity +@Table(name="NLCONNECT") +//@NamedQuery(name="Nlconnect.findAll", query="SELECT g FROM NLCONNECT") public class Nlconnect implements Serializable { private static final long serialVersionUID = 1L; @@ -26,7 +32,9 @@ public class Nlconnect implements Serializable { @Column(length=16, nullable = false) private String ncipadress = null; - + public String getNcipadress() { return ncipadress; } + public void setNcipadress(String ncipadress) { this.ncipadress = ncipadress; } + @Column(precision=9, nullable = false) private Integer ncport = null; public Integer getNcport() { return ncport; } @@ -41,7 +49,7 @@ public class Nlconnect implements Serializable { @Column(length=40, nullable = false) private String nctype = null; public String getNctype() { return nctype; } - public void setNctype(String nctype) { this.nctype = nctype; } + public void setNctype(NanoTypeEnum nctype) { this.nctype = nctype.name(); } @Column(precision=9, nullable = false) private Integer nccountpanel = null; @@ -58,7 +66,7 @@ public class Nlconnect implements Serializable { public Nlconnect() { - // TODO Auto-generated constructor stub + } } diff --git a/src/main/java/de/tvo/database/tables/NLCONNECT/NlconnectWorker.java b/src/main/java/de/tvo/database/tables/NLCONNECT/NlconnectWorker.java new file mode 100644 index 0000000..3af0716 --- /dev/null +++ b/src/main/java/de/tvo/database/tables/NLCONNECT/NlconnectWorker.java @@ -0,0 +1,40 @@ +package de.tvo.database.tables.NLCONNECT; + +import de.tvo.database.DBHandler; +import de.tvo.nanoleaf.enums.NanoTypeEnum; +import de.tvo.toolset.DBTools.SchemataENUM; + +public class NlconnectWorker { + + public NlconnectWorker() { + + + + } + + public static void main(String[] args) { + new NlconnectWorker(); + + } + + public boolean insertNlconnect(Nlconnect nlconnect) throws Exception { + boolean finish = true; + + try { + DBHandler dbHandler = new DBHandler(SchemataENUM.MARIADBNL); + + dbHandler.insertObject(nlconnect); + + } catch (Exception e) { + finish = false; + e.printStackTrace(); + throw e; + } + + + + + return finish; + } + +} diff --git a/src/main/java/de/tvo/global/workplace/WorkplaceConfig.java b/src/main/java/de/tvo/global/workplace/WorkplaceConfig.java new file mode 100644 index 0000000..cc4a6fb --- /dev/null +++ b/src/main/java/de/tvo/global/workplace/WorkplaceConfig.java @@ -0,0 +1,511 @@ +package de.tvo.global.workplace; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import org.eclnt.jsfserver.util.HttpSessionAccess; +import org.eclnt.util.log.CLog; + +import de.tvo.session.SessionTyp; +import de.tvo.tools.NumericUtil; +import de.tvo.tools.StringUtil; +import de.tvo.toolset.PropertiesHandler; +import de.tvo.toolset.PropertiesHandlerException; + +/** + * DE: + * + * EN: + * + * + * Program changes + * ************************************************************************************** + * Date * Ticket * KonzFirm * Responsible * programmer * + * Change * + * ************************************************************************************** + * + * @author VogelT + * @version 1.0 + * + */ + +public class WorkplaceConfig implements Serializable { + + private static final long serialVersionUID = 1L; + + private static PropertiesHandler propertiesHandler; + + /** + * WorkplaceConfig ("config/workplace/config.properties") + * + * @param fileName + * @throws PropertiesHandlerException + */ +// public WorkplaceConfig(String fileName) throws PropertiesHandlerException { +// if (propertiesHandler == null) { +// propertiesHandler = new PropertiesHandler(getRootPath() + fileName); +// propertiesHandler.loadINI(); +// } +// +// } + + public static PropertiesHandler getPropertiesHandler() { + if (propertiesHandler == null) { + try { + System.out.println("getRootPath " + getRootPath()); + CLog.L.log(CLog.LL_ERR, "getRootPath " + getRootPath()); + propertiesHandler = new PropertiesHandler(getRootPath() + "config/workplace/config.properties"); + propertiesHandler.loadINI(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + return propertiesHandler; + } + + /** + * Get Root Path from Portal + * + * @return + */ + public static String getRootPath() { + String rootPath = null; + + rootPath = HttpSessionAccess.getServletContext().getRealPath("/"); + + return rootPath; + } + + /** + * Get Default Parameter + * + * @param parameter + * @return + */ + public static String getParameter(String parameter) { + return getPropertiesHandler().getParameter(parameter, "DEFAULT"); + } + + /** + * Get Workplace Parameter + * + * @param parameter + * @return + */ + public static String getParameterWorkplace(String parameter) { + return getPropertiesHandler().getParameter(parameter, "WORKPLACE"); + } + + /** + * Get Parameter from Parameter and Segment + * + * @param parameter + * @param segment + * @return + */ + public static String getParameter(String parameter, String segment) { + return getPropertiesHandler().getParameter(parameter, segment); + } + + /** + * Get all Parameters from Segment + * + * @param segment + * @return + */ + public static Hashtable getAllParameter(String segment) { + return getPropertiesHandler().getAllParametersFromSegment(segment); + } + + /** + * Get Workplace Environment + * + * @return true=Test false=Real + */ + public final static boolean getWorkplaceEnvironment() { + String value = null; + boolean result = false; + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("TEST", "WORKPLACE")); + + if (value == null || value.equalsIgnoreCase("true")) { + result = true; + } + return result; + } + + /** + * get Anzahl der Login versuche. + * + * @return Max count Login fail + */ + public final static int getWorkplaceMaxLoginAttempts() { + int maxLogin = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MAX_LOGIN_ATTEMPTS", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + maxLogin = Integer.parseInt(value); + } else { + maxLogin = 3; + } + + + return maxLogin; + } + + /** + * get Anzahl der Login versuche. + * + * @return Max count Login fail + */ + public final static int getWorkplaceRightsUpdateNextInterval() { + int interval = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("RIGHTS_UPDATE_NEXT_INTERVAL", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + interval = Integer.parseInt(value); + } else { + interval = 5; + } + + + return interval; + } + + + + /** + * get Anzahl der Login versuche. + * + * @return Max count Login fail + */ + public final static int getWorkplace() { + int maxLogin = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MAX_LOGIN_ATTEMPTS", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + maxLogin = Integer.parseInt(value); + } else { + maxLogin = 3; + } + + + return maxLogin; + } + + public final static int getWorkplaceSessionDiffTime() { + int difftime = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SESSION_DIFF_TIME", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + difftime = Integer.parseInt(value); + } else { + difftime = 2; + } + + + return difftime; + } + + public final static int getWorkplaceSessionAutoLogoutTime() { + int difftime = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SESSION_AUTO_LOGOUT_TIME", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + difftime = Integer.parseInt(value); + } else { + difftime = 60; + } + + + return difftime; + } + + + + + + /** + * get Anzahl fehlversuche bis eine Email versendet wird. + * + * @return Integer + */ + public final static int getWorkplaceSendEmailFailLogin() { + int sendEmail = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SEND_EMAIL_FAIL_LOGIN", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + sendEmail = Integer.parseInt(value); + } else { + sendEmail = 2; + } + + + return sendEmail; + } + + /** + * get send Email from Portal + * + * @return String emailadress + */ + public final static String getWorkplaceSendMailFromPortal() { + String from = null; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SEND_EMAIL_FROM_PORTAL", "WORKPLACE")); + + if (value != null) { + from = value; + } else { + from = ""; + } + return from; + } + + public static String[] getWorkplaceSendMailToPortalLogin() { + String[] to = null; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SEND_EMAIL_TO_LOGIN", "WORKPLACE")); + + if (value != null) { + to = value.split(";"); + } else { + to = new String[]{"thomas.vogel@geis-group.de","markus.kirchner@geis-group.de"}; + } + return to; + } + + public static String[] getWorkplaceSendMailToPortalErrorMsg() { + String[] to = null; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SEND_EMAIL_ERROR_MSG", "WORKPLACE")); + + if (value != null) { + to = value.split(";"); + } else { + to = new String[]{"thomas.vogel@geis-group.de","markus.kirchner@geis-group.de"}; + } + return to; + } + + + /** + * get Anzahl Tage bis Msg aus Status Delete gesetzt wird. + * + * @return Integer + */ + public final static int getWorkplaceMessagesDeleteStatusSetDays() { + int sendEmail = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MSG_DELETE_STATUS_SET", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + sendEmail = Integer.parseInt(value); + } else { + sendEmail = 10; + } + + + return sendEmail; + } + + + /** + * get Anzahl Tage bis Messages aus DB geloescht werden + * + * @return Integer + */ + public final static int getWorkplaceMessagesDeleteDatabaseDays() { + int days = 0; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MSG_DELETE_FROM_DB", "WORKPLACE")); + + if (value != null && NumericUtil.isNumericInt(value)) { + days = Integer.parseInt(value); + } else { + days = 360; + } + + + return days; + } + + /** + * get Anzahl Tage bis Messages aus DB geloescht werden + * + * TEXT_MSG;TEXT_MSG_PUSH;EMAIL_MSG + * + * @return Integer + */ + public final static List getWorkplaceMessagesDeleteTypen() { + List msgTypeEnumList = new ArrayList(); + + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MSG_DELETE_TYPEN_SET", "WORKPLACE")); + + if (value != null) { + String[] data = value.split(";"); + + for (String msgType : data) { + msgTypeEnumList.add(StringUtil.safeTrim(msgType)); + } + } else { + msgTypeEnumList.add("TEXT_MSG"); + msgTypeEnumList.add("TEXT_MSG_PUSH"); + msgTypeEnumList.add("EMAIL_MSG"); + //msgTypeEnumList.add(MsgTypeEnum.TEXT_MSG); + } + + + return msgTypeEnumList; + } + + + /** + * get Anzahl Tage bis Messages aus DB geloescht werden + * + * @return Integer + */ + public final static boolean getWorkplaceMessagesDeleteDatabaseActiv() { + Boolean activ = false; + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("MSG_DELETE_FROM_DB_ACTIV", "WORKPLACE")); + + if (value != null) { + activ = Boolean.valueOf(value); + } else { + activ = false; + } + return activ; + } + + /** + * Anmelde LoginTyp + * + * * @return List of LoginTyp + */ +// public final static List getWorkplaceLoginTypActivList() { +// List loginTypList = new ArrayList(); +// +// String value = null; +// +// value = StringUtil.safeTrim(getPropertiesHandler().getParameter("PORTAL_LOGINTYP", "WORKPLACE")); +// +// if (value == null) { +// value = "WEB_USER;INTRANET_USER;CLIENT_USER"; +// } +// +// if (value != null) { +// String[] data = value.split(";"); +// +// for (String loginType : data) { +// try { +// LoginTyp loginTyp = LoginTyp.valueOf(StringUtil.safeTrim(loginType)); +// +// loginTypList.add(loginTyp); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// return loginTypList; +// } + + /** + * URL Test Portal + * + * @return + */ + public final static String getPortalUrlTest() { + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("PORTAL_URL_TEST", "WORKPLACE")); + + if (value == null) { + value = "https://webportal-test.geis-group.de"; + } + + return value; + } + + /** + * URL Portal + * + * @return + */ + public final static String getPortalUrlReal() { + String value = null; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("PORTAL_URL", "WORKPLACE")); + + if (value == null) { + value = "https://webportal.geis-group.de"; + } + + return value; + } + + /** + * Get Workplace SessionTyp + * + * @return + */ + public final static SessionTyp getWorkplaceSessionTyp() { + String value = null; + SessionTyp sessionTyp = SessionTyp.CLIENT_SESSION; + + value = StringUtil.safeTrim(getPropertiesHandler().getParameter("SESSION_TYP", "WORKPLACE")); + + if (!StringUtil.safeIsBlank(value)) { + switch (value) { + case "PORTAL_SESSION": + sessionTyp = SessionTyp.PORTAL_SESSION; + break; + + case "MDE_SESSION": + sessionTyp = SessionTyp.MDE_SESSION; + break; + + default: + sessionTyp = SessionTyp.CLIENT_SESSION; + break; + } + } + return sessionTyp; + } + + public static void main(String[] arg) { + + System.out.println(WorkplaceConfig.getWorkplaceEnvironment()); + + + + + } + + + + + +} diff --git a/src/main/java/de/tvo/log4j2/Log4j2Handler.java b/src/main/java/de/tvo/log4j2/Log4j2Handler.java new file mode 100644 index 0000000..4216f33 --- /dev/null +++ b/src/main/java/de/tvo/log4j2/Log4j2Handler.java @@ -0,0 +1,743 @@ +package de.tvo.log4j2; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.ThreadContext; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.LoggerContext; + +import de.tvo.global.workplace.WorkplaceConfig; +import de.tvo.mailer.MailAttachment; +import de.tvo.session.SessionUtil; + +public class Log4j2Handler { + private Logger LOGGER; + + private Class clazz; + + private String user = ""; + + LoggerContext ctx; + + private boolean isDebug = false; + + /** + * Contructor for Log4j2Handler + * + * @param clazz + * Class which calls the constructor + */ + public Log4j2Handler(Class clazz) { + try { + ctx = (LoggerContext) LogManager.getContext(false); + LOGGER = ctx.getLogger(clazz.getName()); + this.clazz = clazz; + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Contructor for Log4j2Handler + * + * @param clazz + * Object of class which calls the constructor + */ + public Log4j2Handler(Object clazz) { + try { + ctx = (LoggerContext) LogManager.getContext(false); + LOGGER = ctx.getLogger(clazz.getClass().getName()); + this.clazz = clazz.getClass(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * + * @param ex Exception + * @return + * Pretty Exception + */ + private String ExceptionWriter(Exception ex) { + StringWriter errors = new StringWriter(); + ex.printStackTrace(new PrintWriter(errors)); + return errors.toString(); + } + + /** + * @param th Throwable + * @return + * Pretty Exception + */ + private String ExceptionWriter(Throwable th) { + StringWriter errors = new StringWriter(); + th.printStackTrace(new PrintWriter(errors)); + return errors.toString(); + } + + /** + * Only use in PIC Logging-section and for Log4j2 use Example + * + * @return + * Collection of Logger + */ + public Collection getLoggers() { + Collection collection = ctx.getLoggers(); + return collection; + } + + public boolean getDebug() { return isDebug; } + + /** + * Get's name of Logger (Class) + * + * @return loggername + * + */ + public String getLoggerName() { return LOGGER.getName(); } + + /** + * + * @return + * Current loggedin User + */ + public String getUser() { return user; } + + /** + * Logs entry to a method. Used when the method in question has no parameters or when the parameters should not belogged.
+ *
+ * SOURCE: SYSTEM + */ + public void logEntry() { + setMethod(); + setParam("SOURCE", Log4j2Source.SYSTEM.name()); + LOGGER.traceEntry(); + } + + /** + * Logs exit from a method. Used for methods that do not return anything.
+ *
+ * SOURCE: SYSTEM + */ + public void logExit() { + setMethod(); + setParam("SOURCE", Log4j2Source.SYSTEM.name()); + LOGGER.traceExit(); + } + + /** + * Logs a message object with the given level. + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param msg + * Optional Message + */ + public void log(Level logLevel, Log4j2Source log4j2Source, String msg) { + setMethod(); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + LOGGER.log(logLevel, msg); + } + + /** + * Logs a message object with the given level. + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param exception + * Thrown Exeption + */ + public void log(Level logLevel, Log4j2Source log4j2Source, Exception exception) { + setMethod(exception); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + LOGGER.log(logLevel, subExceptionMsg(ExceptionWriter(exception))); + } + + /** + * Logs a message object with the given level. + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param exception + * Thrown Exeption + * @param msg + * Optional Message + * + */ + public void log(Level logLevel, Log4j2Source log4j2Source, Exception exception, String msg) { + setMethod(exception); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + LOGGER.log(logLevel, msg, subExceptionMsg(ExceptionWriter(exception))); + } + + /** + * Logs a message object with the given level. + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param obj + * Does object.toString() + * + */ + public void log(Level logLevel, Log4j2Source log4j2Source, Object obj) { + setMethod(); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + LOGGER.log(logLevel, obj); + } + + /** + * + * Logs a message object with the given level.
+ * Send Mail even if email = null, else only to the Mail who specified + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param msg + * Optional Message + * @param exception + * Thrown Exeption + * @param emails + */ + public void log(Level logLevel, Log4j2Source log4j2Source, String msg, Exception exception, String[] emails) { +// setMethod(exception); +// setUsername(getUser()); +// setParam("SOURCE", log4j2Source.name()); +// if (msg == null) { +// LOGGER.log(logLevel, ExceptionWriter(exception)); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), new String[0], null); +// } +// } +// else if (msg.equals("") || msg.equals(exception.getMessage())) { +// LOGGER.log(logLevel, ExceptionWriter(exception)); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), new String[0], null); +// } +// } +// else { +// LOGGER.log(logLevel, msg, exception); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), subExceptionMsg(msg), emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(subExceptionMsg(ExceptionWriter(exception))), subExceptionMsg(msg), new String[0], null); +// } +// } + } + + /** + * Logs a message object with the given level. + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param exception + * Thrown Exeption + * + */ + public void log(Level logLevel, Log4j2Source log4j2Source, Throwable throwable) { + setMethod(throwable); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + LOGGER.log(logLevel, subExceptionMsg(ExceptionWriter(throwable))); + } + + /** + * Logs a message object with the given level.
+ * Ignores msg if null + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param msg + * Optional Message + * @param throwable + * Throwable + */ + public void log(Level logLevel, Log4j2Source log4j2Source, String msg, Throwable throwable) { + setMethod(throwable); + setUsername(getUser()); + setParam("SOURCE", log4j2Source.name()); + if (msg == null) { + LOGGER.log(logLevel, subExceptionMsg(ExceptionWriter(throwable))); + } + LOGGER.log(logLevel, msg, throwable); + } + + /** + * + * Logs a message object with the given level.
+ * Send Mail even if email = null, else only to the Mail who specified + * + * @param logLevel + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param log4j2Source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param msg + * Optional Message + * @param throwable + * Throwable + * @param emails + */ + public void log(Level logLevel, Log4j2Source log4j2Source, String msg, Throwable throwable, String[] emails) { +// setMethod(throwable); +// setUsername(getUser()); +// setParam("SOURCE", log4j2Source.name()); +// if (msg == null) { +// LOGGER.log(logLevel, ExceptionWriter(throwable)); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), new String[0], null); +// } +// } +// else if (msg.equals("") || msg.equals(throwable.getMessage())) { +// LOGGER.log(logLevel, ExceptionWriter(throwable)); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), new String[0], null); +// } +// } +// else { +// LOGGER.log(logLevel, msg, throwable); +// if (emails != null) { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), msg, emails, null); +// } +// else { +// sendMail(logLevel, log4j2Source, prettyExceptionEmail(ExceptionWriter(throwable)), msg, new String[0], null); +// } +// } + } + + /** + *

Only Used for Dispatcher Error


+ * Logs a message object with the FATAL level. + * + * @param msg + * Optional Message + * @param exception + * Thrown Exception + */ + public void logFatalDispatcher(String msg, Exception exception) { + setMethod(exception); + setUsername(getUser()); + Log4j2Source source = Log4j2Source.SYSTEM; + setParam("SOURCE", source.name()); + LOGGER.fatal(ExceptionWriter(exception)); +// sendMail(Level.FATAL, source, prettyExceptionEmail(ExceptionWriter(exception)), new String[0], null); + } + + /** + *

Only Used for Dispatcher Error


+ * Logs a message object with the FATAL level. + * + * @param msg + * Optional Message + * @param throwable + * Throwable + */ + public void logFatalDispatcher(String msg, Throwable throwable) { + setMethod(throwable); + setUsername(getUser()); + Log4j2Source source = Log4j2Source.SYSTEM; + setParam("SOURCE", source.name()); + LOGGER.fatal(ExceptionWriter(throwable)); +// sendMail(Level.FATAL, source, prettyExceptionEmail(ExceptionWriter(throwable)), new String[0], null); + } + + /** + * Replaces \t with tabs who is understanding from Email-Client + * + * @param s + * Exeption as String + * @return + * String + */ + private String prettyExceptionEmail(String s) { + return s.replace("\t", "  "); + } + + /** + * Wird nur in der PIC_Log4j2Bean benötigt. Reloads die Config von xml + */ + public void reconfigureLogger() { + ctx.reconfigure(); + } + + /** + * Private method to send Mail if needed + * + * @param level + * @param source + * @param freitext + * @param email + * @param emailanhang + */ +// private void sendMail(Level level, Log4j2Source source, String freitext, String msg, String[] email, MailAttachment[] emailanhang) { +// try { +// StringBuilder mb = new StringBuilder(); +// String subject = ""; +// +// SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); +// +// mb.append(df.format(new Date())); +// mb.append(" - "); +// mb.append(source.name()); +// mb.append(" - "); +// if (WorkplaceConfig.getWorkplaceEnvironment()) +// mb.append("Test"); +// else +// mb.append("Echt"); +// mb.append(" - "); +// mb.append(level.name()); +// mb.append(" - "); +// mb.append(clazz.getCanonicalName()); +// user = (!getUser().isEmpty() ? user : ("UNKNOWN")); +// if (user != null) { +// mb.append(" - " + user); +// } +// +// mb.append(" -- " + SessionUtil.getServerHostname()); +// mb.append(" -- " + SessionUtil.getSessionName()); +// +// subject = mb.toString(); +// mb = new StringBuilder(); +// mb.append(msg); +// mb.append("\r\n"); +// mb.append(System.getProperty("line.separator")); +// mb.append(freitext); +// mb.append(System.getProperty("line.separator")); +// +// String body = mb.toString(); +// +// if (email != null) { +// if (isDebug) { +// System.out.println("Subject: " + subject + "\nMesage: " + body); +// } +// if (email.length <= 0) { +// EmailHandler.sentLog4jMail(subject, body, null, emailanhang); +//// logInfo("Sent Email", Log4j2Source.PROGRAM); +// } +// else { +// EmailHandler.sentLog4jMail(subject, body, email, emailanhang); +//// logInfo("Sent Email", Log4j2Source.PROGRAM); +// } +// } +// } +// catch (Exception e) { +// setMethod(); +// LOGGER.fatal(e); +// } +// } + + /** + * Private method to send Mail if needed + * + * @param level + * @param source + * @param freitext + * @param email + * @param emailanhang + */ + private void sendMail(Level level, Log4j2Source source, String freitext, String[] email, MailAttachment[] emailanhang) { + try { + StringBuilder mb = new StringBuilder(); + String subject = ""; + + SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + + mb.append(df.format(new Date())); + mb.append(" - "); + mb.append(source.name()); + mb.append(" - "); + if (WorkplaceConfig.getWorkplaceEnvironment()) + mb.append("Test"); + else + mb.append("Echt"); + mb.append(" - "); + mb.append(level.name()); + mb.append(" - "); + mb.append(clazz.getCanonicalName()); + user = (!getUser().isEmpty() ? user : ("UNKNOWN")); + if (user != null) { + mb.append(" - " + user); + } + + mb.append(" -- " + SessionUtil.getServerHostname()); + mb.append(" -- " + SessionUtil.getSessionName()); + + subject = mb.toString(); + + mb.append(System.getProperty("line.separator")); + mb.append(freitext); + mb.append(System.getProperty("line.separator")); + + if (email != null) { + if (isDebug) { + System.out.println("Subject: " + subject + "\nMesage: " + freitext); + } + if (email.length <= 0) { +// EmailHandler.sentLog4jMail(subject, freitext, null, emailanhang); +// logInfo("Sent Email", Log4j2Source.PROGRAM); + } + else { +// EmailHandler.sentLog4jMail(subject, freitext, email, emailanhang); +// logInfo("Sent Email", Log4j2Source.PROGRAM); + } + } + } + catch (Exception e) { + setMethod(); + LOGGER.fatal(e); + } + } + + /** + * + * Method to create own Errormails + * + * @param level + * TRACE / DEBUG / INFO / WARN / ERROR / FATAL + * @param source + * DATABASE / SYSTEM / PROGRAM / TOOLS + * @param text + * Optional Message + * @param emails + * @param errorUser + * User who is Displayed in Mail + * @param emailArrachment + * @param logClass + * Which class called this Method + */ + public void sendMail(Level level, Log4j2Source source, String text, String[] email, String errorUser, MailAttachment[] emailArrachment, Object logClass) { + try { + StringBuilder mb = new StringBuilder(); + String subject = ""; + String message = ""; + + SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + + if (level == null) { + level = LOGGER.getLevel(); + } + + mb.append(df.format(new Date())); + mb.append(" - "); + mb.append(source.name()); + mb.append(" - "); + if (WorkplaceConfig.getWorkplaceEnvironment()) + mb.append("Test"); + else + mb.append("Echt"); + mb.append(" - "); + mb.append(level.name()); + mb.append(" - "); + mb.append(logClass.getClass().getCanonicalName()); + user = (!getUser().isEmpty() ? user : ("UNKNOWN")); + if (user != null) { + mb.append(" - " + user); + } + + mb.append(" -- " + SessionUtil.getServerHostname()); + mb.append(" -- " + SessionUtil.getSessionName()); + + subject = mb.toString(); + + mb.append(System.getProperty("line.separator")); + mb.append(text); + mb.append(System.getProperty("line.separator")); + + message = text; + + setMethod(); + if (errorUser == null) { + setUser(getUser()); + } else { + setUsername(errorUser); + } + + setParam("SOURCE", source.name()); + LOGGER.log(level, text); + + if (isDebug) { + System.out.println("Subject: " + subject + "\nMesage: " + text); + } + if (email == null || email.length <= 0) { +// EmailHandler.sentLog4jMail(subject, message, null, emailArrachment); +// logInfo("Sent Email", Log4j2Source.PROGRAM); + } + else { +// EmailHandler.sentLog4jMail(subject, message, email, emailArrachment); +// logInfo("Sent Email", Log4j2Source.PROGRAM); + } + } + catch (Exception e) { + setMethod(); + LOGGER.fatal(e); + } + } + + /** + * Aktuell nur für Email-Debugging + * Sendet EMail und gibt in Console aus + * + * @param isDebug + */ + public void setDebug(boolean isDebug) { this.isDebug = isDebug; } + + /** + * Sets Class, Methodname, linenumber for Log + */ + private void setMethod() { + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + String methodName = ""; + int lineNumber = 0; + String fileName = ""; + for (StackTraceElement stackTraceElement : stackTraceElements) { + methodName = stackTraceElement.getMethodName(); + lineNumber = stackTraceElement.getLineNumber(); + fileName = stackTraceElement.getFileName(); + + if (stackTraceElement.getClassName().startsWith("de.geis") && !methodName.equals("setMethod") && !methodName.equals("log") && !methodName.equals("subExceptionMsg")) { + break; + } + } + methodName = methodName.replace("<", ""); + methodName = methodName.replace(">", ""); + + if (fileName != null) { + fileName = fileName.replace(".java", ""); + } + ThreadContext.put("METHOD".toUpperCase(), methodName); + ThreadContext.put("LINE", lineNumber + ""); + ThreadContext.put("FILE", fileName); + } + + private void setMethod(Object exceptionOrThrowable) { + if (exceptionOrThrowable instanceof Exception) { + Exception exception = (Exception) exceptionOrThrowable; + StackTraceElement[] stackTraceElements = exception.getStackTrace(); + for (StackTraceElement stackTraceElement : stackTraceElements) { + if (stackTraceElement.getClassName().startsWith("de.geis") && !stackTraceElement.getMethodName().equals("setMethod") && !stackTraceElement.getMethodName().equals("log") && !stackTraceElement.getMethodName().equals("subExceptionMsg")) { + setMethod(stackTraceElement.getMethodName(), stackTraceElement.getFileName(), stackTraceElement.getLineNumber(), exception.getClass().getSimpleName()); + break; + } + } + } + else if (exceptionOrThrowable instanceof Throwable) { + Throwable throwable = (Throwable) exceptionOrThrowable; + StackTraceElement[] stackTraceElements = throwable.getStackTrace(); + for (StackTraceElement stackTraceElement : stackTraceElements) { + if (stackTraceElement.getClassName().startsWith("de.geis") && !stackTraceElement.getMethodName().equals("setMethod") && !stackTraceElement.getMethodName().equals("log") && !stackTraceElement.getMethodName().equals("subExceptionMsg")) { + setMethod(stackTraceElement.getMethodName(), stackTraceElement.getFileName(), stackTraceElement.getLineNumber(), throwable.getClass().getSimpleName()); + break; + } + } + } + } + + /** + * Only use if setMethod() does not work + * + * @param method + * @param file + * @param line + * @param exception + */ + private void setMethod(String method, String file, Integer line, String exception) { + method = method.replace("<", ""); + method = method.replace(">", ""); + + file = file.replace(".java", ""); + ThreadContext.put("METHOD".toUpperCase(), method); + ThreadContext.put("LINE", line + ""); + ThreadContext.put("FILE", file); + ThreadContext.put("EXCEPTION", exception); + } + + /** + * Setzt weitere parameter + * + *
+	 * Aktuell nicht benötigt bzw. sinnvoll
+	 * 
+ * + * @param Param + * @param value + */ + private void setParam(String Param, String value) { + ThreadContext.put(Param.toUpperCase(), value); + } + + public void setUser(String username) { user = username; } + + /** + * Sets Username for Log + * + * @param username + */ + public void setUsername(String username) { + ThreadContext.put("USERNAME", username); + user = username; + } + + /** + * Removes the "java.lang.Error:" in front of Exception + * + * @param msg + * @return + */ + private String subExceptionMsg(String msg) { + try { + if (msg.trim().startsWith("java.lang.Error: ")) { + while (msg.trim().startsWith("java.lang.Error: ")) { + int index = msg.trim().indexOf("java.lang.Error: ") + 17; + msg = msg.trim().substring(index, msg.trim().length()); + } + + return msg; + } + else { + return msg; + } + } + catch (Exception e) { + e.printStackTrace(); + return msg; + } + } +} diff --git a/src/main/java/de/tvo/mailer/MailAttachment.java b/src/main/java/de/tvo/mailer/MailAttachment.java new file mode 100644 index 0000000..408c9ac --- /dev/null +++ b/src/main/java/de/tvo/mailer/MailAttachment.java @@ -0,0 +1,65 @@ +package de.tvo.mailer; + +import java.io.File; +import java.io.Serializable; + +import org.apache.commons.codec.binary.Base64; + + +public class MailAttachment implements Serializable { + + private static final long serialVersionUID = 1L; + + private String fileName = "emptyfile.dat"; + private byte[] fileContent = null; + private File file = null; + private boolean deleteFile = false; + + public MailAttachment(String fileName, byte[] fileContent) { + this.fileName = fileName; + this.fileContent = fileContent; + } + + public MailAttachment(String fileName, File file, boolean deleteFile) { + this.fileName = fileName; + this.file = file; + this.deleteFile = deleteFile; + } + + public MailAttachment(String fileName, File file) { + this(fileName, file, false); + } + + public byte[] getFileContent() { + return fileContent; + } + + public void setFileContent(byte[] fileContent) { + this.fileContent = fileContent; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public boolean getDeleteFile() { + return deleteFile; + } + + public String getBase64EncodedString() { + return Base64.encodeBase64String(getFileContent()); + } + +} diff --git a/src/main/java/de/tvo/nanoleaf/enums/NanoTypeEnum.java b/src/main/java/de/tvo/nanoleaf/enums/NanoTypeEnum.java new file mode 100644 index 0000000..caed469 --- /dev/null +++ b/src/main/java/de/tvo/nanoleaf/enums/NanoTypeEnum.java @@ -0,0 +1,14 @@ +package de.tvo.nanoleaf.enums; + +public enum NanoTypeEnum { + + CANVAS, + + SHAPES, + + + + ; + + +} diff --git a/src/main/java/de/tvo/nanoleaf/oclasses/MatrixInfo.java b/src/main/java/de/tvo/nanoleaf/oclasses/MatrixInfo.java new file mode 100644 index 0000000..092b855 --- /dev/null +++ b/src/main/java/de/tvo/nanoleaf/oclasses/MatrixInfo.java @@ -0,0 +1,33 @@ +package de.tvo.nanoleaf.oclasses; + +public class MatrixInfo { + + int m_matrixX = 0; + int m_matrixY = 0; + //int m_Panels = 1; + + public MatrixInfo(int matrixX, int matrixY) { + //this.m_Panels = Panels; + this.m_matrixX = matrixX; + this.m_matrixY = matrixY; + } + + public int getMatrixX() { + return m_matrixX; + } + + public void setMatrixX(int matrixX) { + m_matrixX = matrixX; + } + + public int getMatrixY() { + return m_matrixY; + } + + public void setMatrixY(int matrixY) { + m_matrixY = matrixY; + } + + + +} diff --git a/src/main/java/de/tvo/session/SessionTyp.java b/src/main/java/de/tvo/session/SessionTyp.java new file mode 100644 index 0000000..025a648 --- /dev/null +++ b/src/main/java/de/tvo/session/SessionTyp.java @@ -0,0 +1,12 @@ +package de.tvo.session; + +public enum SessionTyp { + + PORTAL_SESSION, // Reguläre User Session + PORTAL_TOKEN_SESSION, // Sitzung die sich automatisch anmeldet über ein valides Token (gatway.risc?token=abc) + MDE_SESSION, // der MDE Server mit anderen Menüs speziell für die MDEs + CLIENT_SESSION, // Wenn Server und Client die selbe IP hat, quasi Embedded + + + ; +} diff --git a/src/main/java/de/tvo/session/SessionUtil.java b/src/main/java/de/tvo/session/SessionUtil.java new file mode 100644 index 0000000..a9e58b9 --- /dev/null +++ b/src/main/java/de/tvo/session/SessionUtil.java @@ -0,0 +1,416 @@ +package de.tvo.session; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.time.Duration; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.eclnt.jsfserver.util.HttpSessionAccess; +import org.xbill.DNS.Lookup; +import org.xbill.DNS.PTRRecord; +import org.xbill.DNS.Record; +import org.xbill.DNS.SimpleResolver; +import org.xbill.DNS.Type; + +import de.tvo.tools.StringUtil; +import jakarta.servlet.http.HttpSession; + +public class SessionUtil { + + private SessionUtil() { + + } + + /** + * Function to return Client IP + * @return Client IP + */ + public static String getClientIP(){ + return HttpSessionAccess.getCurrentRequest().getRemoteAddr(); + } + + /** + * Function to return Client Hostname for Portal Server + * @return Client Hostname + */ + public static String getClientHostname() { + return getClientHostname(SessionTyp.PORTAL_SESSION); + } + + /** + * Function to return Client Hostname + * @return Client Hostname + */ + public static String getClientHostname(SessionTyp sessionTyp) { + System.out.println("getClientHostname: " + sessionTyp); + + String clientIP = getClientIP(); + System.out.println("clientIP " + clientIP); + + if (StringUtil.safeTrim(clientIP).equals("0:0:0:0:0:0:0:1") || StringUtil.safeTrim(clientIP).equals("127.0.0.1")) { + sessionTyp = SessionTyp.PORTAL_SESSION; + } + + try { + switch (sessionTyp) { + case CLIENT_SESSION: + case PORTAL_SESSION: { + + + String ipAddress = InetAddress.getByName(HttpSessionAccess.getCurrentRequest().getRemoteAddr()).getHostName(); + if (ipAddress != null) { + if (ipAddress.indexOf(".") != -1) { + return ipAddress.substring(0, ipAddress.indexOf(".")).toUpperCase(); + } else { + return ipAddress.toUpperCase(); + } + } + + break; + } + +// case MDE_SESSION: { +// String clientName = null; +// System.out.println("clientIP " + clientIP); +// +// if (StringUtil.safeTrim(clientIP).equals("0:0:0:0:0:0:0:1")) { +// clientIP = getServerIP(); +// } +// +// +// +// if (StringUtil.getCountLetter(clientIP, '.') == 3) { +// DBHandler dbHandler = new DBHandler(WorkplaceConfig.getWorkplaceEnvironment() ? SchemataENUM.GEISV8T : SchemataENUM.GEISV8E); +// StringBuilder sqlBuilder = new StringBuilder(); +// sqlBuilder.append("select pakey2 "); +// sqlBuilder.append("from Gxpadat "); +// sqlBuilder.append("where pakonz='EDV' and pafirm='MDE' "); +// sqlBuilder.append("and pawert='MDEHOSTNAMEN' and pakey1='" + clientIP + "' "); +// +// +// List clientList = dbHandler.jdbcSelect(sqlBuilder.toString()); +// System.out.println("clientList: " + clientList.size()); +// if (clientList != null && clientList.size() == 1) { +// Object[] data = clientList.get(0); +// clientName = StringUtil.safeTrimObj(data[0]); +// +// } else { +// clientName = "UNKNOWN"; +// } +// } +// +// // cutPos = StringUtil.getPositionSearchString(clientIP, '.', 3); +// // +// // if (cutPos != -1) { +// // clientNummer = clientIP.substring(cutPos); +// // ipBereich = clientIP.substring(0, cutPos); +// // System.out.println("ipBereich " + ipBereich); +// // clientName = "MDERF" + clientNummer; +// // } +// +// +// return clientName; +// } + + default: + break; + } + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String getInetAddress() { + String adr = null; + + try { + adr = InetAddress.getByName(HttpSessionAccess.getCurrentRequest().getRemoteAddr()).getHostName(); + } catch (Exception e) { + e.printStackTrace(); + } + return adr; + } + + /** + * Function to return the Servers IP + * @return Server IP + */ + public static String getServerIP(){ + try { + + String serverIP = null; + String isDocker = System.getenv("ISDOCKER"); + + if (!StringUtil.safeIsBlank(isDocker) && isDocker.equalsIgnoreCase("true")) { + serverIP = InetAddress.getByName(getServerHostname()).getHostAddress(); + } else { + serverIP = InetAddress.getLocalHost().getHostAddress(); + } + + + return serverIP; + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + + /** + * Function to return the ServerHostname + * @return Server Hostname + */ + public static String getServerHostname(){ + try { + String hostname = null; + + String isDocker = System.getenv("ISDOCKER"); + + if (!StringUtil.safeIsBlank(isDocker) && isDocker.equalsIgnoreCase("true")) { + hostname = System.getenv("HOSTNAME"); + + } else { + hostname = InetAddress.getLocalHost().getHostName(); + } + + if (hostname.indexOf(".") != -1) { + hostname = hostname.substring(0, hostname.indexOf(".")); + } + + return hostname; + } catch (UnknownHostException e) { + e.printStackTrace(); + } + return ""; + } + + /** + * Return activ HttpSession + * + * @return HttpSession + */ + public static HttpSession getHttpSession() { + HttpSession httpSession = null; + try { + httpSession = HttpSessionAccess.getCurrentHttpSession(); + } catch (Exception e) { + e.printStackTrace(); + } + return httpSession; + } + + +// /** +// * Return SessionType +// * +// * @return SessionType +// */ +// public static SessionTyp getServerSessionType() { +// SessionTyp sessionType = SessionTyp.PORTAL_SESSION; +// +// try { +// +// String serverName = getServerHostname(); +// +// if (serverName != null) { +// if (serverName.startsWith("NESAS")) { +// sessionType = SessionTyp.PORTAL_SESSION; +// } else { +// sessionType = SessionTyp.CLIENT_SESSION; +// } +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return sessionType; +// } + + /** + * Return SessionID + * @return SessionID + */ + public static String getHttpSessionID() { + return HttpSessionAccess.getCurrentHttpSession().getId(); + } + + public static String getRootPath() { + String rootPath = null; + try { + rootPath = HttpSessionAccess.getServletContext().getRealPath("/"); + } catch (Exception e) { + e.printStackTrace(); + } + return rootPath; + } + + /** + * @return gibt den Namen des Tomcats zurück, z.B. GWPTESTTC1 + */ + public static String getSessionName() { + String id = null; + try { + id = HttpSessionAccess.getCurrentHttpSession().getId(); + } catch (Exception e) { + e.printStackTrace(); + } + if (id != null && id.indexOf(".") != -1) { + id = id.substring(id.indexOf(".")+1); + } else { + id = ""; + } + return id; + } + + /** + * Resolves the hostname of the IP by the DNS, if not possible by the secondDNS
+ * If this isn't possible the IP itself is the result + * @param dns Primary DNS + * @param secondDNS Secondary DNS + * @param ip IP-Adress + * @return Hostname of the IP-Adress, if not possible the Adress itself + */ + public static String getNameByIP(final String dns, final String secondDNS, final String ip) { + try { + //Splitte the IP in ihre Oktetten + final List oktetten = Arrays.stream(ip.split(Pattern.quote("."))).collect(Collectors.toList()); + + //Vertausche the Oktetten + Collections.reverse(oktetten); + + //Bilde aus den Oktetten die Reverse-Lookup-Adresse + final String reverseLookupIP = oktetten.stream().collect(Collectors.joining(".")) + ".in-addr.arpa"; + + //PTR ist der DNS-Typ für Reverse Lookups (https://www.ionos.de/digitalguide/hosting/hosting-technik/ptr-record/) + final Lookup l = new Lookup(reverseLookupIP, Type.PTR); + + //Resolver für den Primary DNS + { + final SimpleResolver sp = new SimpleResolver(dns); + sp.setTimeout(Duration.ofSeconds(5l)); + l.setResolver(sp); + final Record[] records = l.run(); + + if (records != null) { + for (final Record r : records) { + final String target = (((PTRRecord) r).getTarget().getLabelString(0)); + return target; + } + } + } + System.out.println("Primary DNS (" + dns + ") failed reversing: \"" + ip + "\""); + + //Falls nicht gefunden wird und es einen Secondary DNS gibt: + if (secondDNS != null && !secondDNS.trim().isEmpty()) { + final SimpleResolver sp2 = new SimpleResolver(secondDNS); + sp2.setTimeout(Duration.ofSeconds(5l)); + l.setResolver(sp2); + final Record[] records2 = l.run(); + + if (records2 != null) { + for (final Record r : records2) { + final String target = (((PTRRecord) r).getTarget().getLabelString(0)); + return target; + } + } + } + System.out.println("Secondary DNS (" + secondDNS + ") failed reversing: \"" + ip + "\""); + } catch (final Throwable e) { + e.printStackTrace(); + } + System.out.println("Returning\"" + ip + "\" as fallback"); + //Als Fallback wir die IP-Adresse zurückgegeben + return ip; + } + + /** + * Wandelt einen Hostnamen in einen LFS-Hostnamen um, für Mediamarkt Göttingen + * @param hostname + * @return GMM + PC (1) oder Notebook (2) + 4 stellige Nummer + */ + public static String getLFSNameForGoettingenHostname(String hostname) { + try { + if (hostname.contains(".")) { + hostname = hostname.substring(0, hostname.indexOf('.')); + } + + final int length = hostname.length(); + + final String p1 = "GMM"; + final String wksOrnob = hostname.substring(length - 7, length - 4).toUpperCase(); + String p2 = ""; + if (wksOrnob.equals("WKS")) { + p2 = "1"; + } else if (wksOrnob.equals("NOB")) { + p2 = "2"; + } else { + throw new IllegalArgumentException("PC type of hostname \"" + hostname + "\" must be either wks or nob, but it's: \"" + wksOrnob + "\""); + } + + final String p3 = hostname.substring(length - 4); + try { + Integer.parseInt(p3); + } catch (final Exception e) { + throw new IllegalArgumentException("PC number of hostname \"" + hostname + "\" must be a number with 4 digits, but it's: \"" + hostname.substring(length - 4) + "\""); + } + + return p1 + p2 + p3; + } catch (final Exception e) { + System.out.println("Hostname: \"" + hostname + "\""); + e.printStackTrace(); + } + return hostname; + } + + /** + * Check if IP is within an Subnet defined by Network Address and Network Mask
+ * Via: https://stackoverflow.com/a/54514071/3123870 + * @param ip + * @param net + * @param mask + * @return + */ + public static final boolean isIpInSubnet(final String ip, final String net, final int prefix) { + try { + final byte[] ipBin = java.net.InetAddress.getByName(ip).getAddress(); + final byte[] netBin = java.net.InetAddress.getByName(net).getAddress(); + if (ipBin.length != netBin.length) { + return false; + } + int p = prefix; + int i = 0; + while (p >= 8) { + if (ipBin[i] != netBin[i]) { + return false; + } + ++i; + p -= 8; + } + final int m = (65280 >> p) & 255; + if ((ipBin[i] & m) != (netBin[i] & m)) { + return false; + } + + return true; + } catch (final Throwable t) { + return false; + } + } + + + /** + * Resolves the Hostname of a Goettingen IP via Mediamarkt DNS + * @param IP + * @return + */ + public static String getGoettingenHostname(final String ip) { + return getNameByIP("10.162.192.2", "10.162.192.4", ip); + } + +} diff --git a/src/main/java/de/tvo/tools/Exceptions.java b/src/main/java/de/tvo/tools/Exceptions.java index 58416fa..f3e278f 100644 --- a/src/main/java/de/tvo/tools/Exceptions.java +++ b/src/main/java/de/tvo/tools/Exceptions.java @@ -65,14 +65,14 @@ public class Exceptions { return new StringBuilder(new Timestamp(System.currentTimeMillis()).toString()).append(" - ").append(new Exception().getStackTrace()[1].toString()); } - public final static String prettyPrintGeisException(Throwable e, boolean consolePrint){ + public final static String prettyPrintTvoException(Throwable e, boolean consolePrint){ StringBuilder builder = new StringBuilder(e.getClass().getSimpleName()); if (e.getMessage() != null) { builder.append("\t\tMessage: \"").append(e.getMessage()).append('\"'); } - for (StackTraceElement peter : e.getStackTrace()) { - if (peter.getClassName().startsWith("de.geis") || peter.getClassName().startsWith("managedbeans")) { - builder.append("\n\t").append(peter); + for (StackTraceElement petter : e.getStackTrace()) { + if (petter.getClassName().startsWith("de.tvo") || petter.getClassName().startsWith("managedbeans")) { + builder.append("\n\t").append(petter); } } if (consolePrint) { diff --git a/src/main/java/de/tvo/tools/NumericUtil.java b/src/main/java/de/tvo/tools/NumericUtil.java new file mode 100644 index 0000000..7544127 --- /dev/null +++ b/src/main/java/de/tvo/tools/NumericUtil.java @@ -0,0 +1,248 @@ +package de.tvo.tools; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.Random; +import java.util.regex.Pattern; + +public class NumericUtil { + + public NumericUtil() { + + } + + public static boolean checkGanzZahl(double value){ + //Fuern A....!!!!! + //return Math.abs(value) < Float.MIN_VALUE; + + return (value % 1 == 0); + } + + /** + * Returns random double between low and high + * + * @param low + * lowest possible + * @param high + * highest possible + * @return random Double between low and high + */ + public static Double myRandom(double low, double high) { + return new Random().nextDouble() * (high - low) + low; + } + + /** + * Returns random Integer between low and high + * + * @param low + * lowest possible + * @param high + * highest possible + * @return Integer between low and high + */ + public static int myRandom(int low, int high) { + return new Random().nextInt(high - low) + low; + } + + /** + * Returns boolean numeric Int is true or false + * + * @param number + * Integer + * @return + */ + public static boolean isNumericInt(String number) { + boolean numeric = false; + + if (number != null && number.matches("[\\+\\-]{0,1}[0-9]+$")) { + numeric = true; + } + + return numeric; + } + + /** + * + * Check If a String Is a Numeric + * + * @return true if numeric + */ + public static boolean isNumeric(String str) { + return StringUtil.safeTrimObjWithReplace(str).replace(",", ".").matches("-?\\d+(\\.\\d+)?"); + } + + /** + * Returns boolean numeric Double is true or false + * + * @param number + * Double + * @return + */ + public static boolean isNumericDouble(String number) { + boolean numeric = false; + + if (number != null && number.matches("^[\\+\\-]{0,1}[0-9]+[\\.\\,]{1}[0-9]+$")) { + numeric = true; + } + return numeric; + } + + public static Float formatStringToNumericFloat(Object zahl) { + return Float.valueOf(formatStringToNumeric(zahl, "Float").toString()); + } + + public static Object formatStringToNumeric(Object zahlobj, String type) { + return formatStringToNumericWithScale(zahlobj, type, 2, false); + } + + public static Object formatStringToNumericWeight(Object zahlobj, String type) { + return formatStringToNumericWithScale(zahlobj, type, 3, false); + } + + public static Object formatStringToNumericWithScale(Object zahlobj, String type, int scale) { + return formatStringToNumericWithScale(zahlobj, type, scale, false); + } + + public static Object formatStringToNumericWithScale(Object zahlobj, String type, int scale, boolean negativ) { + return formatStringToNumericWithScale(zahlobj, type, scale, negativ, 0, null); + } + + public static Object formatStringToNumericWithScale(Object zahlobj, String type, int scale, boolean negativ, + int decimalPlace, String kommapunkt) { + Object result = null; + String zahl = null; + if (zahlobj == null) + return 0; + + if (type == null) + return 0; + + System.out.println("Type: " + type); + + if (type.equals("String")) { + return zahlobj; + } + + if (scale < 1 || scale > 12) + scale = 2; + try { + zahl = zahlobj.toString().trim(); + + if (negativ == false) { + if (zahl.startsWith("-")) + return 0; + } + + zahl = StringUtil.replaceAllWithReplace(zahl, ",", "."); + + try { + BigDecimal decimal = new BigDecimal(zahl); + + zahl = decimal.toString(); + } catch (Exception e) { + return 0; + } + System.out.println("formatStringToNumericWithScale: " + zahl); + + if (checkNummerischAll(zahl) == false) + return 0; + + Object nachkomma = StringUtil.fillString("0", decimalPlace, "0", "right"); + + DecimalFormat format = new DecimalFormat("#0." + nachkomma); + + if (type.equalsIgnoreCase("Integer")) { + BigDecimal dzahl = new BigDecimal(zahl); + dzahl = dzahl.setScale(0, RoundingMode.HALF_UP); + result = dzahl.intValue(); + } else if (type.equalsIgnoreCase("Long")) { + BigDecimal dzahl = new BigDecimal(zahl); + dzahl = dzahl.setScale(0, RoundingMode.HALF_UP); + result = dzahl.longValue(); + } else if (type.equalsIgnoreCase("Double")) { + BigDecimal dzahl = new BigDecimal(zahl); + dzahl = dzahl.setScale(scale, RoundingMode.HALF_UP); + + if (decimalPlace != 0) { + result = format.format(dzahl); + } else { + result = dzahl.doubleValue(); + } + } else if (type.equalsIgnoreCase("Float")) { + BigDecimal dzahl = new BigDecimal(zahl); + dzahl = dzahl.setScale(scale, RoundingMode.HALF_UP); + + if (decimalPlace != 0) { + result = format.format(dzahl); + } else { + result = dzahl.floatValue(); + } + + } else { + result = zahl.toString(); + } + + if (!StringUtil.safeIsBlank(kommapunkt)) + result = StringUtil.replaceAllWithReplace(result.toString(), ".", kommapunkt); + + } catch (Exception e) { + e.printStackTrace(); + // LogHandler.logError("Tools", e, "formatStringToNumeric", ""); + return null; + } + System.out.println("DA: " + result); + + return result; + } + + static public boolean checkNummerischAll(Object datenString) { + Pattern regularDigits = Pattern.compile("((-|\\+)?[0-9]+(\\.[0-9]+)?)+"); + BigDecimal decimal = null; + + try { + Double zahl = Double.valueOf(datenString.toString().replace(",", ".")); + decimal = new BigDecimal(zahl); + + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + System.out.println(decimal); + if (regularDigits.matcher(decimal.toString()).matches()) { + return true; + } + return false; + } + + public static String getFormatFromNumeric(Object numeric) { + String regexDecimal = "^[1-9]\\d*((\\.|\\,)\\d+)?$"; + String regexInteger = "^[1-9]\\d*$"; + String regexDouble = regexDecimal + "|" + regexInteger; + + if (numeric.toString().matches(regexInteger)) { + return "INTEGER"; + } else if (numeric.toString().matches(regexDouble)) { + return "DOUBLE"; + } else { + return "No Numeric"; + } + } + + public static int getAlwaysRoundUp(double value) { + Double result = 0.0; + result = Math.ceil(value); + + return result.intValue(); + } + + /** + * Round given double to max. 2 decimals + * @param val + * @return rounded double + */ + public static double roundTo2Decimals(double val) { + return Math.round(val*100.0)/100.0; + } +} diff --git a/src/main/java/de/tvo/tools/SearchReplaceObj.java b/src/main/java/de/tvo/tools/SearchReplaceObj.java new file mode 100644 index 0000000..98f240c --- /dev/null +++ b/src/main/java/de/tvo/tools/SearchReplaceObj.java @@ -0,0 +1,30 @@ +package de.tvo.tools; + +public class SearchReplaceObj { + + private String m_search; + private String m_replace; + + public SearchReplaceObj(String search, String replace) { + this.m_search = search; + this.m_replace = replace; + } + + public String getSearch() { + return m_search; + } + + public void setSearch(String search) { + m_search = search; + } + + public String getReplace() { + return m_replace; + } + + public void setReplace(String replace) { + m_replace = replace; + } + + +} diff --git a/src/main/java/de/tvo/tools/StringUtil.java b/src/main/java/de/tvo/tools/StringUtil.java index be4700f..127481f 100644 --- a/src/main/java/de/tvo/tools/StringUtil.java +++ b/src/main/java/de/tvo/tools/StringUtil.java @@ -1,10 +1,15 @@ package de.tvo.tools; import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.StringUtils; +import org.apache.xmlbeans.impl.common.Levenshtein; public class StringUtil { @@ -20,7 +25,7 @@ public class StringUtil { */ public static void main(String[] args) { - // TEST + } /** @@ -332,6 +337,18 @@ public class StringUtil { return result; } + /** + * Check Webadresse + * @param webadresse + * @return True = valid; or False = not valid + */ + public static boolean checkWebAdresse(String webadresse) { + String regex = "^(https?:\\/\\/)?([\\w.-]+(?:\\.[\\w\\.-]+)+)(:[0-9]{1,5})?(\\/[^\\s]*)?$"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(webadresse); + return(matcher.matches()); + } + public static List checkIfTextContainsMails(String text) { List correctEmails = new ArrayList<>(); @@ -434,7 +451,109 @@ public class StringUtil { return sb.toString(); } - + /** + * Uppercase the word and the 'ß' stays.
+ * Normally when used toUppercase() it will change to 'SS' + * + * @param string + * @return + */ + public static String toUpperSpecialCharacter(String s) { + StringBuilder sb = new StringBuilder(); + for(char c : s.toCharArray()) { + if (c != 'ß') { + c = Character.toUpperCase(c); + } + sb.append(c); + } + + return sb.toString(); + } + + /** + * Sucht per Levenshtein den ähnlichsten String für searchString aus der searchList + * @param searchString - Zu suchender String + * @param searchList - List aus String + * @return den ähnlichsten String + */ + public static String findClosestMatch(final String searchString, final List searchList) { + return searchList.stream() + .sorted((a, b) -> Levenshtein.distance(searchString, a) - Levenshtein.distance(searchString, b)) + .findFirst() + .orElse(null); + } + + /** + * Sucht per Levenshtein den ähnlichsten String für searchString aus der searchList ohne Beachtung von Groß- und Kleinschreibung + * @param searchString - Zu suchender String + * @param searchList - List aus String + * @return den ähnlichsten String + */ + public static String findClosestMatchIgnoreCase(final String searchString, final List searchList) { + return searchList.stream() + .sorted((a, b) -> Levenshtein.distance(searchString.toLowerCase(), a.toLowerCase()) - Levenshtein.distance(searchString.toLowerCase(), b.toLowerCase())) + .findFirst() + .orElse(null); + } + + /** + * Sucht per Levenshtein den ähnlichsten String zu einem der searchStrings aus der searchList ohne Beachtung von Groß- und Kleinschreibung + * @param searchString1 - Zu suchender String + * @param searchString2 - Zu suchender String + * @param searchList - List aus String + * @return den ähnlichsten String + */ + public static String findClosestMatchIgnoreCase(final String searchString1, final String searchString2, final List searchList) { + String match1 = searchList.stream() + .sorted((a, b) -> Levenshtein.distance(searchString1.toLowerCase(), a.toLowerCase()) - Levenshtein.distance(searchString1.toLowerCase(), b.toLowerCase())) + .findFirst() + .orElse(null); + + if (searchString2 == null || searchString2.trim().isEmpty()) { + return match1; + } + + String match2 = searchList.stream() + .sorted((a, b) -> Levenshtein.distance(searchString2.toLowerCase(), a.toLowerCase()) - Levenshtein.distance(searchString2.toLowerCase(), b.toLowerCase())) + .findFirst() + .orElse(null); + + int distance1 = Levenshtein.distance(searchString1.toLowerCase(), match1.toLowerCase()); + int distance2 = Levenshtein.distance(searchString2.toLowerCase(), match2.toLowerCase()); + + if (distance1 <= distance2) { + return match1; + } + return match2; + } + + /** + * @param converToCamelCase - to converted string + * @return String in Camel Case + */ + public static String getCamelCase(String converToCamelCase) { + if (converToCamelCase != null && !converToCamelCase.isEmpty()) { + StringBuilder newString = new StringBuilder(converToCamelCase.length()); + for (final String StringWort : converToCamelCase.split("\\Q \\E")) { + if (newString.length() != 0) { + newString.append(' '); + } + switch (StringWort.length()) { + case 0: + break; + case 1: + newString.append(Character.toUpperCase(StringWort.charAt(0))); + break; + default: + newString.append(Character.toUpperCase(StringWort.charAt(0))); + newString.append(StringWort.substring(1).toLowerCase()); + break; + } + } + converToCamelCase = newString.toString(); + } + return converToCamelCase; + } /** * Check if the AS/400 can handle the string @@ -445,5 +564,80 @@ public class StringUtil { return Charset.forName("IBM01141").newEncoder().canEncode(str); } + /** + * Removes all non CP273 chars from the string + * @param str + * @return str without of non CP273 chars + */ + public static String removeAllNonCP273Characters(final String str) { + CharsetEncoder cp273encoder = Charset.forName("IBM01141").newEncoder(); + return str + .chars() + .mapToObj(i -> "" + (char) i) + .filter(i -> cp273encoder.canEncode(i)) + .collect(Collectors.joining()); + } + + /** + * Replaces all non CP273 chars from the string + * @param str + * @return str with ASCii instead of non CP273 chars + */ + public static String replaceAllNonCP273CharactersWithAscii(final String str) { + CharsetEncoder cp273encoder = Charset.forName("IBM01141").newEncoder(); + String result = ""; + for (char ch : str.toCharArray()) { + if(cp273encoder.canEncode(ch)) { + result += ""+ch; + } else { + result += StringUtils.stripAccents(""+ch); + } + } + return result; + } + + /** + * convertToUpperCaseExceptSharpS + * @param input + * @return + */ + public static String convertToUpperCaseExceptSharpS(String input) { + if (input == null) { + return null; + } + StringBuilder result = new StringBuilder(); + for (int i = 0; i < input.length(); i++) { + char currentChar = input.charAt(i); + if (currentChar == 'ß') { + result.append(currentChar); + } else { + result.append(Character.toUpperCase(currentChar)); + } + } + return result.toString(); + } + /** + * replaceAllFromList + * @param text + * @return + */ + public static String replaceAllFromList(String text, boolean trim) { + String result = null; + // Search Replace List + List searchReplaceList = new ArrayList(); + searchReplaceList.add(new SearchReplaceObj("–", "-")); + + + if (trim) { + result = text.trim(); + } else { + result = text; + } + for (SearchReplaceObj searchReplaceObj: searchReplaceList) { + result = StringUtil.replaceAllWithReplace(result, searchReplaceObj.getSearch(), searchReplaceObj.getReplace()); + } + + return result; + } } diff --git a/src/main/java/de/tvo/tools/XMLUtils.java b/src/main/java/de/tvo/tools/XMLUtils.java deleted file mode 100644 index 1033e93..0000000 --- a/src/main/java/de/tvo/tools/XMLUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.tvo.tools; - -import java.io.StringReader; -import java.io.StringWriter; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.xml.sax.InputSource; - -public class XMLUtils { - - public static String convertXMLDocumentToString(Document doc) { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer; - try { - transformer = tf.newTransformer(); - // below code to remove XML declaration - // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - StringWriter writer = new StringWriter(); - transformer.transform(new DOMSource(doc), new StreamResult(writer)); - String output = writer.getBuffer().toString(); - return output; - } catch (TransformerException e) { - e.printStackTrace(); - return null; - } - - } - - public static Document convertStringToXMLDocument(String xmlStr) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder; - try { - builder = factory.newDocumentBuilder(); - Document doc = builder.parse(new InputSource(new StringReader(xmlStr))); - return doc; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/src/main/java/de/tvo/toolset/PropertiesHandler.java b/src/main/java/de/tvo/toolset/PropertiesHandler.java new file mode 100644 index 0000000..368df7a --- /dev/null +++ b/src/main/java/de/tvo/toolset/PropertiesHandler.java @@ -0,0 +1,446 @@ +package de.tvo.toolset; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Set; +import java.util.Vector; + +/** + * DE: + * + * EN: + * + * + * Program changes + * ************************************************************************************** + * Date * Ticket * KonzFirm * Responsible * programmer * + * Change * + * ************************************************************************************** + * + * @author VogelT + * @version 1.0 + * + */ + + + + +public class PropertiesHandler { + private Vector iniVector = null; + String filename; + private Hashtable> iniHash = new Hashtable>(); + /** + * + * @param filename Pfad zum ini File + */ + public PropertiesHandler(String fileName) throws PropertiesHandlerException { + filename=fileName; +/* File file = new File(filename); + int size = (int) file.length(); + FileReader readFile; + try { + readFile = new FileReader(file); + } catch (Exception e) { + String message = new String("Fehler beim öffnen " + filename + "\n" + e.getMessage()); + throw new PropertiesHandlerException(e, message, "Überprüfen Bildschirmkonfiguration"); + } + char[] data = new char[size]; + int chars_read=0; + try { + while(readFile.ready()){ + chars_read += readFile.read(data,chars_read, size-chars_read); + } + readFile.close(); + } catch (Exception e) { + String message = new String("Fehler beim lesen " + filename + "\n" + e.getMessage()); + throw new PropertiesHandlerException(e, message, "Überprüfen Bildschirmkonfiguration"); + } + this.filename = new String(filename); + iniVector = getZeilenFromCharArray(data); + */ + } + + /** + * Holt alle Daten aus dem INI File + */ + public void init() throws PropertiesHandlerException{ + String segment = null; + String getSegment = null; + for(int pos=0; pos < iniVector.size(); pos++){ + String line = iniVector.get(pos).toString(); + line = destroyBlank(line); + getSegment = checkSegment(line); + if(getSegment != null) { + segment = getSegment; + continue; + } + isParameter(line,segment); + } + } + + /** + * Nimmt alle Blanks hinten und vorne weg + * @param line Zeile + * @return String ohne Blanks + */ + private String destroyBlank(String line){ + String newLine; + int pos; + for(pos=0; pos < line.length(); pos++) + if(line.charAt(pos) != ' ') + break; + if(pos==line.length()) return new String(""); + newLine = line.substring(pos,line.length()); + for(pos=line.length()-1; pos >= 0; pos--) + if(line.charAt(pos) != ' ') + break; + newLine = newLine.substring(0,pos+1); + return newLine; + } + + /** + * Holt alle Parameter von einem Segment + * @param Segment + * @return + */ + public Hashtable getAllParametersFromSegment(String segment){ + return iniHash.get(segment); + } + + /** + * Holt alle Segmente der IniDatei + * @return + */ + public Enumeration getAllSegments(){ + return iniHash.keys(); + } + + /** + * Überprüft ob die Zeile ein Segment darstellt, wenn ja wird dieses in die Hashtable gestellt + * @param line Zeile + * @return true Ist ein Segmenteintrag + * false Ist kein Segmenteintrag + */ + private String checkSegment(String line) throws PropertiesHandlerException{ + if(line.length()==0) return null; + if(line.charAt(0) == '['){ + for(int pos=1; pos < line.length(); pos++){ + if(line.charAt(pos) == ']'){ + String segment = new String(line.substring(1,pos)); + segment = segment.toUpperCase(); + Hashtable parameters = new Hashtable(); + if(iniHash.get(segment)!=null){ + throw new PropertiesHandlerException(new Exception(),"Segment " + segment + "doppelt vorhanden", + "Auswerten " + filename); + } + iniHash.put(segment,parameters); + return segment; + } + } + } + return null; + } + + /** + * Überprüft ob es sich um einen Parameter handelt und trägt diesen ein + * @param line + * @return + */ + private boolean isParameter(String line, String segment) throws PropertiesHandlerException{ + String parameter = null, + value = null; + if(line.length()==0) return false; + if(line.startsWith("##")) return false; + if(line.startsWith("=") ||(line.charAt(line.length()-1)=='=')){ + throw new PropertiesHandlerException(new Exception(""),"Parameterzeile " + line + "\n" + + "Falsches Format","Auswerten " + filename); + } + for(int pos=0; pos < line.length(); pos++){ + if(line.charAt(pos) == '='){ + parameter = new String(line.substring(0, pos)); + value = new String(line.substring(pos+1)); + break; + } + } + if(parameter == null) + throw new PropertiesHandlerException(new Exception(""),"Parameterzeile " + line + "\n" + + "Falsches Format","Auswerten " + filename); + // Wenn segment == null dann haben wir noch kein Segment + if(segment == null){ + throw new PropertiesHandlerException(new Exception(),"Formatfehler: Parameter" + parameter + + " ohne Segment", "Auswerten " + filename); + } + parameter = parameter.toUpperCase(); + Hashtable parameters = iniHash.get(segment); + if(parameters.get(parameter)!=null){ + throw new PropertiesHandlerException(new Exception(),"Parameter " + parameter + "doppelt vorhanden", + "Auswerten " + filename); + } + parameters.put(parameter,value); + return true; + } + + /** + * Holt den Wert eines Parameters + * @param parameter + * @param segment + */ + public String getParameter(String parameter, String segment){ + parameter = parameter.toUpperCase(); + segment = segment.toUpperCase(); + Hashtable parameters = iniHash.get(segment); + // Wenn es das Segment ar nicht gibt + if(parameters==null) return null; + Object opar = parameters.get(parameter); + if(opar == null) return null; + return opar.toString(); + } + + /** + * Setzt den Parameter + * @param parameter + * @param value + * @param segment + */ + public void setParameter(String parameter, String value, String segment){ + + + + parameter = parameter.toUpperCase(); + segment = segment.toUpperCase(); + Hashtable parameters = iniHash.get(segment); + // Wenn es das Segment ar nicht gibt + if(parameters==null){ + Hashtable newSegment = new Hashtable(); + newSegment.put(parameter,value); + iniHash.put(segment,newSegment); + return; + } + if(parameters.get(parameter)!=null) + parameters.remove(parameter); + //System.out.println("Value (setParameter): "+value); + + parameters.put(parameter,value); + + + // Diese metode wird nicht benoetigt. + //setParameterAndSave(parameter, value, segment); + + + + } + + +public void setParameterAndSave(String parameter, String value, String segment) { + + + //System.out.println("setParameterAndSave ---"); + //System.out.println("parameter: " + parameter); + //System.out.println("value: " + value); + //System.out.println("segment: " + segment); + + boolean nowInSegment = false; + boolean parameterDelivered = false; + int lastParamIndexOfSegment = 0; + + segment = "[" + segment + "]"; + + for (int i = 0; i < iniVector.size(); i++) { + + String line = (String)iniVector.get(i); + + if (line.startsWith("##")) continue; + + // Haben das Segment gefunden und gehen und springen nun in den nächsten Schleifenduchlauf + if (line.trim().equals( segment.toUpperCase() )) { + nowInSegment = true; + continue; + } + + // Hier suchen wir ein schon vorhandes Element und füllen die Daten ein + if (nowInSegment && line.trim().startsWith( parameter.toUpperCase() )) { + iniVector.set(i, parameter.toUpperCase() + "=" + value); + parameterDelivered = true; + } + + + // Hier erkennen wir das wir schon ein neues Segment betreten und haben aber die "Post" noch nicht abgeliefert + if (nowInSegment && line.startsWith("[") ) { + nowInSegment = false; + if (!parameterDelivered) iniVector.insertElementAt(parameter.toUpperCase() + "=" + value, lastParamIndexOfSegment+1); + } + + if (nowInSegment && !line.trim().equals("")) lastParamIndexOfSegment = i; + + + } + + + /* + * Und nun noch zum Schluss den iniVector wegschreiben + */ + + + PrintWriter pw = null; + try { + + Writer fw = new FileWriter( this.filename ); + Writer bw = new BufferedWriter( fw ); + pw = new PrintWriter( bw ); + + for (int i = 0; i < iniVector.size(); i++) { + pw.println( iniVector.get(i) ); + } + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (pw != null) pw.close(); + } + + } +@Deprecated + public void loadINI(){ + iniHash = new Hashtable>(); + String line = null; + this.iniVector =new Vector<>(); + BufferedReader bufferedReader=null; + FileReader readFile=null; + File file = new File(filename); + + try { + readFile = new FileReader(file); + bufferedReader=new BufferedReader(readFile); + } catch (Exception e) { + String message = new String("Fehler beim öffnen " + filename + "\n" + e.getMessage()); + System.out.println(message); + } + + try { + while((line = bufferedReader.readLine()) != null) { + iniVector.add(line); + //System.out.println(line); + } + // Always close files. + bufferedReader.close(); + readFile.close(); + } catch (Exception e) { +// String message = new String("Fehler beim lesen " + filename + "\n" + e.getMessage()); + //System.out.println(message); + } + this.filename = new String(filename); + try { + init(); + } catch (PropertiesHandlerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + public void loadINI(byte[] content){ + iniHash = new Hashtable>(); + String line = null; + this.iniVector =new Vector<>(); + BufferedReader bufferedReader=null; + InputStream is = null; + + + try { + is = new ByteArrayInputStream(content); + bufferedReader=new BufferedReader(new InputStreamReader(is)); + } catch (Exception e) { + + } + + try { + while((line = bufferedReader.readLine()) != null) { + iniVector.add(line); + //System.out.println(line); + } + // Always close files. + bufferedReader.close(); + + } catch (Exception e) { + + } + try { + init(); + } catch (PropertiesHandlerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Deprecated + public void saveINI(boolean appendToFile){ + + + try { + // Assume default encoding. + //System.out.println("Write to file:"+filename); + FileWriter fileWriter = + new FileWriter(filename,appendToFile); + + // Always wrap FileWriter in BufferedWriter. + BufferedWriter bufferedWriter = + new BufferedWriter(fileWriter); + + // Note that write() does not automatically + // append a newline character. + Set keys = iniHash.keySet(); + for (String key:keys){ + bufferedWriter.write("["+key+"]"); + //System.out.println(key); + bufferedWriter.newLine(); + Hashtable parameters = iniHash.get(key); + Setparam=parameters.keySet(); + for (String par:param){ + bufferedWriter.write(par+"="+parameters.get(par)); + bufferedWriter.newLine(); + } + } + // Always close files. + bufferedWriter.close(); + } catch(IOException ex) { + //System.out.println("Error writing to file '" + filename + "'"); + // Or we could just do this: + ex.printStackTrace(); + } + + } +//test + public StringBuilder saveINI(){ + StringBuilder bufferedWriter = new StringBuilder(); + + // Note that write() does not automatically + // append a newline character. + Set keys = iniHash.keySet(); + for (String key:keys){ + bufferedWriter.append("["+key+"]"); + //System.out.println(key); + bufferedWriter.append(System.lineSeparator()); + Hashtable parameters = iniHash.get(key); + Setparam=parameters.keySet(); + for (String par:param){ + bufferedWriter.append(par+"="+parameters.get(par)); + bufferedWriter.append(System.lineSeparator()); + } + } + return bufferedWriter; + } + +} \ No newline at end of file diff --git a/src/main/java/de/tvo/toolset/PropertiesHandlerException.java b/src/main/java/de/tvo/toolset/PropertiesHandlerException.java new file mode 100644 index 0000000..50cc582 --- /dev/null +++ b/src/main/java/de/tvo/toolset/PropertiesHandlerException.java @@ -0,0 +1,41 @@ +package de.tvo.toolset; + +import org.eclnt.util.log.CLog; + +/** + * DE: + * + * EN: + * + * + * Program changes + * ************************************************************************************** + * Date * Ticket * KonzFirm * Responsible * programmer * Change * + * ************************************************************************************** + * + * @author VogelT + * @version 1.0 + * + */ + +public class PropertiesHandlerException extends Exception { + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * + * @param e Exception Ursprung + * @param message Fehlermeldung + * @param header Meldungstextüberschrift + */ + public PropertiesHandlerException(Exception e, String message, String header) { + + CLog.L.log(CLog.LL_INF, "Exception PropertiesHandlerException " + message + " --> " + header, e.getStackTrace()); + // Menu.fehlerMeldung(message,header); + // Log4jHandler.log(Log.ARGUS, Log.SYSTEM, + // this.getClass().getSimpleName(), e.getStackTrace(), header + + // message); + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/MARIADBNL.cfg.xml b/src/main/resources/META-INF/MARIADBNL.cfg.xml index 45099bc..54f6efe 100644 --- a/src/main/resources/META-INF/MARIADBNL.cfg.xml +++ b/src/main/resources/META-INF/MARIADBNL.cfg.xml @@ -3,19 +3,19 @@ "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> - - vtigercrm + MARIADBNL org.hibernate.dialect.MariaDBDialect java:comp/env/jdbc/mariadbnl - - - + \ No newline at end of file diff --git a/src/main/resources/META-INF/services/javax.xml.soap.MetaFactory b/src/main/resources/META-INF/services/javax.xml.soap.MetaFactory deleted file mode 100644 index fbf3f5c..0000000 --- a/src/main/resources/META-INF/services/javax.xml.soap.MetaFactory +++ /dev/null @@ -1 +0,0 @@ -com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl \ No newline at end of file diff --git a/src/main/resources/META-INF/services/javax.xml.soap.SAAJMetaFactory b/src/main/resources/META-INF/services/javax.xml.soap.SAAJMetaFactory deleted file mode 100644 index fbf3f5c..0000000 --- a/src/main/resources/META-INF/services/javax.xml.soap.SAAJMetaFactory +++ /dev/null @@ -1 +0,0 @@ -com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl \ No newline at end of file diff --git a/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider b/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider deleted file mode 100644 index 22547fd..0000000 --- a/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider +++ /dev/null @@ -1 +0,0 @@ -org.apache.cxf.jaxws.spi.ProviderImpl \ No newline at end of file diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml index 13b3f43..0e65c79 100644 --- a/src/main/webapp/META-INF/context.xml +++ b/src/main/webapp/META-INF/context.xml @@ -9,26 +9,4 @@ will share the same session id cookie - which may have server side problems as consequence. --> - - - - -