final ExportFormat exportFormat,
final boolean noPreserve) {
if (kamName == null) {
return;
}
final Kam kam;
try {
setUp();
kam = kAMStore.getKam(kamName);
// establish a default if output path is not set
if (outputFilename == null) {
outputFilename =
kam.getKamInfo().getName()
+ defaultExtension(exportFormat);
}
if (!noPreserve && new File(outputFilename).exists()) {
teardown();
fatal("File '" + outputFilename + "' exists, specify --"
+ LONG_OPT_NO_PRESERVE + " to override.");
}
final String formatString;
if (exportFormat == ExportFormat.XGMML) {
formatString = "XGMML";
XGMMLExporter.exportKam(kam, kAMStore, outputFilename);
} else if (exportFormat == ExportFormat.RDF) {
formatString = "RDF";
RDFExporter.exportRdf(kam, kAMStore.getKamInfo(kamName),
kAMStore, outputFilename);
} else if (exportFormat == ExportFormat.PORTABLE_KAM) {
formatString = "portable";
pkamService.serializeKAM(kamName, outputFilename);
} else {
throw new UnsupportedOperationException(exportFormat.toString()
+ " is not supported.");
}
if (!quiet) {
reportable.output(format(
"Exported '%s' KAM to %s format in '%s'.",
kam.getKamInfo().getName(), formatString,
outputFilename));
}
} catch (PKAMSerializationFailure e) {
reportable.error(e.getUserFacingMessage());
} catch (KAMStoreException e) {