add ASLSession object in class GWTdbManagerServiceImpl to manage variables for each user Http session. Classes CancelQueryExecutionEvent, CancelQueryExecutionEventHandler added. Pom file modified to add aslSession adding the related dependency.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99175 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-08-01 09:27:40 +00:00
parent 4837482f5d
commit 9c21766b70
11 changed files with 562 additions and 126 deletions

View File

@ -25,16 +25,16 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/loredana/Desktop/libraries/gxt-2.2.5.zip"/>
<classpathentry kind="var" path="GLOBUS_LOCATION"/>
<classpathentry kind="var" path="KEYS"/>
<classpathentry kind="lib" path="/home/loredana/Desktop/libraries/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="/home/loredana/Desktop/libraries/slf4j-api-1.6.4.jar"/>
<classpathentry kind="lib" path="/home/loredana/Desktop/libraries/slf4j-log4j12-1.6.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/databases-manager-portlet-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

27
pom.xml
View File

@ -111,7 +111,12 @@
<artifactId>common-scope-maps</artifactId>
<version>[1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
@ -135,16 +140,16 @@
<!-- <scope>runtime</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.slf4j</groupId> -->
<!-- <artifactId>slf4j-api</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.slf4j</groupId> -->
<!-- <artifactId>slf4j-log4j12</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.slf4j</groupId> -->
<!-- <artifactId>slf4j-api</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.slf4j</groupId> -->
<!-- <artifactId>slf4j-log4j12</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>log4j</groupId>

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.databasesmanager.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
@ -45,5 +46,7 @@ public interface GWTdbManagerService extends RemoteService {
PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
String keyword) throws Exception;
}

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.databasesmanager.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.user.databasesmanager.client.events;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.CancelQueryExecutionEventHandler;
import com.google.gwt.event.shared.GwtEvent;
public class CancelQueryExecutionEvent extends
GwtEvent<CancelQueryExecutionEventHandler> {
public static Type<CancelQueryExecutionEventHandler> TYPE = new Type<CancelQueryExecutionEventHandler>();
@Override
public Type<CancelQueryExecutionEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(CancelQueryExecutionEventHandler handler) {
handler.onCancelQueryExecution(this);
}
public EventsTypeEnum getKey() {
return EventsTypeEnum.CANCEL_EXECUTION_QUERY;
}
}

View File

@ -9,6 +9,7 @@ public enum EventsTypeEnum {
SMART_SAMPLING_EVENT,
RANDOM_SAMPLING_EVENT,
LOAD_TABLES_EVENT,
SELECTED_TABLE_EVENT;
SELECTED_TABLE_EVENT,
CANCEL_EXECUTION_QUERY;
}

View File

