Skip to content

Commit

Permalink
Compatibilità con postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Jan 24, 2018
1 parent 6fa09fb commit c204dd0
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ CMD ["./bin/standalone.sh", "-b", "0.0.0.0", "--debug", "8787", "-bmanagement",
COPY src/main/docker/bin/standalone.conf ./standalone-custom.conf
COPY src/main/docker/standalone/configuration/ standalone/configuration/
COPY src/main/docker/domain/configuration/ domain/configuration/
COPY src/main/docker/modules/system/layers/base/com/informix/jdbc/ modules/system/layers/base/com/informix/jdbc/
COPY src/main/docker/modules/system/layers/base/org/postgresql/postgresql/ modules/system/layers/base/org/postgresql/postgresql/
COPY src/main/docker/modules/system/layers/base/com/oracle/jdbc/ modules/system/layers/base/com/oracle/jdbc/
COPY src/main/docker/modules/system/layers/base/com/informix/jdbc/ modules/system/layers/base/com/informix/jdbc/
COPY src/main/docker/modules/system/layers/base/it/cnr/sigla/configuration/main/ modules/system/layers/base/it/cnr/sigla/configuration/main/

EXPOSE 9990
Expand Down
4 changes: 3 additions & 1 deletion SIGLA/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@
<archive>
<manifestEntries>
<Dependencies>
com.oracle.jdbc, org.apache.xerces,
com.oracle.jdbc,
org.postgresql.postgresql,
org.apache.xerces,
org.apache.commons.collections,
org.codehaus.jackson.jackson-mapper-asl,
com.fasterxml.jackson.core.jackson-annotations,
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<sonar.skip>true</sonar.skip>
<java.version>1.8</java.version>
<spring.version>4.3.3.RELEASE</spring.version>
<jada.version>5.0.58</jada.version>
<jada.version>5.0.59</jada.version>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<sigla.build.number>${maven.build.timestamp}</sigla.build.number>
<slf4j.version>1.7.21</slf4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import it.cnr.jada.persistency.sql.LoggableStatement;
import it.cnr.jada.persistency.sql.PersistentHome;
import it.cnr.jada.persistency.sql.SQLBuilder;
import it.cnr.jada.util.PropertyNames;
import it.cnr.jada.util.RemoteIterator;
import it.cnr.jada.util.ejb.EJBCommonServices;

Expand Down Expand Up @@ -405,7 +406,7 @@ public List<SessionTraceBulk> sessionList(UserContext userContext, String cdUten
public void registerUser(UserContext userContext,String id_clone) throws it.cnr.jada.comp.ComponentException {
unregisterUser(userContext);
try {
java.sql.CallableStatement stm = getConnection(userContext).prepareCall("{ call CNRCTB850.register(?,?,?,?,?) }");
java.sql.CallableStatement stm = getConnection(userContext).prepareCall(PropertyNames.getProperty("package.cnrctb850.register"));
stm.setString(1,CNRUserContext.getCd_cds(userContext));
stm.setInt(2,CNRUserContext.getEsercizio(userContext).intValue());
stm.setString(3,CNRUserContext.getUser(userContext));
Expand All @@ -422,7 +423,7 @@ public void registerUser(UserContext userContext,String id_clone) throws it.cnr.
}
public void unregisterUser(UserContext userContext) throws it.cnr.jada.comp.ComponentException {
try {
java.sql.CallableStatement stm = getConnection(userContext).prepareCall("{ call CNRCTB850.unregister(?) }");
java.sql.CallableStatement stm = getConnection(userContext).prepareCall(PropertyNames.getProperty("package.cnrctb850.unregister"));
stm.setString(1,userContext.getSessionId());
try {
stm.execute();
Expand All @@ -436,7 +437,7 @@ public void unregisterUser(UserContext userContext) throws it.cnr.jada.comp.Comp
public void unregisterUsers(String id_clone) throws it.cnr.jada.comp.ComponentException {
try {
Connection conn = it.cnr.jada.util.ejb.EJBCommonServices.getConnection();
java.sql.CallableStatement stm = conn.prepareCall("{ call CNRCTB850.unregisterAll(?) }");
java.sql.CallableStatement stm = conn.prepareCall(PropertyNames.getProperty("package.cnrctb850.unregisterall"));
stm.setString(1,id_clone);
try {
stm.execute();
Expand Down
13 changes: 13 additions & 0 deletions sigla-ejb/src/main/resources/it/cnr/jada/util/oracle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### PACKAGE
package.lock.transaction={ call IBMUTL001.LOCK_TRANSACTION() }
package.unlock.transaction={ call IBMUTL001.UNLOCK_TRANSACTION() }
package.trace.user.connection={ call IBMUTL001.TRACE_USER_CONNECTION(?,?,?)}
package.getdbrefreshdate={? = call IBMUTL001.getDBRefreshDate}
package.cnrctb850.register={ call CNRCTB850.register(?,?,?,?,?) }
package.cnrctb850.unregister={ call CNRCTB850.unregister(?) }
package.cnrctb850.unregisterall={ call CNRCTB850.unregisterAll(?) }

#QUERY SYNTAX
query.date=SELECT TRUNC(SYSDATE) FROM DUAL
query.exists=SELECT 1 FROM DUAL WHERE EXISTS (
query.count.end=)
13 changes: 13 additions & 0 deletions sigla-ejb/src/main/resources/it/cnr/jada/util/postgres.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### PACKAGE
package.lock.transaction={ call IBMUTL001_LOCK_TRANSACTION() }
package.unlock.transaction={ call IBMUTL001_UNLOCK_TRANSACTION() }
package.trace.user.connection={ call IBMUTL001_TRACE_USER_CONNECTION(?,?,?)}
package.getdbrefreshdate={? = call IBMUTL001_getDBRefreshDate() }
package.cnrctb850.register={ call CNRCTB850_register(?,?,?,?,?) }
package.cnrctb850.unregister={ call CNRCTB850_unregister(?) }
package.cnrctb850.unregisterall={ call CNRCTB850_unregisterAll(?) }

#QUERY SYNTAX
query.date=SELECT NOW()
query.exists=SELECT 1 WHERE EXISTS (
query.count.end=) AS COUNT
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.cnr.contab.util.servlet;

import it.cnr.contab.utente00.nav.ejb.GestioneLoginComponentSession;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.contab.utenze00.bulk.SessionTraceBulk;
import it.cnr.jada.UserContext;
Expand All @@ -15,6 +16,7 @@
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Optional;

import javax.ejb.EJBException;
import javax.servlet.ServletException;
Expand Down Expand Up @@ -145,16 +147,23 @@ public void sessionCreated(HttpSessionEvent se) {
}
public void sessionDestroyed(HttpSessionEvent se) {
UserContext userContext = (UserContext) se.getSession().getAttribute("UserContext");
if (userContext != null){
StringBuffer infoUser = new StringBuffer();
infoUser.append("LogOut User:"+userContext.getUser());
log.warn(infoUser.toString());
}
try {
Optional.ofNullable(userContext)
.ifPresent(userContext1 -> {
try {
StringBuffer infoUser = new StringBuffer();
infoUser.append("LogOut User:"+userContext1.getUser());
log.warn(infoUser.toString());
createGestioneLoginComponentSession().unregisterUser(userContext1);
} catch (ComponentException|RemoteException e) {
log.error("", e);
}
});
SessionTraceBulk sessionTrace = (SessionTraceBulk)createCRUDComponentSession().inizializzaBulkPerModifica(new CNRUserContext("SESSIONTRACE",se.getSession().getId(),null,null,null,null), new SessionTraceBulk(se.getSession().getId()));
sessionTrace.setToBeDeleted();
createCRUDComponentSession().eliminaConBulk(new CNRUserContext("SESSIONTRACE",se.getSession().getId(),null,null,null,null), sessionTrace);
} catch (Exception e) {
log.error("", e);
}
HttpEJBCleaner httpejbcleaner = (HttpEJBCleaner)se.getSession().getAttribute("it.cnr.jada.util.ejb.HttpEJBCleaner");
if (httpejbcleaner != null)
Expand All @@ -164,5 +173,8 @@ public void sessionDestroyed(HttpSessionEvent se) {
public CRUDComponentSession createCRUDComponentSession() throws javax.ejb.EJBException,java.rmi.RemoteException {
return (CRUDComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("JADAEJB_CRUDComponentSession");
}


public GestioneLoginComponentSession createGestioneLoginComponentSession() throws javax.ejb.EJBException,java.rmi.RemoteException {
return (GestioneLoginComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRUTENZE00_NAV_EJB_GestioneLoginComponentSession");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- JDBC Drivers module.xml file to configure your JDBC drivers-->
<!-- Postgres example -->
<module xmlns="urn:jboss:module:1.0" name="org.postgresql.postgresql">
<resources>
<resource-root path="postgresql-9.2-1004.jdbc41.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Binary file not shown.
31 changes: 30 additions & 1 deletion src/main/docker/standalone/configuration/standalone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,33 @@
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:/jdbc/CIR" pool-name="OracleDSSIGLAPool" enabled="true" use-java-context="true" statistics-enabled="true">
<datasource jndi-name="java:/jdbc/CIR" pool-name="PostgresDSSIGLAPool" enabled="${env.SIGLA_POSTGRES_ENABLE:false}" use-java-context="true" statistics-enabled="true">
<connection-url>${env.SIGLA_CONNECTION_URL:jdbc:postgresql://localhost:5432/mydb?schema=public}</connection-url>
<driver>postgres</driver>
<new-connection-sql>select 1;</new-connection-sql>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>${env.SIGLA_CONNECTION_USERNAME:sigla}</user-name>
<password>${env.SIGLA_CONNECTION_PASSWORD:siglapw}</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
</datasource>
<datasource jndi-name="java:/jdbc/CIR" pool-name="OracleDSSIGLAPool" enabled="${env.SIGLA_ORACLE_ENABLE:true}" use-java-context="true" statistics-enabled="true">
<connection-url>${env.SIGLA_CONNECTION_URL:jdbc:oracle:thin:@dbtest.cedrc.cnr.it:1521:SIGLAF}</connection-url>
<driver>ojdbc</driver>
<pool>
Expand Down Expand Up @@ -189,6 +215,9 @@
<driver name="informix" module="com.informix.jdbc">
<driver-class>com.informix.jdbc.IfxDriver</driver-class>
</driver>
<driver name="postgres" module="org.postgresql.postgresql">
<driver-class>org.postgresql.Driver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
Expand Down

0 comments on commit c204dd0

Please sign in to comment.