try
{
if (expanded)
{
Archive epub;
try
{
epub = new Archive(path, true);
}
catch (RuntimeException ex)
{
System.err.println(Messages.get("there_were_errors"));
return 1;
}
epub.createArchive();
report.setEpubFileName(epub.getEpubFile().getAbsolutePath());
EpubCheck check = new EpubCheck(epub.getEpubFile(), report);
int validationResult = check.doValidate();
if (validationResult == 0)
{
outWriter.println(Messages.get("no_errors__or_warnings"));
result = 0;
}
else if (validationResult == 1)
{
System.err.println(Messages.get("there_were_warnings"));
result = failOnWarnings ? 1 : 0;
}
else if (validationResult >= 2)
{
System.err.println(Messages.get("there_were_errors"));
result = 1;
}
if (keep)
{
if ((report.getErrorCount() > 0) || (report.getFatalErrorCount() > 0))
{
//keep if valid or only warnings
System.err.println(Messages.get("deleting_archive"));
epub.deleteEpubFile();
}
}
else
{
epub.deleteEpubFile();
}
}
else
{
if (mode != null)