@ -0,0 +1,8 @@
package org.gcube.portlets.user.databasesmanager.client.events.interfaces;
import org.gcube.portlets.user.databasesmanager.client.events.CancelQueryExecutionEvent;
import com.google.gwt.event.shared.EventHandler;
public interface CancelQueryExecutionEventHandler extends EventHandler{
public void onCancelQueryExecution(CancelQueryExecutionEvent cancelQueryExecutionEvent);
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -114,8 +115,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
west = new ContentPanel();
center = new LayoutContainer();
treePanel = new GxtTreePanel(eventBus, service);
toolbar = new GxtToolbarFunctionality(eventBus);
// toolbar = new GxtToolbarFunctionality(eventBus, RPCservice);
// toolbar = new GxtToolbarFunctionality(eventBus);
toolbar = new GxtToolbarFunctionality(eventBus, RPCservice);
this.setHeaderVisible(false); // hide the header of the panel
@ -850,6 +851,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "Dialect used for smart correction: "
+ language);
// remote rpc
RPCservice.submitQuery(dataForSubmitQuery, dataQuery.getQuery(), true,

View File

@ -1,9 +1,11 @@
package org.gcube.portlets.user.databasesmanager.client.toolbar;
import java.util.LinkedHashMap;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
@ -54,28 +56,28 @@ public class GxtToolbarFunctionality {
.getLogger("GxtToolbarFunctionality");
// RPC service
// private GWTdbManagerServiceAsync RPCservice = null;
private GWTdbManagerServiceAsync RPCservice = null;
// Constructor
public GxtToolbarFunctionality(HandlerManager eBus) {
eventBus = eBus;
toolBar = new ToolBar();
initToolBar();
addHandler();
addSelectionListenersOnToolBar();
}
// public GxtToolbarFunctionality(HandlerManager eBus) {
// eventBus = eBus;
// toolBar = new ToolBar();
// initToolBar();
// addHandler();
// addSelectionListenersOnToolBar();
// }
// Constructor with GWTdbManagerServiceAsync service parameter
// public GxtToolbarFunctionality(HandlerManager eBus,
// GWTdbManagerServiceAsync service) {
//
// eventBus = eBus;
// RPCservice = service;
// toolBar = new ToolBar();
// initToolBar();
// addHandler();
// addSelectionListenersOnToolBar();
// }
public GxtToolbarFunctionality(HandlerManager eBus,
GWTdbManagerServiceAsync service) {
eventBus = eBus;
RPCservice = service;
toolBar = new ToolBar();
initToolBar();
addHandler();
addSelectionListenersOnToolBar();
}
private void initToolBar() {
@ -239,6 +241,11 @@ public class GxtToolbarFunctionality {
@Override
public void componentSelected(ButtonEvent ce) {
//start computation and get id
//generate a UUID for this request
// UUID id = UUID.randomUUID();
// recover info from dialog
setInfoOnSubmitQuery(form, dialog,
dialogID);
@ -257,6 +264,9 @@ public class GxtToolbarFunctionality {
ButtonEvent ce) {
rootLogger.log(Level.INFO,
"button Cancel event");
//remove computation
dialog.hide();
}
});

View File

@ -1,9 +1,11 @@
package org.gcube.portlets.user.databasesmanager.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@ -12,6 +14,7 @@ import java.net.URLStreamHandler;
import javax.servlet.http.HttpSession;
import org.apache.regexp.RE;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection;
import org.gcube.data.analysis.statisticalmanager.proxies.StatisticalManagerDSL;
@ -44,6 +47,8 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.Parameter;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
import org.gcube.portlets.user.databasesmanager.server.util.WsUtil;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
@ -54,25 +59,56 @@ import org.apache.log4j.Logger;
public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
GWTdbManagerService {
// the result generated in the LoadTables method
private List<Result> result = null;
// // the result generated in the LoadTables method
// private List<Result> result = null;
// information about a database
private String currentDB = "";
private String previousDB = "";
// private String currentDB = "";
// private String previousDB = "";
// information about a schema
private String currentSchema = "";
private String previousSchema = "";
// private String currentSchema = "";
// private String previousSchema = "";
//Hashmap that contains computationId
// HashMap<UUID, String> computationIDMap = new HashMap<UUID, String>();
// logger
private static Logger logger = Logger
.getLogger(GWTdbManagerServiceImpl.class);
public GWTdbManagerServiceImpl() {
}
private void initVariables(){
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
// the result generated in the LoadTables method
List<Result> result = new ArrayList<Result>();
session.setAttribute("TablesResult", result);
// information about a database
String currentDB = "";
session.setAttribute("currentDB", currentDB);
String previousDB = "";
session.setAttribute("previousDB", previousDB);
// information about a schema
String currentSchema = "";
session.setAttribute("currentSchema", currentSchema);
String previousSchema = "";
session.setAttribute("previousSchema", previousSchema);
}
// to get resources from IS
@Override
public List<FileModel> getResource() throws Exception {
// data input
//initialize variables with application startup
initVariables();
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
List<FileModel> outputParameters = new ArrayList<FileModel>();
@ -201,6 +237,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
@Override
public List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
throws Exception {
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
@ -344,27 +382,41 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
String keyword) throws Exception {
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
List<Result> result = (List<Result>) session.getAttribute("TablesResult");
// check on a database
String currentDB = "";
currentDB = dataInput.get("DatabaseName");
String previousDB = (String) session.getAttribute("previousDB");
if (!currentDB.equals(previousDB)) {
result = null;
// result = null;
result = new ArrayList<Result>();
System.gc();
}
previousDB = currentDB;
session.setAttribute("previousDB", previousDB);
// check on a schema
String currentSchema = "";
currentSchema = dataInput.get("SchemaName");
String previousSchema = (String) session.getAttribute("previousSchema");
if (!currentSchema.equals(previousSchema)) {
result = null;
// result = null;
result = new ArrayList<Result>();
System.gc();
}
previousSchema = currentSchema;
session.setAttribute("previousSchema", previousSchema);
// get tables
if (result == null)
// if (result == null)
// result = getTables(dataInput);
if (result.size()==0)
result = getTables(dataInput);
// Create a sublist and add data to list according
@ -418,90 +470,278 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
loadResult = new BasePagingLoadResult<Result>(sublist,
config.getOffset(), totalNumber);
session.setAttribute("TablesResult", result);
return loadResult;
}
// to submit a query
@Override
public List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
String query, boolean valueReadOnlyQuery,
boolean smartCorrectionQuery, String language) throws Exception {
// to submit a query
@Override
public List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
String query, boolean valueReadOnlyQuery,
boolean smartCorrectionQuery, String language) throws Exception {
logger.info("Dialect used for smart correction: " + language);
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
List<Result> output = new ArrayList<Result>();
// get list of algorithms
List<String> algorithms = new ArrayList<String>();
algorithms = getDatabaseManagerAlgorithms();
// get algorithmId
String algorithmId = null;
for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("SUBMITQUERY")) {
algorithmId = algorithms.get(i);
// print check
// logger.info("algorithmId: " + algorithmId);
}
}
// get input parameters of the algorithm
inputParameters = getParameters(algorithmId);
if (inputParameters.size() != 0) {
// print check
logger.info("algorithm input parameters retrieved");
}
// print check
// for (int i = 0; i < inputParameters.size(); i++) {
// logger.info(inputParameters.get(i).getName());
// }
// print check
logger.info("ResourceName: " + dataDB.get("ResourceName"));
logger.info("DatabaseName: " + dataDB.get("DatabaseName"));
logger.info("Query: " + query);
logger.info("SmartCorrections check: " + smartCorrectionQuery);
inputParameters.get(0).setValue(dataDB.get("ResourceName"));
inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
inputParameters.get(4).setValue(language);
inputParameters.get(5).setValue(query);
// create data structure
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// computationIDMap.put(id, computationId);
// print check on retrieving data
// logger.info("output data retrieved");
// data output values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String,
String>();
// data output keys
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String,
String>();
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
Result row = new Result(mapKeys.get(String.valueOf(i)),
mapValues.get(String.valueOf(i)));
output.add(row);
}
return output;
}
logger.info("Dialect used for smart correction: " + language);
// // to submit a query
// public String startSubmitQueryComputation(
// LinkedHashMap<String, String> dataDB, String query,
// boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
// String language) {
//
// logger.info("Dialect used for smart correction: " + language);
//
// // data input
// List<Parameter> inputParameters = new ArrayList<Parameter>();
// // data output
// List<Result> output = new ArrayList<Result>();
//
// // get list of algorithms
// List<String> algorithms = new ArrayList<String>();
// algorithms = getDatabaseManagerAlgorithms();
//
// // get algorithmId
// String algorithmId = null;
//
// for (int i = 0; i < algorithms.size(); i++) {
// if (algorithms.get(i).equals("SUBMITQUERY")) {
// algorithmId = algorithms.get(i);
//
// // print check
// // logger.info("algorithmId: " + algorithmId);
// }
// }
//
// // get input parameters of the algorithm
// inputParameters = getParameters(algorithmId);
//
// if (inputParameters.size() != 0) {
// // print check
// logger.info("algorithm input parameters retrieved");
// }
//
// // print check
// // for (int i = 0; i < inputParameters.size(); i++) {
// // logger.info(inputParameters.get(i).getName());
// // }
//
// // print check
// logger.info("ResourceName: " + dataDB.get("ResourceName"));
// logger.info("DatabaseName: " + dataDB.get("DatabaseName"));
// logger.info("Query: " + query);
// logger.info("SmartCorrections check: " + smartCorrectionQuery);
//
// inputParameters.get(0).setValue(dataDB.get("ResourceName"));
// inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
// inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
// inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
// inputParameters.get(4).setValue(language);
// inputParameters.get(5).setValue(query);
//
// // // create data structure
// // ComputationOutput outputData = new ComputationOutput();
//
// // get computation id
//
// SMComputationConfig config = new SMComputationConfig();
// SMInputEntry[] list = new SMInputEntry[inputParameters.size()];
// int i = 0;
//
// for (Parameter p : inputParameters)
// list[i++] = new SMInputEntry(p.getName(), p.getValue());
// config.parameters(new SMEntries(list));
// config.algorithm(algorithmId);
//
// // create a computation request
// SMComputationRequest request = new SMComputationRequest();
// request.user(getUsername());
// request.config(config);
//
// // execute computation
// StatisticalManagerFactory factory = getFactory();
// String computationId = factory.executeComputation(request);
//
// return computationId;
// }
// data input
List<Parameter> inputParameters = new ArrayList<Parameter>();
// data output
List<Result> output = new ArrayList<Result>();
// public float startCheckSubmitQueryComputation(String computationId) {
//
// String scope = getScope();
// String user = getUsername();
//
// ScopeProvider.instance.set(scope);
//
// StatisticalManagerFactory factory = StatisticalManagerDSL
// .createStateful().build();
//
// SMComputation computation = factory.getComputation(computationId);
//
// SMOperationStatus status = SMOperationStatus.values()[computation
// .operationStatus()];
//
// float percentage = 0;
//
// if (status == SMOperationStatus.RUNNING) {
//
// // logger.info("RUNNING");
// SMOperationInfo infos = factory.getComputationInfo(computationId,
// user);
// // percentage = Float.parseFloat(infos.percentage());
// // logger.info("Percentage:" +
// // percentage);
// // computation = factory.getComputation(computationId);
//
// status = SMOperationStatus.values()[computation.operationStatus()];
// } else if ((status == SMOperationStatus.COMPLETED)
// || (status == SMOperationStatus.FAILED)) {
//
// // logger.info("COMPLETED OR FAILED");
//
// SMAbstractResource abstractResource = computation
// .abstractResource();
// SMResource smResource = abstractResource.resource();
// int resourceTypeIndex = smResource.resourceType();
// SMResourceType smResType = SMResourceType.values()[resourceTypeIndex];
//
// // displayOutput(smResource, smResType, outputData);
//
// // print check
// // logger.info("SM resource Name: " + smResource.name());
// // logger.info("SM resource Name: " + smResource.name());
// // logger.info("SM resource ID: " + smResource.resourceId());
// // logger.info("SM resource ID: " + smResource.resourceId());
// // logger.info("SM resource Description: " +
// // smResource.description());
//
// percentage = 100;
// }
// return percentage;
//
// }
// get list of algorithms
List<String> algorithms = new ArrayList<String>();
algorithms = getDatabaseManagerAlgorithms();
// get algorithmId
String algorithmId = null;
for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("SUBMITQUERY")) {
algorithmId = algorithms.get(i);
// print check
// logger.info("algorithmId: " + algorithmId);
}
}
// get input parameters of the algorithm
inputParameters = getParameters(algorithmId);
if (inputParameters.size() != 0) {
// print check
logger.info("algorithm input parameters retrieved");
}
// print check
// for (int i = 0; i < inputParameters.size(); i++) {
// logger.info(inputParameters.get(i).getName());
// }
// print check
logger.info("ResourceName: " + dataDB.get("ResourceName"));
logger.info("DatabaseName: " + dataDB.get("DatabaseName"));
logger.info("Query: " + query);
logger.info("SmartCorrections check: " + smartCorrectionQuery);
inputParameters.get(0).setValue(dataDB.get("ResourceName"));
inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
inputParameters.get(4).setValue(language);
inputParameters.get(5).setValue(query);
// create data structure
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// print check on retrieving data
// logger.info("output data retrieved");
// data output values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
// data output keys
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
Result row = new Result(mapKeys.get(String.valueOf(i)),
mapValues.get(String.valueOf(i)));
output.add(row);
}
return output;
}
// public List<Result> getSubmitQueryOutput(String computationId)
// throws Exception {
//
// String scope = getScope();
//
// ScopeProvider.instance.set(scope);
//
// StatisticalManagerFactory factory = StatisticalManagerDSL
// .createStateful().build();
//
// SMComputation computation = factory.getComputation(computationId);
//
// SMAbstractResource abstractResource = computation.abstractResource();
// SMResource smResource = abstractResource.resource();
// int resourceTypeIndex = smResource.resourceType();
// SMResourceType smResType = SMResourceType.values()[resourceTypeIndex];
//
// // create data structure
// ComputationOutput outputData = new ComputationOutput();
//
// displayOutput(smResource, smResType, outputData);
//
// // print check on retrieving data
// logger.info("output data retrieved");
//
// // data output
// List<Result> output = new ArrayList<Result>();
//
// // data output values
// LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
// // data output keys
// LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
//
// mapValues = outputData.getMapValues();
// mapKeys = outputData.getmapKeys();
//
// for (int i = 0; i < mapValues.size(); i++) {
// Result row = new Result(mapKeys.get(String.valueOf(i)),
// mapValues.get(String.valueOf(i)));
// output.add(row);
// }
//
// return output;
// }
@Override
public List<Result> sample(LinkedHashMap<String, String> dataInput)
@ -799,6 +1039,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// parse a csv row in a list of values
@Override
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
throws Exception {
@ -1045,7 +1286,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
}
//get output result
// get output result
private void getMap(SMObject objRes, ComputationOutput outputData)
throws Exception {
@ -1089,7 +1330,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (smsubResType == SMResourceType.OBJECT) {
SMObject obje = (SMObject) smres;
String outstring = obje.url();
// logger.info("key: " + smsubResType);
// logger.info("object: " + outstring);
mapValues.put(String.valueOf(i), outstring);
@ -1129,4 +1370,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
public void removeComputation(String computationId) throws Exception {
StatisticalManagerFactory factory = getFactory();
factory.removeComputation(computationId);
}
}

View File

@ -0,0 +1,130 @@
package org.gcube.portlets.user.databasesmanager.server.util;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
//import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
//import org.gcube.applicationsupportlayer.social.NotificationsManager;
//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.Workspace;
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
//import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
//import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
//import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
//import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter;
//import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
//import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
//import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 18, 2014
*
*/
public class WsUtil {
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
// public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
// public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
// public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
// public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
// public static final String NOTIFICATION_MANAGER = "NOTIFICATION_MANAGER";
// public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_PRODUCER";
// public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
// public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
// public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
// public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
// public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
// public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
// public static final String TEST_SCOPE = "/gcube/devsec";
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
// public static final String TEST_USER = "pasquale.pagano";
// public static final String TEST_USER = "federico.defaveri";
// public static final String TEST_USER = "massimiliano.assante";
// public static final String TEST_USER = "pasquale.pagano";
// public static final String TEST_USER = "aureliano.gentile";
// public static final String TEST_USER = "antonio.gioia";
//COMMENT THIS FOR RELEASE
// public static final String TEST_USER = "francesco.mangiacrapa";
// public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
//UNCOMMENT THIS FOR RELEASE
// public static final String TEST_USER = "test.user";
// public static final String TEST_USER_FULL_NAME = "Test User";
public static final String TEST_USER = "dbmanager";
public static final String TEST_USER_FULL_NAME = "dbmanager";
protected static Logger logger = Logger.getLogger(WsUtil.class);
public static boolean withoutPortal = false;
public static ASLSession getAslSession(HttpSession httpSession)
{
String sessionID = httpSession.getId();
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
ASLSession session;
if (user == null) {
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
user=TEST_USER;
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
// user = "valentina.marioli";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);
logger.warn("TEST_USER: "+user);
logger.warn("TEST_SCOPE: "+TEST_SCOPE);
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setScope(TEST_SCOPE);
//MANDATORY FOR SOCIAL LIBRARY
session.setUserAvatarId(user + "Avatar");
session.setUserFullName(TEST_USER_FULL_NAME);
session.setUserEmailAddress(user + "@mail.test");
//SET HTTP SESSION ATTRIBUTE
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
withoutPortal = true;
return session;
}else if(user.compareToIgnoreCase(TEST_USER)==0){
withoutPortal = true;
//*** COMMENT THIS IN PRODUCTION ENVIROMENT
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
//
// withoutPortal = true;
//*** END UNCOMMENT
}else{
withoutPortal = false;
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
}