Ejemplo n.º 1
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n\n\n\n\n\n\n\n\n\n\n\n\n");

      // Get handle on the Monitoring plugin
      MonitoringPlugin plugin =
          (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("monitoring");
      ConversationManager conversationManager =
          (ConversationManager) plugin.getModule(ConversationManager.class);

      XMPPServer server = XMPPServer.getInstance();
      UserManager userManager = UserManager.getInstance();

      out.write(
          "\n\n<html>\n    <head>\n        <title>Conversations</title>\n        <meta name=\"pageID\" content=\"active-conversations\"/>\n        <script src=\"/js/prototype.js\" type=\"text/javascript\"></script>\n        <script src=\"/js/scriptaculous.js\" type=\"text/javascript\"></script>\n        <script src=\"/plugins/monitoring/dwr/engine.js\" type=\"text/javascript\" ></script>\n        <script src=\"/plugins/monitoring/dwr/util.js\" type=\"text/javascript\" ></script>\n        <script src=\"/plugins/monitoring/dwr/interface/conversations.js\" type=\"text/javascript\"></script>\n    </head>\n    <body>\n\n<style type=\"text/css\">\n\t@import \"style/style.css\";\n</style>\n<script type=\"text/javascript\">\nDWREngine.setErrorHandler(handleError);\nwindow.onerror = handleError;\nfunction handleError() {\n    // swallow errors: probably caused by the server being down\n}\n\nvar peConversations = new PeriodicalExecuter(conversationUpdater, 10);\n\nfunction conversationUpdater() {\n    try {\n        conversations.getConversations(updateConversations, true);\n    } catch(err) {\n");
      out.write(
          "        // swallow errors\n    }\n}\n\nfunction updateConversations(data) {\n    conversationsTable = $('conversations');\n    rows = conversationsTable.getElementsByTagName(\"tr\");\n    // loop over existing rows in the table\n    var rowsToDelete = new Array();\n    for (i = 0; i < rows.length; i++) {\n        // is this a conversation row?\n        if (rows[i].id == 'noconversations') {\n            rowsToDelete.push(i);\n        } else if (rows[i].id != '') {\n            // does the conversation exist in update we received?\n            convID = rows[i].id.replace('conversation-', '');\n            if (data[convID] != undefined) {\n\n                row = rows[i];\n                cells = row.getElementsByTagName('td');\n                conversation = data[convID];\n                if (cells[3].innerHTML != conversation.messageCount) {\n                    users = conversation.participant1 + '<br />' + conversation.participant2;\n                    cells[0].innerHTML = users;\n                    cells[1].innerHTML = conversation.duration;\n");
      out.write(
          "                    cells[2].innerHTML = conversation.lastActivity;\n                    cells[3].innerHTML = conversation.messageCount;\n                    new Effect.Highlight(row, {duration: 3.0});\n                }\n            // doesn't exist in update, delete from table\n            } else {\n                rowsToDelete.push(i);\n            }\n        }\n    }\n\n    for (i=0; i<rowsToDelete.length; i++) {\n        conversationsTable.deleteRow(rowsToDelete[i]);\n    }\n\n\n    // then add any new conversations from the update\n    counter = 0;\n    for (var c in data) {\n        counter++;\n        // does this conversation already exist?\n        if ($('conversation-' + c) == undefined) {\n            conversation = data[c];\n            users = conversation.participant1 + '<br />' + conversation.participant2;\n            var newTR = document.createElement(\"tr\");\n            newTR.setAttribute('id', 'conversation-' + c)\n            conversationsTable.appendChild(newTR);\n            var TD = document.createElement(\"TD\");\n");
      out.write(
          "            TD.innerHTML = users;\n            newTR.appendChild(TD);\n\n            TD = document.createElement(\"TD\");\n            TD.innerHTML = conversation.duration;\n            newTR.appendChild(TD);\n\n            TD = document.createElement(\"TD\");\n            TD.innerHTML = conversation.lastActivity;\n            newTR.appendChild(TD);\n\n            TD = document.createElement(\"TD\");\n            TD.innerHTML = conversation.messageCount;\n            newTR.appendChild(TD);\n        }\n    }\n\n    // update activeConversations number\n    $('activeConversations').innerHTML = counter;\n}\n\n</script>\n\n<!-- <a href=\"#\" onclick=\"conversationUpdater(); return false;\">click me</a> -->\n<p>\n    ");
      if (_jspx_meth_fmt_message_0(_jspx_page_context)) return;
      out.write("\n    <span id=\"activeConversations\">");
      out.print(conversationManager.getConversationCount());
      out.write("</span\n</p>\n\n");

      Collection<Conversation> conversations = conversationManager.getConversations();

      out.write(
          "\n\n\n<div class=\"jive-table\">\n<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" id=\"conversations\">\n<thead>\n    <tr>\n        <th nowrap>");
      if (_jspx_meth_fmt_message_1(_jspx_page_context)) return;
      out.write("</th>\n        <th nowrap>");
      if (_jspx_meth_fmt_message_2(_jspx_page_context)) return;
      out.write("</th>\n        <th nowrap>");
      if (_jspx_meth_fmt_message_3(_jspx_page_context)) return;
      out.write("</th>\n        <th nowrap>");
      if (_jspx_meth_fmt_message_4(_jspx_page_context)) return;
      out.write("</th>\n    </tr>\n</thead>\n<tbody>\n    ");

      if (conversations.isEmpty()) {

        out.write(
            "\n        <tr id=\"noconversations\">\n            <td colspan=\"4\">\n                ");
        if (_jspx_meth_fmt_message_5(_jspx_page_context)) return;
        out.write("\n            </td>\n        </tr>\n\n    ");
      }
      out.write("\n    ");

      for (Conversation conversation : conversations) {
        Collection<JID> participants = conversation.getParticipants();

        out.write("\n    <tr id=\"conversation-");
        out.print(conversation.getConversationID());
        out.write("\">\n        <td>\n            ");
        if (conversation.getRoom() == null) {
          out.write("\n                ");
          for (JID jid : participants) {
            out.write("\n                    ");
            if (server.isLocal(jid) && userManager.isRegisteredUser(jid.getNode())) {
              out.write("\n                        <a href=\"/user-properties.jsp?username="******"');
              out.write('>');
              out.print(jid);
              out.write("</a><br />\n                    ");
            } else {
              out.write("\n                        ");
              out.print(jid.toBareJID());
              out.write("<br/>\n                    ");
            }
            out.write("\n                ");
          }
          out.write("\n            ");
        } else {
          out.write("\n                ");
          //  fmt:message
          org.apache.taglibs.standard.tag.rt.fmt.MessageTag _jspx_th_fmt_message_6 =
              (org.apache.taglibs.standard.tag.rt.fmt.MessageTag)
                  _jspx_tagPool_fmt_message_key.get(
                      org.apache.taglibs.standard.tag.rt.fmt.MessageTag.class);
          _jspx_th_fmt_message_6.setPageContext(_jspx_page_context);
          _jspx_th_fmt_message_6.setParent(null);
          _jspx_th_fmt_message_6.setKey("archive.group_conversation");
          int _jspx_eval_fmt_message_6 = _jspx_th_fmt_message_6.doStartTag();
          if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
            if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
              out = _jspx_page_context.pushBody();
              _jspx_th_fmt_message_6.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
              _jspx_th_fmt_message_6.doInitBody();
            }
            do {
              out.write("\n                    ");
              //  fmt:param
              org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_0 =
                  (org.apache.taglibs.standard.tag.rt.fmt.ParamTag)
                      _jspx_tagPool_fmt_param_value_nobody.get(
                          org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class);
              _jspx_th_fmt_param_0.setPageContext(_jspx_page_context);
              _jspx_th_fmt_param_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_6);
              _jspx_th_fmt_param_0.setValue(
                  "<a href='../../muc-room-occupants.jsp?roomJID="
                      + URLEncoder.encode(conversation.getRoom().toBareJID(), "UTF-8")
                      + "'>");
              int _jspx_eval_fmt_param_0 = _jspx_th_fmt_param_0.doStartTag();
              if (_jspx_th_fmt_param_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
                _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0);
                return;
              }
              _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0);
              out.write("\n                    ");
              //  fmt:param
              org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_1 =
                  (org.apache.taglibs.standard.tag.rt.fmt.ParamTag)
                      _jspx_tagPool_fmt_param_value_nobody.get(
                          org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class);
              _jspx_th_fmt_param_1.setPageContext(_jspx_page_context);
              _jspx_th_fmt_param_1.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_6);
              _jspx_th_fmt_param_1.setValue("</a>");
              int _jspx_eval_fmt_param_1 = _jspx_th_fmt_param_1.doStartTag();
              if (_jspx_th_fmt_param_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
                _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_1);
                return;
              }
              _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_1);
              out.write("\n                ");
              int evalDoAfterBody = _jspx_th_fmt_message_6.doAfterBody();
              if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break;
            } while (true);
            if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)
              out = _jspx_page_context.popBody();
          }
          if (_jspx_th_fmt_message_6.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_6);
            return;
          }
          _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_6);
          out.write("\n            ");
        }
        out.write("\n        </td>\n        ");

        long duration =
            conversation.getLastActivity().getTime() - conversation.getStartDate().getTime();

        out.write("\n        <td>");
        out.print(StringUtils.getTimeFromLong(duration));
        out.write("</td>\n        <td>");
        out.print(JiveGlobals.formatTime(conversation.getLastActivity()));
        out.write("</td>\n        <td>");
        out.print(conversation.getMessageCount());
        out.write("</td>\n    </tr>\n    ");
      }
      out.write("\n</tbody>\n</table>\n</div>\n\n</body>\n</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Ejemplo n.º 2
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext =
          _jspxFactory.getPageContext(this, request, response, "error.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n\n\n\n\n\n\n\n\n");
      out.write('\n');
      org.jivesoftware.util.WebManager webManager = null;
      synchronized (_jspx_page_context) {
        webManager =
            (org.jivesoftware.util.WebManager)
                _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE);
        if (webManager == null) {
          webManager = new org.jivesoftware.util.WebManager();
          _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\n');
      webManager.init(request, response, session, application, out);
      out.write('\n');
      out.write('\n');
      // Get paramters
      boolean doTest = request.getParameter("test") != null;
      boolean cancel = request.getParameter("cancel") != null;
      boolean sent = ParamUtils.getBooleanParameter(request, "sent");
      boolean success = ParamUtils.getBooleanParameter(request, "success");
      String from = ParamUtils.getParameter(request, "from");
      String to = ParamUtils.getParameter(request, "to");
      String subject = ParamUtils.getParameter(request, "subject");
      String body = ParamUtils.getParameter(request, "body");

      // Cancel if requested
      if (cancel) {
        response.sendRedirect("system-email.jsp");
        return;
      }

      // Variable to hold messaging exception, if one occurs
      Exception mex = null;

      // Validate input
      Map<String, String> errors = new HashMap<String, String>();
      if (doTest) {
        if (from == null) {
          errors.put("from", "");
        }
        if (to == null) {
          errors.put("to", "");
        }
        if (subject == null) {
          errors.put("subject", "");
        }
        if (body == null) {
          errors.put("body", "");
        }

        EmailService service = EmailService.getInstance();

        // Validate host - at a minimum, it needs to be set:
        String host = service.getHost();
        if (host == null) {
          errors.put("host", "");
        }

        // if no errors, continue
        if (errors.size() == 0) {
          // Create a message
          MimeMessage message = service.createMimeMessage();
          // Set the date of the message to be the current date
          SimpleDateFormat format =
              new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", java.util.Locale.US);
          format.setTimeZone(JiveGlobals.getTimeZone());
          message.setHeader("Date", format.format(new Date()));

          // Set to and from.
          message.setRecipient(Message.RecipientType.TO, new InternetAddress(to, null));
          message.setFrom(new InternetAddress(from, null));
          message.setSubject(subject);
          message.setText(body);
          // Send the message, wrap in a try/catch:
          try {
            service.sendMessagesImmediately(Collections.singletonList(message));
            // success, so indicate this:
            response.sendRedirect("system-emailtest.jsp?sent=true&success=true");
            return;
          } catch (MessagingException me) {
            me.printStackTrace();
            mex = me;
          }
        }
      }

      // Set var defaults
      Collection<JID> jids = webManager.getXMPPServer().getAdmins();
      User user = null;
      if (!jids.isEmpty()) {
        for (JID jid : jids) {
          if (webManager.getXMPPServer().isLocal(jid)) {
            user = webManager.getUserManager().getUser(jid.getNode());
            if (user.getEmail() != null) {
              break;
            }
          }
        }
      }
      if (from == null) {
        from = user.getEmail();
      }
      if (to == null) {
        to = user.getEmail();
      }
      if (subject == null) {
        subject = "Test email sent via Openfire";
      }
      if (body == null) {
        body = "This is a test message.";
      }

      out.write("\n\n<html>\n    <head>\n        <title>");
      if (_jspx_meth_fmt_message_0(_jspx_page_context)) return;
      out.write(
          "</title>\n        <meta name=\"pageID\" content=\"system-email\"/>\n    </head>\n    <body>\n\n<script language=\"JavaScript\" type=\"text/javascript\">\nvar clicked = false;\nfunction checkClick(el) {\n    if (!clicked) {\n        clicked = true;\n        return true;\n    }\n    return false;\n}\n</script>\n\n<p>\n");
      if (_jspx_meth_fmt_message_1(_jspx_page_context)) return;
      out.write("\n</p>\n\n");
      if (JiveGlobals.getProperty("mail.smtp.host") == null) {
        out.write(
            "\n\n    <div class=\"jive-error\">\n    <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n    <tbody>\n        <tr>\n        \t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n\t        <td class=\"jive-icon-label\">\n\t\t        ");
        if (_jspx_meth_fmt_message_2(_jspx_page_context)) return;
        out.write("\n\t        </td>\n        </tr>\n    </tbody>\n    </table>\n    </div>\n\n");
      }
      out.write('\n');
      out.write('\n');
      if (doTest || sent) {
        out.write("\n\n    ");
        if (success) {
          out.write(
              "\n\n        <div class=\"jive-success\">\n        <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n        <tbody>\n            <tr>\n            \t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n            \t<td class=\"jive-icon-label\">");
          if (_jspx_meth_fmt_message_3(_jspx_page_context)) return;
          out.write(
              "</td>\n            </tr>\n        </tbody>\n        </table>\n        </div>\n\n    ");
        } else {
          out.write(
              "\n\n        <div class=\"jive-error\">\n        <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n        <tbody>\n            <tr><td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n            <td class=\"jive-icon-label\">\n                ");
          if (_jspx_meth_fmt_message_4(_jspx_page_context)) return;
          out.write("\n                ");
          if (mex != null) {
            out.write("\n                    ");
            if (mex instanceof AuthenticationFailedException) {
              out.write("\n                    \t");
              if (_jspx_meth_fmt_message_5(_jspx_page_context)) return;
              out.write("                        \n                    ");
            } else {
              out.write("\n                        (Message: ");
              out.print(mex.getMessage());
              out.write(")\n                    ");
            }
            out.write("\n                ");
          }
          out.write(
              "\n            </td></tr>\n        </tbody>\n        </table>\n        </div>\n\n    ");
        }
        out.write("\n\n    <br>\n\n");
      }
      out.write(
          "\n\n<form action=\"system-emailtest.jsp\" method=\"post\" name=\"f\" onsubmit=\"return checkClick(this);\">\n\n<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n<tbody>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_6(_jspx_page_context)) return;
      out.write(":\n        </td>\n        <td>\n            ");
      String host = JiveGlobals.getProperty("mail.smtp.host");
      if (host == null) {

        out.write("\n                <i>");
        if (_jspx_meth_fmt_message_7(_jspx_page_context)) return;
        out.write("</i>\n            ");

      } else {

        out.write("\n                ");
        out.print(host);
        out.write(':');
        out.print(JiveGlobals.getIntProperty("mail.smtp.port", 25));
        out.write("\n\n                ");
        if (JiveGlobals.getBooleanProperty("mail.smtp.ssl", false)) {
          out.write("\n\n                    (");
          if (_jspx_meth_fmt_message_8(_jspx_page_context)) return;
          out.write(")\n\n                ");
        }
        out.write("\n            ");
      }
      out.write("\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_9(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"hidden\" name=\"from\" value=\"");
      out.print(from);
      out.write("\">\n            ");
      out.print(StringUtils.escapeHTMLTags(from));
      out.write(
          "\n            <span class=\"jive-description\">\n            (<a href=\"user-edit-form.jsp?username="******"\">Update Address</a>)\n            </span>\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_10(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"text\" name=\"to\" value=\"");
      out.print(((to != null) ? to : ""));
      out.write(
          "\"\n             size=\"40\" maxlength=\"100\">\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_11(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"text\" name=\"subject\" value=\"");
      out.print(((subject != null) ? subject : ""));
      out.write(
          "\"\n             size=\"40\" maxlength=\"100\">\n        </td>\n    </tr>\n    <tr valign=\"top\">\n        <td>\n            ");
      if (_jspx_meth_fmt_message_12(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <textarea name=\"body\" cols=\"45\" rows=\"5\" wrap=\"virtual\">");
      out.print(body);
      out.write(
          "</textarea>\n        </td>\n    </tr>\n    <tr>\n        <td colspan=\"2\">\n            <br>\n            <input type=\"submit\" name=\"test\" value=\"");
      if (_jspx_meth_fmt_message_13(_jspx_page_context)) return;
      out.write("\">\n            <input type=\"submit\" name=\"cancel\" value=\"");
      if (_jspx_meth_fmt_message_14(_jspx_page_context)) return;
      out.write(
          "\">\n        </td>\n    </tr>\n</tbody>\n</table>\n\n</form>\n\n    </body>\n</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }