use of org.codice.ddf.migration.MigrationException 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;
}
use of org.codice.ddf.migration.MigrationException in project ddf by codice.
the class MigratableUtil method copyFileFromJavaPropertyValue.
/**
* Copies a file, whose path is taken from the value a Java properties file, to a destination.
* directory. The file to copy must be a relative path under {@code ddf.home}, and its path
* must not contain any symbolic link, otherwise the file will not be copied and a
* {@link MigrationWarning} will be returned.
*
* @param propertyFilePath path to the Java properties file that contains the path to the
* source file to copy
* @param javaProperty name of the property inside the Java properties file that contains
* the path to the source file
* @param exportDirectory path to the destination
* @param warnings any warnings generated during this operation (e.g., source file
* outside of {@code ddf.home}) will be added to this collection
*/
public void copyFileFromJavaPropertyValue(@NotNull Path propertyFilePath, @NotNull String javaProperty, @NotNull Path exportDirectory, @NotNull Collection<MigrationWarning> warnings) throws MigrationException {
notNull(propertyFilePath, "Java properties file cannot be null");
Properties properties = readPropertiesFile(ddfHome.resolve(propertyFilePath));
String source = (String) properties.get(javaProperty);
notEmpty(source, String.format("Source path property [%s] is invalid: [%s]", javaProperty, source));
Path sourcePath = Paths.get(source);
copy(sourcePath, exportDirectory, warnings, () -> isSourceMigratable(sourcePath, (reason) -> new PathMigrationWarning(propertyFilePath, javaProperty, sourcePath, reason), warnings));
}
use of org.codice.ddf.migration.MigrationException in project ddf by codice.
the class MetacardsMigratableTest method exportWhenTaskManagerFinishFailsWithMigrationException.
@Test(expected = MigrationException.class)
public void exportWhenTaskManagerFinishFailsWithMigrationException() throws Exception {
doThrow(new MigrationException("")).when(mockTaskManager).close();
migratable.export(EXPORT_PATH);
}
use of org.codice.ddf.migration.MigrationException in project ddf by codice.
the class MetacardsMigratableTest method exportWhenExportMetacardFailsWithMigrationException.
@Test(expected = RuntimeException.class)
public void exportWhenExportMetacardFailsWithMigrationException() throws Exception {
doThrow(new MigrationException("")).when(mockTaskManager).exportMetacardQuery(results, 1);
try {
migratable.export(EXPORT_PATH);
} finally {
verify(mockTaskManager).exportMetacardQuery(results, 1);
verify(mockTaskManager).close();
verifyNoMoreInteractions(mockTaskManager);
}
}
Aggregations