Esempio n. 1
0
 public final int doWikiStartTag() throws IOException {
   WikiSession session = m_wikiContext.getWikiSession();
   if (CLEAR.equals(m_action)) {
     if (m_topic == null) {
       session.clearMessages();
     } else {
       session.clearMessages(m_topic);
     }
   } else {
     String[] messages = (m_topic == null) ? session.getMessages() : session.getMessages(m_topic);
     if (messages.length > 0) {
       StringBuffer sb = new StringBuffer();
       if (messages.length == 1) {
         sb.append(
             "<div class=\""
                 + m_div
                 + "\">"
                 + m_prefix
                 + TextUtil.replaceEntities(messages[0])
                 + "</div>");
       } else {
         sb.append("<div class=\"" + m_div + "\">" + m_prefix);
         sb.append("<ul>");
         for (int i = 0; i < messages.length; i++) {
           sb.append("<li>" + TextUtil.replaceEntities(messages[i]) + "</li>");
         }
         sb.append("</ul></div>");
       }
       pageContext.getOut().println(sb.toString());
     }
   }
   return SKIP_BODY;
 }
Esempio n. 2
0
  /**
   * Returns a {@link WikiContext} for the given page, with user {@link Users#JANNE} logged in.
   *
   * @param page given {@link WikiPage}.
   * @return {@link WikiContext} associated to given {@link WikiPage}.
   * @throws WikiException problems while logging in.
   */
  WikiContext getJanneBasedWikiContextFor(WikiPage page) throws WikiException {
    MockHttpServletRequest request = testEngine.newHttpRequest();
    WikiSession session = WikiSession.getWikiSession(testEngine, request);
    testEngine.getAuthenticationManager().login(session, request, Users.JANNE, Users.JANNE_PASS);

    return new WikiContext(testEngine, request, page);
  }