System.exit(1);
}
List<String> catalogList = readCatalogFile(args[0]);
InvCatalogFactory factory = new InvCatalogFactory("default", true);
URI cataURI = null;
try {
String uriString = args[1];
cataURI = new URI(uriString);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(cataURI);
final StringBuilder buff = new StringBuilder();
if (catalog.check(buff)) {
for (String cata : catalogList) {
// create
InvCatalogRef ref = new InvCatalogRef(null,
cata.substring(0, cata.lastIndexOf('.')), "1/"+ cata);
catalog.removeDataset(ref);
if ((args.length < 3) || (!args[2].equals("remove"))) {
catalog.addDataset(ref);
}
}
catalog.finish();
} else {
throw new Exception(buff.toString());
}
// write out catalog to String
try {
OutputStream fout = new FileOutputStream(new File(cataURI.getPath()));
factory.writeXML(catalog, fout, true);
System.out.println("Final xref catalog output:" + cataURI.getPath());
} catch (IOException e) {
e.printStackTrace();