Fixed Token null on reload session problem

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@141367 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-12-22 13:45:36 +00:00
parent 4af60c671a
commit 0ece4c7a9f
1 changed files with 18 additions and 2 deletions

View File

@ -86,6 +86,7 @@ public class SessionUtil {
}
logger.debug("Scope: " + scope);
if (scope == null || scope.isEmpty()) {
String error = "Error retrieving scope: " + scope;
logger.error(error);
@ -107,7 +108,7 @@ public class SessionUtil {
} else {
gCubeUser = pContext.getCurrentUser(httpServletRequest);
}
if (gCubeUser == null) {
String error = "Error retrieving gCubeUser in scope " + scope
+ ": " + gCubeUser;
@ -116,6 +117,7 @@ public class SessionUtil {
}
userName = gCubeUser.getUsername();
logger.debug("UserName: " + userName);
if (userName == null || userName.isEmpty()) {
String error = "Error retrieving username in scope " + scope
@ -124,8 +126,22 @@ public class SessionUtil {
throw new ServiceException(error);
}
token = pContext.getCurrentUserToken(scope, httpServletRequest);
if (hasCurrUserId) {
try {
token = pContext.getCurrentUserToken(scope,
Long.valueOf(currUserId));
} catch (Exception e) {
String error = "Error retrieving token for: [userId= "
+ currUserId + ", scope: " + scope + "]";
logger.error(error, e);
throw new ServiceException(error);
}
} else {
token = pContext.getCurrentUserToken(scope, httpServletRequest);
}
logger.debug("Token: " + token);
if (token == null || token.isEmpty()) {
String error = "Error retrieving token for " + userName
+ " in " + scope + ": " + token;