Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96664 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-06-04 15:27:10 +00:00
parent 9621ec4d17
commit 5d925b93e3
7 changed files with 96 additions and 64 deletions

View File

@ -68,8 +68,8 @@ public class CodelistMappingUploadServlet extends HttpServlet {
codelistMappingFileUploadSession.setId(session.getId());
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.STARTED);
codelistMappingFileUploadSession.setCodelistMappingMonitor(codelistMappingMonitor);
codelistMappingFileUploadSession.setFileUploadMonitor(fileUploadMonitor);
SessionUtil.setFileUploadMonitor(session,fileUploadMonitor);
try {
SessionUtil.setCodelistMappingFileUploadSession(session,codelistMappingFileUploadSession);
@ -99,7 +99,9 @@ public class CodelistMappingUploadServlet extends HttpServlet {
}
}
} catch (FileUploadException e) {
codelistMappingFileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
@ -114,7 +116,10 @@ public class CodelistMappingUploadServlet extends HttpServlet {
}
if (uploadItem == null) {
codelistMappingFileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
SessionUtil.setFileUploadMonitor(session, fum);
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
@ -136,7 +141,10 @@ public class CodelistMappingUploadServlet extends HttpServlet {
try {
FileUtil.setImportFileCodelistMapping(codelistMappingFileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
} catch (Exception e) {
codelistMappingFileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
@ -154,7 +162,10 @@ public class CodelistMappingUploadServlet extends HttpServlet {
uploadItem.delete();
logger.trace("changing state");
codelistMappingFileUploadSession.getFileUploadMonitor().setState(FileUploadState.COMPLETED);
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
try {
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
} catch (TDGWTSessionExpiredException e) {

View File

@ -68,7 +68,7 @@ public class LocalUploadServlet extends HttpServlet {
fileUploadSession.setId(session.getId());
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
fileUploadSession.setCsvImportMonitor(csvImportMonitor);
fileUploadSession.setFileUploadMonitor(fileUploadMonitor);
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
try {
@ -99,7 +99,9 @@ public class LocalUploadServlet extends HttpServlet {
}
}
} catch (FileUploadException e) {
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
@ -114,7 +116,9 @@ public class LocalUploadServlet extends HttpServlet {
}
if (uploadItem == null) {
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
@ -136,7 +140,9 @@ public class LocalUploadServlet extends HttpServlet {
try {
FileUtil.setImportFileCSV(fileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
} catch (Exception e) {
fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
try {
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
@ -154,7 +160,9 @@ public class LocalUploadServlet extends HttpServlet {
uploadItem.delete();
logger.trace("changing state");
fileUploadSession.getFileUploadMonitor().setState(FileUploadState.COMPLETED);
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
try {
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
} catch (TDGWTSessionExpiredException e) {

View File

@ -106,6 +106,8 @@ public class SessionConstants {
protected static final String CODELIST_MAPPING_FILE_UPLOAD_SESSION = "CODELIST_MAPPING_FILE_UPLOAD_SESSION";
protected static final String CODELIST_MAPPING_TASK = "CODELIST_MAPPING_TASK";
protected static final String CODELIST_MAPPING_MONITOR = "CODELIST_MAPPING_MONITOR";
protected static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR";

View File

@ -25,6 +25,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
@ -326,6 +327,8 @@ public class SessionUtil {
}
return fileUploadSession;
}
//TODO
@ -350,7 +353,31 @@ public class SessionUtil {
return fileUploadSession;
}
//
public static FileUploadMonitor getFileUploadMonitor(
HttpSession httpSession) {
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
if (fileUploadMonitor != null) {
return fileUploadMonitor;
} else {
fileUploadMonitor = new FileUploadMonitor();
httpSession
.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR, fileUploadMonitor);
return fileUploadMonitor;
}
}
public static void setFileUploadMonitor(HttpSession httpSession,
FileUploadMonitor fileUploadMonitor) {
FileUploadMonitor fum = (FileUploadMonitor) httpSession
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
if (fum != null) {
httpSession.removeAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
}
httpSession.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR, fileUploadMonitor);
}
//
public static ArrayList<Codelist> retrieveCodelists(HttpSession httpSession)

View File

@ -2495,13 +2495,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
CSVFileUploadSession fileUploadSession = SessionUtil
.getCSVFileUploadSession(session);
if (fileUploadSession == null) {
FileUploadMonitor fileUploadMonitor= SessionUtil
.getFileUploadMonitor(session);
if (fileUploadMonitor == null) {
throw new TDGWTServiceException(
"Error retrieving the fileUploadSession: null");
"Error retrieving the fileUploadMonitor: null");
}
return fileUploadSession.getFileUploadMonitor();
logger.debug("FileUploadMonitor: "+fileUploadMonitor);
return fileUploadMonitor;
}
/**
@ -2899,11 +2905,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
CSVFileUploadSession fileUploadSession = new CSVFileUploadSession();
CSVImportMonitor csvImportMonitor = new CSVImportMonitor();
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
fileUploadSession.setId(session.getId());
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
fileUploadSession.setCsvImportMonitor(csvImportMonitor);
fileUploadSession.setFileUploadMonitor(fileUploadMonitor);
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
@ -2915,15 +2922,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
FileUtil.setImportFileCSV(fileUploadSession, is, wi.getName(),
Constants.FILE_CSV_MIMETYPE);
} catch (Throwable e) {
fileUploadSession/**
* Get informations on tabular resource
*
* @return
* @throws TDGWTServiceException
*/
.getFileUploadMonitor().setFailed(
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed(
"An error occured elaborating the file",
FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
logger.error("Error elaborating the input stream", e);
@ -2933,8 +2936,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
logger.trace("changing state");
fileUploadSession.getFileUploadMonitor().setState(
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(
FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
}
@ -8031,8 +8036,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
fileUploadSession.setId(session.getId());
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
fileUploadSession.setCodelistMappingMonitor(codelistMappingMonitor);
fileUploadSession.setFileUploadMonitor(fileUploadMonitor);
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
SessionUtil.setCodelistMappingFileUploadSession(session,
fileUploadSession);
@ -8044,15 +8049,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
FileUtil.setImportFileCodelistMapping(fileUploadSession, is,
wi.getName(), Constants.FILE_XML_MIMETYPE);
} catch (Throwable e) {
fileUploadSession/**
* Get informations on tabular resource
*
* @return
* @throws TDGWTServiceException
*/
.getFileUploadMonitor().setFailed(
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed(
"An error occured elaborating the file",
FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
SessionUtil.setCodelistMappingFileUploadSession(session,
fileUploadSession);
@ -8063,8 +8064,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
logger.trace("changing state");
fileUploadSession.getFileUploadMonitor().setState(
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(
FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
SessionUtil.setCodelistMappingFileUploadSession(session,
fileUploadSession);

View File

@ -25,8 +25,6 @@ public class CSVFileUploadSession implements Serializable {
protected File csvFile;
protected String csvName;
protected FileUploadMonitor fileUploadMonitor;
protected CSVParserConfiguration parserConfiguration;
protected CSVImportMonitor csvImportMonitor;
@ -64,14 +62,6 @@ public class CSVFileUploadSession implements Serializable {
this.csvName = csvName;
}
public FileUploadMonitor getFileUploadMonitor() {
return fileUploadMonitor;
}
public void setFileUploadMonitor(FileUploadMonitor fileUploadMonitor) {
this.fileUploadMonitor = fileUploadMonitor;
}
public CSVParserConfiguration getParserConfiguration() {
return parserConfiguration;
}
@ -90,12 +80,12 @@ public class CSVFileUploadSession implements Serializable {
@Override
public String toString() {
return "FileUploadSession [id=" + id + ", fileUploadState=" + fileUploadState
+ ", csvFile=" + csvFile + ", csvName=" + csvName
+ ", fileUploadMonitor=" + fileUploadMonitor
+ ", parserConfiguration=" + parserConfiguration
+ ", csvImportMonitor=" + csvImportMonitor +"]";
return "CSVFileUploadSession [id=" + id + ", fileUploadState="
+ fileUploadState + ", csvFile=" + csvFile + ", csvName="
+ csvName + ", parserConfiguration=" + parserConfiguration
+ ", csvImportMonitor=" + csvImportMonitor + "]";
}

View File

@ -4,7 +4,6 @@ import java.io.File;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState;
/**
@ -24,8 +23,6 @@ public class CodelistMappingFileUploadSession implements Serializable {
protected File codelistMappingFile;
protected String codelistMappingName;
protected FileUploadMonitor fileUploadMonitor;
protected CodelistMappingMonitor codelistMappingMonitor;
public String getId() {
@ -44,14 +41,7 @@ public class CodelistMappingFileUploadSession implements Serializable {
this.fileUploadState = fileUploadState;
}
public FileUploadMonitor getFileUploadMonitor() {
return fileUploadMonitor;
}
public void setFileUploadMonitor(FileUploadMonitor fileUploadMonitor) {
this.fileUploadMonitor = fileUploadMonitor;
}
public File getCodelistMappingFile() {
return codelistMappingFile;
}
@ -83,8 +73,8 @@ public class CodelistMappingFileUploadSession implements Serializable {
+ ", fileUploadState=" + fileUploadState
+ ", codelistMappingFile=" + codelistMappingFile
+ ", codelistMappingName=" + codelistMappingName
+ ", fileUploadMonitor=" + fileUploadMonitor
+ ", codelistMappingMonitor=" + codelistMappingMonitor + "]";
}
}