Search in sources :

Example 71 with JspWriter

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;
}
Also used : PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 72 with JspWriter

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;
}
Also used : Context(org.apache.wiki.api.core.Context) PageContext(javax.servlet.jsp.PageContext) DifferenceManager(org.apache.wiki.diff.DifferenceManager) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 73 with JspWriter

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;
}
Also used : PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 74 with JspWriter

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;
}
Also used : Page(org.apache.wiki.api.core.Page) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 75 with JspWriter

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;
}
Also used : Page(org.apache.wiki.api.core.Page) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Aggregations

JspWriter (javax.servlet.jsp.JspWriter)145 IOException (java.io.IOException)72 JspException (javax.servlet.jsp.JspException)68 HttpServletRequest (javax.servlet.http.HttpServletRequest)17 JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)14 PageContext (javax.servlet.jsp.PageContext)13 Iterator (java.util.Iterator)9 Engine (org.apache.wiki.api.core.Engine)9 JspContext (javax.servlet.jsp.JspContext)8 JspTagException (javax.servlet.jsp.JspTagException)8 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)7 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)6 HttpSession (javax.servlet.http.HttpSession)5 BodyContent (javax.servlet.jsp.tagext.BodyContent)5 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 Page (org.apache.wiki.api.core.Page)5 HtmlCode (org.compiere.util.HtmlCode)5 MissingParametersRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)5 IPropertyRuleIntrospector (org.jaffa.rules.IPropertyRuleIntrospector)5