Source:
<code>public WizardPageController firstPageController() { return new CsvDatastoreUploadOrExistingFileWizardPage(getWizardContext()) { @Override protected WizardPageController nextPageControllerUpload(final String filename, final File tempFile) { return new CsvDatastoreLocationWizardPage(getWizardContext(), filename, true) { @Override protected WizardPageController nextPageController(Resource resource) { if (resource instanceof FileResource){ final File file = ((FileResource) resource).getFile(); final File directory = file.getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new DCUserInputException("Could not create directory for file:\n" + file.getAbsolutePath()); } if (!directory.canWrite()) { throw new DCUserInputException("Cannot write data to directory of file:\n" + file.getAbsolutePath()); } FileHelper.copy(tempFile, file); } _resource = resource; return showCsvConfigurationPage(filename); } }; } @Override protected WizardPageController nextPageControllerExisting() { return new CsvDatastoreLocationWizardPage(getWizardContext(), "my_file.csv", false) { @Override protected WizardPageController nextPageController(Resource resource) { if (resource instanceof FileResource) { final File file = ((FileResource) resource).getFile(); final String filepath = file.getAbsolutePath(); <START> if (!filepath.toLowerCase().endsWith(".csv")) { <END> if (!filepath.toLowerCase().endsWith(".tsv")) { if (!filepath.toLowerCase().endsWith(".txt")) { throw new DCUserInputException( "For security reasons, only existing .csv, .tsv or .txt files can be referenced on the server"); } } if (file.exists() && !file.canRead()) { throw new DCUserInputException("Cannot read from file:\n" + filepath); } } } _resource = resource; return showCsvConfigurationPage(resource.getName()); } }; } }; }</code><technical_language>a pretty nasty construct. ORing instead (I'm pretty convinced tools for checking extensions, varargs array of extensions check for)? special case for txt files</technical_language>

Target:
public WizardPageController firstPageController() { return new CsvDatastoreUploadOrExistingFileWizardPage(getWizardContext()) { @Override protected WizardPageController nextPageControllerUpload(final String filename, final File tempFile) { return new CsvDatastoreLocationWizardPage(getWizardContext(), filename, true) { @Override protected WizardPageController nextPageController(Resource resource) { if (resource instanceof FileResource){ final File file = ((FileResource) resource).getFile(); final File directory = file.getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new DCUserInputException("Could not create directory for file:\n" + file.getAbsolutePath()); } if (!directory.canWrite()) { throw new DCUserInputException("Cannot write data to directory of file:\n" + file.getAbsolutePath()); } FileHelper.copy(tempFile, file); } _resource = resource; return showCsvConfigurationPage(filename); } }; } @Override protected WizardPageController nextPageControllerExisting() { return new CsvDatastoreLocationWizardPage(getWizardContext(), "my_file.csv", false) { @Override protected WizardPageController nextPageController(Resource resource) { if (resource instanceof FileResource) { final File file = ((FileResource) resource).getFile(); final String filepath = file.getAbsolutePath(); if (!FilenameUtils.isExtension(file.getName() , extensions)) { throw new DCUserInputException( "For security reasons, only existing .csv, .tsv or .txt files can be referenced on the server"); } if (file.exists() && !file.canRead()) { throw new DCUserInputException("Cannot read from file:\n" + filepath); } } _resource = resource; return showCsvConfigurationPage(resource.getName()); } }; } }; }