Exception {
if (null == distributionFile) {
throw new IllegalArgumentException("distributionFile == null");
}
BundleDistributionInfo info = null;
String recipe = null;
RecipeParseResults recipeParseResults = null;
Map<String, File> bundleFiles = null;
// try and parse the recipe, if successful then process the distributionFile completely
RecipeVisitor recipeVisitor = new RecipeVisitor(this, "deploy.txt");
ZipUtil.walkZipFile(distributionFile, recipeVisitor);
recipe = recipeVisitor.getRecipe();
recipeParseResults = recipeVisitor.getResults();
if (null == recipeParseResults) {
// we also want to support the ability to provide just a file template recipe as the distro file
// so see if we can parse it, but note that we don't even bother if its a really big file since
// that's probably not a recipe file and we don't want to risk loading in a huge file in memory
if (distributionFile.length() < 50000L) {
byte[] content = StreamUtil.slurp(new FileInputStream(distributionFile));
recipe = new String(content);
content = null;
recipeParseResults = parseRecipe(recipe); // if it isn't a recipe either, this will throw UnknownRecipeException
} else {
throw new UnknownRecipeException("Not a File Template Bundle");
}
} else {
// if we parsed the recipe, then this is a distribution zip we can deal with, get the bundle file Map
BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleMetadata()
.getBundleName(), recipeParseResults.getBundleFileNames());
ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);
bundleFiles = bundleFileVisitor.getBundleFiles();
}
info = new BundleDistributionInfo(recipe, recipeParseResults, bundleFiles);
return info;
}