// todo: add a debug log here? does this use notification?
}
if (recognisedPath || !applyPathRecognition) {
Version identifiedVersion = null;
Iterator contentRecognisersIterator = contentIdentifiers.iterator();
while (contentRecognisersIterator.hasNext()) {
input.restart();
ContentIdentifier contentRecogniser =
(ContentIdentifier) contentRecognisersIterator.next();
// todo: later: potentially a recognition exception should not
// always be fatal. It may be that there are multiple
// recognisers for a path and that one of the ones that throws
// an exception is not the one that actually recognises the
// content. In this case we could log the error, continue on,
// and only fail if there is no match in the end.
boolean identifiedContent;
try {
identifiedContent = contentRecogniser.identifyContent(input);
} catch (Exception e) {
throw new ResourceMigrationException("Error identifying " +
"content for type " + getName() + " version " +
contentRecogniser.getVersion().getName(), e);
}
if (identifiedContent) {
if (identifiedVersion == null) {
identifiedVersion = contentRecogniser.getVersion();
} else {
throw new IllegalStateException("Duplicate version " +
"match: " + contentRecogniser.getVersion().
getName() + " and " + identifiedVersion +
" both match the content");
}
}
}
if (identifiedVersion != null &&
!identifiedVersion.equals(graph.getTargetVersion())) {
// Extract the sequence of steps that starts with the
// identified version. This might generate an exception if
// we didn't do much validation at build time and the
// identified version does not have a matching step.
Iterator sequence = graph.getSequence(identifiedVersion);
match = factory.createMatch(getName(),
identifiedVersion.getName(), sequence);
}
}
return match;
}