fixed ckanutils creation

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129463 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-06-27 09:55:06 +00:00
parent 7099328d5f
commit a96155863b
1 changed files with 15 additions and 9 deletions

View File

@ -56,9 +56,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
public static final String CKAN_TOKEN_KEY = "ckanToken";
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
* @return
@ -66,13 +68,17 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
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);
}
}
}
}
@ -280,7 +286,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// get usermanager (liferay)
UserManager liferUserManager = new LiferayUserManager();
GCubeUser userOwner = liferUserManager.getUserByUsername(owner);
// build bean
logger.debug("Building bean");