Added Guava Cache for gcubeProfiles Per UCD_ID
This commit is contained in:
parent
aba4e0dca0
commit
7647628716
|
@ -6,7 +6,6 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
|
||||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery.ImagesSectionGallery;
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery.ImagesSectionGallery;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||||
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
|
||||||
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.cache.RemovalListener;
|
||||||
|
import com.google.common.cache.RemovalNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class GcubeProfilesPerUCDIdCache.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Oct 12, 2022
|
||||||
|
*/
|
||||||
|
public class GcubeProfilesPerUCDIdCache {
|
||||||
|
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(GcubeProfilesPerUCDIdCache.class);
|
||||||
|
|
||||||
|
private static LoadingCache<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> gCubeProfilesPerProfileIDCache;
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
CacheLoader<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> loader = new CacheLoader<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>>() {
|
||||||
|
@Override
|
||||||
|
public LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> load(String scope) throws Exception {
|
||||||
|
LOG.info("Loading the cache for scope: " + scope);
|
||||||
|
return loadGcubeProfilesForUCDIdInTheScope(scope);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
RemovalListener<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> removalListener = new RemovalListener<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>>() {
|
||||||
|
public void onRemoval(
|
||||||
|
RemovalNotification<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> removal) {
|
||||||
|
LOG.debug("cache expired");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gCubeProfilesPerProfileIDCache = CacheBuilder.newBuilder().maximumSize(1000)
|
||||||
|
.expireAfterWrite(15, TimeUnit.MINUTES).removalListener(removalListener).build(loader);
|
||||||
|
|
||||||
|
LOG.info("cache instancied");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the.
|
||||||
|
*
|
||||||
|
* @param scope the scope
|
||||||
|
* @return the geonetwork instance
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> get(String scope) throws Exception {
|
||||||
|
LOG.info("GcubeProfilesPerUCDIdCache get - called in the scope: " + scope);
|
||||||
|
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> map = gCubeProfilesPerProfileIDCache.get(scope);
|
||||||
|
LOG.info("GcubeProfilesPerUCDIdCache returning map null? " + (map==null));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load geonetwork instance.
|
||||||
|
*
|
||||||
|
* @param scope the scope
|
||||||
|
* @return the linked hash map
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
private static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> loadGcubeProfilesForUCDIdInTheScope(
|
||||||
|
String scope) throws Exception {
|
||||||
|
LOG.info("loadGcubeProfilesForUCDIdInTheScope called in the scope: " + scope);
|
||||||
|
|
||||||
|
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
|
||||||
|
try {
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||||
|
List<UseCaseDescriptor> listUCDs = clientUCD.getList();
|
||||||
|
LOG.debug("listUCDs: " + listUCDs);
|
||||||
|
|
||||||
|
for (UseCaseDescriptor ucd : listUCDs) {
|
||||||
|
|
||||||
|
LOG.info("Loaded UCD for ID: " + ucd.getId());
|
||||||
|
String profileID = ucd.getId();
|
||||||
|
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
||||||
|
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
||||||
|
|
||||||
|
if (handlers.size() == 0) {
|
||||||
|
LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loading Handler gcube_profiles
|
||||||
|
HandlerDeclaration dataEntryHandler = handlers.get(0);
|
||||||
|
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
||||||
|
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||||
|
|
||||||
|
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
|
||||||
|
LOG.debug("" + handlerGcubeProfiles);
|
||||||
|
|
||||||
|
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
||||||
|
// List of gCube Profiles defined in the UCD
|
||||||
|
List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
|
||||||
|
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
||||||
|
|
||||||
|
List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
|
||||||
|
// Loading Metadata Profile from IS
|
||||||
|
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
||||||
|
|
||||||
|
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
|
||||||
|
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(scope,
|
||||||
|
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
||||||
|
|
||||||
|
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
||||||
|
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
||||||
|
gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
|
||||||
|
gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
|
||||||
|
listProfilesBean.add(gCubeProfileMetadataForUCD);
|
||||||
|
|
||||||
|
}
|
||||||
|
linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
|
||||||
|
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
|
||||||
|
LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
|
||||||
|
LOG.error(erroMsg, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("GcubeProfilesPerUCDIdCache loaded with " + linkedMap_UCDId_gCubeProfiles.size() + " item/s");
|
||||||
|
return linkedMap_UCDId_gCubeProfiles;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,5 @@ public class GeoportalDataViewerHttpSessionListener implements HttpSessionListen
|
||||||
@Override
|
@Override
|
||||||
public void sessionCreated(HttpSessionEvent arg0) {
|
public void sessionCreated(HttpSessionEvent arg0) {
|
||||||
LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId());
|
LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId());
|
||||||
|
|
||||||
new GeoportalDataViewerServiceImpl().preloadgCubeProfilesForUCDs();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,17 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import javax.servlet.ServletConfig;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
|
||||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
|
||||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
|
||||||
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
||||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||||
|
@ -25,14 +24,11 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||||
|
@ -56,7 +52,6 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
||||||
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
||||||
|
@ -68,6 +63,7 @@ import org.json.JSONArray;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
@ -87,13 +83,13 @@ import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
|
||||||
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
|
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
|
||||||
|
|
||||||
public static final String PRODUCT_ID = "product_id";
|
public static final String PRODUCT_ID = "product_id";
|
||||||
/** The Constant LOG. */
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
|
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
|
||||||
|
|
||||||
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
||||||
|
|
||||||
public static final String JSON_$_POINTER = "$";
|
public static final String JSON_$_POINTER = "$";
|
||||||
|
|
||||||
public static enum COMMON_IMAGES_FORMAT {
|
public static enum COMMON_IMAGES_FORMAT {
|
||||||
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
|
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
|
||||||
}
|
}
|
||||||
|
@ -275,8 +271,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
|
return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the concessione for id.
|
* Gets the concessione for id.
|
||||||
*
|
*
|
||||||
|
@ -290,109 +284,92 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
throw new Exception("getConcessioneForId must be removed!");
|
throw new Exception("getConcessioneForId must be removed!");
|
||||||
/*
|
/*
|
||||||
ConcessioneDV concessionDV = null;
|
* ConcessioneDV concessionDV = null;
|
||||||
|
*
|
||||||
if (mongoId == null)
|
* if (mongoId == null) throw new
|
||||||
throw new Exception("Invalid parameter. The itemId is null");
|
* Exception("Invalid parameter. The itemId is null");
|
||||||
|
*
|
||||||
try {
|
* try { LOG.info("Trying to get record for id " + mongoId);
|
||||||
LOG.info("Trying to get record for id " + mongoId);
|
*
|
||||||
|
* GeoportalServiceIdentityProxy cms = new
|
||||||
GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
* GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); Concessione
|
||||||
Concessione concessione = cms.getItemById(mongoId);
|
* concessione = cms.getItemById(mongoId);
|
||||||
|
*
|
||||||
LOG.info("Got concessione for mongoId: " + mongoId);
|
* LOG.info("Got concessione for mongoId: " + mongoId); if (concessione != null)
|
||||||
if (concessione != null) {
|
* { concessionDV = ConvertToDataViewModel.toConcessione(concessione);
|
||||||
concessionDV = ConvertToDataViewModel.toConcessione(concessione);
|
*
|
||||||
|
* String userName = null; try { userName =
|
||||||
String userName = null;
|
* SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||||
try {
|
*
|
||||||
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
* } catch (Exception e) {
|
||||||
|
* LOG.info("User not found in session, so going to apply the acess policies");
|
||||||
} catch (Exception e) {
|
* }
|
||||||
LOG.info("User not found in session, so going to apply the acess policies");
|
*
|
||||||
}
|
* // TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE
|
||||||
|
* MOMENT, // A USER AUTHENTICATED CAN ACCESS EVERYTHING // I CAN CHECK THE
|
||||||
// TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT,
|
* ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. if (userName ==
|
||||||
// A USER AUTHENTICATED CAN ACCESS EVERYTHING
|
* null) {
|
||||||
// I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN.
|
*
|
||||||
if (userName == null) {
|
* // CHECKING ACCESS POLICY
|
||||||
|
* LOG.info("Applying access policies for concessione " + mongoId +
|
||||||
// CHECKING ACCESS POLICY
|
* " returned by service"); LayerConcessioneDV layerPosizionamento =
|
||||||
LOG.info("Applying access policies for concessione " + mongoId + " returned by service");
|
* concessionDV.getPosizionamentoScavo(); if (layerPosizionamento != null) { if
|
||||||
LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo();
|
* (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(),
|
||||||
if (layerPosizionamento != null) {
|
* userName)) { concessionDV.setPosizionamentoScavo(null);
|
||||||
if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) {
|
* LOG.info("Posizionamento di Scavo is not accessible by current user: " +
|
||||||
concessionDV.setPosizionamentoScavo(null);
|
* userName); } }
|
||||||
LOG.info("Posizionamento di Scavo is not accessible by current user: " + userName);
|
*
|
||||||
}
|
* List<LayerConcessioneDV> listLayersDV = concessionDV.getPianteFineScavo(); if
|
||||||
}
|
* (listLayersDV != null) { List<LayerConcessioneDV> accessibleListLayersDV =
|
||||||
|
* new ArrayList<LayerConcessioneDV>(); for (LayerConcessioneDV layerDV :
|
||||||
List<LayerConcessioneDV> listLayersDV = concessionDV.getPianteFineScavo();
|
* listLayersDV) { if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(),
|
||||||
if (listLayersDV != null) {
|
* userName)) { accessibleListLayersDV.add(layerDV); } else {
|
||||||
List<LayerConcessioneDV> accessibleListLayersDV = new ArrayList<LayerConcessioneDV>();
|
* LOG.info("(Pianta) Layer " + layerDV.getLayerName() +
|
||||||
for (LayerConcessioneDV layerDV : listLayersDV) {
|
* " is not accessible by current user: " + userName); } }
|
||||||
if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) {
|
* concessionDV.setPianteFineScavo(accessibleListLayersDV); }
|
||||||
accessibleListLayersDV.add(layerDV);
|
*
|
||||||
} else {
|
* AbstractRelazioneScavoDV abstractRS =
|
||||||
LOG.info("(Pianta) Layer " + layerDV.getLayerName()
|
* concessionDV.getAbstractRelazioneScavo(); if (abstractRS != null) { if
|
||||||
+ " is not accessible by current user: " + userName);
|
* (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) {
|
||||||
}
|
* concessionDV.setAbstractRelazioneScavo(null);
|
||||||
}
|
* LOG.info("Abstract relazione is not accessible by current user: " +
|
||||||
concessionDV.setPianteFineScavo(accessibleListLayersDV);
|
* userName); } }
|
||||||
}
|
*
|
||||||
|
* RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo(); if
|
||||||
AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo();
|
* (relazioneScavo != null) { if
|
||||||
if (abstractRS != null) {
|
* (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName))
|
||||||
if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) {
|
* { concessionDV.setRelazioneScavo(null);
|
||||||
concessionDV.setAbstractRelazioneScavo(null);
|
* LOG.info("Relazione scavo is not accessible by current user: " + userName); }
|
||||||
LOG.info("Abstract relazione is not accessible by current user: " + userName);
|
* }
|
||||||
}
|
*
|
||||||
}
|
* List<UploadedImageDV> immagini = concessionDV.getImmaginiRappresentative();
|
||||||
|
* if (immagini != null && immagini.size() > 0) { List<UploadedImageDV>
|
||||||
RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo();
|
* accessibleListImages = new ArrayList<UploadedImageDV>();
|
||||||
if (relazioneScavo != null) {
|
*
|
||||||
if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) {
|
* // SHOWING ACESSIBLE IMAGES for (UploadedImageDV uploadedImageDV : immagini)
|
||||||
concessionDV.setRelazioneScavo(null);
|
* {
|
||||||
LOG.info("Relazione scavo is not accessible by current user: " + userName);
|
*
|
||||||
}
|
* if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(),
|
||||||
}
|
* userName)) { accessibleListImages.add(uploadedImageDV); } else {
|
||||||
|
* LOG.info("Immagine " + uploadedImageDV.getTitolo() +
|
||||||
List<UploadedImageDV> immagini = concessionDV.getImmaginiRappresentative();
|
* " is not accessible by current user: " + userName); }
|
||||||
if (immagini != null && immagini.size() > 0) {
|
*
|
||||||
List<UploadedImageDV> accessibleListImages = new ArrayList<UploadedImageDV>();
|
* } concessionDV.setImmaginiRappresentative(accessibleListImages);
|
||||||
|
*
|
||||||
// SHOWING ACESSIBLE IMAGES
|
* }
|
||||||
for (UploadedImageDV uploadedImageDV : immagini) {
|
*
|
||||||
|
* // END CHECKING ACCESS POLICY LOG.info("Access policies applied"); } }
|
||||||
if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) {
|
*
|
||||||
accessibleListImages.add(uploadedImageDV);
|
* if (concessionDV == null) throw new Exception("Concessione with id '" +
|
||||||
} else {
|
* mongoId + "' not available");
|
||||||
LOG.info("Immagine " + uploadedImageDV.getTitolo()
|
*
|
||||||
+ " is not accessible by current user: " + userName);
|
* LOG.debug("For id " + mongoId + " returning " +
|
||||||
}
|
* ConcessioneDV.class.getSimpleName() + ": " + concessionDV); return
|
||||||
|
* concessionDV;
|
||||||
}
|
*
|
||||||
concessionDV.setImmaginiRappresentative(accessibleListImages);
|
* } catch (Exception e) { String erroMsg = Concessione.class.getSimpleName() +
|
||||||
|
* " with id '" + mongoId + "' not available"; LOG.error(erroMsg, e); throw new
|
||||||
}
|
* Exception(erroMsg); }
|
||||||
|
|
||||||
// END CHECKING ACCESS POLICY
|
|
||||||
LOG.info("Access policies applied");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (concessionDV == null)
|
|
||||||
throw new Exception("Concessione with id '" + mongoId + "' not available");
|
|
||||||
|
|
||||||
LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV);
|
|
||||||
return concessionDV;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available";
|
|
||||||
LOG.error(erroMsg, e);
|
|
||||||
throw new Exception(erroMsg);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,47 +605,41 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
|
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
|
||||||
|
|
||||||
throw new Exception("getUploadedImagesForId must be revisited");
|
throw new Exception("getUploadedImagesForId must be revisited");
|
||||||
|
|
||||||
/*if (itemType == null)
|
|
||||||
throw new Exception("Invalid parameter. The itemType is null");
|
|
||||||
|
|
||||||
if (itemId == null)
|
/*
|
||||||
throw new Exception("Invalid parameter. The itemId is null");
|
* if (itemType == null) throw new
|
||||||
|
* Exception("Invalid parameter. The itemType is null");
|
||||||
List<UploadedImageDV> listUI = null;
|
*
|
||||||
|
* if (itemId == null) throw new
|
||||||
try {
|
* Exception("Invalid parameter. The itemId is null");
|
||||||
|
*
|
||||||
if (itemType.equalsIgnoreCase("concessione")) {
|
* List<UploadedImageDV> listUI = null;
|
||||||
|
*
|
||||||
LOG.info("Trying to get concessione for id " + itemId);
|
* try {
|
||||||
GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(httpServletRequest);
|
*
|
||||||
Concessione concessione = cms.getItemById(itemId);
|
* if (itemType.equalsIgnoreCase("concessione")) {
|
||||||
if (concessione != null) {
|
*
|
||||||
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
|
* LOG.info("Trying to get concessione for id " + itemId);
|
||||||
List<UploadedImage> images = concessione.getImmaginiRappresentative();
|
* GeoportalServiceIdentityProxy cms = new
|
||||||
|
* GeoportalServiceIdentityProxy(httpServletRequest); Concessione concessione =
|
||||||
if (images != null) {
|
* cms.getItemById(itemId); if (concessione != null) { LOG.info("For id " +
|
||||||
listUI = new ArrayList<UploadedImageDV>();
|
* itemId + ", got concessione " + concessione.getNome() + " from service");
|
||||||
int max = maxImages < images.size() ? maxImages : images.size();
|
* List<UploadedImage> images = concessione.getImmaginiRappresentative();
|
||||||
for (int i = 0; i < max; i++) {
|
*
|
||||||
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
|
* if (images != null) { listUI = new ArrayList<UploadedImageDV>(); int max =
|
||||||
listUI.add(ui);
|
* maxImages < images.size() ? maxImages : images.size(); for (int i = 0; i <
|
||||||
}
|
* max; i++) { UploadedImageDV ui =
|
||||||
LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s");
|
* ConvertToDataViewModel.toUploadedImage(images.get(i)); listUI.add(ui); }
|
||||||
}
|
* LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); } }
|
||||||
} else
|
* else throw new Exception("Concessione with id '" + itemId +
|
||||||
throw new Exception("Concessione with id '" + itemId + "' not available");
|
* "' not available"); }
|
||||||
}
|
*
|
||||||
|
* return listUI;
|
||||||
return listUI;
|
*
|
||||||
|
* } catch (Exception e) { String erroMsg = UploadedImage.class.getSimpleName()
|
||||||
} catch (Exception e) {
|
* + " not available for " + Concessione.class.getSimpleName() + " with id " +
|
||||||
String erroMsg = UploadedImage.class.getSimpleName() + " not available for "
|
* itemId; LOG.error(erroMsg, e); throw new Exception(erroMsg); }
|
||||||
+ Concessione.class.getSimpleName() + " with id " + itemId;
|
*/
|
||||||
LOG.error(erroMsg, e);
|
|
||||||
throw new Exception(erroMsg);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +676,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
return profile.getListItemFields();
|
return profile.getListItemFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -738,11 +709,30 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
super.init(config);
|
||||||
|
LOG.info("init called");
|
||||||
|
//Init one GcubeProfilesPerUCDIdCache for the application
|
||||||
|
new GcubeProfilesPerUCDIdCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBeforeRequestDeserialized(String serializedRequest) {
|
||||||
|
LOG.info("onBeforeRequestDeserialized called");
|
||||||
|
String scope = "";
|
||||||
|
try {
|
||||||
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||||
|
scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
|
//Loading GcubeProfilesPerUCDIdCache per scope
|
||||||
|
GcubeProfilesPerUCDIdCache.get(scope);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error on loading the " + GcubeProfilesPerUCDIdCache.class.getSimpleName() + " for scope: "+scope, e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
super.onBeforeRequestDeserialized(serializedRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list concessioni.
|
* Gets the list concessioni.
|
||||||
*
|
*
|
||||||
|
@ -783,81 +773,79 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Preloadg cube profiles for UC ds.
|
// * Preloadg cube profiles for UC ds.
|
||||||
*/
|
// */
|
||||||
public void preloadgCubeProfilesForUCDs() {
|
// public void preloadgCubeProfilesForUCDs() {
|
||||||
LOG.info("preloadgCubeProfilesForUCDs called");
|
// LOG.info("preloadgCubeProfilesForUCDs called");
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
String currentContext = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
// String currentContext = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
LOG.info("preloadgCubeProfilesForUCDs context: "+currentContext);
|
// LOG.info("preloadgCubeProfilesForUCDs context: " + currentContext);
|
||||||
UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
// UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
// SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
List<UseCaseDescriptor> listUCDs = clientUCD.getList();
|
// List<UseCaseDescriptor> listUCDs = clientUCD.getList();
|
||||||
LOG.debug("listUCDs: "+listUCDs);
|
// LOG.debug("listUCDs: " + listUCDs);
|
||||||
|
//
|
||||||
for (UseCaseDescriptor ucd : listUCDs) {
|
// for (UseCaseDescriptor ucd : listUCDs) {
|
||||||
|
//
|
||||||
|
// LOG.info("Loaded UCD for ID: " + ucd.getId());
|
||||||
|
// String profileID = ucd.getId();
|
||||||
|
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
||||||
|
// List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
||||||
|
//
|
||||||
|
// if (handlers.size() == 0) {
|
||||||
|
// LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Loading Handler gcube_profiles
|
||||||
|
// HandlerDeclaration dataEntryHandler = handlers.get(0);
|
||||||
|
// HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
||||||
|
// .toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||||
|
//
|
||||||
|
// LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
|
||||||
|
// LOG.debug("" + handlerGcubeProfiles);
|
||||||
|
//
|
||||||
|
// ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
||||||
|
// // List of gCube Profiles defined in the UCD
|
||||||
|
// List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
|
||||||
|
// LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
||||||
|
//
|
||||||
|
// List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
|
||||||
|
// // Loading Metadata Profile from IS
|
||||||
|
// MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
||||||
|
//
|
||||||
|
// LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
|
||||||
|
// for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||||
|
// String context = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
|
// GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
|
||||||
|
// List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(context,
|
||||||
|
// gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
||||||
|
//
|
||||||
|
// String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
||||||
|
// LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
||||||
|
// gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
|
||||||
|
// gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
|
||||||
|
// listProfilesBean.add(gCubeProfileMetadataForUCD);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
|
||||||
|
//
|
||||||
|
// for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
|
||||||
|
// LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SessionUtil.setMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID,
|
||||||
|
// linkedMap_UCDId_gCubeProfiles);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
|
||||||
|
// LOG.error(erroMsg, e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
LOG.info("Loaded UCD for ID: " + ucd.getId());
|
|
||||||
String profileID = ucd.getId();
|
|
||||||
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
|
||||||
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
|
||||||
|
|
||||||
if (handlers.size() == 0) {
|
|
||||||
LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loading Handler gcube_profiles
|
|
||||||
HandlerDeclaration dataEntryHandler = handlers.get(0);
|
|
||||||
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
|
||||||
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
|
||||||
|
|
||||||
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
|
|
||||||
LOG.debug("" + handlerGcubeProfiles);
|
|
||||||
|
|
||||||
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
|
||||||
// List of gCube Profiles defined in the UCD
|
|
||||||
List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
|
|
||||||
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
|
||||||
|
|
||||||
List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
|
|
||||||
// Loading Metadata Profile from IS
|
|
||||||
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
|
||||||
|
|
||||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
|
|
||||||
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
|
||||||
String context = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
|
||||||
GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
|
|
||||||
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(context,
|
|
||||||
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
|
||||||
|
|
||||||
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
|
||||||
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
|
||||||
gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
|
|
||||||
gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
|
|
||||||
listProfilesBean.add(gCubeProfileMetadataForUCD);
|
|
||||||
|
|
||||||
}
|
|
||||||
linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
|
|
||||||
|
|
||||||
for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
|
|
||||||
LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
SessionUtil.setMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID,
|
|
||||||
linkedMap_UCDId_gCubeProfiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
|
|
||||||
LOG.error(erroMsg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the layers for id.
|
* Gets the layers for id.
|
||||||
*
|
*
|
||||||
|
@ -951,7 +939,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
String userName = null;
|
String userName = null;
|
||||||
try {
|
try {
|
||||||
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||||
|
@ -972,14 +960,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
ProjectView projectView = new ProjectView();
|
ProjectView projectView = new ProjectView();
|
||||||
projectView.setTheProjectDV(theProjectDV);
|
projectView.setTheProjectDV(theProjectDV);
|
||||||
|
|
||||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = SessionUtil
|
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache.get(scope);
|
||||||
.getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
|
|
||||||
|
|
||||||
if(linkedMap_UCDId_gCubeProfiles==null) {
|
|
||||||
preloadgCubeProfilesForUCDs();
|
|
||||||
linkedMap_UCDId_gCubeProfiles = SessionUtil
|
|
||||||
.getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NO UCD defined, applyong default
|
// NO UCD defined, applyong default
|
||||||
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
|
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
|
||||||
|
@ -988,9 +969,44 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
SectionView sectionView = new SectionView();
|
SectionView sectionView = new SectionView();
|
||||||
sectionView.setSectionTitle("Document");
|
sectionView.setSectionTitle("Document");
|
||||||
SubDocumentView subDocumentView = new SubDocumentView();
|
SubDocumentView subDocumentView = new SubDocumentView();
|
||||||
subDocumentView.setMetadataAsJSON(theProjectDV.getTheDocument().getDocumentAsJSON());
|
|
||||||
sectionView.addSubDocument(subDocumentView);
|
Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
|
||||||
projectView.addSectionView(sectionView);
|
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, JSON_$_POINTER,
|
||||||
|
userName);
|
||||||
|
|
||||||
|
// If is accessible
|
||||||
|
if (isAccessibleSection) {
|
||||||
|
|
||||||
|
// Creating one Project with one SectionView and SubDocumentView
|
||||||
|
String wholeSectionDoc = sectionDoc.toJson();
|
||||||
|
subDocumentView.setMetadataAsJSON(wholeSectionDoc);
|
||||||
|
|
||||||
|
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
|
||||||
|
List<FilesetDV> listImages = new ArrayList<FilesetDV>();
|
||||||
|
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, "fileset");
|
||||||
|
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
|
||||||
|
FilesetDV filesetDV = new FilesetDV();
|
||||||
|
filesetDV.setName("fileset");
|
||||||
|
for (Payload payload : listPayloads) {
|
||||||
|
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
||||||
|
filesetDV.addPayloadDV(payloadDV);
|
||||||
|
boolean isImage = ImageDetector.isImage(payload.getMimetype());
|
||||||
|
|
||||||
|
if (isImage) {
|
||||||
|
listImages.add(filesetDV);
|
||||||
|
} else {
|
||||||
|
listFiles.add(filesetDV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO LAYERS
|
||||||
|
subDocumentView.setListImages(listImages);
|
||||||
|
subDocumentView.setListFiles(listFiles);
|
||||||
|
sectionView.addSubDocument(subDocumentView);
|
||||||
|
projectView.addSectionView(sectionView);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles.get(profileID);
|
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles.get(profileID);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -15,7 +14,6 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
|
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.server.GcubeProfilesMetadataForUCD;
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
@ -182,24 +180,6 @@ public class SessionUtil {
|
||||||
return shortener;
|
return shortener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> getMap_UCDId_gCubeProfiles(
|
|
||||||
HttpServletRequest httpServletRequest, String profileID) {
|
|
||||||
|
|
||||||
HttpSession session = httpServletRequest.getSession();
|
|
||||||
return (LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>) session
|
|
||||||
.getAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setMap_UCDId_gCubeProfiles(HttpServletRequest httpServletRequest,
|
|
||||||
String profileID, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> map) {
|
|
||||||
|
|
||||||
HttpSession session = httpServletRequest.getSession();
|
|
||||||
session.setAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID, map);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the GNA base maps.
|
* Gets the GNA base maps.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue