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,8 +317,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
public TRId restoreUISession() throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//SessionUtil.getAslSession(session);
|
||||
|
||||
// SessionUtil.getAslSession(session);
|
||||
|
||||
TRId trId = SessionUtil.getTRId(session);
|
||||
logger.debug("restoreUISession()");
|
||||
if (trId == null) {
|
||||
|
@ -3309,6 +3309,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public String startCSVImport(CSVImportSession csvImportSession)
|
||||
throws TDGWTServiceException {
|
||||
CSVFileUploadSession fileUploadSession = null;
|
||||
|
||||
try {
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
|
@ -3324,24 +3326,55 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
logger.debug("StartCSVImport: " + csvImportSession.toString());
|
||||
|
||||
CSVFileUploadSession fileUploadSession = SessionUtil
|
||||
.getCSVFileUploadSession(session);
|
||||
fileUploadSession = SessionUtil.getCSVFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
|
||||
String taskId = importCSVFileOnService(session, aslSession, user,
|
||||
String fileUrlOnStorage = loadCSVFileOnStorage(user,
|
||||
fileUploadSession, csvImportSession);
|
||||
|
||||
fileUploadSession.getCsvFile().delete();
|
||||
|
||||
String taskId = importCSVFileOnService(session, aslSession, user,
|
||||
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
||||
|
||||
return taskId;
|
||||
|
||||
} 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;
|
||||
} 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();
|
||||
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
||||
} 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();
|
||||
throw new TDGWTServiceException("Error in CSVImport: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -3385,11 +3418,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @param csvImportSession
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected String importCSVFileOnService(HttpSession session,
|
||||
ASLSession aslSession, String user,
|
||||
protected String loadCSVFileOnStorage(String user,
|
||||
CSVFileUploadSession fileUploadSession,
|
||||
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
||||
|
||||
String fileUrlOnStorage=null;
|
||||
|
||||
logger.debug("File Storage Access");
|
||||
|
||||
logger.debug("CSVImportSession skip:"
|
||||
|
@ -3410,19 +3443,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
* } }
|
||||
*/
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
||||
String fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
||||
fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
||||
fileUploadSession.getCsvFile());
|
||||
logger.debug("File Url On Storage:" + fileUrlOnStorage);
|
||||
fileUploadSession.getCsvFile().delete();
|
||||
|
||||
if (fileUrlOnStorage == null || fileUrlOnStorage.isEmpty()) {
|
||||
throw new TDGWTServiceException(
|
||||
"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(
|
||||
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
||||
|
||||
|
@ -4839,45 +4878,43 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
checkTabularResourceIsFinal(tabularResource);
|
||||
|
||||
|
||||
OpExecution4LabelColumn opEx = new OpExecution4LabelColumn(service,
|
||||
labelColumnSession);
|
||||
OpExecutionDirector director = new OpExecutionDirector();
|
||||
director.setOperationExecutionBuilder(opEx);
|
||||
director.constructOperationExecution();
|
||||
/*List<OperationExecution> invocations = director
|
||||
.getListOperationExecution();
|
||||
/*
|
||||
* List<OperationExecution> invocations = director
|
||||
* .getListOperationExecution();
|
||||
*
|
||||
* if (invocations == null) { throw new
|
||||
* TDGWTServiceException("Operation not supported"); }
|
||||
*
|
||||
* logger.debug("OperationInvocation: \n" + invocations);
|
||||
*/
|
||||
OperationExecution invocation = director.getOperationExecution();
|
||||
|
||||
if (invocations == null) {
|
||||
throw new TDGWTServiceException("Operation not supported");
|
||||
}
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocations);
|
||||
*/
|
||||
OperationExecution invocation =director.getOperationExecution();
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation);
|
||||
|
||||
|
||||
service.executeSynchMetadataOperation(invocation, tabularResourceId);
|
||||
|
||||
|
||||
/*
|
||||
for(OperationExecution op:invocations){
|
||||
service.executeSynchMetadataOperation(op, tabularResourceId);
|
||||
//executeBatch(invocations, tabularResourceId);
|
||||
}
|
||||
|
||||
/*
|
||||
Task trTask = service.executeBatch(invocations, tabularResourceId);
|
||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ChangeColumnLabel,
|
||||
labelColumnSession.getTrId());
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
*/
|
||||
* for(OperationExecution op:invocations){
|
||||
* service.executeSynchMetadataOperation(op, tabularResourceId);
|
||||
* //executeBatch(invocations, tabularResourceId); }
|
||||
*
|
||||
* /* Task trTask = service.executeBatch(invocations,
|
||||
* tabularResourceId); logger.debug("Start Task on service: TaskId "
|
||||
* + trTask.getId()); TaskWrapper taskWrapper = new
|
||||
* TaskWrapper(trTask, UIOperationsId.ChangeColumnLabel,
|
||||
* labelColumnSession.getTrId());
|
||||
* SessionUtil.setStartedTask(session, taskWrapper);
|
||||
*
|
||||
* return trTask.getId().getValue();
|
||||
*/
|
||||
return "ok";
|
||||
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
|
@ -6542,7 +6579,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TableDescriptorMetadata tableDesc = null;
|
||||
TRId trId;
|
||||
|
||||
|
||||
if (table.contains(TableDescriptorMetadata.class)) {
|
||||
tableDesc = table.getMetadata(TableDescriptorMetadata.class);
|
||||
if (tableDesc.getRefId() == 0) {
|
||||
|
@ -6556,14 +6593,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
trId = retrieveTabularResourceBasicData(tId);
|
||||
}
|
||||
|
||||
} else{
|
||||
} else {
|
||||
logger.debug("Attention: No TableDescriptorMetadata found for table. Supposed Time Dimension :"
|
||||
+ table);
|
||||
trId = new TRId();
|
||||
trId.setTableId(refColumn.getTableId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
ColumnData columnData = getColumn(refColumn.getColumnId(), trId);
|
||||
|
||||
return columnData;
|
||||
|
|
|
@ -49,6 +49,7 @@ public class FilesStorage {
|
|||
logger.error("Error no csv file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
return url;
|
||||
|
|
Loading…
Reference in New Issue