throw new Exception("FileManager returned null metadata");
}
if (outputDir != null) {
if (outputDir.exists()) {
XMLUtils.writeXmlFile(
new SerializableMetadata(metadata).toXML(), new File(
outputDir.getAbsoluteFile(),
generateFilename(metadata)).getAbsolutePath());
} else {
throw new Exception("Output dir '" + outputDir
+ "' does not exist");
}
} else {
OutputStream os = new OutputStream() {
private StringBuffer sb = new StringBuffer("");
@Override
public void write(int character) throws IOException {
sb.append((char) character);
}
@Override
public void close() throws IOException {
super.close();
printer.println(sb.toString());
}
};
XMLUtils.writeXmlToStream(
new SerializableMetadata(metadata).toXML(),
os);
os.close();
}
} catch (Exception e) {
throw new CmdLineActionException(