private void applySnippetFilters(PageContentTO page, String mode) {
Map<SnippetInstanceTO, SnippetPageFilter> filters = null;
for (Iterator i = page.getSnippets().iterator(); i.hasNext();) {
SnippetInstanceTO snip = (SnippetInstanceTO) i.next();
SnippetDefinition def = snip.getDefinition();
SnippetPageFilter filter = null;
try {
if (def != null)
filter = def.getFilter(mode, null);
} catch (Exception e) {
logger.log(Level.SEVERE,
"Unable to create page filter for snippet '"
+ snip.getSnippetID() + "'", e);
}
if (filter != null) {
if (filters == null)
filters = new LinkedHashMap();
filters.put(snip, filter);
}
}
if (filters != null) {
// if any filters were found, run them all against the page.
for (Map.Entry<SnippetInstanceTO, SnippetPageFilter> e : filters
.entrySet()) {
SnippetInstanceTO snip = e.getKey();
SnippetPageFilter f = e.getValue();
try {
f.filter(page, snip, mode);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Snippet page filter '"
+ snip.getSnippetID()
+ "' encountered an exception while running.", ex);
}