fixed getCkanUtilsObj() method
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@129876 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d203fb1836
commit
40b4ae8f50
|
@ -41,6 +41,7 @@ import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
|||
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsImpl;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
|
@ -119,27 +120,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish
|
||||
private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles
|
||||
|
||||
// ckan utils methods
|
||||
private CKanUtilsImpl instance;
|
||||
private Object LOCK = new Object();
|
||||
|
||||
/**
|
||||
* Retrieve the ckan utils object
|
||||
* Since it needs the scope, we need to check if it is null or not
|
||||
* @return
|
||||
*/
|
||||
private CKanUtilsImpl getCkanUtils(){
|
||||
private CKanUtils getCkanUtilsObj(){
|
||||
|
||||
if(instance == null){
|
||||
synchronized (LOCK) {
|
||||
if(instance == null){
|
||||
try{
|
||||
String currentScope = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()).getScope();
|
||||
instance = new CKanUtilsImpl(currentScope);
|
||||
}catch(Exception e){
|
||||
workspaceLogger.error("Unable to retrieve ckan information");
|
||||
}
|
||||
}
|
||||
}
|
||||
// check into session
|
||||
HttpSession httpSession = getThreadLocalRequest().getSession();
|
||||
String currentScope = WsUtil.getAslSession(httpSession).getScope();
|
||||
|
||||
CKanUtils instance = null;
|
||||
|
||||
try{
|
||||
workspaceLogger.debug("The ckan util object was null");
|
||||
instance = new CKanUtilsImpl(currentScope);
|
||||
}catch(Exception e){
|
||||
workspaceLogger.error("Unable to retrieve ckan utils", e);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
@ -3461,7 +3458,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
return role;
|
||||
else{
|
||||
|
||||
CKanUtilsImpl ckanUtils = getCkanUtils();
|
||||
CKanUtils ckanUtils = getCkanUtilsObj();
|
||||
boolean result = false;
|
||||
|
||||
try{
|
||||
|
@ -3591,7 +3588,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
if(httpSession.getAttribute(keyPerScope) != null)
|
||||
token = (String)httpSession.getAttribute(keyPerScope);
|
||||
else{
|
||||
token = getCkanUtils().getApiKeyFromUsername(username);
|
||||
token = getCkanUtilsObj().getApiKeyFromUsername(username);
|
||||
httpSession.setAttribute(keyPerScope, token);
|
||||
workspaceLogger.debug("Ckan token has been set for user " + username);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue