"\n You will need to manually create one -ds.xml for each JDBC DataSource " +
"\n with a JNDI name of <connector binding name>DS, " +
"\n where any spaces in the name are replace by _");
System.exit(-1);
}
File file = new File(args[0]);
if (!file.exists()) {
System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
System.exit(-1);
}
String fullName = file.getName();
String fileName = fullName.substring(0, fullName.length() - 4);
String ext = FileUtils.getExtension(file);
if (ext == null) {
System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
System.exit(-1);
}
ext = ext.toLowerCase();
if (ext.endsWith("vdb")) {
File dir = createTempDirectory();
try {
extract(file, dir);
File metainf = new File(dir, "META-INF");
File config = new File(dir, "ConfigurationInfo.def");
File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
if (manifest.exists()) {
String configStr = ObjectConverterUtil.convertFileToString(config);
String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
int index = configStr.lastIndexOf("</VDB>");
int manifestBegin = manifestStr.indexOf("<xmi");
configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
FileUtils.write(configStr.getBytes(), config);
manifest.delete();
}
transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
config.delete();
FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
int parentLength = dir.getPath().length();
addDirectory(dir, zos, parentLength);
zos.close();
} finally {
FileUtils.removeDirectoryAndChildren(dir);
}
} else if (ext.endsWith("xml") || ext.endsWith("def")){
File parent = file.getParentFile();
transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
} else {
System.err.println(fullName + " is not a vdb or xml file. Run with no arguments for help."); //$NON-NLS-1$
System.exit(-1);
}
}