Search in sources :

Example 51 with Session

use of org.apache.wiki.api.core.Session in project jspwiki by apache.

the class MessagesTag method doWikiStartTag.

@Override
public final int doWikiStartTag() throws IOException {
    final Session session = m_wikiContext.getWikiSession();
    if (CLEAR.equals(m_action)) {
        if (m_topic == null) {
            session.clearMessages();
        } else {
            session.clearMessages(m_topic);
        }
    } else {
        final String[] messages = (m_topic == null) ? session.getMessages() : session.getMessages(m_topic);
        if (messages.length > 0) {
            final StringBuilder sb = new StringBuilder();
            if (messages.length == 1) {
                sb.append("<div class=\"").append(m_div).append("\">").append(m_prefix).append(TextUtil.replaceEntities(messages[0])).append("</div>");
            } else {
                sb.append("<div class=\"").append(m_div).append("\">").append(m_prefix);
                sb.append("<ul>");
                for (final String message : messages) {
                    sb.append("<li>").append(TextUtil.replaceEntities(message)).append("</li>");
                }
                sb.append("</ul></div>");
            }
            pageContext.getOut().println(sb.toString());
        }
    }
    return SKIP_BODY;
}
Also used : Session(org.apache.wiki.api.core.Session)

Aggregations

Session (org.apache.wiki.api.core.Session)51 Test (org.junit.jupiter.api.Test)25 WikiSessionTest (org.apache.wiki.WikiSessionTest)19 Principal (java.security.Principal)18 MockHttpServletRequest (net.sourceforge.stripes.mock.MockHttpServletRequest)11 AllPermission (org.apache.wiki.auth.permissions.AllPermission)9 PageManager (org.apache.wiki.pages.PageManager)9 HttpSession (javax.servlet.http.HttpSession)8 Group (org.apache.wiki.auth.authorize.Group)8 PagePermission (org.apache.wiki.auth.permissions.PagePermission)8 Permission (java.security.Permission)7 Page (org.apache.wiki.api.core.Page)7 AuthenticationManager (org.apache.wiki.auth.AuthenticationManager)7 WikiPermission (org.apache.wiki.auth.permissions.WikiPermission)7 UnresolvedPrincipal (org.apache.wiki.auth.acl.UnresolvedPrincipal)6 UserProfile (org.apache.wiki.auth.user.UserProfile)6 GroupPrincipal (org.apache.wiki.auth.GroupPrincipal)5 WikiPrincipal (org.apache.wiki.auth.WikiPrincipal)5 Role (org.apache.wiki.auth.authorize.Role)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4