String name = jxlDocument.getName();
if (jxlDocument.isRemoveAccents()) {
name = Database.convertToDatabaseName(name);
}
Document document = new Document(name, ClientConfiguration.getDefault().getCompression());
Date date = jxlDocument.getDate();
if (date != null) {
document.setCreationDate(date);
document.setModificationDate(date);
}
spider = new Spider(document, jxlDocument, httpCache, cookieStore, maxConnections,
Spider.DEFAULT_MAX_PARSE_THREADS, httpTimeout);
try {
for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
SpiderListener spiderListener = (SpiderListener) iterator.next();
spider.addSpiderListener(spiderListener);
}
if (!running) {
break;
}
spider.run();
} finally {
for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
SpiderListener spiderListener = (SpiderListener) iterator.next();
spider.removeSpiderListener(spiderListener);
}
}
boolean success = false;
if (!running) {
break;
}
String uri = jxlDocument.getStartingURI().toString();
if (document.contains(uri)) {
try {
document.setHome(uri);
document.setOutputEncoding(jxlDocument.getOutputEncoding());
document.setIncludeImageAltText(jxlDocument.isIncludeAltText());
document.setCategories(jxlDocument.getCategories());
document.setDefaultLinkColor(jxlDocument.getLinkColor());
document.setUnresolvedLinkColor(jxlDocument.getUnresolvedLinkColor());
document.setRemoveUnresolvedLinks(jxlDocument.isRemoveUnresolvedLinks());
document.setIncludeURIInfo(jxlDocument.isIncludeURIInfo());
document.setBackup(jxlDocument.isSetBackupBit());
document.setEncoding(jxlDocument.getOutputEncoding());
// Sort bookmarks for sites
if (jxlDocument instanceof Site) {
Site site = (Site) jxlDocument;
if (site.isSortBookmarks()) {
document.sortBookmarks();
}
}
fireGenerationStarted(jxlDocument);
for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
document.addRecordListener((RecordListener) it.next());
}
document.setFilename(jxlDocument.getFilename());
long size = destination.write(document);
jxlDocument.converted(size);
fireGenerationCompleted(jxlDocument);
logger.info("Completed conversion: " + jxlDocument.getName());
success = true;
} catch (Exception e) {
logger.severe("Could not generate document: " + e.getClass() + " " + e.getMessage());
e.printStackTrace();
} finally {
for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
document.removeRecordListener((RecordListener) it.next());
}
}
} else {
logger.severe(jxlDocument.getName() + ": could not load starting URI " + jxlDocument.getUri() +
". Document cannot be generated.");