Merged from patches

This commit is contained in:
Fabio Sinibaldi 2022-05-27 15:04:35 +02:00
parent f1b7790cda
commit 4d52bf7123
3 changed files with 14 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.service.engine.mongo.UCDManagerI; import org.gcube.application.geoportal.service.engine.mongo.UCDManagerI;
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager; import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager;
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManagerI;
import org.gcube.application.geoportal.service.engine.providers.*; import org.gcube.application.geoportal.service.engine.providers.*;
import org.gcube.application.geoportal.service.engine.providers.ucd.ProfileMap; import org.gcube.application.geoportal.service.engine.providers.ucd.ProfileMap;
import org.gcube.application.geoportal.service.engine.providers.ucd.LocalFolderProfileMapCache; import org.gcube.application.geoportal.service.engine.providers.ucd.LocalFolderProfileMapCache;
@ -50,7 +51,7 @@ public class GeoPortalService extends ResourceConfig{
ImplementationProvider.get().setEngine(new MongoClientProvider(), Mongo.class); ImplementationProvider.get().setEngine(new MongoClientProvider(), Mongo.class);
ImplementationProvider.get().setEngine(new StorageClientProvider(), StorageUtils.class); ImplementationProvider.get().setEngine(new StorageClientProvider(), StorageUtils.class);
ImplementationProvider.get().setEngine(new PostgisConnectionProvider(), PostgisDBManager.class); ImplementationProvider.get().setEngine(new PostgisConnectionProvider(), PostgisDBManagerI.class);
ImplementationProvider.get().setEngine(new SingleISResourceUCDProvider(), ProfileMap.class); ImplementationProvider.get().setEngine(new SingleISResourceUCDProvider(), ProfileMap.class);
ImplementationProvider.get().setEngine(new PluginManager(), PluginManager.PluginMap.class); ImplementationProvider.get().setEngine(new PluginManager(), PluginManager.PluginMap.class);
ImplementationProvider.get().setEngine(new StorageHubProvider(), StorageHubClient.class); ImplementationProvider.get().setEngine(new StorageHubProvider(), StorageHubClient.class);

View File

@ -1,19 +1,19 @@
package org.gcube.application.geoportal.service.engine.postgis; package org.gcube.application.geoportal.service.engine.postgis;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection; import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
import org.gcube.application.geoportal.common.model.rest.PostgisIndexDescriptor; import org.gcube.application.geoportal.common.model.rest.PostgisIndexDescriptor;
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
import org.gcube.application.geoportal.service.engine.materialization.SDIManager; import org.gcube.application.geoportal.service.engine.materialization.SDIManager;
import org.gcube.application.geoportal.service.model.internal.db.DBConstants; import org.gcube.application.geoportal.service.model.internal.db.DBConstants;
import org.gcube.application.geoportal.service.model.internal.db.PostgisTable; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable;
import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.Field; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.Field;
import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.FieldType; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.FieldType;
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
import org.gcube.application.geoportal.service.model.internal.faults.PublishException; import org.gcube.application.geoportal.service.model.internal.faults.PublishException;
import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException; import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException;
import org.gcube.application.geoportal.service.utils.Serialization;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
@ -39,7 +39,7 @@ public class PostgisIndex {
private SDIManager sdiManager; private SDIManager sdiManager;
private String wmsLink=null; private String wmsLink=null;
private static PostgisDBManagerI getDB() throws ConfigurationException { private static PostgisDBManagerI getDB() throws ConfigurationException {
return ImplementationProvider.get().getDbProvider().getObject(); return ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class);
}; };
public PostgisIndex() throws SDIInteractionException, SQLException, ConfigurationException { public PostgisIndex() throws SDIInteractionException, SQLException, ConfigurationException {
@ -60,7 +60,7 @@ public class PostgisIndex {
public String init() throws SQLException, ConfigurationException, SDIInteractionException { public String init() throws SQLException, ConfigurationException, SDIInteractionException {
log.debug("Contacting postgis DB .. "); log.debug("Contacting postgis DB .. ");
PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class);
log.debug("Checking if centroids table exists.."); log.debug("Checking if centroids table exists..");
PostgisTable table=getCentroidsTable(); PostgisTable table=getCentroidsTable();
db.create(table); db.create(table);
@ -77,7 +77,7 @@ public class PostgisIndex {
Map<String,String> centroidRow=evaluateCentroid(record); Map<String,String> centroidRow=evaluateCentroid(record);
log.debug("Contacting postgis DB .. "); log.debug("Contacting postgis DB .. ");
PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class);
PostgisTable centroidsTable=getCentroidsTable(); PostgisTable centroidsTable=getCentroidsTable();
log.debug("Inserting / updated centroid Row {} ",centroidRow); log.debug("Inserting / updated centroid Row {} ",centroidRow);
@ -107,7 +107,7 @@ public class PostgisIndex {
public void removeCentroid(Concessione record) { public void removeCentroid(Concessione record) {
try { try {
PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class);
PostgisTable centroidsTable=getCentroidsTable(); PostgisTable centroidsTable=getCentroidsTable();
log.debug("Deleting centroid if present. ID is "+record.getMongo_id()); log.debug("Deleting centroid if present. ID is "+record.getMongo_id());
int result= db.deleteByFieldValue(centroidsTable, new Field(DBConstants.Concessioni.PRODUCT_ID,FieldType.TEXT), record.getMongo_id()); int result= db.deleteByFieldValue(centroidsTable, new Field(DBConstants.Concessioni.PRODUCT_ID,FieldType.TEXT), record.getMongo_id());
@ -164,7 +164,7 @@ public class PostgisIndex {
centroidsRow.put(DBConstants.Concessioni.FINANZIAMENTO,asString(record.getFontiFinanziamento())); centroidsRow.put(DBConstants.Concessioni.FINANZIAMENTO,asString(record.getFontiFinanziamento()));
centroidsRow.put(DBConstants.Concessioni.SOGGETTO,asString(record.getSoggetto())); centroidsRow.put(DBConstants.Concessioni.SOGGETTO,asString(record.getSoggetto()));
centroidsRow.put(DBConstants.Concessioni.RISORSE,asString(record.getRisorseCorrelate())); centroidsRow.put(DBConstants.Concessioni.RISORSE,asString(record.getRisorseCorrelate()));
centroidsRow.put(DBConstants.Concessioni.DATE_SCAVO,Serialization.FULL_FORMATTER.format(record.getDataFineProgetto())); centroidsRow.put(DBConstants.Concessioni.DATE_SCAVO, Serialization.FULL_FORMATTER.format(record.getDataFineProgetto()));
centroidsRow.put(DBConstants.Concessioni.DATA_ARCHIVIAZIONE,Serialization.FULL_FORMATTER.format(record.getLastUpdateTime())); centroidsRow.put(DBConstants.Concessioni.DATA_ARCHIVIAZIONE,Serialization.FULL_FORMATTER.format(record.getLastUpdateTime()));
centroidsRow.put(DBConstants.Concessioni.VERSIONE,record.getVersion()); centroidsRow.put(DBConstants.Concessioni.VERSIONE,record.getVersion());
centroidsRow.put(DBConstants.Concessioni.LICENZA,record.getLicenzaID()); centroidsRow.put(DBConstants.Concessioni.LICENZA,record.getLicenzaID());

View File

@ -1,14 +1,15 @@
package org.gcube.application.geoportal.service.engine.providers; package org.gcube.application.geoportal.service.engine.providers;
import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager; import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager;
import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManagerI; 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.sql.SQLException;
import java.time.Duration; import java.time.Duration;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManagerI>{ public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManagerI> {
public PostgisConnectionProvider() { public PostgisConnectionProvider() {
@ -17,7 +18,7 @@ public class PostgisConnectionProvider extends AbstractScopedMap<PostgisDBManage
} }
@Override @Override
protected PostgisDBManagerI retrieveObject() throws ConfigurationException { protected PostgisDBManagerI retrieveObject(String key) throws ConfigurationException {
try { try {
return PostgisDBManager.get(); return PostgisDBManager.get();
} catch (SQLException throwables) { } catch (SQLException throwables) {