/**
* The slice and splice parser code is very similar, so this method simply consolidates
* that code to avoid duplication.
*/
private static String[] executeSliceOrSplice(ParserOutput parserOutput, String context, Locale locale, String virtualWiki, String topicName, int targetSection, String replacementText, boolean isSlice) throws ParserException {
Topic topic = null;
try {
topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName, false, null);
} catch (DataAccessException e) {
throw new ParserException(e);
}
if (topic == null || topic.getTopicContent() == null) {
return null;
}
ParserInput parserInput = new ParserInput();
parserInput.setContext(context);
parserInput.setLocale(locale);
parserInput.setTopicName(topicName);
parserInput.setVirtualWiki(virtualWiki);
AbstractParser parser = ParserUtil.parserInstance(parserInput);
String content = null;
if (isSlice) {
content = parser.parseSlice(parserOutput, topic.getTopicContent(), targetSection);
} else {
content = parser.parseSplice(parserOutput, topic.getTopicContent(), targetSection, replacementText);
}
String sectionName = parserOutput.getSectionName();
return new String[]{sectionName, content};
}