{
int nRowsChanged = 0;
if (action.equals("ADD"))
{
File temp = File.createTempFile("molgenis", "tab");
CsvWriter csvWriter = new CsvWriter(temp);
try
{
if (req.get(INPUT_SILENT) != null && req.getBoolean(INPUT_SILENT) == true)
{
csvWriter.close();
csvWriter = null;
}
if (req.get(INPUT_DATA) != null)
{
logger.info("processing textarea upload...");
nRowsChanged = db.add(entityClass, csvReader, csvWriter);
}
else if (req.get(INPUT_FILE) != null)
{
logger.info("processing file upload...");
nRowsChanged = db.add(entityClass, csvReader, csvWriter);
}
else
{
logger.error("no input data or input file provided.");
out.print("ERROR: no input data or input file provided.");
}
out.print("Uploaded " + formatter.format(nRowsChanged) + " rows of "
+ entityClass.getCanonicalName() + "\n");
}
finally
{
if (csvWriter != null) csvWriter.close();
}
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(temp),
Charset.forName("UTF-8")));
try
{