fixed getCkanUtilsObj() method

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129875 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-04 14:24:53 +00:00
parent 38c73da8e8
commit e886724721
1 changed files with 5 additions and 19 deletions

View File

@ -60,14 +60,12 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
// ckan keys for ASL
private static final String CKAN_TOKEN_KEY = "ckanToken";
private static final String CKAN_OBJ_KEY = "ckanObj";
private static final String CKAN_ORGS_USER_KEY = "ckanOrgs"; // organizations to whom he belongs
private static final String CKAN_HIGHEST_ROLE = "ckanHighestRole"; // editor, member, admin, sysadmin
private static final String CKAN_LICENSES_KEY = "ckanLicenses"; // licenses
private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish
private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles
/**
* Since it needs the scope, we need to check if it is null or not
* @return
@ -77,28 +75,16 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
// check into session
HttpSession httpSession = getThreadLocalRequest().getSession();
String currentScope = getASLSession(httpSession).getScope();
String keyForScope = concatenateSessionKeyScope(CKAN_OBJ_KEY, currentScope);
CKanUtils instance = null;
if(httpSession.getAttribute(keyForScope) == null){
try{
logger.debug("The ckan util object was null");
instance = new CKanUtilsImpl(currentScope);
// put it into session
logger.debug("Putting object into session ");
httpSession.setAttribute(keyForScope, instance);
}catch(Exception e){
logger.error("Unable to retrieve ckan utils", e);
}
}else{
instance = (CKanUtils)httpSession.getAttribute(keyForScope);
logger.debug("Ckan utils object was into session");
try{
logger.debug("The ckan util object was null");
instance = new CKanUtilsImpl(currentScope);
}catch(Exception e){
logger.error("Unable to retrieve ckan utils", e);
}
return instance;
}
/* (non-Javadoc)