exceptions management in servlet. Class StatisticalManagerException created in order to manage exceptions generated from the statistical.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100260 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6a96111918
commit
1176464f8a
|
@ -69,6 +69,7 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResu
|
|||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.StatisticalManagerException;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
|
@ -109,9 +110,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
CacheManager cacheManager = CacheManager.create();
|
||||
|
||||
if (cacheManager == null) {
|
||||
logger.error("dbmanager-> Failed to get the cacheManager. cacheManager null");
|
||||
logger.error("dbmanager-> Error while starting the servlet. Failed to get the cacheManager. cacheManager null");
|
||||
throw new ServletException(
|
||||
"Failed to get the cacheManager. cacheManager null");
|
||||
"Error while starting the servlet. Failed to get the cacheManager. cacheManager null");
|
||||
}
|
||||
|
||||
if (cacheManager != null) {
|
||||
|
@ -133,9 +134,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
createCache(cachePath);
|
||||
|
||||
if (employeeCache == null) {
|
||||
logger.error("dbmanager-> Failed to get the cache. cache null");
|
||||
logger.error("dbmanager-> Error while starting the servlet. Failed to get the cache. cache null");
|
||||
throw new ServletException(
|
||||
"Failed to get the cache. cache null");
|
||||
"Error while starting the servlet. Failed to get the cache. cache null");
|
||||
} else {
|
||||
cacheManager.addCache(employeeCache);
|
||||
logger.info("dbmanager-> cache added to the cacheManager");
|
||||
|
@ -158,12 +159,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw e;
|
||||
|
||||
throw new ServletException(
|
||||
"Error while starting the servlet. Exception: " + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createCache(String cachePath) throws ServletException {
|
||||
public void createCache(String cachePath) throws Exception {
|
||||
|
||||
try {
|
||||
|
||||
|
@ -186,11 +189,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("dbmanager-> Failed to create the cache", e);
|
||||
// logger.error("dbmanager-> Error while starting the servlet. Failed to create the cache", e);
|
||||
throw new Exception("Error while starting the servlet. Failed to create the cache. Exception: " +e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
||||
|
@ -210,16 +215,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
cacheManager.shutdown();
|
||||
|
||||
} else {
|
||||
logger.error("dbmanager-> Failed to get the cacheManager. cacheManager null");
|
||||
logger.error("dbmanager-> Error while destroying the servlet. Failed to get the cacheManager. cacheManager null");
|
||||
throw new Exception(
|
||||
"Failed to get the cacheManager. cacheManager null");
|
||||
"Error while destroying the servlet. Failed to get the cacheManager. cacheManager null");
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("dbmanager-> Failed to destroy the cache", e);
|
||||
logger.error(
|
||||
"dbmanager-> Error while destroying the servlet. Exception:",
|
||||
e);
|
||||
// e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -267,10 +275,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public List<FileModel> getResource() throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
// initialize variables with application startup
|
||||
initVariables();
|
||||
|
||||
|
@ -289,8 +299,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// the computation is started otherwise data are retrieved from
|
||||
// cache.
|
||||
|
||||
try {
|
||||
|
||||
// get data from cache
|
||||
// check if data exist considering as key the input parameters
|
||||
// String key = inputParameters.get(0).getDefaultValue();
|
||||
|
@ -345,15 +353,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to load data. " + e);
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
// }
|
||||
return outputParameters;
|
||||
|
||||
}
|
||||
|
||||
// to get information about databases of a resource
|
||||
|
@ -361,9 +376,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public LinkedHashMap<String, FileModel> getDBInfo(String resourceName)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data output
|
||||
|
@ -382,7 +399,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.add(resource);
|
||||
inputParameters.get(0).setValue(resourceName);
|
||||
|
||||
try {
|
||||
// get data from cache
|
||||
// check if data exist considering as key the input parameters
|
||||
String key = inputParameters.get(0).getValue();
|
||||
|
@ -447,15 +463,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to load data " + );
|
||||
logger.error("dbmanager-> ", e);
|
||||
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
}
|
||||
|
||||
// to get schema for a database
|
||||
|
@ -463,10 +487,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data output
|
||||
|
@ -501,7 +527,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// logger.info(inputParameters.get(i).getName());
|
||||
// }
|
||||
|
||||
try {
|
||||
// get data from cache
|
||||
// check if data exist considering as key the input parameters
|
||||
String key = inputParameters.get(0).getValue()
|
||||
|
@ -560,21 +585,30 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to load data. " + e);
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
|
||||
}
|
||||
|
||||
return outputParameters;
|
||||
}
|
||||
|
||||
// to get tables
|
||||
private List<Result> getTables(LinkedHashMap<String, String> dataInput,
|
||||
String elementType) throws Exception {
|
||||
|
||||
try {
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data output
|
||||
|
@ -625,7 +659,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(1).setValue(db);
|
||||
inputParameters.get(2).setValue(scm);
|
||||
|
||||
try {
|
||||
// get data from cache
|
||||
// check if data exist considering as key the input parameters
|
||||
String key = inputParameters.get(0).getValue()
|
||||
|
@ -683,11 +716,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
return outputParameters;
|
||||
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to load data. " + e);
|
||||
logger.error("dbmanager-> ", e);
|
||||
// logger.error("dbmanager-> ", e);
|
||||
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
@ -716,7 +757,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// outputParameters.add(row);
|
||||
// }
|
||||
|
||||
return outputParameters;
|
||||
}
|
||||
|
||||
// to load tables
|
||||
|
@ -759,10 +799,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// previousSchema = currentSchema;
|
||||
// session.setAttribute("previousSchema", previousSchema);
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
List<Result> result = new ArrayList<>();
|
||||
|
||||
// get tables
|
||||
|
@ -789,7 +831,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
int totalNumber = result.size();
|
||||
|
||||
if ((SearchTable == false) || keyword == null || keyword.length() == 0) {
|
||||
if ((SearchTable == false) || keyword == null
|
||||
|| keyword.length() == 0) {
|
||||
sublist = new ArrayList<Result>(result.subList(start, limit));
|
||||
} else {
|
||||
// print check
|
||||
|
@ -797,8 +840,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
// search the table
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
if ((result.get(i).getValue().toLowerCase()).startsWith(keyword
|
||||
.toLowerCase())) {
|
||||
if ((result.get(i).getValue().toLowerCase())
|
||||
.startsWith(keyword.toLowerCase())) {
|
||||
sublist.add(result.get(i));
|
||||
}
|
||||
}
|
||||
|
@ -810,7 +853,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
if (start < sublen - 1) {
|
||||
limit = Math.min(sublen, limit);
|
||||
totalNumber = sublist.size();
|
||||
sublist = new ArrayList<Result>(sublist.subList(start, limit));
|
||||
sublist = new ArrayList<Result>(sublist.subList(start,
|
||||
limit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -824,6 +868,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
config.getOffset(), totalNumber);
|
||||
// session.setAttribute("TablesResult", result);
|
||||
return loadResult;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.error("dbmanager-> ", e);
|
||||
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// to submit a query
|
||||
|
@ -833,10 +890,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||
String language, String UID) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
logger.info("dbmanager-> Dialect used for smart correction: "
|
||||
+ language);
|
||||
|
||||
|
@ -896,13 +955,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(0).setValue(rs);
|
||||
inputParameters.get(1).setValue(db);
|
||||
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
|
||||
inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
|
||||
inputParameters.get(3).setValue(
|
||||
String.valueOf(smartCorrectionQuery));
|
||||
inputParameters.get(4).setValue(language);
|
||||
inputParameters.get(5).setValue(query);
|
||||
|
||||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
try {
|
||||
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData, UID);
|
||||
|
@ -956,19 +1016,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
} else {
|
||||
listAttributes = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
|
||||
// TODO TO REMOVE. Exception Statistical management to remove a
|
||||
// computation
|
||||
if (e.getMessage()
|
||||
.contains(
|
||||
"javax.xml.ws.soap.SOAPFaultException: java.lang.IndexOutOfBoundsException")) {
|
||||
e = new Exception("ServerException");
|
||||
}
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// generate the file csv output
|
||||
String name = "SubmitQuery";
|
||||
|
@ -984,6 +1031,27 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
listAttributes, convertedQuery, partialPathFile);
|
||||
|
||||
return obj;
|
||||
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
logger.error("dbmanager-> ", e);
|
||||
|
||||
// TODO TO REMOVE. Exception Statistical management to remove a
|
||||
// computation
|
||||
if (e.getMessage()
|
||||
.contains(
|
||||
"javax.xml.ws.soap.SOAPFaultException: java.lang.IndexOutOfBoundsException")) {
|
||||
throw new Exception("ServerException");
|
||||
}
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -991,9 +1059,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// output sample result
|
||||
|
@ -1059,8 +1129,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId, inputParameters,
|
||||
outputData);
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData);
|
||||
|
||||
// print check on retrieving data
|
||||
// logger.info("output data retrieved");
|
||||
|
@ -1091,6 +1161,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
output, partialPathFile);
|
||||
|
||||
return obj;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1098,9 +1178,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// output sample result
|
||||
|
@ -1166,8 +1248,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId, inputParameters,
|
||||
outputData);
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData);
|
||||
|
||||
// print check on retrieving data
|
||||
// logger.info("dbmanager-> output data retrieved");
|
||||
|
@ -1198,6 +1280,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
output, partialPathFile);
|
||||
|
||||
return obj;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1205,10 +1297,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// output sample result
|
||||
|
@ -1274,8 +1367,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId, inputParameters,
|
||||
outputData);
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData);
|
||||
|
||||
// print check on retrieving data
|
||||
// logger.info("dbmanager-> output data retrieved");
|
||||
|
@ -1306,16 +1399,28 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
output, partialPathFile);
|
||||
|
||||
return obj;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<String, FileModel> getTableDetails(
|
||||
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data ouptut
|
||||
|
@ -1353,8 +1458,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// create data structure
|
||||
ComputationOutput outputData = new ComputationOutput();
|
||||
// computation id
|
||||
String computationId = startComputation(algorithmId, inputParameters,
|
||||
outputData);
|
||||
String computationId = startComputation(algorithmId,
|
||||
inputParameters, outputData);
|
||||
|
||||
// print check on retrieving data
|
||||
// logger.info("output data retrieved");
|
||||
|
@ -1377,16 +1482,26 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
return outputParameters;
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// parse result for Submit query
|
||||
public PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config,
|
||||
List<String> listAttributes, String UID) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
// System.out.println("Server - loadSubmitResultMethod");
|
||||
// data parsed
|
||||
List<Row> data = new ArrayList<Row>();
|
||||
|
@ -1419,14 +1534,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
int totalNumber = data.size();
|
||||
sublist = new ArrayList<Row>(data.subList(start, limit));
|
||||
loadResult = new BasePagingLoadResult<Row>(sublist, config.getOffset(),
|
||||
totalNumber);
|
||||
loadResult = new BasePagingLoadResult<Row>(sublist,
|
||||
config.getOffset(), totalNumber);
|
||||
|
||||
// System.out.println("start: " + start);
|
||||
// System.out.println("limit: " + limit);
|
||||
// System.out.println("sublist size: " + sublist.size());
|
||||
|
||||
return loadResult;
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// get attributes list for display the result in a table
|
||||
|
@ -1465,8 +1586,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
List<Row> rows = new ArrayList<Row>();
|
||||
|
@ -1794,7 +1915,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
} catch (Exception e) {
|
||||
logger.info("dbmanager-> startComputation: the job submit has failed!");
|
||||
// e.printStackTrace();
|
||||
logger.error("dbmanager-> ", e);
|
||||
// logger.error("dbmanager-> ", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -1868,11 +1989,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// rootLogger.log(Level.SEVERE, "Output is other");
|
||||
}
|
||||
|
||||
// EXCEPTION MANAGEMENT
|
||||
// StatisticalManager EXCEPTION MANAGEMENT
|
||||
if (smResType.equals(SMResourceType.ERROR)) {
|
||||
Exception e = new Exception(smResource.description());
|
||||
StatisticalManagerException e = new StatisticalManagerException(
|
||||
smResource.description());
|
||||
// e.printStackTrace();
|
||||
logger.error("dbmanager-> ", e);
|
||||
// logger.error("dbmanager-> ", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -1964,17 +2086,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public Boolean removeComputation(String uidSubmitQuery) throws Exception {
|
||||
// System.out.println("server UID: " + uidSubmitQuery);
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
String computationId = null;
|
||||
|
||||
if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) {
|
||||
// get job status
|
||||
// ASLSession session = WsUtil.getAslSession(this
|
||||
// .getThreadLocalRequest().getSession());
|
||||
// HashMap<String, String> JobStatusMap = (HashMap<String, String>)
|
||||
// HashMap<String, String> JobStatusMap = (HashMap<String,
|
||||
// String>)
|
||||
// session
|
||||
// .getAttribute("JobStatusList");
|
||||
// String status = JobStatusMap.get(uidSubmitQuery);
|
||||
|
@ -2003,7 +2127,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
|
||||
logger.info("dbmanager-> Could not remove the computation ID "
|
||||
+ computationId + " corresponding to jobID "
|
||||
+ computationId
|
||||
+ " corresponding to jobID "
|
||||
+ uidSubmitQuery);
|
||||
logger.error("dbmanager-> ", e);
|
||||
}
|
||||
|
@ -2011,12 +2136,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// remove job status
|
||||
removeJobStatus(uidSubmitQuery);
|
||||
return (new Boolean(true));
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshDataOnServer(String submitQueryUID) throws Exception{
|
||||
public void refreshDataOnServer(String submitQueryUID) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
if ((submitQueryUID != null) && (!submitQueryUID.equals(""))) {
|
||||
|
@ -2040,10 +2172,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> inputData, FileModel element)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
// session check
|
||||
if (isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
try {
|
||||
|
||||
// // call the method related to the element selected
|
||||
//
|
||||
String resourceName = "";
|
||||
|
@ -2066,12 +2200,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
break;
|
||||
case "database":
|
||||
if (element.getDatabaseType().equals(
|
||||
ConstantsPortlet.POSTGRES)) { // refresh schema list
|
||||
ConstantsPortlet.POSTGRES)) { // refresh schema
|
||||
// list
|
||||
key = inputData.get("ResourceName")
|
||||
+ inputData.get("DatabaseName");
|
||||
}
|
||||
if (element.getDatabaseType()
|
||||
.equals(ConstantsPortlet.MYSQL)) { // refresh table
|
||||
if (element.getDatabaseType().equals(
|
||||
ConstantsPortlet.MYSQL)) { // refresh table
|
||||
// list
|
||||
key = inputData.get("ResourceName")
|
||||
+ inputData.get("DatabaseName")
|
||||
|
@ -2142,6 +2277,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
logger.error("dbmanager-> ", e);
|
||||
if (!(e instanceof StatisticalManagerException)) {
|
||||
// GWT can't serialize all exceptions
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void refreshCache(String key) throws Exception {
|
||||
|
@ -2149,8 +2293,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
employeeCache.remove(key);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
logger.error("dbmanager-> ", e);
|
||||
throw new Exception("Failure to clear the cache. " + e);
|
||||
// logger.error("dbmanager-> ", e);
|
||||
// throw new Exception("Failure to clear the cache. " + e);
|
||||
throw new Exception(
|
||||
"Error in server while loading data. Exception: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2197,8 +2343,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
//to check if the session is expired
|
||||
// to check if the session is expired
|
||||
private boolean isSessionExpired() throws Exception {
|
||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
|
||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,13 +53,16 @@ public class SessionUtil {
|
|||
|
||||
public static boolean isSessionExpired(HttpSession httpSession) throws Exception {
|
||||
logger.info("session validating...");
|
||||
//READING USERNAME FROM ASL SESSION
|
||||
//reading username from asl session
|
||||
String userUsername = getAslSession(httpSession).getUsername();
|
||||
|
||||
/*COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||
|
||||
if(userUsername.compareToIgnoreCase(USER)==0){
|
||||
logger.error("session is expired! username is: "+SessionUtil.USER);
|
||||
return true; //is USER, session is expired
|
||||
}
|
||||
|
||||
if(userUsername.compareToIgnoreCase(TEST_USER)==0){
|
||||
logger.error("session is expired! username is: "+SessionUtil.TEST_USER);
|
||||
return true; //is TEST_USER, session is expired
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.gcube.portlets.user.databasesmanager.shared;
|
||||
|
||||
public class SessionExpiredException extends Exception{
|
||||
public class SessionExpiredException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SessionExpiredException() {
|
||||
super("Session expired");
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.portlets.user.databasesmanager.shared;
|
||||
|
||||
public class StatisticalManagerException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public StatisticalManagerException(){
|
||||
super();
|
||||
}
|
||||
|
||||
public StatisticalManagerException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue