public static File parseParametersForWritableDirectory(Map<String, String> parameters,
String parameterName)
throws JournalException {
String directoryString = parameters.get(parameterName);
if (directoryString == null) {
throw new JournalException("'" + parameterName + "' is required.");
}
File directory = new File(directoryString);
if (!directory.exists()) {
throw new JournalException("Directory '" + directory
+ "' does not exist.");
}
if (!directory.isDirectory()) {
throw new JournalException("Directory '" + directory
+ "' is not a directory.");
}
if (!directory.canWrite()) {
throw new JournalException("Directory '" + directory
+ "' is not writable.");
}
return directory;
}