logger.info("Connecting to storage for campaign: " + campaign);
// sanity checks
if(campaign == null) {
throw new CampaignStorageException("No campaign set!");
}
if(campaign.getStorageUri() == null) {
throw new CampaignStorageException("Storage URI not set for campaign: " + campaign);
}
File storagePathFile = new File(storagePath);
if(!storagePathFile.exists()) {
logger.info("Storage path doesn't exist; creating: " + storagePath);
PathUtils.createPath(storagePath);
}
// checks if the directory is present
if(!storagePathFile.exists()) {
throw new CampaignStorageException("Can't find storage path: " + storagePath);
}
if(!storagePathFile.isDirectory()) {
throw new CampaignStorageException("Storage path is not a directory: " + storagePath);
}
// check if the directory is readable and writable
if(!storagePathFile.canRead()) {
throw new CampaignStorageException("Storage path is not readable: " + storagePath);
}
if(!storagePathFile.canWrite()) {
throw new CampaignStorageException("Storage path is not writable: " + storagePath);
}
doSetStatus(CampaignStorageConstants.STORAGE_STATUS_ONLINE);
logger.info("Connection established to local file storage: " + storagePath);