Added PortalContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@134830 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-11-25 15:10:40 +00:00
parent 45e969b3df
commit a2c1edf556
25 changed files with 352 additions and 329 deletions

View File

@ -2,6 +2,7 @@
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-2-0"
date="2016-12-01">
<Change>Updated Output support</Change>
<Change>Added PortalContext</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-1-0"
date="2016-10-01">

31
pom.xml
View File

@ -164,20 +164,9 @@
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>xalan</artifactId>
<groupId>xalan</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@ -186,6 +175,14 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>client-context-library</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
<scope>compile</scope>
</dependency>
<!-- Authorization -->
<dependency>
@ -207,14 +204,6 @@
<scope>compile</scope>
</dependency>
<!-- Session Checker -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>session-checker</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- Storage -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>

View File

@ -10,16 +10,12 @@ import org.gcube.portlets.user.dataminermanager.client.resources.Resources;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaRegionType;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaRequestEventType;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
@ -61,13 +57,14 @@ public class DataMinerManager implements EntryPoint {
// onModuleLoad2
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loadScope();
//loadScope();
loadMainPanel();
}
});
}
private void loadScope() {
/*private void loadScope() {
ClientScopeHelper.getService().setScope(Location.getHref(),
new AsyncCallback<Boolean>() {
@Override
@ -89,7 +86,7 @@ public class DataMinerManager implements EntryPoint {
}
});
}
}*/
private void loadMainPanel() {
dataMinerManagerController = new DataMinerManagerController();

View File

@ -38,7 +38,7 @@ 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.widgets.sessionchecker.client.CheckSession;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -84,11 +84,11 @@ public class DataMinerManagerController {
private void checkSession() {
// if you do not need to something when the session expire
CheckSession.getInstance().startPolling();
//CheckSession.getInstance().startPolling();
}
private void sessionExpiredShow() {
CheckSession.showLogoutDialog();
//CheckSession.showLogoutDialog();
}
/*

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.CancelExecutionFromComputationsRequestEvent;
@ -499,7 +500,10 @@ public class ComputationsExecutedPanel extends FramedPanel {
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName());
+ "=" + selectedItem.getName()
+ "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
@ -227,7 +228,7 @@ public class InputDataSetsPanel extends FramedPanel {
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
event.getDataMinerWorkArea().getInputDataSets().getFolder()
.getId(), false, showProperties, filterCriteria,
true, DISPLAY_FIELD.CREATION_DATE);
true, DISPLAY_FIELD.CREATION_DATE);
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
@Override
public void onSelectedItem(Item item) {
@ -257,8 +258,7 @@ public class InputDataSetsPanel extends FramedPanel {
.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanel");
wsResourcesExplorerPanel.setHeightToInternalScroll(300);
// DND
dnd = new MultipleDNDUpload();
@ -355,16 +355,18 @@ public class InputDataSetsPanel extends FramedPanel {
v.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
v.add(dnd, new VerticalLayoutData(1, 1, new Margins(0)));
add(v);
v.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
int scrollBarHeight=event.getHeight()-toolBar.getElement().getHeight(false);
Log.debug("ScrollBarHeight: "+scrollBarHeight);
wsResourcesExplorerPanel.setHeightToInternalScroll(scrollBarHeight);
int scrollBarHeight = event.getHeight()
- toolBar.getElement().getHeight(false);
Log.debug("ScrollBarHeight: " + scrollBarHeight);
wsResourcesExplorerPanel
.setHeightToInternalScroll(scrollBarHeight);
forceLayout();
}
});
forceLayout();
@ -421,7 +423,10 @@ public class InputDataSetsPanel extends FramedPanel {
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName());
+ "=" + selectedItem.getName()
+ "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
@ -420,7 +421,10 @@ public class OutputDataSetsPanel extends FramedPanel {
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName());
+ "=" + selectedItem.getName()
+ "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.user.dataminermanager.client.resources;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ExternalTextResource;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
/**
*

View File

@ -15,8 +15,7 @@
value="pretty" />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- OpenLayer Basic Widgets -->
<inherits
name='org.gcube.portlets.widgets.openlayerbasicwidgets.olbasicwidgets' />

View File

@ -11,7 +11,6 @@ import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,8 +44,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 context using ScopeHelper");
//ScopeHelper.setContext(request);
logger.trace("passing to the render");
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);

View File

@ -6,11 +6,11 @@ import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletService;
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClient;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.server.util.DataMinerWorkAreaManager;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
import org.gcube.portlets.user.dataminermanager.server.util.TableReader;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.TableItemSimple;
@ -24,6 +24,8 @@ 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;
@ -64,16 +66,16 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
@Override
public UserInfo hello() throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token = SessionUtil.getToken(aslSession);
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
aslSession.getGroupId(), aslSession.getGroupName(),
aslSession.getScope(), aslSession.getScopeName(),
aslSession.getUserEmailAddress(),
aslSession.getUserFullName());
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("hello()");
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(),
serviceCredentials.getGroupId(),
serviceCredentials.getGroupName(),
serviceCredentials.getScope(),
serviceCredentials.getEmail(),
serviceCredentials.getFullName());
logger.debug("UserInfo: " + userInfo);
logger.debug("UserToken: " + token);
return userInfo;
} catch (ServiceException e) {
e.printStackTrace();
@ -92,8 +94,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
SClient smClient = SessionUtil.getSClient(aslSession, session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
List<OperatorsClassification> list = smClient
.getOperatorsClassifications();
return list;
@ -114,9 +116,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
SClient smClient = SessionUtil.getSClient(aslSession, session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
List<Parameter> list = smClient.getInputParameters(operator);
return list;
} catch (ServiceException e) {
@ -135,9 +137,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("StartComputation(): [ operator=" + operator + "]");
SClient smClient = SessionUtil.getSClient(aslSession, session);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
ComputationId computationId = smClient.startComputation(operator);
return computationId;
} catch (ServiceException e) {
@ -156,11 +158,11 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
Map<String, String> properties = StorageUtil.getProperties(
aslSession.getUsername(), itemDescription.getId());
serviceCredentials.getUserName(), itemDescription.getId());
logger.debug("Properties: " + properties);
SClient smClient = SessionUtil.getSClient(aslSession, session);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
ComputationId computationId = smClient
.resubmitComputation(properties);
return computationId;
@ -180,8 +182,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
SClient smClient = SessionUtil.getSClient(aslSession, session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
ComputationStatus computationStatus = smClient
.getComputationStatus(computationId);
return computationStatus;
@ -201,12 +203,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
public void deleteItem(ItemDescription itemDescription)
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token = SessionUtil.getToken(aslSession);
logger.debug("UserToken: " + token);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("DeleteItem(): " + itemDescription);
StorageUtil.deleteItem(aslSession.getUsername(),
StorageUtil.deleteItem(serviceCredentials.getUserName(),
itemDescription.getId());
return;
@ -224,12 +223,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
public TableItemSimple retrieveTableInformation(Item item)
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token = SessionUtil.getToken(aslSession);
logger.debug("UserToken: " + token);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("retrieveTableInformation(): " + item);
TableReader tableReader = new TableReader(aslSession, item);
TableReader tableReader = new TableReader(serviceCredentials, item);
TableItemSimple tableItemSimple = tableReader.getTableItemSimple();
return tableItemSimple;
} catch (ServiceException e) {
@ -245,13 +241,10 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
@Override
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token = SessionUtil.getToken(aslSession);
logger.debug("UserToken: " + token);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("getDataMinerWorkArea()");
DataMinerWorkAreaManager dataMinerWorkAreaManager = new DataMinerWorkAreaManager(
aslSession);
serviceCredentials);
return dataMinerWorkAreaManager.getDataMinerWorkArea();
} catch (ServiceException e) {
@ -268,12 +261,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
public String getPublicLink(ItemDescription itemDescription)
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token = SessionUtil.getToken(aslSession);
logger.debug("UserToken: " + token);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("GetPublicLink(): " + itemDescription);
String link = StorageUtil.getPublicLink(aslSession.getUsername(),
String link = StorageUtil.getPublicLink(serviceCredentials.getUserName(),
itemDescription.getId());
return link;
@ -292,9 +282,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("CancelComputation(): " + computationId);
SClient smClient = SessionUtil.getSClient(aslSession, session);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
String result = smClient.cancelComputation(computationId);
// SessionUtil.putSClient(session, smClient);
return result;
@ -312,10 +302,10 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
public OutputData getOutputDataByComputationId(ComputationId computationId)
throws ServiceException {
try {
Log.debug("getOutputDataByComputationId: " + computationId);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
SClient smClient = SessionUtil.getSClient(aslSession, session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
Log.debug("getOutputDataByComputationId: " + computationId);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
OutputData outputData = smClient
.getOutputDataByComputationId(computationId);
Log.debug("OutputData: " + outputData);
@ -337,14 +327,14 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("OutputDataByComputationItemt(): " + itemDescription);
Map<String, String> properties = StorageUtil.getProperties(
aslSession.getUsername(), itemDescription.getId());
serviceCredentials.getUserName(), itemDescription.getId());
logger.debug("Properties: " + properties);
SClient smClient = SessionUtil.getSClient(aslSession, session);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
ComputationData computationData = smClient
.getComputationDataByComputationProperties(properties);
return computationData;
@ -365,7 +355,7 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("CancelComputation(): " + itemDescription);
String compId = itemDescription.getName();
if (compId == null) {
@ -381,7 +371,7 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
}
ComputationId computationId = new ComputationId();
computationId.setId(compId);
SClient smClient = SessionUtil.getSClient(aslSession, session);
SClient smClient = SessionUtil.getSClient(serviceCredentials, session);
String result = smClient.cancelComputation(computationId);
return result;
} catch (ServiceException e) {

View File

@ -12,8 +12,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.IOUtils;
import org.gcube.application.framework.core.session.ASLSession;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -75,16 +76,18 @@ public class DownloadFolderServlet extends HttpServlet {
}
logger.debug("DownloadFolderServlet session id: " + session.getId());
ASLSession aslSession = SessionUtil.getASLSession(session);
String token=SessionUtil.getToken(aslSession);
logger.debug("UserToken: "+token);
String scopeGroupId=request.getParameter(Constants.CURR_GROUP_ID);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(request, scopeGroupId);
ScopeProvider.instance.set(serviceCredentials.getScope());
String itemId = request.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER);
String folderName = request.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER);
logger.debug("Request: [itemId=" + itemId + ", folderName="
+ folderName + "]");
File tmpZip = StorageUtil.zipFolder(aslSession.getUsername(),
File tmpZip = StorageUtil.zipFolder(serviceCredentials.getUserName(),
itemId);
response.setHeader("Content-Disposition", "attachment; filename=\""
+ folderName + ".zip\"");

View File

@ -3,26 +3,19 @@
*/
package org.gcube.portlets.user.dataminermanager.server;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.common.portal.PortalContext;
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;
import org.gcube.portlets.user.dataminermanager.server.dmservice.SClientDirector;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredential;
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.SessionExpiredServiceException;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
/**
@ -35,59 +28,76 @@ public class SessionUtil {
private static final Logger logger = Logger.getLogger(SessionUtil.class);
public static ASLSession getASLSession(HttpSession httpSession)
public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest)
throws ServiceException {
String username = (String) httpSession
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
ASLSession aslSession;
if (username == null) {
if (Constants.DEBUG_MODE) {
logger.info("no user found in session, use test user");
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
username);
aslSession = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
aslSession.setScope(scope);
} else {
logger.info("no user found in session!");
throw new SessionExpiredServiceException("Session Expired!");
}
} else {
aslSession = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
}
logger.info("SessionUtil: aslSession " + aslSession.getUsername() + " "
+ aslSession.getScope());
return aslSession;
return getServiceCredentials(httpServletRequest, null);
}
public static String getToken(ASLSession aslSession)
throws Exception {
public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest, String scopeGroupId)
throws ServiceException {
ServiceCredentials sCredentials = null;
String userName = null;
String scope = null;
String token = null;
if (Constants.DEBUG_MODE) {
token = Constants.DEFAULT_TOKEN;
} else {
token = aslSession.getSecurityToken();
}
logger.info("received token: " + token);
return token;
if (Constants.DEBUG_MODE) {
logger.info("No credential found in session, use test user!");
userName = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
token = Constants.DEFAULT_TOKEN;
sCredentials = new ServiceCredentials(userName, scope, token);
} else {
logger.info("Retrieving credential in session!");
PortalContext pContext = PortalContext.getConfiguration();
if(scopeGroupId!=null&&!scopeGroupId.isEmpty()){
scope = pContext.getCurrentScope(scopeGroupId);
} else {
scope = pContext.getCurrentScope(httpServletRequest);
}
userName = pContext.getCurrentUser(httpServletRequest)
.getUsername();
token = pContext.getCurrentUserToken(httpServletRequest);
String name = pContext.getCurrentUser(httpServletRequest)
.getFirstName();
String lastName = pContext.getCurrentUser(httpServletRequest)
.getLastName();
String fullName = pContext.getCurrentUser(httpServletRequest)
.getFullname();
String userAvatarURL = pContext.getCurrentUser(httpServletRequest)
.getUserAvatarURL();
String email = pContext.getCurrentUser(httpServletRequest)
.getEmail();
String groupId = String.valueOf(pContext
.getCurrentGroupId(httpServletRequest));
String groupName = pContext.getCurrentGroupName(httpServletRequest);
sCredentials = new ServiceCredentials(userName, fullName, name,
lastName, email, scope, groupId, groupName, userAvatarURL, token);
}
logger.info("ServiceCredentials: " + sCredentials);
return sCredentials;
}
public static SClient getSClient(ASLSession aslSession, HttpSession session)
public static SClient getSClient(ServiceCredentials serviceCredentials, HttpSession session)
throws Exception {
if (aslSession == null) {
logger.error("ASLSession is null!");
throw new SessionExpiredServiceException("Session Expired!");
if (serviceCredentials == null) {
logger.error("ServiceCredentials is null!");
throw new ServiceException("Service Credentials is null!");
}
SClient sClient;
@ -96,37 +106,31 @@ public class SessionUtil {
logger.info("Create new SClientMap");
HashMap<String, SClient> sClientMap = new HashMap<>();
logger.info("Create new SClient");
ServiceCredential serviceCredential = new ServiceCredential(
aslSession.getUsername(), aslSession.getScope(),
SessionUtil.getToken(aslSession));
SClientBuilder sBuilder = new SClient4WPSBuilder(serviceCredential);
SClientBuilder sBuilder = new SClient4WPSBuilder(serviceCredentials);
SClientDirector director = new SClientDirector();
director.setSClientBuilder(sBuilder);
director.constructSClient();
sClient = director.getSClient();
sClientMap.put(aslSession.getScope(), sClient);
sClientMap.put(serviceCredentials.getScope(), sClient);
session.setAttribute(Constants.SClientMap, sClientMap);
} else {
if (obj instanceof HashMap<?, ?>) {
@SuppressWarnings("unchecked")
HashMap<String, SClient> sClientMap = (HashMap<String, SClient>) obj;
if (sClientMap.containsKey(aslSession.getScope())) {
if (sClientMap.containsKey(serviceCredentials.getScope())) {
logger.info("Use SClient in session");
sClient = sClientMap.get(aslSession.getScope());
sClient = sClientMap.get(serviceCredentials.getScope());
} else {
logger.info("Create new SClient");
ServiceCredential serviceCredential = new ServiceCredential(
aslSession.getUsername(), aslSession.getScope(),
SessionUtil.getToken(aslSession));
SClientBuilder sBuilder = new SClient4WPSBuilder(
serviceCredential);
serviceCredentials);
SClientDirector director = new SClientDirector();
director.setSClientBuilder(sBuilder);
director.constructSClient();
sClient = director.getSClient();
sClientMap.put(aslSession.getScope(), sClient);
sClientMap.put(serviceCredentials.getScope(), sClient);
session.setAttribute(Constants.SClientMap, sClientMap);
}

View File

@ -37,7 +37,7 @@ import org.gcube.portlets.user.dataminermanager.server.dmservice.wps.WPS2DM;
import org.gcube.portlets.user.dataminermanager.server.dmservice.wps.computationsvalue.ComputationValueBuilder;
import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredential;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
@ -94,7 +94,7 @@ public class SClient4WPS extends SClient {
private SClient4WPSSession wpsClient;
public SClient4WPS(ServiceCredential serviceCredential) throws Exception {
public SClient4WPS(ServiceCredentials serviceCredential) throws Exception {
super();
process = new HashMap<>();
runningProcess = new HashMap<>();
@ -111,7 +111,7 @@ public class SClient4WPS extends SClient {
wpsToken = token;
}
String userName = serviceCredential.getUsername();
String userName = serviceCredential.getUserName();
if (userName == null || userName.isEmpty()) {
logger.error("Error invalid user name: " + userName);
throw new Exception("Error invalid user name: " + userName);

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.server.dmservice;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredential;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,9 +15,9 @@ import org.slf4j.LoggerFactory;
public class SClient4WPSBuilder extends SClientBuilder {
private static Logger logger = LoggerFactory
.getLogger(SClient4WPSBuilder.class);
private ServiceCredential serviceCredendial;
private ServiceCredentials serviceCredendial;
public SClient4WPSBuilder(ServiceCredential serviceCredential) {
public SClient4WPSBuilder(ServiceCredentials serviceCredential) {
this.serviceCredendial= serviceCredential;
}

View File

@ -7,16 +7,10 @@ import java.util.Date;
import java.util.Map;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
@ -199,9 +193,7 @@ public class StorageUtil {
return item;
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException
| WrongItemTypeException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
@ -225,9 +217,7 @@ public class StorageUtil {
return item;
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException
| WrongItemTypeException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
@ -249,9 +239,7 @@ public class StorageUtil {
ws.removeItems(itemId);
return;
} catch (InsufficientPrivilegesException
| WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.server.util;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
@ -27,17 +27,17 @@ public class DataMinerWorkAreaManager {
public static final Logger logger = LoggerFactory
.getLogger(DataMinerWorkAreaManager.class);
private ASLSession aslSession;
private ServiceCredentials serviceCredentials;
public DataMinerWorkAreaManager(ASLSession aslSession) {
this.aslSession = aslSession;
public DataMinerWorkAreaManager(ServiceCredentials serviceCredentials) {
this.serviceCredentials = serviceCredentials;
}
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
DataMinerWorkArea dataMinerWorkArea = null;
try {
WorkspaceItem wiDataMinerFolder = StorageUtil
.getItemInRootFolderOnWorkspace(aslSession.getUsername(),
.getItemInRootFolderOnWorkspace(serviceCredentials.getUserName(),
DATA_MINER_FOLDER);
if (wiDataMinerFolder == null) {
@ -66,7 +66,7 @@ public class DataMinerWorkAreaManager {
InputDataSets inputDataSets = null;
try {
WorkspaceItem wiImportedDataFolder = StorageUtil
.getItemInFolderOnWorkspace(aslSession.getUsername(),
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), IMPORTED_DATA_FOLDER);
ItemDescription importedDataFolder = null;
@ -88,7 +88,7 @@ public class DataMinerWorkAreaManager {
OutputDataSets outputDataSets = null;
try {
WorkspaceItem wiComputedDataFolder = StorageUtil
.getItemInFolderOnWorkspace(aslSession.getUsername(),
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), COMPUTED_DATA_FOLDER);
ItemDescription computedDataFolder = null;
@ -109,7 +109,7 @@ public class DataMinerWorkAreaManager {
Computations computations = null;
try {
WorkspaceItem wiComputationsDataFolder = StorageUtil
.getItemInFolderOnWorkspace(aslSession.getUsername(),
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), COMPUTATIONS_FOLDER);
ItemDescription computationsDataFolder = null;

View File

@ -1,66 +0,0 @@
package org.gcube.portlets.user.dataminermanager.server.util;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ServiceCredential implements Serializable {
private static final long serialVersionUID = 3560918948310315680L;
private String username;
private String scope;
private String token;
public ServiceCredential() {
super();
}
/**
*
* @param user
* @param scope
* @param token
*/
public ServiceCredential(String username, String scope, String token) {
super();
this.username = username;
this.scope = scope;
this.token = token;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
@Override
public String toString() {
return "ServiceCredential [username=" + username + ", scope=" + scope
+ ", token=" + token + "]";
}
}

View File

@ -0,0 +1,141 @@
package org.gcube.portlets.user.dataminermanager.server.util;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ServiceCredentials implements Serializable {
private static final long serialVersionUID = 3560918948310315680L;
private String userName;
private String fullName;
private String name;
private String lastName;
private String email;
private String scope;
private String groupId;
private String groupName;
private String userAvatarURL;
private String token;
public ServiceCredentials() {
super();
}
public ServiceCredentials(String userName, String scope, String token) {
super();
this.userName = userName;
this.scope = scope;
this.token = token;
}
public ServiceCredentials(String userName, String fullName, String name,
String lastName, String email, String scope, String groupId,
String groupName, String userAvatarURL, String token) {
super();
this.userName = userName;
this.fullName = fullName;
this.name = name;
this.lastName = lastName;
this.email = email;
this.scope = scope;
this.groupId = groupId;
this.groupName = groupName;
this.userAvatarURL = userAvatarURL;
this.token = token;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getUserAvatarURL() {
return userAvatarURL;
}
public void setUserAvatarURL(String userAvatarURL) {
this.userAvatarURL = userAvatarURL;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
@Override
public String toString() {
return "ServiceCredentials [userName=" + userName + ", fullName="
+ fullName + ", name=" + name + ", lastName=" + lastName
+ ", email=" + email + ", scope=" + scope + ", groupId="
+ groupId + ", groupName=" + groupName + ", userAvatarURL="
+ userAvatarURL + ", token=" + token + "]";
}
}

View File

@ -9,7 +9,6 @@ import java.util.List;
import net.sf.csv4j.CSVReader;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.shared.data.ColumnItem;
import org.gcube.portlets.user.dataminermanager.shared.data.TableItemSimple;
@ -27,24 +26,24 @@ import org.slf4j.LoggerFactory;
public class TableReader {
private static Logger logger = LoggerFactory.getLogger(TableReader.class);
private ASLSession aslSession;
private ServiceCredentials serviceCredentials;
private Item item;
public TableReader(ASLSession aslSession, Item item) {
this.aslSession = aslSession;
public TableReader(ServiceCredentials serviceCredentials, Item item) {
this.serviceCredentials = serviceCredentials;
this.item= item;
}
public TableItemSimple getTableItemSimple() throws ServiceException {
InputStream is = StorageUtil.getInputStreamForItemOnWorkspace(
aslSession.getUsername(), item.getId());
serviceCredentials.getUserName(), item.getId());
Reader fileReader = new InputStreamReader(is);
CSVReader csvReader = new CSVReader(fileReader);
List<String> firstLine = getFirstLine(csvReader, false);
ArrayList<String> columns = new ArrayList<String>(firstLine);
String publicLink=StorageUtil.getPublicLink(aslSession.getUsername(), item.getId());
String publicLink=StorageUtil.getPublicLink(serviceCredentials.getUserName(), item.getId());
TableItemSimple tableItemSimple=new TableItemSimple(publicLink,item.getName(), item.getType().name());
ArrayList<ColumnItem> columnItemList=new ArrayList<ColumnItem>();

View File

@ -57,6 +57,7 @@ public class Constants {
public static final String DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER = "itemId";
public static final String DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER = "folderName";
//
public static final String CURR_GROUP_ID="CURR_GROUP_ID";
}

View File

@ -13,10 +13,9 @@ public class UserInfo implements Serializable {
private static final long serialVersionUID = -2826549639677017234L;
private String username;
private Long groupId;
private String groupId;
private String groupName;
private String scope;
private String scopeName;
private String userEmailAddress;
private String userFullName;
@ -24,25 +23,13 @@ public class UserInfo implements Serializable {
super();
}
/**
*
* @param username
* @param groupId
* @param groupName
* @param scope
* @param scopeName
* @param userEmailAddress
* @param userFullName
*/
public UserInfo(String username, Long groupId, String groupName,
String scope, String scopeName, String userEmailAddress,
String userFullName) {
public UserInfo(String username, String groupId, String groupName,
String scope, String userEmailAddress, String userFullName) {
super();
this.username = username;
this.groupId = groupId;
this.groupName = groupName;
this.scope = scope;
this.scopeName = scopeName;
this.userEmailAddress = userEmailAddress;
this.userFullName = userFullName;
}
@ -55,11 +42,11 @@ public class UserInfo implements Serializable {
this.username = username;
}
public Long getGroupId() {
public String getGroupId() {
return groupId;
}
public void setGroupId(Long groupId) {
public void setGroupId(String groupId) {
this.groupId = groupId;
}
@ -79,14 +66,6 @@ public class UserInfo implements Serializable {
this.scope = scope;
}
public String getScopeName() {
return scopeName;
}
public void setScopeName(String scopeName) {
this.scopeName = scopeName;
}
public String getUserEmailAddress() {
return userEmailAddress;
}
@ -107,8 +86,10 @@ public class UserInfo implements Serializable {
public String toString() {
return "UserInfo [username=" + username + ", groupId=" + groupId
+ ", groupName=" + groupName + ", scope=" + scope
+ ", scopeName=" + scopeName + ", userEmailAddress="
+ userEmailAddress + ", userFullName=" + userFullName + "]";
+ ", userEmailAddress=" + userEmailAddress + ", userFullName="
+ userFullName + "]";
}
}

View File

@ -15,8 +15,7 @@
value="pretty" />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- OpenLayer Basic Widgets -->
<inherits
name='org.gcube.portlets.widgets.openlayerbasicwidgets.olbasicwidgets' />

View File

@ -28,14 +28,8 @@
<servlet-name>workspaceUploadServletStream</servlet-name>
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
</servlet>
<servlet>
<servlet-name>checkServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>scopeService</servlet-name>
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DataMinerManagerServlet</servlet-name>
<url-pattern>/dataminermanager/dataminerman</url-pattern>
@ -60,14 +54,7 @@
<servlet-name>workspaceUploadServletStream</servlet-name>
<url-pattern>/dataminermanager/workspaceUploadServletStream</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>checkServlet</servlet-name>
<url-pattern>/dataminermanager/checksession</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>scopeService</servlet-name>
<url-pattern>/dataminermanager/scopeService</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>DataMinerManager.html</welcome-file>
</welcome-file-list>

View File

@ -19,10 +19,9 @@ import java.util.zip.GZIPInputStream;
import junit.framework.TestCase;
import org.apache.commons.codec.binary.Base64;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredentials;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -51,10 +50,9 @@ public class TestDataMinerService extends TestCase {
wpsUser = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
ASLSession aslSession = SessionManager.getInstance().getASLSession(
"1234567890123456", wpsUser);
aslSession.setScope(scope);
ServiceCredentials serviceCredentials=new ServiceCredentials();
serviceCredentials.setUserName(wpsUser);
serviceCredentials.setScope(scope);
List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE);
@ -65,8 +63,8 @@ public class TestDataMinerService extends TestCase {
try {
wpsToken = authorizationService().generateUserToken(
new UserInfo(aslSession.getUsername(), userRoles),
aslSession.getScope());
new UserInfo(serviceCredentials.getUserName(), userRoles),
serviceCredentials.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: "
+ e.getLocalizedMessage());
@ -74,11 +72,12 @@ public class TestDataMinerService extends TestCase {
throw new Exception("Error generating the token for test: "
+ e.getLocalizedMessage());
}
serviceCredentials.setToken(wpsToken);
List<String> serviceAddress = InformationSystemUtils
.retrieveServiceAddress(
Constants.DATAMINER_SERVICE_CATEGORY,
Constants.DATA_MINER_SERVICE_NAME, scope);
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
logger.debug("Service Address retrieved:" + serviceAddress);
if (serviceAddress == null || serviceAddress.size() < 1) {
logger.error("No DataMiner service address available!");