final Map<String, String> tempFileMapping = getTempFileDeclarations(
pathNode, toolIOProfileElementName);
if (!tempFileMapping.isEmpty() && toolIOProfile.usePipedIO()) {
throw new MigrationPathConfigException(
"Both piped IO and temporary file is specified in the "
+ "tool IO profile. Only one type may be "
+ "specified in the '"
+ toolIOProfileElementName
+ "' element of the '" + pathNode.getNodeName()
+ "' element.");
}
if (tempFileMapping.isEmpty() && !toolIOProfile.usePipedIO()) {
throw new MigrationPathConfigException(
"Either piped IO or a temporary file must be specified"
+ " in the '" + toolIOProfileElementName
+ "' element of the '" + pathNode.getNodeName()
+ "' element.");
}
if (tempFileMapping.size() > 1) {
throw new MigrationPathConfigException(
"Only one temporary file may be specified in the tool"
+ " IO profile. " + tempFileMapping.size()
+ " were specified in the '"
+ toolIOProfileElementName
+ "' element of the '" + pathNode.getNodeName()
+ "' element.");
}
if (!toolIOProfile.usePipedIO()) {
// Based on the above code, we are sure that the temp. file map
// contains exactly one element, thus this is OK.
final String tempFileLabel = tempFileMapping.keySet()
.iterator().next();
toolIOProfile.setCommandLineFileLabel(tempFileLabel);
toolIOProfile.setDesiredTempFileName(tempFileMapping
.get(tempFileLabel));
}
return toolIOProfile;
} catch (XPathExpressionException xPathExpressionException) {
throw new MigrationPathConfigException(
"Failed reading tool IO profile information from the '"
+ toolIOProfileElementName + "' element in the '"
+ pathNode.getNodeName() + "' element.",
xPathExpressionException);
}