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.WorkspaceTrashFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsImpl;
|
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsImpl;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
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_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
|
||||||
|
|
||||||
// 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
|
* @return
|
||||||
*/
|
*/
|
||||||
private CKanUtilsImpl getCkanUtils(){
|
private CKanUtils getCkanUtilsObj(){
|
||||||
|
|
||||||
if(instance == null){
|
// check into session
|
||||||
synchronized (LOCK) {
|
HttpSession httpSession = getThreadLocalRequest().getSession();
|
||||||
if(instance == null){
|
String currentScope = WsUtil.getAslSession(httpSession).getScope();
|
||||||
try{
|
|
||||||
String currentScope = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()).getScope();
|
CKanUtils instance = null;
|
||||||
instance = new CKanUtilsImpl(currentScope);
|
|
||||||
}catch(Exception e){
|
try{
|
||||||
workspaceLogger.error("Unable to retrieve ckan information");
|
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;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -3461,7 +3458,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return role;
|
return role;
|
||||||
else{
|
else{
|
||||||
|
|
||||||
CKanUtilsImpl ckanUtils = getCkanUtils();
|
CKanUtils ckanUtils = getCkanUtilsObj();
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -3591,7 +3588,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
if(httpSession.getAttribute(keyPerScope) != null)
|
if(httpSession.getAttribute(keyPerScope) != null)
|
||||||
token = (String)httpSession.getAttribute(keyPerScope);
|
token = (String)httpSession.getAttribute(keyPerScope);
|
||||||
else{
|
else{
|
||||||
token = getCkanUtils().getApiKeyFromUsername(username);
|
token = getCkanUtilsObj().getApiKeyFromUsername(username);
|
||||||
httpSession.setAttribute(keyPerScope, token);
|
httpSession.setAttribute(keyPerScope, token);
|
||||||
workspaceLogger.debug("Ckan token has been set for user " + username);
|
workspaceLogger.debug("Ckan token has been set for user " + username);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue