Commit 44f06f57 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '8-remove-file-upload' into 'master'

Resolve "Remove file upload"

Closes #8

See merge request !6
parents beb5e6fe 22eae393
......@@ -37,7 +37,7 @@ import org.springframework.web.servlet.support.AbstractDispatcherServletInitiali
* @author Matija Obreza
*/
public class ServletInitializer extends AbstractDispatcherServletInitializer {
private static final long MAX_FILE_SIZE = 1024 * 1024 * 10; // 10M
private static final long MAX_FILE_SIZE = 0; // 10M
private static final long MAX_REQUEST_SIZE = MAX_FILE_SIZE * 2;
private static final int FILE_SIZE_THRESHOLD = 0;
......
......@@ -16,8 +16,6 @@
package org.genesys.taxonomy.checker.web.controller;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.text.ParseException;
import java.util.List;
......@@ -34,7 +32,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
/**
* The controller
......@@ -61,43 +58,6 @@ public class ValidatorController {
return "index";
}
/**
* Process file.
*
* @param file the file
* @param separator the separator
* @param quoteChar the quote char
* @param escapeChar the escape char
* @param toCurrentTaxa the to current taxa
* @param model the model
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
* @throws ParseException the parse exception
* @throws TaxonomyException the taxonomy exception
*/
@RequestMapping(value = "process", method = RequestMethod.POST, params = "csvFile")
public String processFile(@RequestParam final MultipartFile file, @RequestParam(name = "separator", required = false, defaultValue = ",") final Character separator,
@RequestParam(name = "quoteChar", required = false, defaultValue = "\"") final Character quoteChar,
@RequestParam(name = "escapeChar", required = false, defaultValue = "0") final Character escapeChar,
@RequestParam(name = "toCurrentTaxa", required = false) final Boolean toCurrentTaxa,
@RequestParam(name = "validateType", required = false, defaultValue = "") final String validateType,
@RequestParam(name = "decimalMark", defaultValue = ".") final Character decimalMark,
final ModelMap model) throws IOException, ParseException, TaxonomyException {
LOG.info("Processing uploaded file");
try (Reader reader = new InputStreamReader(file.getInputStream())) {
List<String[]> rows = processService.process(reader, separator, quoteChar, escapeChar, validateType, toCurrentTaxa, decimalMark);
model.addAttribute("result", rows);
model.addAttribute("tableHeaders", rows.get(0));
model.addAttribute("newLineSymbol", "\n");
model.addAttribute("symbolQuote", "\"");
model.addAttribute("separator", separator);
model.addAttribute("columnStyles", getStyles(rows.get(0)));
return "result";
}
}
/**
* Process string.
*
......@@ -115,13 +75,13 @@ public class ValidatorController {
@RequestMapping(value = "process", method = RequestMethod.POST, params = "csvText")
public String processString(@RequestParam(name = "separator", required = false, defaultValue = ",") final Character separator,
@RequestParam(name = "quoteChar", required = false, defaultValue = "\"") final Character quoteChar,
@RequestParam(name = "escapeChar", required = false, defaultValue = "0") final Character escapeChar, @RequestParam(name = "csvText", required = true) final String csvText,
@RequestParam(name = "escapeChar", required = false, defaultValue = "\0") final Character escapeChar, @RequestParam(name = "csvText", required = true) final String csvText,
@RequestParam(name = "toCurrentTaxa", required = false) final Boolean toCurrentTaxa,
@RequestParam(name = "validateType", defaultValue = "") final String validateType,
@RequestParam(name = "decimalMark", defaultValue = ".") final Character decimalMark,
final ModelMap model) throws IOException, ParseException, TaxonomyException {
LOG.info("Processing uploaded CSV string");
LOG.trace("Processing uploaded CSV string:\n{}", csvText);
List<String[]> rows = processService.process(new StringReader(StringUtils.defaultString(csvText, "")), separator, quoteChar, escapeChar, validateType,
toCurrentTaxa, decimalMark);
......
label.title=MCPD Taxonomy Check
label.title=MCPD Taxonomy Check
label.run-check=Validate Taxonomic data
label.run-check-country=Validate Country of Origin
label.run-check-land=Classify Land or Water
label.copy-paste-csv=Copy-paste data from Excel
hint.copy-paste-csv=Select the range of cells (including headers) in Excel and paste the data in to the textbox.
label.file=Upload CSV file
hint.upload-file=Select and upload a CSV (text) file from your computer for validation. If you provide a file, the data in the textbox will be ignored.
hint.copy-paste-csv=Select the range of cells (including headers) in Excel and paste the data in to the textbox.
label.csv-separator=Separator character
hint.csv-separator=The separator character in CSV separates "columns".
......
......@@ -62,12 +62,6 @@
<textarea name="csvText" id="csvText"></textarea>
</div>
<div>
<label for="file"><spring:message code="label.file"/>:</label>
<input id="file" type="file" name="csvFile" accept="text/*"/>
<p class="hint"><spring:message code="hint.upload-file"/></p>
</div>
<h2>CSV Configuration</h2>
<div>
<label for="separator"><spring:message code="label.csv-separator"/>:</label>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment