Minor updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86830 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-11 13:09:15 +00:00
parent 2ba5621b6a
commit 0c0c8cf946
1 changed files with 67 additions and 69 deletions

View File

@ -122,9 +122,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
protected static Logger logger = LoggerFactory.getLogger(TDGWTServiceImpl.class);
protected static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
protected TabularDataService service;
protected HttpSession session;
protected ASLSession aslSession;
/**
*
@ -133,7 +130,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public void setTabResource(TabResource tabResource) throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (tabResource == null) {
logger.error("Error setting TabResource: null");
throw new TDGWTServiceException(
@ -161,7 +158,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
*/
@Override
public TabResource getTabResourceInformation() throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
return getTabulaResourceInformationForHttpSession(session);
}
@ -172,7 +169,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
private TabResource getTabulaResourceInformationForHttpSession(HttpSession session) throws TDGWTServiceException{
try {
aslSession = SessionUtil.getAslSession(session);
//ASLSession aslSession = SessionUtil.getAslSession(session);
TabResource currentTR = SessionUtil.getTabResource(session);
if (currentTR == null) {
@ -199,8 +196,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public TabResource getTabResourceInformation(TRId trId)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
//ASLSession aslSession = SessionUtil.getAslSession(session);
TabResource currentTR = new TabResource();
currentTR.setTrId(trId);
@ -262,8 +259,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public ArrayList<ColumnData> getColumns() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
TabResource currentTR = SessionUtil.getTabResource(session);
if (currentTR == null) {
@ -273,7 +270,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
}
TRId trId = currentTR.getTrId();
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
Table table = service.getLastTable(new TabularResourceId(Long
@ -339,10 +336,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public TableData getLastTable(TRId trId) throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
Table table = service.getLastTable(new TabularResourceId(Long
@ -387,7 +384,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public void startTDOpen(TDOpenSession s) throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setTDOpenSession(session, s);
return;
@ -425,9 +422,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
* @param tr
* @throws TDGWTServiceException
*/
protected void retriveTRMetadataFromService(TabularResource tr)
protected void retriveTRMetadataFromService(TabularDataService service,TabularResource tr)
throws TDGWTServiceException {
retriveTRMetadataFromService(tr, 0);
retriveTRMetadataFromService(service,tr, 0);
}
/**
@ -440,7 +437,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
* @return TabResource for Grid
* @throws TDGWTServiceException
*/
protected TabResource retriveTRMetadataFromService(TabularResource tr, int i)
protected TabResource retriveTRMetadataFromService(TabularDataService service,
TabularResource tr, int i)
throws TDGWTServiceException {
Table table = null;
@ -490,9 +488,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public ArrayList<TabResource> getTabularResources()
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
List<TabularResource> trs = service.getTabularResources();
@ -503,7 +501,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
int i;
for (i = 0; i < trs.size(); i++) {
TabularResource tr = trs.get(i);
TabResource t = retriveTRMetadataFromService(tr, i);
TabResource t = retriveTRMetadataFromService(service, tr, i);
if (t.getTrId() != null) {
ltr.add(t);
}
@ -531,15 +529,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public void removeTabularResource(TRId trId) throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
if (trId == null) {
logger.error("Error removing TabularResource: trId is null");
throw new TDGWTServiceException(
"Error removing TabularResource no parameters set");
}
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
TabularResourceId id = new TabularResourceId(Long.valueOf(trId
.getId()));
@ -562,15 +560,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public TabResource createTabularResource(TabResource tabResource)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
if (tabResource == null) {
logger.error("Error creating new TabularResource: tabResource is null");
throw new TDGWTServiceException(
"Error creating new TabularResource no parameters set");
}
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
TabularResource serviceTR = service.createTabularResource();
Table table = service.getLastTable(serviceTR.getId());
@ -597,7 +595,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public ArrayList<Codelist> getCodelists() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
return SessionUtil.retrieveCodelists(session);
} catch (Exception e) {
e.printStackTrace();
@ -613,7 +611,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public ArrayList<Dataset> getDatasets() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
return SessionUtil.retrieveDatasets(session);
} catch (Exception e) {
e.printStackTrace();
@ -629,7 +627,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public ArrayList<Agencies> getAgencies() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
return SessionUtil.retrieveAgencies(session);
} catch (Exception e) {
e.printStackTrace();
@ -673,11 +671,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setSDMXImportSession(session, sdmxImportSession);
aslSession = SessionUtil.getAslSession(session);
ASLSession aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
OperationInterface oService = service;
TabularResourceInterface trService = service;
@ -765,8 +763,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public SDMXImportMonitor getSDMXImportMonitor()
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
//ASLSession aslSession = SessionUtil.getAslSession(session);
Task task = SessionUtil.getSDMXImportTask(session);
TabResource sdmxImportTabResource = SessionUtil
.getSDMXImportTabResource(session);
@ -857,7 +855,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setSDMXRegistrySource(session, sdmxRegistrySource);
return;
@ -879,7 +877,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public void setCSVSession(CSVImportSession importSession)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setCSVImportSession(session, importSession);
return;
@ -901,7 +899,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public FileUploadMonitor getFileUploadMonitor()
throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
@ -921,7 +919,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public AvailableCharsetList getAvailableCharset()
throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
@ -937,7 +935,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public ArrayList<String> configureCSVParser(String encoding,
HeaderPresence headerPresence, char delimiter, char comment)
throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
@ -983,7 +981,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public ArrayList<CSVRowError> checkCSV(long errorsLimit)
throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
@ -1013,14 +1011,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public void startCSVImport(CSVImportSession csvImportSession)
throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
aslSession = SessionUtil.getAslSession(session);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
throw new TDGWTServiceException(
"Error retrieving the asl session: null");
@ -1035,7 +1033,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
"Error retrieving the fileUploadSession: null");
}
importCSVFileOnService(user, fileUploadSession, csvImportSession);
importCSVFileOnService(session,aslSession,user, fileUploadSession, csvImportSession);
}
@ -1071,7 +1069,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
* @param csvImportSession
* @throws TDGWTServiceException
*/
protected void importCSVFileOnService(String user,
protected void importCSVFileOnService(HttpSession session,ASLSession aslSession,String user,
FileUploadSession fileUploadSession,
CSVImportSession csvImportSession) throws TDGWTServiceException {
logger.debug("File Storage Access");
@ -1086,7 +1084,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
fileUrlOnStorage, fileUploadSession, csvImportSession);
logger.debug("Tabular Data Service");
service = TabularDataServiceFactory
TabularDataService service = TabularDataServiceFactory
.getService(aslSession.getUsername());
List<OperationDescriptor> capabilities = service.getCapabilities();
@ -1128,8 +1126,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public CSVImportMonitor getCSVImportMonitor() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
//ASLSession aslSession = SessionUtil.getAslSession(session);
Task task = SessionUtil.getCSVImportFileTask(session);
TabResource csvImportTabResource = SessionUtil
.getCSVImportTabResource(session);
@ -1220,8 +1218,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public void getFileFromWorkspace(CSVImportSession csvImportSession)
throws TDGWTServiceException {
// TODO Auto-generated method stub
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
Workspace w = null;
WorkspaceItem wi = null;
@ -1302,10 +1300,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
TabularResource tr = service
.getTabularResource(new TabularResourceId(Long.valueOf(trId
@ -1378,10 +1376,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public ArrayList<TabMetadata> getTableMetadata(TRId trId)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession
TabularDataService service = TabularDataServiceFactory.getService(aslSession
.getUsername());
Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId())));
@ -1534,14 +1532,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public void startSDMXExport(SDMXExportSession exportSession)
throws TDGWTServiceException {
logger.debug("Start SDMX Export");
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
aslSession = SessionUtil.getAslSession(session);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
throw new TDGWTServiceException(
"Error retrieving the asl session: null");
@ -1564,7 +1562,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
Map<String, Object> parameterInstance = sdmxExportParameter(exportSession);
logger.debug("Tabular Data Service");
service = TabularDataServiceFactory
TabularDataService service = TabularDataServiceFactory
.getService(aslSession.getUsername());
List<OperationDescriptor> capabilities = service.getCapabilities();
@ -1603,8 +1601,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public SDMXExportMonitor getSDMXExportMonitor()
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
//ASLSession aslSession = SessionUtil.getAslSession(session);
Task task = SessionUtil.getSDMXExportTask(session);
SDMXExportMonitor exportMonitor = new SDMXExportMonitor();
@ -1688,14 +1686,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
public void startCSVExport(CSVExportSession exportSession)
throws TDGWTServiceException {
logger.debug("Start CSV Export");
session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
aslSession = SessionUtil.getAslSession(session);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
throw new TDGWTServiceException(
"Error retrieving the asl session: null");
@ -1718,7 +1716,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
Map<String, Object> parameterInstance = csvExportFileParameter(exportSession);
logger.debug("Tabular Data Service");
service = TabularDataServiceFactory
TabularDataService service = TabularDataServiceFactory
.getService(aslSession.getUsername());
List<OperationDescriptor> capabilities = service.getCapabilities();
@ -1758,8 +1756,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
@Override
public CSVExportMonitor getCSVExportMonitor() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
CSVExportSession exportSession = SessionUtil
.getCSVExportSession(session);
Task task = SessionUtil.getCSVExportTask(session);
@ -1809,7 +1807,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
trExportMetadata.setExportDate(sdf
.format(exportMetadata.getExportDate()));
exportMonitor.setTrExportMetadata(trExportMetadata);
saveInDestination(aslSession.getUsername(),
saveInDestination(session,aslSession.getUsername(),
exportMetadata, exportSession);
break;
@ -1841,7 +1839,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
}
protected void saveInDestination(String user,
protected void saveInDestination(HttpSession session,String user,
ExportMetadata exportMetadata, CSVExportSession exportSession)
throws TDGWTServiceException {
if (exportSession.getDestination().getId().compareTo("Workspace") == 0) {