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"; public static final String CKAN_TOKEN_KEY = "ckanToken";
private Object LOCK = new Object();
// library util instance // library util instance
private CKanUtilsImpl 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
@ -66,13 +68,17 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
private CKanUtilsImpl getCkanUtilsObj(){ private CKanUtilsImpl getCkanUtilsObj(){
if(instance == null){ if(instance == null){
// retrieve ckan information synchronized(LOCK){
try{ if(instance == null){
String currentScope = ScopeProvider.instance.get(); // retrieve ckan information
logger.debug("Scope is " + currentScope); try{
instance = new CKanUtilsImpl(currentScope); String currentScope = ScopeProvider.instance.get();
}catch(Exception e){ logger.debug("Scope is " + currentScope);
logger.error("Unable to retrieve ckan information", e); 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) // get usermanager (liferay)
UserManager liferUserManager = new LiferayUserManager(); UserManager liferUserManager = new LiferayUserManager();
GCubeUser userOwner = liferUserManager.getUserByUsername(owner); GCubeUser userOwner = liferUserManager.getUserByUsername(owner);
// build bean // build bean
logger.debug("Building bean"); logger.debug("Building bean");