Merge pull request 'bug_23381' (#4) from bug_23381 into master
Reviewed-on: #4
This commit is contained in:
commit
458df96496
|
@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-service
|
||||
|
||||
|
||||
## [v1.0.9] 2021-09-20
|
||||
- Fixes [#23381](https://support.d4science.org/issues/23381)
|
||||
|
||||
## [v1.0.8] 2021-09-20
|
||||
- Logging
|
||||
- Fixes [#22193](https://support.d4science.org/issues/22193)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-service</artifactId>
|
||||
<version>1.0.8</version>
|
||||
<version>1.0.9</version>
|
||||
<name>Geoportal Service</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
@ -85,11 +85,13 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
<version>1.0.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-plugin-framework</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -216,6 +218,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>concessioni-lifecycle</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -240,6 +243,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -17,49 +17,57 @@ import java.util.regex.Pattern;
|
|||
@Slf4j
|
||||
public class PostgisDBManager implements PostgisDBManagerI {
|
||||
|
||||
@Synchronized
|
||||
public static PostgisDBManager get() throws SQLException, ConfigurationException {
|
||||
if(config==null) {
|
||||
log.debug("Looking for Default Configuration.. ");
|
||||
// @Synchronized
|
||||
// public static PostgisDBManager get() throws SQLException, ConfigurationException {
|
||||
// if(config==null) {
|
||||
// log.debug("Looking for Default Configuration.. ");
|
||||
//
|
||||
// // TODO GENERIC
|
||||
// DatabaseConnection defaultConfiguration=
|
||||
// ImplementationProvider.get().getIsProvider().getIS().queryForDB("postgis", "Concessioni");
|
||||
//
|
||||
// log.debug("Found configuration : "+defaultConfiguration);
|
||||
// config=defaultConfiguration;
|
||||
// }
|
||||
// return new PostgisDBManager();
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
// TODO GENERIC
|
||||
DatabaseConnection defaultConfiguration=
|
||||
|
||||
public static PostgisDBManagerI get() throws SQLException, ConfigurationException {
|
||||
return get(false);
|
||||
}
|
||||
|
||||
private static PostgisDBManagerI get(boolean autocommit) throws SQLException, ConfigurationException {
|
||||
DatabaseConnection config=
|
||||
ImplementationProvider.get().getIsProvider().getIS().queryForDB("postgis", "Concessioni");
|
||||
|
||||
log.debug("Found configuration : "+defaultConfiguration);
|
||||
config=defaultConfiguration;
|
||||
}
|
||||
return new PostgisDBManager();
|
||||
}
|
||||
public static PostgisDBManagerI get(boolean autocommit) throws SQLException, ConfigurationException {
|
||||
PostgisDBManager toReturn=get();
|
||||
log.debug("Found configuration : "+config);
|
||||
PostgisDBManager toReturn=new PostgisDBManager(config);
|
||||
toReturn.conn.setAutoCommit(autocommit);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static DatabaseConnection config;
|
||||
|
||||
|
||||
// private static DatabaseConnection config;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static Connection getConnection() throws SQLException {
|
||||
|
||||
Connection toReturn= DriverManager.getConnection(config.getUrl(),config.getUser(),config.getPwd());
|
||||
|
||||
//TODO configure behaviour
|
||||
toReturn.setAutoCommit(false);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Connection conn=null;
|
||||
private DatabaseConnection config;
|
||||
|
||||
private PostgisDBManager(DatabaseConnection config) throws SQLException {
|
||||
this.config=config;
|
||||
log.info("Opening connection to {}",config);
|
||||
conn= DriverManager.getConnection(config.getUrl(),config.getUser(),config.getPwd());
|
||||
|
||||
private PostgisDBManager() throws SQLException {
|
||||
conn=getConnection();
|
||||
//TODO configure behaviour
|
||||
conn.setAutoCommit(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class PostgisIndex {
|
|||
|
||||
private SDIManager sdiManager;
|
||||
private String wmsLink=null;
|
||||
private static PostgisDBManager getDB() throws ConfigurationException {
|
||||
private static PostgisDBManagerI getDB() throws ConfigurationException {
|
||||
return ImplementationProvider.get().getDbProvider().getObject();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
package org.gcube.application.geoportal.service.engine.providers;
|
||||
|
||||
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager;
|
||||
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManagerI;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManager>{
|
||||
public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManagerI>{
|
||||
|
||||
|
||||
public PostgisConnectionProvider() {
|
||||
super("Postgis connection descriptor cache");
|
||||
setTTL(Duration.of(30, ChronoUnit.SECONDS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PostgisDBManager retrieveObject() throws ConfigurationException {
|
||||
protected PostgisDBManagerI retrieveObject() throws ConfigurationException {
|
||||
try {
|
||||
return PostgisDBManager.get();
|
||||
} catch (SQLException throwables) {
|
||||
|
@ -22,7 +26,7 @@ public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManage
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void dispose(PostgisDBManager toDispose) {
|
||||
protected void dispose(PostgisDBManagerI toDispose) {
|
||||
// toDispose.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue