use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class DefaultRenderingManager method getHTML.
/**
* Returns the converted HTML of the page's specific version. The version must be a positive integer, otherwise the current
* version is returned.
*
* @param pagename WikiName of the page to convert.
* @param version Version number to fetch
* @return HTML-rendered page text.
*/
@Override
public String getHTML(final String pagename, final int version) {
final Page page = m_engine.getManager(PageManager.class).getPage(pagename, version);
final Context context = Wiki.context().create(m_engine, page);
context.setRequestContext(ContextEnum.PAGE_NONE.getRequestContext());
return getHTML(context, page);
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class AttachmentsIteratorTag method doStartTag.
/**
* {@inheritDoc}
*/
@Override
public final int doStartTag() {
m_wikiContext = (Context) pageContext.getAttribute(Context.ATTR_CONTEXT, PageContext.REQUEST_SCOPE);
final Engine engine = m_wikiContext.getEngine();
final AttachmentManager mgr = engine.getManager(AttachmentManager.class);
final Page page;
page = m_wikiContext.getPage();
if (!mgr.attachmentsEnabled()) {
return SKIP_BODY;
}
try {
if (page != null && engine.getManager(PageManager.class).wikiPageExists(page)) {
final List<Attachment> atts = mgr.listAttachments(page);
if (atts == null) {
log.debug("No attachments to display.");
// There are no attachments included
return SKIP_BODY;
}
m_iterator = atts.iterator();
if (m_iterator.hasNext()) {
final Attachment att = (Attachment) m_iterator.next();
final Context context = m_wikiContext.clone();
context.setPage(att);
pageContext.setAttribute(Context.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
pageContext.setAttribute(getId(), att);
} else {
return SKIP_BODY;
}
} else {
return SKIP_BODY;
}
return EVAL_BODY_BUFFERED;
} catch (final ProviderException e) {
log.fatal("Provider failed while trying to iterator through history", e);
// FIXME: THrow something.
}
return SKIP_BODY;
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class HistoryIteratorTag method doAfterBody.
/**
* {@inheritDoc}
*/
@Override
public final int doAfterBody() {
if (bodyContent != null) {
try {
final JspWriter out = getPreviousOut();
out.print(bodyContent.getString());
bodyContent.clearBody();
} catch (final IOException e) {
LOG.error("Unable to get inner tag text", e);
// FIXME: throw something?
}
}
if (m_iterator != null && m_iterator.hasNext()) {
final Context context = m_wikiContext.clone();
context.setPage((Page) m_iterator.next());
pageContext.setAttribute(Context.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
pageContext.setAttribute(getId(), context.getPage());
return EVAL_BODY_BUFFERED;
}
return SKIP_BODY;
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class PluginBeanTest method testDoGet.
@Test
public void testDoGet() throws WikiException, NotCompliantMBeanException {
testEngine = new TestEngine(props);
final Context context = Wiki.context().create(testEngine, Wiki.contents().page(testEngine, "TestPage01"));
final PluginBean pb = new PluginBean(testEngine);
final String expectedHtml = "<div>" + "<h4>Plugins</h4>" + "<table border=\"1\">" + "<tr><th>Name</th><th>Alias</th><th>Author</th><th>Notes</th></tr>" + "<tr><td>IfPlugin</td><td>If</td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>Note</td><td></td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>SamplePlugin</td><td>samplealias</td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>SamplePlugin2</td><td>samplealias2</td><td>Janne Jalkanen</td><td></td></tr>" + "</table>" + "</div>";
Assertions.assertEquals(expectedHtml, pb.doGet(context));
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class RPCHandlerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
m_handler = new RPCHandler();
final Context ctx = Wiki.context().create(m_engine, Wiki.contents().page(m_engine, "Dummy"));
m_handler.initialize(ctx);
}
Aggregations