Fixed CSV Import, monitor added to control file loading on storage
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@102146 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7684fbcfde
commit
9b8e78ff1d
|
@ -317,7 +317,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
public TRId restoreUISession() throws TDGWTServiceException {
|
public TRId restoreUISession() throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
//SessionUtil.getAslSession(session);
|
// SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
TRId trId = SessionUtil.getTRId(session);
|
TRId trId = SessionUtil.getTRId(session);
|
||||||
logger.debug("restoreUISession()");
|
logger.debug("restoreUISession()");
|
||||||
|
@ -3309,6 +3309,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
@Override
|
@Override
|
||||||
public String startCSVImport(CSVImportSession csvImportSession)
|
public String startCSVImport(CSVImportSession csvImportSession)
|
||||||
throws TDGWTServiceException {
|
throws TDGWTServiceException {
|
||||||
|
CSVFileUploadSession fileUploadSession = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
@ -3324,24 +3326,55 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
logger.debug("StartCSVImport: " + csvImportSession.toString());
|
logger.debug("StartCSVImport: " + csvImportSession.toString());
|
||||||
|
|
||||||
CSVFileUploadSession fileUploadSession = SessionUtil
|
fileUploadSession = SessionUtil.getCSVFileUploadSession(session);
|
||||||
.getCSVFileUploadSession(session);
|
|
||||||
if (fileUploadSession == null) {
|
if (fileUploadSession == null) {
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(
|
||||||
"Error retrieving the fileUploadSession: null");
|
"Error retrieving the fileUploadSession: null");
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskId = importCSVFileOnService(session, aslSession, user,
|
String fileUrlOnStorage = loadCSVFileOnStorage(user,
|
||||||
fileUploadSession, csvImportSession);
|
fileUploadSession, csvImportSession);
|
||||||
|
|
||||||
|
fileUploadSession.getCsvFile().delete();
|
||||||
|
|
||||||
|
String taskId = importCSVFileOnService(session, aslSession, user,
|
||||||
|
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
||||||
|
|
||||||
return taskId;
|
return taskId;
|
||||||
|
|
||||||
} catch (TDGWTServiceException e) {
|
} catch (TDGWTServiceException e) {
|
||||||
|
try {
|
||||||
|
if (fileUploadSession != null
|
||||||
|
&& fileUploadSession.getCsvFile() != null
|
||||||
|
&& fileUploadSession.getCsvFile().exists()) {
|
||||||
|
fileUploadSession.getCsvFile().delete();
|
||||||
|
}
|
||||||
|
} catch (Throwable e1) {
|
||||||
|
logger.error(e1.getLocalizedMessage());
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
try {
|
||||||
|
if (fileUploadSession != null
|
||||||
|
&& fileUploadSession.getCsvFile() != null
|
||||||
|
&& fileUploadSession.getCsvFile().exists()) {
|
||||||
|
fileUploadSession.getCsvFile().delete();
|
||||||
|
}
|
||||||
|
} catch (Throwable e1) {
|
||||||
|
logger.error(e1.getLocalizedMessage());
|
||||||
|
}
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
try {
|
||||||
|
if (fileUploadSession != null
|
||||||
|
&& fileUploadSession.getCsvFile() != null
|
||||||
|
&& fileUploadSession.getCsvFile().exists()) {
|
||||||
|
fileUploadSession.getCsvFile().delete();
|
||||||
|
}
|
||||||
|
} catch (Throwable e1) {
|
||||||
|
logger.error(e1.getLocalizedMessage());
|
||||||
|
}
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TDGWTServiceException("Error in CSVImport: "
|
throw new TDGWTServiceException("Error in CSVImport: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
|
@ -3385,10 +3418,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
* @param csvImportSession
|
* @param csvImportSession
|
||||||
* @throws TDGWTServiceException
|
* @throws TDGWTServiceException
|
||||||
*/
|
*/
|
||||||
protected String importCSVFileOnService(HttpSession session,
|
protected String loadCSVFileOnStorage(String user,
|
||||||
ASLSession aslSession, String user,
|
|
||||||
CSVFileUploadSession fileUploadSession,
|
CSVFileUploadSession fileUploadSession,
|
||||||
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
||||||
|
String fileUrlOnStorage=null;
|
||||||
|
|
||||||
logger.debug("File Storage Access");
|
logger.debug("File Storage Access");
|
||||||
|
|
||||||
|
@ -3410,19 +3443,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
*
|
*
|
||||||
* } }
|
* } }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FilesStorage filesStorage = new FilesStorage();
|
FilesStorage filesStorage = new FilesStorage();
|
||||||
|
|
||||||
String fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
||||||
fileUploadSession.getCsvFile());
|
fileUploadSession.getCsvFile());
|
||||||
logger.debug("File Url On Storage:" + fileUrlOnStorage);
|
logger.debug("File Url On Storage:" + fileUrlOnStorage);
|
||||||
fileUploadSession.getCsvFile().delete();
|
|
||||||
|
|
||||||
if (fileUrlOnStorage == null || fileUrlOnStorage.isEmpty()) {
|
if (fileUrlOnStorage == null || fileUrlOnStorage.isEmpty()) {
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(
|
||||||
"Tabular Data Service error loading file on storage");
|
"Tabular Data Service error loading file on storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fileUrlOnStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String importCSVFileOnService(HttpSession session,
|
||||||
|
ASLSession aslSession, String user, String fileUrlOnStorage,
|
||||||
|
CSVFileUploadSession fileUploadSession,
|
||||||
|
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
||||||
|
|
||||||
Map<String, Object> parameterInstance = csvImportFileParameter(
|
Map<String, Object> parameterInstance = csvImportFileParameter(
|
||||||
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
||||||
|
|
||||||
|
@ -4845,36 +4884,34 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
OpExecutionDirector director = new OpExecutionDirector();
|
OpExecutionDirector director = new OpExecutionDirector();
|
||||||
director.setOperationExecutionBuilder(opEx);
|
director.setOperationExecutionBuilder(opEx);
|
||||||
director.constructOperationExecution();
|
director.constructOperationExecution();
|
||||||
/*List<OperationExecution> invocations = director
|
/*
|
||||||
.getListOperationExecution();
|
* List<OperationExecution> invocations = director
|
||||||
|
* .getListOperationExecution();
|
||||||
if (invocations == null) {
|
*
|
||||||
throw new TDGWTServiceException("Operation not supported");
|
* if (invocations == null) { throw new
|
||||||
}
|
* TDGWTServiceException("Operation not supported"); }
|
||||||
|
*
|
||||||
logger.debug("OperationInvocation: \n" + invocations);
|
* logger.debug("OperationInvocation: \n" + invocations);
|
||||||
*/
|
*/
|
||||||
OperationExecution invocation =director.getOperationExecution();
|
OperationExecution invocation = director.getOperationExecution();
|
||||||
|
|
||||||
logger.debug("OperationInvocation: \n" + invocation);
|
logger.debug("OperationInvocation: \n" + invocation);
|
||||||
|
|
||||||
service.executeSynchMetadataOperation(invocation, tabularResourceId);
|
service.executeSynchMetadataOperation(invocation, tabularResourceId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(OperationExecution op:invocations){
|
* for(OperationExecution op:invocations){
|
||||||
service.executeSynchMetadataOperation(op, tabularResourceId);
|
* service.executeSynchMetadataOperation(op, tabularResourceId);
|
||||||
//executeBatch(invocations, tabularResourceId);
|
* //executeBatch(invocations, tabularResourceId); }
|
||||||
}
|
*
|
||||||
|
* /* Task trTask = service.executeBatch(invocations,
|
||||||
/*
|
* tabularResourceId); logger.debug("Start Task on service: TaskId "
|
||||||
Task trTask = service.executeBatch(invocations, tabularResourceId);
|
* + trTask.getId()); TaskWrapper taskWrapper = new
|
||||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
* TaskWrapper(trTask, UIOperationsId.ChangeColumnLabel,
|
||||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
* labelColumnSession.getTrId());
|
||||||
UIOperationsId.ChangeColumnLabel,
|
* SessionUtil.setStartedTask(session, taskWrapper);
|
||||||
labelColumnSession.getTrId());
|
*
|
||||||
SessionUtil.setStartedTask(session, taskWrapper);
|
* return trTask.getId().getValue();
|
||||||
|
|
||||||
return trTask.getId().getValue();
|
|
||||||
*/
|
*/
|
||||||
return "ok";
|
return "ok";
|
||||||
|
|
||||||
|
@ -6556,14 +6593,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
trId = retrieveTabularResourceBasicData(tId);
|
trId = retrieveTabularResourceBasicData(tId);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else{
|
} else {
|
||||||
logger.debug("Attention: No TableDescriptorMetadata found for table. Supposed Time Dimension :"
|
logger.debug("Attention: No TableDescriptorMetadata found for table. Supposed Time Dimension :"
|
||||||
+ table);
|
+ table);
|
||||||
trId = new TRId();
|
trId = new TRId();
|
||||||
trId.setTableId(refColumn.getTableId());
|
trId.setTableId(refColumn.getTableId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ColumnData columnData = getColumn(refColumn.getColumnId(), trId);
|
ColumnData columnData = getColumn(refColumn.getColumnId(), trId);
|
||||||
|
|
||||||
return columnData;
|
return columnData;
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class FilesStorage {
|
||||||
logger.error("Error no csv file loaded on storage"
|
logger.error("Error no csv file loaded on storage"
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|
Loading…
Reference in New Issue