Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98985 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-25 10:35:43 +00:00
parent 10238bc416
commit 6f408bcc8a
6 changed files with 76 additions and 12 deletions

View File

@ -11,7 +11,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
@ -569,7 +569,7 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public ArrayList<CSVRowError> checkCSV(long errorsLimit)
public CheckCSVSession checkCSV(long errorsLimit)
throws TDGWTServiceException;
/**

View File

@ -11,7 +11,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
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.file.HeaderPresence;
@ -186,7 +186,7 @@ public interface TDGWTServiceAsync {
void configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment, AsyncCallback<ArrayList<String>> callback);
void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError>> callback);
void checkCSV(long errorsLimit, AsyncCallback<CheckCSVSession> callback);
void startCSVImport(CSVImportSession csvImportSession, AsyncCallback<Void> callback);

View File

@ -132,7 +132,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVFileUtil;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVParserConfiguration;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
@ -2680,7 +2680,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
* {@inheritDoc}
*/
public ArrayList<CSVRowError> checkCSV(long errorsLimit)
@Override
public CheckCSVSession checkCSV(long errorsLimit)
throws TDGWTServiceException {
HttpSession session = this.getThreadLocalRequest().getSession();

View File

@ -126,18 +126,19 @@ public class CSVFileUtil {
return outCSVFile;
}
public static ArrayList<CSVRowError> checkCSV(File csvFile,
public static CheckCSVSession checkCSV(File csvFile,
CSVParserConfiguration config, long errorsLimit)
throws ParseException, IOException {
return checkCSV(csvFile, config.getCharset(), config.getDelimiter(),
config.getComment(), errorsLimit);
}
public static ArrayList<CSVRowError> checkCSV(File csvFile,
public static CheckCSVSession checkCSV(File csvFile,
Charset charset, char delimiter, char comment, long errorsLimit)
throws IOException {
logger.trace("checkCSV charset: " + charset + " delimiter: "
+ delimiter + " comment: " + comment);
CheckCSVSession checkCSVSesssion;
ArrayList<CSVRowError> errors = new ArrayList<CSVRowError>();
Reader fileReader = new InputStreamReader(new FileInputStream(csvFile),
@ -185,8 +186,14 @@ public class CSVFileUtil {
} while (count >= 0 && errors.size() < errorsLimit
&& maxRowCheck < MAXROWCHECK);
return errors;
if(maxRowCheck < MAXROWCHECK){
checkCSVSesssion=new CheckCSVSession(errors, false);
} else {
checkCSVSesssion=new CheckCSVSession(errors, true);
}
return checkCSVSesssion;
}
public static void toJson(File csvFile, Charset inputCharset,

View File

@ -5,9 +5,13 @@ package org.gcube.portlets.user.td.gwtservice.shared.csv;
import java.io.Serializable;
/**
* An error for a row in the CSV.
* @author Federico De Faveri defaveri@isti.cnr.it
* Errors for row
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CSVRowError implements Serializable {

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.td.gwtservice.shared.csv;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CheckCSVSession implements Serializable {
private static final long serialVersionUID = 7775024048559018931L;
protected ArrayList<CSVRowError> csvRowErrorList;
protected boolean csvFileUpperMaxSizeCheck;
public CheckCSVSession() {
}
public CheckCSVSession(ArrayList<CSVRowError> csvRowErrorList,
boolean csvFileUpperMaxSizeCheck) {
this.csvFileUpperMaxSizeCheck = csvFileUpperMaxSizeCheck;
this.csvRowErrorList = csvRowErrorList;
}
public ArrayList<CSVRowError> getCsvRowErrorList() {
return csvRowErrorList;
}
public void setCsvRowErrorList(ArrayList<CSVRowError> csvRowErrorList) {
this.csvRowErrorList = csvRowErrorList;
}
public boolean isCsvFileUpperMaxSizeCheck() {
return csvFileUpperMaxSizeCheck;
}
public void setCsvFileUpperMaxSizeCheck(boolean csvFileUpperMaxSizeCheck) {
this.csvFileUpperMaxSizeCheck = csvFileUpperMaxSizeCheck;
}
@Override
public String toString() {
return "CheckCSVSession [csvRowErrorList=" + csvRowErrorList
+ ", csvFileUpperMaxSizeCheck=" + csvFileUpperMaxSizeCheck
+ "]";
}
}