refactoring

This commit is contained in:
Francesco Mangiacrapa 2021-09-24 11:13:25 +02:00
parent 85230de9bb
commit 46ae55e8dd
4 changed files with 279 additions and 177 deletions

View File

@ -7,8 +7,12 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
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.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader;
import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.GeoportalCommon;
@ -26,7 +30,6 @@ import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioneImageUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
@ -36,6 +39,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
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.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles; import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis; import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
@ -60,6 +64,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** The Constant LOG. */ /** 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";
/** /**
* Parses the wms request. * Parses the wms request.
* *
@ -152,8 +158,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (concessioneIds != null && concessioneIds.size() > 0) { if (concessioneIds != null && concessioneIds.size() > 0) {
String cId = concessioneIds.get(0); String cId = concessioneIds.get(0);
try { try {
UploadedImageDV uplImg = SessionUtil UploadedImageDV uplImg = sessionloadPreviewImageForConcessione(this.getThreadLocalRequest(),
.getPreviewImageForConcessione(this.getThreadLocalRequest(), "Concessione", cId); "Concessione", cId);
// List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1); // List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1);
Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>(); Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
mapImages.put(cId, Arrays.asList(uplImg)); mapImages.put(cId, Arrays.asList(uplImg));
@ -188,8 +194,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
throws Exception { throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
return new ConcessioneImageUtil().getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
maxImages);
} }
/** /**
@ -551,4 +556,109 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return listDAO; return listDAO;
} }
/**
* Gets the preview image for concessione from http session. It is the first
* image retrieved from mongoService for mongoConcessioneId. Caching it into
* session
*
* @param httpServletRequest the http servlet request
* @param itemType the item type
* @param mongoConcessioneId the mongo concessione id
* @return the preview image for concessione
*/
private UploadedImageDV sessionloadPreviewImageForConcessione(HttpServletRequest httpServletRequest,
String itemType, String mongoConcessioneId) {
LOG.info("sessionloadPreviewImageForConcessione [mongoConcessioneId: " + mongoConcessioneId + ", itemType: "
+ itemType + "] called");
HttpSession session = httpServletRequest.getSession();
Map<String, List<UploadedImageDV>> mapImages = null;
List<UploadedImageDV> lUI = null;
try {
mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE);
if (mapImages == null) {
mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
}
List<UploadedImageDV> imagePreviewForConcessione = mapImages.get(mongoConcessioneId);
if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) {
LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId "
+ mongoConcessioneId + " is empty or null, loading from service and filling it");
lUI = getUploadedImagesForId(httpServletRequest, itemType, mongoConcessioneId, 1);
mapImages.put(mongoConcessioneId, lUI);
}
lUI = mapImages.get(mongoConcessioneId);
LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI);
session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages);
} catch (Exception e) {
LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e);
}
if (lUI == null || lUI.isEmpty())
return null;
return lUI.get(0);
}
/**
* Gets the uploaded images for id.
*
* @param httpServletRequest the http servlet request
* @param itemType the item type
* @param itemId the item id
* @param maxImages the max images
* @return the uploaded images for id
* @throws Exception the exception
*/
private List<UploadedImageDV> getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType,
String itemId, Integer maxImages) throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null");
if (itemId == null)
throw new Exception("Invalid parameter. The itemId is null");
List<UploadedImageDV> listUI = null;
try {
if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id " + itemId);
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest);
Concessione concessione = cms.getItemById(itemId);
if (concessione != null) {
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
List<UploadedImage> images = concessione.getImmaginiRappresentative();
if (images != null) {
listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size();
for (int i = 0; i < max; i++) {
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui);
}
LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s");
}
} else
throw new Exception("Concessione with id '" + itemId + "' not available");
}
return listUI;
} catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() + " not available for "
+ Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
} }

View File

