securis/src/main/java/net/curisit/securis/db/Application.java
.. .. @@ -15,6 +15,9 @@ 15 15 import javax.persistence.OneToMany; 16 16 import javax.persistence.Table; 17 17 18 +import org.apache.logging.log4j.LogManager;19 +import org.apache.logging.log4j.Logger;20 +18 21 import com.fasterxml.jackson.annotation.JsonAutoDetect; 19 22 import com.fasterxml.jackson.annotation.JsonIgnore; 20 23 import com.fasterxml.jackson.annotation.JsonInclude; .. .. @@ -33,6 +36,8 @@ 33 36 @NamedQuery(name = "list-applications", query = "SELECT a FROM Application a") 34 37 }) 35 38 public class Application implements Serializable { 39 +40 + private static final Logger LOG = LogManager.getLogger(Application.class);36 41 37 42 private static final long serialVersionUID = 1L; 38 43 .. .. @@ -85,6 +90,7 @@ 85 90 } 86 91 87 92 public Date getCreationTimestamp() { 93 + LOG.info("APP {} TS: {}", this.id, this.creationTimestamp);88 94 return creationTimestamp; 89 95 } 90 96 securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
.. .. @@ -12,6 +12,9 @@ 12 12 import javax.persistence.NamedQuery; 13 13 import javax.persistence.Table; 14 14 15 +import org.apache.logging.log4j.LogManager;16 +import org.apache.logging.log4j.Logger;17 +15 18 import com.fasterxml.jackson.annotation.JsonAutoDetect; 16 19 import com.fasterxml.jackson.annotation.JsonIgnore; 17 20 import com.fasterxml.jackson.annotation.JsonInclude; .. .. @@ -30,6 +33,8 @@ 30 33 @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") 31 34 }) 32 35 public class ApplicationMetadata implements Serializable { 36 +37 + private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class);33 38 34 39 private static final long serialVersionUID = 1L; 35 40 .. .. @@ -68,6 +73,7 @@ 68 73 } 69 74 70 75 public Date getCreationTimestamp() { 76 + LOG.info("APP_MD (app: {}) {} TS: {}", this.application.getId(), this.key, this.creationTimestamp);71 77 return creationTimestamp; 72 78 } 73 79 securis/src/main/java/net/curisit/securis/services/ApplicationResource.java
.. .. @@ -123,8 +123,9 @@ 123 123 if (app.getApplicationMetadata() != null) { 124 124 for (ApplicationMetadata md : app.getApplicationMetadata()) { 125 125 md.setApplication(app); 126 - md.setCreationTimestamp(app.getCreationTimestamp());126 + md.setCreationTimestamp(new Date());127 127 em.persist(md); 128 + LOG.info("Creating METADATA: '{}' -> {}", md.getKey(), md.getCreationTimestamp());128 129 } 129 130 } 130 131 LOG.info("Creating application with date: " + app.getCreationTimestamp()); securis/src/main/resources/META-INF/persistence.xml
.. .. @@ -14,7 +14,9 @@ 14 14 <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> 15 15 <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/SeCurisDS" /> 16 16 17 - <property name="hibernate.show_sql" value="true" />17 +<!-- <property name="hibernate.show_sql" value="true" />18 + <property name="hibernate.format_sql" value="true"/>19 + -->18 20 </properties> 19 21 20 22 </persistence-unit> securis/src/main/resources/db/create_db.sql
.. .. @@ -0,0 +1,7 @@ 1 +create database securis CHARACTER SET utf8 COLLATE utf8_bin;2 +create user securis identified by 'securis';3 +create user securis@localhost identified by 'securis';4 +grant all on securis.* to securis;5 +grant all on securis.* to securis@localhost;6 +#Update passwords7 +flush privileges;securis/src/main/resources/db/schema.sql
.. .. @@ -35,7 +35,7 @@ 35 35 `key` VARCHAR(100) NOT NULL , 36 36 value VARCHAR(200) NULL , 37 37 mandatory BOOLEAN NOT NULL default true, 38 - creation_timestamp DATETIME NOT NULL default now(),38 + creation_timestamp DATETIME NULL default now(),39 39 PRIMARY KEY (application_id, `key`)); 40 40 41 41 securis/src/main/resources/log4j2.xml
.. .. @@ -1,42 +1,49 @@ 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <Configuration> 3 - <Appenders>3 + <Appenders>4 4 5 - <RollingFile name="defaultFile" fileName="${sys:user.home}/.SeCuris/logs/securis-server.log" append="true"6 - filePattern="${sys:user.home}/.SeCuris/logs/securis-server-%d{yyyy-MM-dd-HH}.log.gz">7 - <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>8 - <Policies>9 - <TimeBasedTriggeringPolicy interval="1" modulate="true" />10 - </Policies>11 - <DefaultRolloverStrategy max="10"/>12 - </RollingFile>13 - <Async name="defaultFileAsync" includeLocation="true">14 - <AppenderRef ref="defaultFile"/>15 - </Async>16 -17 - <Console name="stdout" target="SYSTEM_OUT">18 - <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>19 - </Console>5 + <RollingFile name="defaultFile"6 + fileName="${sys:user.home}/.SeCuris/logs/securis-server.log" append="true"7 + filePattern="${sys:user.home}/.SeCuris/logs/securis-server-%d{yyyy-MM-dd-HH}.log.gz">8 + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />9 + <Policies>10 + <TimeBasedTriggeringPolicy interval="1"11 + modulate="true" />12 + </Policies>13 + <DefaultRolloverStrategy max="10" />14 + </RollingFile>15 + <Async name="defaultFileAsync" includeLocation="true">16 + <AppenderRef ref="defaultFile" />17 + </Async>20 18 21 - <Console name="console" target="SYSTEM_OUT">22 - <PatternLayout pattern="%m%n"/>23 - </Console>19 + <Console name="stdout" target="SYSTEM_OUT">20 + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />21 + </Console>24 22 25 - </Appenders>26 - <Loggers>27 -28 - <Logger name="net.curisit" level="INFO" additivity="false">29 - <AppenderRef ref="defaultFileAsync"/>30 - <AppenderRef ref="stdout"/>31 - </Logger>32 -33 - <Logger name="console" level="INFO" additivity="false">34 - <AppenderRef ref="console"/>35 - </Logger>36 -37 - <Root level="INFO" >38 - <AppenderRef ref="stdout"/>39 - </Root>23 + <Console name="console" target="SYSTEM_OUT">24 + <PatternLayout pattern="%m%n" />25 + </Console>40 26 41 - </Loggers>27 + </Appenders>28 + <Loggers>29 +30 + <Logger name="net.curisit" level="INFO" additivity="false">31 + <AppenderRef ref="defaultFileAsync" />32 + <AppenderRef ref="stdout" />33 + </Logger>34 +35 + <Logger name="console" level="INFO" additivity="false">36 + <AppenderRef ref="console" />37 + </Logger>38 +39 +<!-- <logger name="org.hibernate.type.descriptor.sql.BasicBinder"40 + level="TRACE" additivity="false">41 + <appender-ref ref="stdout" />42 + </logger> -->43 +44 + <Root level="INFO">45 + <AppenderRef ref="stdout" />46 + </Root>47 +48 + </Loggers>42 49 </Configuration>