Update to new PortalContext
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@142244 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f20954049c
commit
0f6d90b629
14
pom.xml
14
pom.xml
|
@ -216,13 +216,6 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- GCube Widgets -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
|
||||||
<artifactId>gcube-widgets</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Storage -->
|
<!-- Storage -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.contentmanagement</groupId>
|
<groupId>org.gcube.contentmanagement</groupId>
|
||||||
|
@ -258,8 +251,11 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Social -->
|
<!-- Social -->
|
||||||
<!-- <dependency> <groupId>org.gcube.portal</groupId> <artifactId>social-networking-library</artifactId>
|
<!-- <dependency>
|
||||||
<scope>provided</scope> </dependency> -->
|
<groupId>org.gcube.portal</groupId>
|
||||||
|
<artifactId>social-networking-library</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
<artifactId>aslsocial</artifactId>
|
<artifactId>aslsocial</artifactId>
|
||||||
|
|
|
@ -37,7 +37,7 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
|
||||||
*/
|
*/
|
||||||
public class CodeUploadPanel extends FormPanel {
|
public class CodeUploadPanel extends FormPanel {
|
||||||
|
|
||||||
private static final String UPLOAD_SERVLET = "LocalUploadServlet";
|
|
||||||
|
|
||||||
private static final int STATUS_POLLING_DELAY = 1000;
|
private static final int STATUS_POLLING_DELAY = 1000;
|
||||||
|
|
||||||
|
@ -73,7 +73,11 @@ public class CodeUploadPanel extends FormPanel {
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
setId("CodeUploadPanel");
|
setId("CodeUploadPanel");
|
||||||
setAction(GWT.getModuleBaseURL() + UPLOAD_SERVLET);
|
String path = GWT.getModuleBaseURL()
|
||||||
|
+ Constants.LOCAL_UPLOAD_SERVLET + "?"
|
||||||
|
+ Constants.CURR_GROUP_ID + "="
|
||||||
|
+ GCubeClientContext.getCurrentContextId();
|
||||||
|
setAction(path);
|
||||||
setWidth("100%");
|
setWidth("100%");
|
||||||
|
|
||||||
setEncoding(Encoding.MULTIPART);
|
setEncoding(Encoding.MULTIPART);
|
||||||
|
@ -186,11 +190,9 @@ public class CodeUploadPanel extends FormPanel {
|
||||||
parent.setButtonAlign(BoxLayoutPack.CENTER);
|
parent.setButtonAlign(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
Hidden currGroupId=new Hidden(Constants.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId());
|
Hidden currGroupId=new Hidden(Constants.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId());
|
||||||
Hidden currUserId=new Hidden(Constants.CURR_USER_ID, GCubeClientContext.getCurrentUserId());
|
|
||||||
|
|
||||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||||
vlc.add(currGroupId);
|
vlc.add(currGroupId);
|
||||||
vlc.add(currUserId);
|
|
||||||
vlc.add(fileUploadFieldLabel, new VerticalLayoutData(1, -1, new Margins(0)));
|
vlc.add(fileUploadFieldLabel, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
vlc.add(uploadProgressBar, new VerticalLayoutData(1, -1, new Margins(5,0,0,0)));
|
vlc.add(uploadProgressBar, new VerticalLayoutData(1, -1, new Margins(5,0,0,0)));
|
||||||
uploadProgressBar.setVisible(false);
|
uploadProgressBar.setVisible(false);
|
||||||
|
@ -208,12 +210,6 @@ public class CodeUploadPanel extends FormPanel {
|
||||||
|
|
||||||
protected void startUpload() {
|
protected void startUpload() {
|
||||||
disableUpload();
|
disableUpload();
|
||||||
|
|
||||||
StringBuilder actionUrl = new StringBuilder();
|
|
||||||
actionUrl.append(GWT.getModuleBaseURL());
|
|
||||||
actionUrl.append(UPLOAD_SERVLET);
|
|
||||||
setAction(actionUrl.toString());
|
|
||||||
Log.info("Start Upload action Url " + actionUrl.toString());
|
|
||||||
submit();
|
submit();
|
||||||
|
|
||||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.apache.commons.fileupload.FileItemFactory;
|
||||||
import org.apache.commons.fileupload.FileUploadException;
|
import org.apache.commons.fileupload.FileUploadException;
|
||||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUploadListener;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUploadListener;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUtil;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUtil;
|
||||||
|
@ -66,20 +65,31 @@ public class LocalUploadServlet extends HttpServlet {
|
||||||
}
|
}
|
||||||
logger.info("Code Import session id: " + session.getId());
|
logger.info("Code Import session id: " + session.getId());
|
||||||
|
|
||||||
try {
|
ServiceCredentials serviceCredentials;
|
||||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
|
||||||
String currUserId = request.getParameter(Constants.CURR_USER_ID);
|
|
||||||
ServiceCredentials serviceCredentials = SessionUtil
|
|
||||||
.getServiceCredentials(request, scopeGroupId, currUserId);
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
String scopeGroupId = request.getHeader(Constants.CURR_GROUP_ID);
|
||||||
|
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||||
} catch (StatAlgoImporterServiceException e) {
|
scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||||
logger.error(e.getLocalizedMessage());
|
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||||
e.printStackTrace();
|
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||||
throw new ServletException(e.getLocalizedMessage());
|
+ scopeGroupId);
|
||||||
|
throw new ServletException(
|
||||||
|
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||||
|
+ scopeGroupId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||||
|
scopeGroupId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(
|
||||||
|
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||||
|
e);
|
||||||
|
throw new ServletException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
CodeFileUploadSession fileUploadSession = new CodeFileUploadSession();
|
CodeFileUploadSession fileUploadSession = new CodeFileUploadSession();
|
||||||
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
|
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class SessionOp<T> {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(SessionOp.class);
|
||||||
|
|
||||||
|
public T get(HttpServletRequest httpRequest,
|
||||||
|
ServiceCredentials serviceCredentials, String attribute,
|
||||||
|
Class<T> cls) throws Exception {
|
||||||
|
HttpSession httpSession = httpRequest.getSession();
|
||||||
|
T value = null;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMap<String, T> map = (HashMap<String, T>) httpSession
|
||||||
|
.getAttribute(attribute);
|
||||||
|
|
||||||
|
if (map != null) {
|
||||||
|
if (map.containsKey(serviceCredentials.getScope())) {
|
||||||
|
value = map.get(serviceCredentials.getScope());
|
||||||
|
} else {
|
||||||
|
logger.error("" + attribute + " was not acquired");
|
||||||
|
try {
|
||||||
|
value = cls.newInstance();
|
||||||
|
map.put(serviceCredentials.getScope(), value);
|
||||||
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
String error = "Error reading session attribute: "
|
||||||
|
+ e.getLocalizedMessage();
|
||||||
|
logger.error(error, e);
|
||||||
|
throw new Exception(error, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("" + attribute + " was not acquired");
|
||||||
|
map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
value = cls.newInstance();
|
||||||
|
map.put(serviceCredentials.getScope(), value);
|
||||||
|
httpSession.setAttribute(attribute, map);
|
||||||
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
String error = "Error reading session attribute: "
|
||||||
|
+ e.getLocalizedMessage();
|
||||||
|
logger.error(error, e);
|
||||||
|
throw new Exception(error, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(HttpServletRequest httpRequest,
|
||||||
|
ServiceCredentials serviceCredentials, String attribute) {
|
||||||
|
HttpSession httpSession = httpRequest.getSession();
|
||||||
|
T value = null;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMap<String, T> map = (HashMap<String, T>) httpSession
|
||||||
|
.getAttribute(attribute);
|
||||||
|
|
||||||
|
if (map != null) {
|
||||||
|
if (map.containsKey(serviceCredentials.getScope())) {
|
||||||
|
value = map.get(serviceCredentials.getScope());
|
||||||
|
} else {
|
||||||
|
logger.error("" + attribute + " was not acquired");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("" + attribute + " was not acquired");
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(HttpServletRequest httpRequest,
|
||||||
|
ServiceCredentials serviceCredentials, String attribute, T value) {
|
||||||
|
HttpSession httpSession = httpRequest.getSession();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMap<String, T> map = (HashMap<String, T>) httpSession
|
||||||
|
.getAttribute(attribute);
|
||||||
|
|
||||||
|
if (map != null) {
|
||||||
|
map.put(serviceCredentials.getScope(), value);
|
||||||
|
} else {
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put(serviceCredentials.getScope(), value);
|
||||||
|
httpSession.setAttribute(attribute, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(HttpServletRequest httpRequest,
|
||||||
|
ServiceCredentials serviceCredentials, String attribute) {
|
||||||
|
HttpSession httpSession = httpRequest.getSession();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMap<String, T> map = (HashMap<String, T>) httpSession
|
||||||
|
.getAttribute(attribute);
|
||||||
|
|
||||||
|
if (map != null) {
|
||||||
|
map.remove(serviceCredentials.getScope());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,9 @@ import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
|
||||||
|
@ -20,7 +22,6 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUpl
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.SessionConstants;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.SessionConstants;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -36,14 +37,27 @@ public class SessionUtil {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param httpServletRequest
|
||||||
|
* @return
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
public static ServiceCredentials getServiceCredentials(
|
public static ServiceCredentials getServiceCredentials(
|
||||||
HttpServletRequest httpServletRequest)
|
HttpServletRequest httpServletRequest)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
return getServiceCredentials(httpServletRequest, null, null);
|
return getServiceCredentials(httpServletRequest, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param httpServletRequest
|
||||||
|
* @param scopeGroupId
|
||||||
|
* @return
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
public static ServiceCredentials getServiceCredentials(
|
public static ServiceCredentials getServiceCredentials(
|
||||||
HttpServletRequest httpServletRequest, String scopeGroupId, String currUserId)
|
HttpServletRequest httpServletRequest, String scopeGroupId)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
|
|
||||||
ServiceCredentials sCredentials = null;
|
ServiceCredentials sCredentials = null;
|
||||||
|
@ -55,17 +69,29 @@ public class SessionUtil {
|
||||||
|
|
||||||
if (Constants.DEBUG_MODE) {
|
if (Constants.DEBUG_MODE) {
|
||||||
logger.info("No credential found in session, use test user!");
|
logger.info("No credential found in session, use test user!");
|
||||||
|
/*
|
||||||
|
* InfoLocale infoLocale = getInfoLocale(httpServletRequest, null);
|
||||||
|
* Locale locale = new Locale(infoLocale.getLanguage());
|
||||||
|
*
|
||||||
|
* ResourceBundle messages = ResourceBundle.getBundle(
|
||||||
|
* StatAlgoImporterServiceMessagesConstants.TDGWTServiceMessages,
|
||||||
|
* locale);
|
||||||
|
*/
|
||||||
userName = Constants.DEFAULT_USER;
|
userName = Constants.DEFAULT_USER;
|
||||||
scope = Constants.DEFAULT_SCOPE;
|
scope = Constants.DEFAULT_SCOPE;
|
||||||
token = Constants.DEFAULT_TOKEN;
|
token = Constants.DEFAULT_TOKEN;
|
||||||
|
|
||||||
|
logger.info("Set SecurityToken: " + token);
|
||||||
|
SecurityTokenProvider.instance.set(token);
|
||||||
|
logger.info("Set ScopeProvider: " + scope);
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
|
||||||
sCredentials = new ServiceCredentials(userName, scope, token);
|
sCredentials = new ServiceCredentials(userName, scope, token);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.info("Retrieving credential in session!");
|
logger.info("Retrieving credential in session!");
|
||||||
PortalContext pContext = PortalContext.getConfiguration();
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
boolean hasScopeGroupId = false;
|
boolean hasScopeGroupId = false;
|
||||||
boolean hasCurrUserId = false;
|
|
||||||
|
|
||||||
if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
|
if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
|
||||||
hasScopeGroupId = true;
|
hasScopeGroupId = true;
|
||||||
|
@ -74,43 +100,20 @@ public class SessionUtil {
|
||||||
hasScopeGroupId = false;
|
hasScopeGroupId = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currUserId != null && !currUserId.isEmpty()) {
|
|
||||||
hasCurrUserId = true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
hasCurrUserId = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasScopeGroupId) {
|
if (hasScopeGroupId) {
|
||||||
scope = pContext.getCurrentScope(scopeGroupId);
|
scope = pContext.getCurrentScope(scopeGroupId);
|
||||||
} else {
|
} else {
|
||||||
scope = pContext.getCurrentScope(httpServletRequest);
|
scope = pContext.getCurrentScope(httpServletRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Scope: " + scope);
|
|
||||||
if (scope == null || scope.isEmpty()) {
|
if (scope == null || scope.isEmpty()) {
|
||||||
String error = "Error retrieving scope: " + scope;
|
String error = "Error retrieving scope: " + scope;
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
throw new StatAlgoImporterServiceException(error);
|
throw new StatAlgoImporterServiceException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
GCubeUser gCubeUser = null;
|
GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
|
||||||
|
|
||||||
if (hasCurrUserId) {
|
|
||||||
try {
|
|
||||||
gCubeUser = new LiferayUserManager().getUserById(Long
|
|
||||||
.valueOf(currUserId));
|
|
||||||
} catch (Exception e) {
|
|
||||||
String error = "Error retrieving gCubeUser for: [userId= "
|
|
||||||
+ currUserId + ", scope: " + scope + "]";
|
|
||||||
logger.error(error, e);
|
|
||||||
throw new StatAlgoImporterServiceException(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gCubeUser = pContext.getCurrentUser(httpServletRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gCubeUser == null) {
|
if (gCubeUser == null) {
|
||||||
String error = "Error retrieving gCubeUser in scope " + scope
|
String error = "Error retrieving gCubeUser in scope " + scope
|
||||||
+ ": " + gCubeUser;
|
+ ": " + gCubeUser;
|
||||||
|
@ -119,7 +122,6 @@ public class SessionUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
userName = gCubeUser.getUsername();
|
userName = gCubeUser.getUsername();
|
||||||
logger.debug("UserName: " + userName);
|
|
||||||
|
|
||||||
if (userName == null || userName.isEmpty()) {
|
if (userName == null || userName.isEmpty()) {
|
||||||
String error = "Error retrieving username in scope " + scope
|
String error = "Error retrieving username in scope " + scope
|
||||||
|
@ -128,22 +130,8 @@ public class SessionUtil {
|
||||||
throw new StatAlgoImporterServiceException(error);
|
throw new StatAlgoImporterServiceException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCurrUserId) {
|
token = pContext.getCurrentUserToken(scope, userName);
|
||||||
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 StatAlgoImporterServiceException(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
token = pContext.getCurrentUserToken(scope, httpServletRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("Token: " + token);
|
|
||||||
if (token == null || token.isEmpty()) {
|
if (token == null || token.isEmpty()) {
|
||||||
String error = "Error retrieving token for " + userName
|
String error = "Error retrieving token for " + userName
|
||||||
+ " in " + scope + ": " + token;
|
+ " in " + scope + ": " + token;
|
||||||
|
@ -160,6 +148,10 @@ public class SessionUtil {
|
||||||
String email = gCubeUser.getEmail();
|
String email = gCubeUser.getEmail();
|
||||||
|
|
||||||
if (hasScopeGroupId) {
|
if (hasScopeGroupId) {
|
||||||
|
logger.info("Set SecurityToken: " + token);
|
||||||
|
SecurityTokenProvider.instance.set(token);
|
||||||
|
logger.info("Set ScopeProvider: " + scope);
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
|
||||||
groupId = scopeGroupId;
|
groupId = scopeGroupId;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import javax.portlet.PortletException;
|
||||||
import javax.portlet.PortletRequestDispatcher;
|
import javax.portlet.PortletRequestDispatcher;
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
|
import org.gcube.common.portal.PortalContext;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -44,9 +45,9 @@ public class StatAlgoImporterPortlet extends GenericPortlet {
|
||||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||||
|
|
||||||
logger.trace("Loading from JSP: "+VIEW_JSP);
|
logger.trace("Loading from JSP: "+VIEW_JSP);
|
||||||
|
logger.trace("Setting user in session using PortalContext");
|
||||||
|
PortalContext.setUserInSession(request);
|
||||||
|
|
||||||
//logger.trace("setting context using ScopeHelper");
|
|
||||||
//ScopeHelper.setContext(request);
|
|
||||||
|
|
||||||
logger.trace("passing to the render");
|
logger.trace("passing to the render");
|
||||||
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
|
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
|
||||||
|
|
|
@ -28,5 +28,7 @@ public class Constants {
|
||||||
// Session
|
// Session
|
||||||
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
|
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
|
||||||
public static final String CURR_USER_ID = "CURR_USER_ID";
|
public static final String CURR_USER_ID = "CURR_USER_ID";
|
||||||
|
|
||||||
|
public static final String LOCAL_UPLOAD_SERVLET = "LocalUploadServlet";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue