Added PortalContext
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@134844 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e7dbe3a74d
commit
b9558710dd
|
@ -37,11 +37,11 @@ public class SessionUtil {
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
return getServiceCredentials(httpServletRequest, null);
|
return getServiceCredentials(httpServletRequest, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServiceCredentials getServiceCredentials(
|
public static ServiceCredentials getServiceCredentials(
|
||||||
HttpServletRequest httpServletRequest, String scopeGroupId)
|
HttpServletRequest httpServletRequest, String scopeGroupId)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
|
|
||||||
ServiceCredentials sCredentials = null;
|
ServiceCredentials sCredentials = null;
|
||||||
String userName = null;
|
String userName = null;
|
||||||
String scope = null;
|
String scope = null;
|
||||||
|
@ -58,16 +58,37 @@ public class SessionUtil {
|
||||||
} else {
|
} else {
|
||||||
logger.info("Retrieving credential in session!");
|
logger.info("Retrieving credential in session!");
|
||||||
PortalContext pContext = PortalContext.getConfiguration();
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
if(scopeGroupId!=null&&!scopeGroupId.isEmpty()){
|
if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
|
||||||
scope = pContext.getCurrentScope(scopeGroupId);
|
scope = pContext.getCurrentScope(scopeGroupId);
|
||||||
} else {
|
} else {
|
||||||
scope = pContext.getCurrentScope(httpServletRequest);
|
scope = pContext.getCurrentScope(httpServletRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scope == null || scope.isEmpty()) {
|
||||||
|
String error = "Error retrieving scope: " + scope;
|
||||||
|
logger.error(error);
|
||||||
|
throw new StatAlgoImporterServiceException(error);
|
||||||
|
}
|
||||||
|
|
||||||
userName = pContext.getCurrentUser(httpServletRequest)
|
userName = pContext.getCurrentUser(httpServletRequest)
|
||||||
.getUsername();
|
.getUsername();
|
||||||
|
|
||||||
|
if (userName == null || userName.isEmpty()) {
|
||||||
|
String error = "Error retrieving username in scope " + scope
|
||||||
|
+ ": " + userName;
|
||||||
|
logger.error(error);
|
||||||
|
throw new StatAlgoImporterServiceException(error);
|
||||||
|
}
|
||||||
|
|
||||||
token = pContext.getCurrentUserToken(httpServletRequest);
|
token = pContext.getCurrentUserToken(httpServletRequest);
|
||||||
|
|
||||||
|
if (token == null || token.isEmpty()) {
|
||||||
|
String error = "Error retrieving token for " + userName
|
||||||
|
+ " in " + scope + ": " + token;
|
||||||
|
logger.error(error);
|
||||||
|
throw new StatAlgoImporterServiceException(error);
|
||||||
|
}
|
||||||
|
|
||||||
String name = pContext.getCurrentUser(httpServletRequest)
|
String name = pContext.getCurrentUser(httpServletRequest)
|
||||||
.getFirstName();
|
.getFirstName();
|
||||||
String lastName = pContext.getCurrentUser(httpServletRequest)
|
String lastName = pContext.getCurrentUser(httpServletRequest)
|
||||||
|
@ -85,8 +106,8 @@ public class SessionUtil {
|
||||||
String groupName = pContext.getCurrentGroupName(httpServletRequest);
|
String groupName = pContext.getCurrentGroupName(httpServletRequest);
|
||||||
|
|
||||||
sCredentials = new ServiceCredentials(userName, fullName, name,
|
sCredentials = new ServiceCredentials(userName, fullName, name,
|
||||||
lastName, email, scope, groupId, groupName, userAvatarURL, token);
|
lastName, email, scope, groupId, groupName, userAvatarURL,
|
||||||
|
token);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("ServiceCredentials: " + sCredentials);
|
logger.info("ServiceCredentials: " + sCredentials);
|
||||||
|
@ -94,10 +115,6 @@ public class SessionUtil {
|
||||||
return sCredentials;
|
return sCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
public static ArrayList<Recipient> getRecipients(
|
public static ArrayList<Recipient> getRecipients(
|
||||||
ServletContext servletContest) {
|
ServletContext servletContest) {
|
||||||
|
|
Loading…
Reference in New Issue