// Type of validation to be performed by each step
StepType stepType = null;
while (steps.hasNext()) {
final Step step = (Step) steps.next();
if (logger.isDebugEnabled()) {
logger.debug("Invoking migration step :"+step);
}
// Calculate the input stream for this step.
// If we have a previous output, then that must be the
// input for this step, otherwise use the original
// input.
if (buffer != null) {
stepInput = buffer.getInput();
} else {
stepInput = inputStream;
}
// Calculate the output stream for this step.
// If we have another step to process, then we must
// buffer the output of the step, otherwise use the
// original output.
if (steps.hasNext()) {
buffer = streamBufferFactory.create();
stepOutput = buffer.getOutput();
} else {
stepOutput = outputCreator.createOutputStream();
}
// Workout which step this is
stepType = getCurrentStepType(stepType, steps);
// Do the migration.
Exception firstException = null;
try {
step.migrate(stepInput, stepOutput, stepType);
} catch (ResourceMigrationException e) {
firstException = e;
} finally {
try {
stepInput.close();