@ -1,83 +1,83 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; //package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
//
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.List; //import java.util.List;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
//
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.legacy.UploadedImage; //import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; //import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; //import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
//
/** ///**
* The Class ConcessioneImageUtil. // * The Class ConcessioneImageUtil.
* // *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it // * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* // *
* Sep 7, 2021 // * Sep 7, 2021
*/ // */
public class ConcessioneImageUtil { //public class ConcessioneImageUtil {
//
private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class); // private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class);
//
/** // /**
* Gets the uploaded images for id. // * Gets the uploaded images for id.
* // *
* @param httpServletRequest the http servlet request // * @param httpServletRequest the http servlet request
* @param itemType the item type // * @param itemType the item type
* @param itemId the item id // * @param itemId the item id
* @param maxImages the max images // * @param maxImages the max images
* @return the uploaded images for id // * @return the uploaded images for id
* @throws Exception the exception // * @throws Exception the exception
*/ // */
public List<UploadedImageDV> getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, // public List<UploadedImageDV> getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType,
String itemId, Integer maxImages) throws Exception { // String itemId, Integer maxImages) throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); // LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
//
if (itemType == null) // if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null"); // throw new Exception("Invalid parameter. The itemType is null");
//
if (itemId == null) // if (itemId == null)
throw new Exception("Invalid parameter. The itemId is null"); // throw new Exception("Invalid parameter. The itemId is null");
//
List<UploadedImageDV> listUI = null; // List<UploadedImageDV> listUI = null;
//
try { // try {
//
if (itemType.equalsIgnoreCase("concessione")) { // if (itemType.equalsIgnoreCase("concessione")) {
//
LOG.info("Trying to get concessione for id " + itemId); // LOG.info("Trying to get concessione for id " + itemId);
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); // ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest);
Concessione concessione = cms.getItemById(itemId); // Concessione concessione = cms.getItemById(itemId);
if (concessione != null) { // if (concessione != null) {
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); // LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
List<UploadedImage> images = concessione.getImmaginiRappresentative(); // List<UploadedImage> images = concessione.getImmaginiRappresentative();
//
if (images != null) { // if (images != null) {
listUI = new ArrayList<UploadedImageDV>(); // listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size(); // int max = maxImages < images.size() ? maxImages : images.size();
for (int i = 0; i < max; i++) { // for (int i = 0; i < max; i++) {
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); // UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui); // listUI.add(ui);
} // }
LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); // LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s");
} // }
} else // } else
throw new Exception("Concessione with id '" + itemId + "' not available"); // throw new Exception("Concessione with id '" + itemId + "' not available");
} // }
//
return listUI; // return listUI;
//
} catch (Exception e) { // } catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() + " not available for " // String erroMsg = UploadedImage.class.getSimpleName() + " not available for "
+ Concessione.class.getSimpleName() + " with id " + itemId; // + Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e); // LOG.error(erroMsg, e);
throw new Exception(erroMsg); // throw new Exception(erroMsg);
} // }
//
} // }
//
} //}

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.authorization.library.provider.AccessTokenProvider; import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.keycloak.KeycloakClientFactory; import org.gcube.common.keycloak.KeycloakClientFactory;
@ -15,16 +16,18 @@ public class IAMClientIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class); private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class);
private String previousUMAToken = null; private String previousUMAToken = null;
private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS";
@Override @Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception { public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called"); LOG.info("setIdentity called");
String currentScope = SessionUtil.getCurrentContext(httpRequest, true); String currentScope = SessionUtil.getCurrentContext(httpRequest, true);
IAMClientCredentials credentials = SessionUtil.getIAMClientCredentials(httpRequest); IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
try { try {
if(credentials==null) { if(credentials==null) {
credentials = IAMClientCredentialsReader.getCredentials(); credentials = IAMClientCredentialsReader.getCredentials();
SessionUtil.setIAMClientCredentials(httpRequest,credentials); sessionSetIAMClientCredentials(httpRequest,credentials);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error on discovering IAM Client credentials", e); LOG.error("Error on discovering IAM Client credentials", e);
@ -79,5 +82,36 @@ public class IAMClientIdentity implements GcubeIdentity {
LOG.info("resetIdentity to previous AccessToken"); LOG.info("resetIdentity to previous AccessToken");
} }
/**
* Gets the IAM client credentials.
*
* @param httpRequest the http request
* @return the IAM client credentials
*/
public static IAMClientCredentials sessionGetIAMClientCredentials(HttpServletRequest httpRequest) {
HttpSession session = httpRequest.getSession();
try {
return (IAMClientCredentials) session.getAttribute(IAM_CLIENT_CREDENTIALS);
} catch (Exception e) {
LOG.warn("Error occurred when reading " + IAM_CLIENT_CREDENTIALS + " from session");
return null;
}
}
/**
* Sets the IAM client credentials.
*
* @param httpRequest the http request
* @param iamCC the iam CC
*/
public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) {
HttpSession session = httpRequest.getSession();
try {
session.setAttribute(IAM_CLIENT_CREDENTIALS, iamCC);
} catch (Exception e) {
LOG.warn("Error occurred when setting " + IAM_CLIENT_CREDENTIALS + " into session");
}
}
} }

View File

@ -3,19 +3,12 @@
*/ */
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.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; 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.mongoservice.ConcessioneImageUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials;
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;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
@ -42,10 +35,6 @@ public class SessionUtil {
private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS";
/** /**
* Checks if is into portal. * Checks if is into portal.
* *
@ -180,80 +169,49 @@ public class SessionUtil {
return shortener; return shortener;
} }
/** // /**
* Gets the preview image for concessione. It is the first image retrieved from // * Gets the preview image for concessione. It is the first image retrieved from
* mongoService for mongoConcessioneId. Caching it into session // * mongoService for mongoConcessioneId. Caching it into session
* // *
* @param httpServletRequest the http servlet request // * @param httpServletRequest the http servlet request
* @param itemType the item type // * @param itemType the item type
* @param mongoConcessioneId the mongo concessione id // * @param mongoConcessioneId the mongo concessione id
* @return the preview image for concessione // * @return the preview image for concessione
*/ // */
public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType, // public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType,
String mongoConcessioneId) { // String mongoConcessioneId) {
//
HttpSession session = httpServletRequest.getSession(); // HttpSession session = httpServletRequest.getSession();
Map<String, List<UploadedImageDV>> mapImages = null; // Map<String, List<UploadedImageDV>> mapImages = null;
List<UploadedImageDV> lUI = null; // List<UploadedImageDV> lUI = null;
try { // try {
mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); // mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE);
//
if (mapImages == null) { // if (mapImages == null) {
mapImages = new LinkedHashMap<String, List<UploadedImageDV>>(); // mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
} // }
//
List<UploadedImageDV> imagePreviewForConcessione = mapImages.get(mongoConcessioneId); // List<UploadedImageDV> imagePreviewForConcessione = mapImages.get(mongoConcessioneId);
//
if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { // if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) {
LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " // LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId "
+ mongoConcessioneId + " is empty or null, loading from service and filling it"); // + mongoConcessioneId + " is empty or null, loading from service and filling it");
lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType, // lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType,
mongoConcessioneId, 1); // mongoConcessioneId, 1);
mapImages.put(mongoConcessioneId, lUI); // mapImages.put(mongoConcessioneId, lUI);
} // }
//
lUI = mapImages.get(mongoConcessioneId); // lUI = mapImages.get(mongoConcessioneId);
LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); // LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI);
session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); // session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages);
//
} catch (Exception e) { // } catch (Exception e) {
LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); // LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e);
} // }
//
if (lUI == null || lUI.isEmpty()) // if (lUI == null || lUI.isEmpty())
return null; // return null;
//
return lUI.get(0); // return lUI.get(0);
} // }
/**
* Gets the IAM client credentials.
*
* @param httpRequest the http request
* @return the IAM client credentials
*/
public static IAMClientCredentials getIAMClientCredentials(HttpServletRequest httpRequest) {
HttpSession session = httpRequest.getSession();
try {
return (IAMClientCredentials) session.getAttribute(IAM_CLIENT_CREDENTIALS);
} catch (Exception e) {
LOG.warn("Error occurred when reading " + IAM_CLIENT_CREDENTIALS + " from session");
return null;
}
}
/**
* Sets the IAM client credentials.
*
* @param httpRequest the http request
* @param iamCC the iam CC
*/
public static void setIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) {
HttpSession session = httpRequest.getSession();
try {
session.setAttribute(IAM_CLIENT_CREDENTIALS, iamCC);
} catch (Exception e) {
LOG.warn("Error occurred when setting " + IAM_CLIENT_CREDENTIALS + " into session");
}
}
} }