private static void createMissingDirectories(final PersistedConfigurationAdapter pca) throws IOException { FileUtils.forceMkdir(pca.getRScriptsCatalogDirectory()); FileUtils.forceMkdir(pca.getSweaveFilesCatalogDirectory()); FileUtils.forceMkdir(pca.getJobConfigurationCatalogDirectory()); FileUtils.forceMkdir(pca.getEmailRepliesCatalogDirectory()); if (pca.getDepositRootDirectories() != null) { for (final DepositDirectoryConfiguration depositRootDirectoryConfig : pca.getDepositRootDirectories()) { final File depositRootDir = depositRootDirectoryConfig.getRootDirectory(); FileUtils.forceMkdir(depositRootDir); FileUtils.forceMkdir(new File(depositRootDir, Configuration.DEPOSIT_ACCEPTED_SUBDIR)); FileUtils.forceMkdir(new File(depositRootDir, Configuration.DEPOSIT_JOBS_SUBDIR)); FileUtils.forceMkdir(new File(depositRootDir, Configuration.DEPOSIT_RESULTS_SUBDIR)); } } }
static Set<String> validate(final PersistedConfigurationAdapter pca) throws IOException { final Set<String> validationErrors = new HashSet<String>(); LOGGER.info("Validating configuration: " + pca.getConfigurationUrl()); validateNotNull(pca.getActiveMqWorkDirectory(), "activeMqWorkDirectory", validationErrors); validateNotNull(pca.getResultsDirectory(), "rsbResultsDirectory", validationErrors); validateNotNull(pca.getDefaultRserviPoolUri(), "defaultRserviPoolUri", validationErrors); validateNotNull(pca.getSmtpConfiguration(), "smtpConfiguration", validationErrors); if (StringUtils.isNotEmpty(pca.getAdministratorEmail())) { validateIsTrue( EmailValidator.getInstance().isValid(pca.getAdministratorEmail()), "if present, the administrator email must be valid", validationErrors); } if (pca.getDepositRootDirectories() != null) { for (final DepositDirectoryConfiguration depositRootDirectoryConfig : pca.getDepositRootDirectories()) { final String depositApplicationName = depositRootDirectoryConfig.getApplicationName(); validateIsTrue( Util.isValidApplicationName(depositApplicationName), "invalid deposit directory application name: " + depositApplicationName, validationErrors); } } if (pca.getDepositEmailAccounts() != null) { for (final DepositEmailConfiguration depositEmailAccount : pca.getDepositEmailAccounts()) { validateIsTrue( Util.isValidApplicationName(depositEmailAccount.getApplicationName()), "invalid deposit email application name: " + depositEmailAccount.getApplicationName(), validationErrors); if (depositEmailAccount.getResponseFileName() != null) { final File responseFile = new File( pca.getEmailRepliesCatalogDirectory(), depositEmailAccount.getResponseFileName()); validateIsTrue( responseFile.exists(), "missing response file: " + responseFile, validationErrors); } if (depositEmailAccount.getJobConfigurationFileName() != null) { final File jobConfigurationFile = new File( pca.getJobConfigurationCatalogDirectory(), depositEmailAccount.getJobConfigurationFileName()); validateIsTrue( jobConfigurationFile.exists(), "missing job configuration file: " + jobConfigurationFile, validationErrors); } } } if (pca.getDataDirectories() != null) { for (final File dataDirectoryRoot : pca.getDataDirectories()) { validateIsTrue( dataDirectoryRoot.isDirectory(), "invalid data directory: " + dataDirectoryRoot, validationErrors); } } return validationErrors; }