fixed ckanutils creation

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129464 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-06-27 09:55:43 +00:00
parent ee5218ad24
commit d04b8adc20
1 changed files with 12 additions and 7 deletions

View File

@ -64,6 +64,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
// ckan utils methods
private CKanUtilsImpl instance;
private Object LOCK = new Object();
/**
* Since it needs the scope, we need to check if it is null or not
@ -72,13 +73,17 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
private CKanUtilsImpl getCkanUtilsObj(){
if(instance == null){
// retrieve ckan information
try{
String currentScope = ScopeProvider.instance.get();
logger.debug("Scope is " + currentScope);
instance = new CKanUtilsImpl(currentScope);
}catch(Exception e){
logger.error("Unable to retrieve ckan information", e);
synchronized(LOCK){
if(instance == null){
// retrieve ckan information
try{
String currentScope = ScopeProvider.instance.get();
logger.debug("Scope is " + currentScope);
instance = new CKanUtilsImpl(currentScope);
}catch(Exception e){
logger.error("Unable to retrieve ckan information", e);
}
}
}
}