in src/main/java/com/netflix/imflibrary/app/IMPFixer.java [319:390]
public static void main(String args[]) throws
IOException, ParserConfigurationException, SAXException, JAXBException, URISyntaxException, NoSuchAlgorithmException {
if (args.length < 2) {
logger.error(usage());
System.exit(-1);
}
String inputFileName = args[0];
File inputFile = new File(inputFileName);
if (!inputFile.exists()) {
logger.error(String.format("File %s does not exist", inputFile.getAbsolutePath()));
System.exit(-1);
}
String outputFileName = args[1];
File outputFile = new File(outputFileName);
if (!outputFile.exists() && !outputFile.mkdir()) {
logger.error(String.format("Directory %s cannot be created", outputFile.getAbsolutePath()));
System.exit(-1);
}
String versionCPLSchema = "";
Boolean copyTrackFile = true;
Boolean generateHash = true;
for(int argIdx = 2; argIdx < args.length; ++argIdx)
{
String curArg = args[argIdx];
String nextArg = argIdx < args.length - 1 ? args[argIdx + 1] : "";
if(curArg.equalsIgnoreCase("--cpl-schema") || curArg.equalsIgnoreCase("-cs")) {
if(nextArg.length() == 0 || nextArg.charAt(0) == '-') {
logger.error(usage());
System.exit(-1);
}
versionCPLSchema = nextArg;
argIdx++;
}
else if(curArg.equalsIgnoreCase("--no-copy") || curArg.equalsIgnoreCase("-nc")) {
copyTrackFile = false;
}
else if(curArg.equalsIgnoreCase("--no-hash") || curArg.equalsIgnoreCase("-nh")) {
generateHash = false;
}
else {
logger.error(usage());
System.exit(-1);
}
}
if (!inputFile.exists() || !inputFile.isDirectory()) {
logger.error(String.format("Invalid input package path"));
System.exit(-1);
}
else
{
List<ErrorLogger.ErrorObject> errors = analyzePackageAndWrite(inputFile, outputFile, versionCPLSchema, copyTrackFile, generateHash);
if (errors.size() > 0) {
logger.info(String.format("IMPWriter encountered errors:"));
for (ErrorLogger.ErrorObject errorObject : errors) {
if (errorObject.getErrorLevel() != IMFErrorLogger.IMFErrors.ErrorLevels.WARNING) {
logger.error(errorObject.toString());
} else if (errorObject.getErrorLevel() == IMFErrorLogger.IMFErrors.ErrorLevels.WARNING) {
logger.warn(errorObject.toString());
}
}
System.exit(-1);
} else {
logger.info(String.format("Created %s IMP successfully", outputFile.getName()));
}
}
}