public static File getOrCreateDataDirectory(String location) throws StorageException {
File storageDir = new File(location);
if (storageDir.exists() && storageDir.isFile())
throw new PermanentStorageException(String.format("%s exists but is a file.", location));
if (!storageDir.exists() && !storageDir.mkdirs())
throw new PermanentStorageException(String.format("Failed to create directory %s for local storage.", location));
return storageDir;
}