fixed getCkanUtilsObj() method
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129870 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7d768461e2
commit
6f355ecc46
|
@ -60,37 +60,40 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
// ckan keys for ASL
|
// ckan keys for ASL
|
||||||
private static final String CKAN_TOKEN_KEY = "ckanToken";
|
private static final String CKAN_TOKEN_KEY = "ckanToken";
|
||||||
|
private static final String CKAN_OBJ_KEY = "ckanObj";
|
||||||
private static final String CKAN_LICENSES_KEY = "ckanLicenses"; // licenses
|
private static final String CKAN_LICENSES_KEY = "ckanLicenses"; // licenses
|
||||||
private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish
|
private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish
|
||||||
private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles
|
private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles
|
||||||
|
|
||||||
private Object LOCK = new Object();
|
|
||||||
|
|
||||||
// library util instance
|
|
||||||
private CKanUtilsImpl instance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since it needs the scope, we need to check if it is null or not
|
* Since it needs the scope, we need to check if it is null or not
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private CKanUtils getCkanUtilsObj(){
|
private CKanUtils getCkanUtilsObj(){
|
||||||
|
|
||||||
if(instance == null){
|
// check into session
|
||||||
synchronized(LOCK){
|
|
||||||
if(instance == null){
|
|
||||||
// retrieve ckan information
|
|
||||||
try{
|
|
||||||
String currentScope = getASLSession().getScope();
|
String currentScope = getASLSession().getScope();
|
||||||
logger.debug("Scope from asl is " + currentScope);
|
HttpSession httpSession = getThreadLocalRequest().getSession();
|
||||||
|
String keyForScope = concatenateSessionKeyScope(CKAN_OBJ_KEY, currentScope);
|
||||||
|
|
||||||
|
CKanUtils instance = null;
|
||||||
|
|
||||||
|
if(httpSession.getAttribute(keyForScope) == null){
|
||||||
|
try{
|
||||||
|
logger.debug("The ckan util object was null");
|
||||||
instance = new CKanUtilsImpl(currentScope);
|
instance = new CKanUtilsImpl(currentScope);
|
||||||
|
|
||||||
|
// put it into session
|
||||||
|
logger.debug("Putting object into session ");
|
||||||
|
httpSession.setAttribute(keyForScope, instance);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Unable to retrieve ckan information", e);
|
logger.error("Unable to retrieve ckan utils", e);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}else
|
||||||
|
instance = (CKanUtils)httpSession.getAttribute(keyForScope);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue