use of javax.servlet.jsp.JspWriter in project jspwiki by apache.
the class DiffLinkTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
String pageName = m_pageName;
if (m_pageName == null) {
if (m_wikiContext.getPage() != null) {
pageName = m_wikiContext.getPage().getName();
} else {
return SKIP_BODY;
}
}
final JspWriter out = pageContext.getOut();
int r1;
int r2;
// In case the page does not exist, we fail silently.
if (!engine.getManager(PageManager.class).wikiPageExists(pageName)) {
return SKIP_BODY;
}
if (VER_LATEST.equals(getVersion())) {
final Page latest = engine.getManager(PageManager.class).getPage(pageName, WikiProvider.LATEST_VERSION);
if (latest == null) {
// This may occur if matchEnglishPlurals is on, and we access the wrong page name
return SKIP_BODY;
}
r1 = latest.getVersion();
} else if (VER_PREVIOUS.equals(getVersion())) {
r1 = m_wikiContext.getPage().getVersion() - 1;
r1 = Math.max(r1, 1);
} else if (VER_CURRENT.equals(getVersion())) {
r1 = m_wikiContext.getPage().getVersion();
} else {
r1 = Integer.parseInt(getVersion());
}
if (VER_LATEST.equals(getNewVersion())) {
final Page latest = engine.getManager(PageManager.class).getPage(pageName, WikiProvider.LATEST_VERSION);
r2 = latest.getVersion();
} else if (VER_PREVIOUS.equals(getNewVersion())) {
r2 = m_wikiContext.getPage().getVersion() - 1;
r2 = Math.max(r2, 1);
} else if (VER_CURRENT.equals(getNewVersion())) {
r2 = m_wikiContext.getPage().getVersion();
} else {
r2 = Integer.parseInt(getNewVersion());
}
final String url = m_wikiContext.getURL(ContextEnum.PAGE_DIFF.getRequestContext(), pageName, "r1=" + r1 + "&r2=" + r2);
switch(m_format) {
case ANCHOR:
out.print("<a href=\"" + url + "\">");
break;
case URL:
out.print(url);
break;
}
return EVAL_BODY_INCLUDE;
}
use of javax.servlet.jsp.JspWriter in project jspwiki by apache.
the class InsertDiffTag method doWikiStartTag.
/**
* {@inheritDoc}
*/
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
final Context ctx;
if (m_pageName == null) {
ctx = m_wikiContext;
} else {
ctx = m_wikiContext.clone();
ctx.setPage(engine.getManager(PageManager.class).getPage(m_pageName));
}
final Integer vernew = (Integer) pageContext.getAttribute(ATTR_NEWVERSION, PageContext.REQUEST_SCOPE);
final Integer verold = (Integer) pageContext.getAttribute(ATTR_OLDVERSION, PageContext.REQUEST_SCOPE);
log.debug("Request diff between version " + verold + " and " + vernew);
if (ctx.getPage() != null) {
final JspWriter out = pageContext.getOut();
final String diff = engine.getManager(DifferenceManager.class).getDiff(ctx, vernew.intValue(), verold.intValue());
if (diff.isEmpty()) {
return EVAL_BODY_INCLUDE;
}
out.write(diff);
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspWriter in project jspwiki by apache.
the class PageInfoLinkTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
String pageName = m_pageName;
if (m_pageName == null) {
final Page p = m_wikiContext.getPage();
if (p != null) {
pageName = p.getName();
} else {
return SKIP_BODY;
}
}
if (engine.getManager(PageManager.class).wikiPageExists(pageName)) {
final JspWriter out = pageContext.getOut();
final String url = m_wikiContext.getURL(ContextEnum.PAGE_INFO.getRequestContext(), pageName);
switch(m_format) {
case ANCHOR:
out.print("<a class=\"pageinfo\" href=\"" + url + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(url);
break;
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspWriter in project jspwiki by apache.
the class EditLinkTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
Page page = null;
String versionString = "";
final String pageName;
// Determine the page and the link.
if (m_pageName == null) {
page = m_wikiContext.getPage();
if (page == null) {
// You can't call this on the page itself anyways.
return SKIP_BODY;
}
pageName = page.getName();
} else {
pageName = m_pageName;
}
//
if (m_version != null) {
if ("this".equalsIgnoreCase(m_version)) {
if (page == null) {
// No page, so go fetch according to page name.
page = engine.getManager(PageManager.class).getPage(m_pageName);
}
if (page != null) {
versionString = "version=" + page.getVersion();
}
} else {
versionString = "version=" + m_version;
}
}
//
// Finally, print out the correct link, according to what user commanded.
//
final JspWriter out = pageContext.getOut();
switch(m_format) {
case ANCHOR:
out.print("<a href=\"" + m_wikiContext.getURL(ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString) + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(m_wikiContext.getURL(ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString));
break;
}
return EVAL_BODY_INCLUDE;
}
use of javax.servlet.jsp.JspWriter in project jspwiki by apache.
the class InsertPageTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException, ProviderException {
final Engine engine = m_wikiContext.getEngine();
final Page insertedPage;
if (m_pageName == null) {
insertedPage = m_wikiContext.getPage();
if (!engine.getManager(PageManager.class).wikiPageExists(insertedPage))
return SKIP_BODY;
} else {
insertedPage = engine.getManager(PageManager.class).getPage(m_pageName);
}
if (insertedPage != null) {
// FIXME: Do version setting later.
// page.setVersion( WikiProvider.LATEST_VERSION );
log.debug("Inserting page " + insertedPage);
final JspWriter out = pageContext.getOut();
final Page oldPage = m_wikiContext.setRealPage(insertedPage);
switch(m_mode) {
case HTML:
out.print(engine.getManager(RenderingManager.class).getHTML(m_wikiContext, insertedPage));
break;
case PLAIN:
out.print(engine.getManager(PageManager.class).getText(insertedPage));
break;
}
m_wikiContext.setRealPage(oldPage);
}
return SKIP_BODY;
}
Aggregations