ref 6278:DataMiner - getUserId doesn't work when session expires and Reload is performed
https://support.d4science.org/issues/6278 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@142350 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
70e94abbff
commit
4e5f62d95a
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-3-0"
|
||||
date="2016-02-15">
|
||||
<Change>Updated PortalContext [ticket #6278]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-2-0"
|
||||
date="2016-12-01">
|
||||
<Change>Updated Output support</Change>
|
||||
|
|
|
@ -502,9 +502,7 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
|||
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||
+ "=" + selectedItem.getName() + "&"
|
||||
+ Constants.CURR_GROUP_ID + "="
|
||||
+ GCubeClientContext.getCurrentContextId()
|
||||
+ "&" + Constants.CURR_USER_ID + "="
|
||||
+ GCubeClientContext.getCurrentUserId());
|
||||
+ GCubeClientContext.getCurrentContextId());
|
||||
|
||||
Log.debug("Retrieved link: " + actionUrl);
|
||||
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||
|
|
|
@ -425,9 +425,7 @@ public class InputDataSetsPanel extends FramedPanel {
|
|||
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||
+ "=" + selectedItem.getName() + "&"
|
||||
+ Constants.CURR_GROUP_ID + "="
|
||||
+ GCubeClientContext.getCurrentContextId()
|
||||
+ "&" + Constants.CURR_USER_ID + "="
|
||||
+ GCubeClientContext.getCurrentUserId());
|
||||
+ GCubeClientContext.getCurrentContextId());
|
||||
|
||||
Log.debug("Retrieved link: " + actionUrl);
|
||||
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||
|
|
|
@ -424,9 +424,7 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||
+ "=" + selectedItem.getName() + "&"
|
||||
+ Constants.CURR_GROUP_ID + "="
|
||||
+ GCubeClientContext.getCurrentContextId()
|
||||
+ "&" + Constants.CURR_USER_ID + "="
|
||||
+ GCubeClientContext.getCurrentUserId());
|
||||
+ GCubeClientContext.getCurrentContextId());
|
||||
|
||||
Log.debug("Retrieved link: " + actionUrl);
|
||||
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.portlet.PortletRequestDispatcher;
|
|||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -44,8 +45,8 @@ public class DataMinerManager extends GenericPortlet {
|
|||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
|
||||
logger.trace("DataMinerManager loading from JSP: "+VIEW_JSP);
|
||||
//logger.trace("setting context using ScopeHelper");
|
||||
//ScopeHelper.setContext(request);
|
||||
logger.trace("Setting user in session using PortalContext");
|
||||
PortalContext.setUserInSession(request);
|
||||
|
||||
logger.trace("passing to the render");
|
||||
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletService;
|
||||
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClient;
|
||||
|
@ -24,8 +24,6 @@ import org.gcube.portlets.user.dataminermanager.shared.process.OperatorsClassifi
|
|||
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.workspace.DataMinerWorkArea;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
||||
|
||||
|
||||
//import org.gcube.portlets.user.tdw.server.datasource.DataSourceFactoryRegistry;
|
||||
//import org.gcube.portlets.widgets.file_dw_import_wizard.server.file.TargetRegistry;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
@ -93,9 +91,11 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
throws ServiceException {
|
||||
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
List<OperatorsClassification> list = smClient
|
||||
.getOperatorsClassifications();
|
||||
return list;
|
||||
|
@ -115,10 +115,13 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public List<Parameter> getParameters(Operator operator)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
|
||||
List<Parameter> list = smClient.getInputParameters(operator);
|
||||
return list;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -136,10 +139,14 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public ComputationId startComputation(Operator operator)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
logger.debug("StartComputation(): [ operator=" + operator + "]");
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
|
||||
ComputationId computationId = smClient.startComputation(operator);
|
||||
return computationId;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -157,12 +164,16 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public ComputationId resubmit(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
Map<String, String> properties = StorageUtil.getProperties(
|
||||
serviceCredentials.getUserName(), itemDescription.getId());
|
||||
logger.debug("Properties: " + properties);
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
|
||||
ComputationId computationId = smClient
|
||||
.resubmitComputation(properties);
|
||||
return computationId;
|
||||
|
@ -181,9 +192,11 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public ComputationStatus getComputationStatus(ComputationId computationId)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
ComputationStatus computationStatus = smClient
|
||||
.getComputationStatus(computationId);
|
||||
return computationStatus;
|
||||
|
@ -203,7 +216,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public void deleteItem(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("DeleteItem(): " + itemDescription);
|
||||
StorageUtil.deleteItem(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
|
@ -223,7 +238,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public TableItemSimple retrieveTableInformation(Item item)
|
||||
throws ServiceException {
|
||||
try {
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("retrieveTableInformation(): " + item);
|
||||
TableReader tableReader = new TableReader(serviceCredentials, item);
|
||||
TableItemSimple tableItemSimple = tableReader.getTableItemSimple();
|
||||
|
@ -241,7 +258,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
|
||||
try {
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("getDataMinerWorkArea()");
|
||||
DataMinerWorkAreaManager dataMinerWorkAreaManager = new DataMinerWorkAreaManager(
|
||||
serviceCredentials);
|
||||
|
@ -261,10 +280,12 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public String getPublicLink(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
String link = StorageUtil.getPublicLink(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
String link = StorageUtil.getPublicLink(
|
||||
serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -281,10 +302,12 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public String cancelComputation(ComputationId computationId)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("CancelComputation(): " + computationId);
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
String result = smClient.cancelComputation(computationId);
|
||||
// SessionUtil.putSClient(session, smClient);
|
||||
return result;
|
||||
|
@ -302,10 +325,12 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public OutputData getOutputDataByComputationId(ComputationId computationId)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
Log.debug("getOutputDataByComputationId: " + computationId);
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
OutputData outputData = smClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
Log.debug("OutputData: " + outputData);
|
||||
|
@ -326,15 +351,17 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public ComputationData getComputationData(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("OutputDataByComputationItemt(): " + itemDescription);
|
||||
Map<String, String> properties = StorageUtil.getProperties(
|
||||
serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
|
||||
|
||||
logger.debug("Properties: " + properties);
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
|
||||
ComputationData computationData = smClient
|
||||
.getComputationDataByComputationProperties(properties);
|
||||
return computationData;
|
||||
|
@ -354,8 +381,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public String cancelComputation(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("CancelComputation(): " + itemDescription);
|
||||
String compId = itemDescription.getName();
|
||||
if (compId == null) {
|
||||
|
@ -371,7 +399,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
ComputationId computationId = new ComputationId();
|
||||
computationId.setId(compId);
|
||||
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest,
|
||||
serviceCredentials);
|
||||
String result = smClient.cancelComputation(computationId);
|
||||
return result;
|
||||
} catch (ServiceException e) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
|
||||
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||
|
@ -76,13 +75,30 @@ public class DownloadFolderServlet extends HttpServlet {
|
|||
}
|
||||
logger.debug("DownloadFolderServlet session id: " + session.getId());
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
String currUserId = request.getParameter(Constants.CURR_USER_ID);
|
||||
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(request, scopeGroupId, currUserId);
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
String scopeGroupId = request.getHeader(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ 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());
|
||||
}
|
||||
|
||||
String itemId = request
|
||||
.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER);
|
||||
|
|
|
@ -9,7 +9,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClient;
|
||||
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClient4WPSBuilder;
|
||||
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClientBuilder;
|
||||
|
@ -18,7 +20,6 @@ import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
|
|||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
|
||||
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.GCubeUser;
|
||||
|
||||
|
@ -32,14 +33,27 @@ public class SessionUtil {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(SessionUtil.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public static ServiceCredentials getServiceCredentials(
|
||||
HttpServletRequest httpServletRequest) throws ServiceException {
|
||||
return getServiceCredentials(httpServletRequest, null, null);
|
||||
return getServiceCredentials(httpServletRequest, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* @param scopeGroupId
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public static ServiceCredentials getServiceCredentials(
|
||||
HttpServletRequest httpServletRequest, String scopeGroupId,
|
||||
String currUserId) throws ServiceException {
|
||||
HttpServletRequest httpServletRequest, String scopeGroupId)
|
||||
throws ServiceException {
|
||||
|
||||
ServiceCredentials sCredentials = null;
|
||||
String userName = null;
|
||||
|
@ -50,17 +64,29 @@ public class SessionUtil {
|
|||
|
||||
if (Constants.DEBUG_MODE) {
|
||||
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;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
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);
|
||||
|
||||
} else {
|
||||
logger.info("Retrieving credential in session!");
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
boolean hasScopeGroupId = false;
|
||||
boolean hasCurrUserId = false;
|
||||
|
||||
if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
|
||||
hasScopeGroupId = true;
|
||||
|
@ -69,42 +95,19 @@ public class SessionUtil {
|
|||
hasScopeGroupId = false;
|
||||
}
|
||||
|
||||
if (currUserId != null && !currUserId.isEmpty()) {
|
||||
hasCurrUserId = true;
|
||||
|
||||
} else {
|
||||
hasCurrUserId = false;
|
||||
}
|
||||
|
||||
if (hasScopeGroupId) {
|
||||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
} else {
|
||||
scope = pContext.getCurrentScope(httpServletRequest);
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Scope: " + scope);
|
||||
if (scope == null || scope.isEmpty()) {
|
||||
String error = "Error retrieving scope: " + scope;
|
||||
logger.error(error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
|
||||
GCubeUser gCubeUser = null;
|
||||
|
||||
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 ServiceException(error);
|
||||
}
|
||||
} else {
|
||||
gCubeUser = pContext.getCurrentUser(httpServletRequest);
|
||||
}
|
||||
GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
|
||||
|
||||
if (gCubeUser == null) {
|
||||
String error = "Error retrieving gCubeUser in scope " + scope
|
||||
|
@ -114,7 +117,6 @@ public class SessionUtil {
|
|||
}
|
||||
|
||||
userName = gCubeUser.getUsername();
|
||||
logger.debug("UserName: " + userName);
|
||||
|
||||
if (userName == null || userName.isEmpty()) {
|
||||
String error = "Error retrieving username in scope " + scope
|
||||
|
@ -123,22 +125,8 @@ public class SessionUtil {
|
|||
throw new ServiceException(error);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
token = pContext.getCurrentUserToken(scope, userName);
|
||||
|
||||
} else {
|
||||
token = pContext.getCurrentUserToken(httpServletRequest);
|
||||
}
|
||||
|
||||
logger.debug("Token: " + token);
|
||||
if (token == null || token.isEmpty()) {
|
||||
String error = "Error retrieving token for " + userName
|
||||
+ " in " + scope + ": " + token;
|
||||
|
@ -155,6 +143,10 @@ public class SessionUtil {
|
|||
String email = gCubeUser.getEmail();
|
||||
|
||||
if (hasScopeGroupId) {
|
||||
logger.info("Set SecurityToken: " + token);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
logger.info("Set ScopeProvider: " + scope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
groupId = scopeGroupId;
|
||||
|
||||
|
@ -198,13 +190,16 @@ public class SessionUtil {
|
|||
return sCredentials;
|
||||
}
|
||||
|
||||
public static SClient getSClient(ServiceCredentials serviceCredentials,
|
||||
HttpSession session) throws Exception {
|
||||
|
||||
public static SClient getSClient(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) throws Exception {
|
||||
|
||||
|
||||
if (serviceCredentials == null) {
|
||||
logger.error("ServiceCredentials is null!");
|
||||
throw new ServiceException("Service Credentials is null!");
|
||||
}
|
||||
HttpSession session=httpRequest.getSession();
|
||||
|
||||
SClient sClient;
|
||||
|
||||
Object obj = session.getAttribute(Constants.SClientMap);
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
<layout-cacheable>false</layout-cacheable>
|
||||
<instanceable>false</instanceable>
|
||||
<ajaxable>false</ajaxable>
|
||||
<css-class-wrapper>DataMinerManagerCSS</css-class-wrapper>
|
||||
</portlet>
|
||||
</liferay-portlet-app>
|
Loading…
Reference in New Issue