use of org.codice.ddf.migration.UnexpectedMigrationException in project ddf by codice.
the class ConfigurationAdminMigration method export.
public void export(@NotNull Path exportDirectory) throws MigrationException, IOException {
notNull(exportDirectory, "exportDirectory cannot be null");
Path etcDirectory = createEtcDirectory(exportDirectory);
try {
Configuration[] configurations = configurationAdmin.listConfigurations(FILTER);
if (configurations != null) {
for (Configuration configuration : configurations) {
Path exportedFilePath = etcDirectory.resolve(configuration.getPid() + configurationFileExtension);
try {
configurationFileFactory.createConfigurationFile(configuration.getProperties()).exportConfig(exportedFilePath.toString());
} catch (ConfigurationFileException e) {
LOGGER.info("Could not create configuration file {} for configuration {}.", exportedFilePath, configuration.getPid());
throw new ExportMigrationException(e);
} catch (IOException e) {
LOGGER.info("Could not export configuration {} to {}.", configuration.getPid(), exportedFilePath);
throw new ExportMigrationException(e);
}
}
}
} catch (InvalidSyntaxException e) {
LOGGER.info("Invalid filter string {}", FILTER, e);
throw new UnexpectedMigrationException("Export failed", e);
} catch (IOException e) {
LOGGER.info("There was an issue retrieving configurations from ConfigurationAdmin: {}", e.getMessage());
throw new UnexpectedMigrationException("Export failed", e);
}
}
use of org.codice.ddf.migration.UnexpectedMigrationException in project ddf by codice.
the class ConfigurationMigrationManager method export.
@Override
public Collection<MigrationWarning> export(@NotNull Path exportDirectory) throws MigrationException {
notNull(exportDirectory, "Export directory cannot be null");
Collection<MigrationWarning> migrationWarnings = new ArrayList<>();
try {
Files.createDirectories(exportDirectory);
configurationAdminMigration.export(exportDirectory);
migrationWarnings.addAll(exportMigratables(exportDirectory));
} catch (IOException e) {
LOGGER.info("Unable to create export directories", e);
throw new ExportMigrationException("Unable to create export directories", e);
} catch (MigrationException e) {
LOGGER.info("Export operation failed", e);
throw e;
} catch (RuntimeException e) {
LOGGER.info("Failure to export, internal error occurred", e);
throw new UnexpectedMigrationException("Export failed", e);
}
return migrationWarnings;
}
Aggregations