60 lines
1.4 KiB
Java
60 lines
1.4 KiB
Java
|
/**
|
||
|
*
|
||
|
*/
|
||
|
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server;
|
||
|
|
||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||
|
import org.slf4j.Logger;
|
||
|
import org.slf4j.LoggerFactory;
|
||
|
|
||
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* The Class SessionUtil.
|
||
|
*
|
||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||
|
* Jun 10, 2016
|
||
|
*/
|
||
|
public class SessionUtil {
|
||
|
|
||
|
public static final String CKAN_END_POINT = "CKAN_END_POINT";
|
||
|
|
||
|
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||
|
|
||
|
/**
|
||
|
* Gets the ckan end point.
|
||
|
*
|
||
|
* @param session the session
|
||
|
* @return the ckan end point
|
||
|
*/
|
||
|
public static GcoreEndpointReader getCkanEndPoint(ASLSession session){
|
||
|
|
||
|
GcoreEndpointReader ckanEndPoint = (GcoreEndpointReader) session.getAttribute(CKAN_END_POINT);
|
||
|
|
||
|
if(ckanEndPoint==null){
|
||
|
logger.debug("GcoreEndpointReader is null, instancing new..");
|
||
|
ckanEndPoint = new GcoreEndpointReader(session.getScope());
|
||
|
session.setAttribute(CKAN_END_POINT, ckanEndPoint);
|
||
|
}
|
||
|
logger.debug("returning: "+ckanEndPoint);
|
||
|
return ckanEndPoint;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Checks if is into portal.
|
||
|
*
|
||
|
* @return true, if is into portal
|
||
|
*/
|
||
|
public static boolean isIntoPortal() {
|
||
|
try {
|
||
|
UserLocalServiceUtil.getService();
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
logger.trace("Development Mode ON");
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|