use of org.apache.wiki.api.filters.PageFilter in project jspwiki by apache.
the class DefaultFilterManager method doPostSaveFiltering.
/**
* Does the page filtering after the page has been saved.
*
* @param context The WikiContext
* @param pageData WikiMarkup data to be passed through the postSave chain.
* @throws FilterException If any of the filters throws a FilterException
*
* @see PageFilter#postSave(WikiContext, String)
*/
public void doPostSaveFiltering(WikiContext context, String pageData) throws FilterException {
fireEvent(WikiPageEvent.POST_SAVE_BEGIN, context);
for (PageFilter f : m_pageFilters) {
// log.info("POSTSAVE: "+f.toString() );
f.postSave(context, pageData);
}
fireEvent(WikiPageEvent.POST_SAVE_END, context);
}
use of org.apache.wiki.api.filters.PageFilter in project jspwiki by apache.
the class DefaultFilterManager method initPageFilter.
private void initPageFilter(String className, Properties props) {
try {
PageFilterInfo info = m_filterClassMap.get(className);
if (info != null && !checkCompatibility(info)) {
String msg = "Filter '" + info.getName() + "' not compatible with this version of JSPWiki";
log.warn(msg);
return;
}
// FIXME: Currently fixed.
int priority = 0;
Class<?> cl = ClassUtil.findClass("org.apache.wiki.filters", className);
PageFilter filter = (PageFilter) cl.newInstance();
filter.initialize(m_engine, props);
addPageFilter(filter, priority);
log.info("Added page filter " + cl.getName() + " with priority " + priority);
} catch (ClassNotFoundException e) {
log.error("Unable to find the filter class: " + className);
} catch (InstantiationException e) {
log.error("Cannot create filter class: " + className);
} catch (IllegalAccessException e) {
log.error("You are not allowed to access class: " + className);
} catch (ClassCastException e) {
log.error("Suggested class is not a PageFilter: " + className);
} catch (FilterException e) {
log.error("Filter " + className + " failed to initialize itself.", e);
}
}
use of org.apache.wiki.api.filters.PageFilter in project jspwiki by apache.
the class DefaultFilterManagerTest method testInitFilters.
@Test
public void testInitFilters() throws Exception {
FilterManager m = new DefaultFilterManager(engine, props);
List l = m.getFilterList();
Assert.assertEquals("Wrong number of filters", 2, l.size());
Iterator i = l.iterator();
PageFilter f1 = (PageFilter) i.next();
Assert.assertTrue("Not a Profanityfilter", f1 instanceof ProfanityFilter);
PageFilter f2 = (PageFilter) i.next();
Assert.assertTrue("Not a Testfilter", f2 instanceof TestFilter);
}
use of org.apache.wiki.api.filters.PageFilter in project jspwiki by apache.
the class DefaultFilterManager method doPreTranslateFiltering.
/**
* Does the filtering before a translation.
*
* @param context The WikiContext
* @param pageData WikiMarkup data to be passed through the preTranslate chain.
* @throws FilterException If any of the filters throws a FilterException
* @return The modified WikiMarkup
*
* @see PageFilter#preTranslate(WikiContext, String)
*/
public String doPreTranslateFiltering(WikiContext context, String pageData) throws FilterException {
fireEvent(WikiPageEvent.PRE_TRANSLATE_BEGIN, context);
for (PageFilter f : m_pageFilters) {
pageData = f.preTranslate(context, pageData);
}
fireEvent(WikiPageEvent.PRE_TRANSLATE_END, context);
return pageData;
}
use of org.apache.wiki.api.filters.PageFilter in project jspwiki by apache.
the class DefaultFilterManager method doPreSaveFiltering.
/**
* Does the filtering before a save to the page repository.
*
* @param context The WikiContext
* @param pageData WikiMarkup data to be passed through the preSave chain.
* @throws FilterException If any of the filters throws a FilterException
* @return The modified WikiMarkup
* @see PageFilter#preSave(WikiContext, String)
*/
public String doPreSaveFiltering(WikiContext context, String pageData) throws FilterException {
fireEvent(WikiPageEvent.PRE_SAVE_BEGIN, context);
for (PageFilter f : m_pageFilters) {
pageData = f.preSave(context, pageData);
}
fireEvent(WikiPageEvent.PRE_SAVE_END, context);
return pageData;
}
Aggregations