📄 archive-search.jsp
字号:
<%@ page errorPage="/error.jsp" import="org.jivesoftware.openfire.plugin.MonitoringPlugin"%>
<%@ page import="org.jivesoftware.openfire.archive.ArchiveSearch" %>
<%@ page import="org.jivesoftware.openfire.archive.ArchiveSearcher" %>
<%@ page import="org.jivesoftware.openfire.archive.Conversation" %>
<%@ page import="org.jivesoftware.openfire.archive.ConversationManager" %>
<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
<%@ page import="org.jivesoftware.openfire.user.UserManager" %>
<%@ page import="org.jivesoftware.openfire.user.UserNameManager" %>
<%@ page import="org.jivesoftware.openfire.user.UserNotFoundException" %>
<%@ page import="org.jivesoftware.util.*" %>
<%@ page import="org.xmpp.packet.JID" %>
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
// Get handle on the Monitoring plugin
MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(
"monitoring");
ArchiveSearcher archiveSearcher = (ArchiveSearcher) plugin.getModule(
ArchiveSearcher.class);
ConversationManager conversationManager = (ConversationManager) plugin.getModule(
ConversationManager.class);
boolean submit = request.getParameter("submitForm") != null;
if (!submit) {
submit = request.getParameter("parseRange") != null;
}
String query = request.getParameter("keywords");
Collection<Conversation> conversations = null;
String participant1 = request.getParameter("participant1");
String participant2 = request.getParameter("participant2");
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String anyText = LocaleUtils.getLocalizedString("archive.settings.any", "monitoring");
int start = 0;
int range = 15;
int numPages = 1;
int curPage = (start / range) + 1;
if (anyText.equals(participant1)) {
participant1 = null;
}
if (anyText.equals(participant2)) {
participant2 = null;
}
if (anyText.equals(startDate)) {
startDate = null;
}
if (anyText.equals(endDate)) {
endDate = null;
}
if (submit) {
UserManager userManager = UserManager.getInstance();
ArchiveSearch search = new ArchiveSearch();
JID participant1JID = null;
JID participant2JID = null;
String serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
if (participant1 != null && participant1.length() > 0) {
int position = participant1.lastIndexOf("@");
if (position > -1) {
String node = participant1.substring(0, position);
participant1JID = new JID(JID.escapeNode(node) + participant1.substring(position));
} else {
participant1JID = new JID(JID.escapeNode(participant1), serverName, null);
}
}
if (participant2 != null && participant2.length() > 0) {
int position = participant2.lastIndexOf("@");
if (position > -1) {
String node = participant2.substring(0, position);
participant2JID = new JID(JID.escapeNode(node) + participant2.substring(position));
} else {
participant2JID = new JID(JID.escapeNode(participant2), serverName, null);
}
}
if (startDate != null && startDate.length() > 0) {
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
try {
Date date = formatter.parse(startDate);
search.setDateRangeMin(date);
}
catch (Exception e) {
// TODO: mark as an error in the JSP instead of logging..
Log.error(e);
}
}
if (endDate != null && endDate.length() > 0) {
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
try {
Date date = formatter.parse(endDate);
// The user has chosen an end date and expects that any conversation
// that falls on that day will be included in the search results. For
// example, say the user choose 6/17/2006 as an end date. If a conversation
// occurs at 5:33 PM that day, it should be included in the results. In
// order to make this possible, we need to make the end date one millisecond
// before the next day starts.
date = new Date(date.getTime() + JiveConstants.DAY - 1);
search.setDateRangeMax(date);
}
catch (Exception e) {
// TODO: mark as an error in the JSP instead of logging..
Log.error(e);
}
}
if (query != null && query.length() > 0) {
search.setQueryString(query);
}
if (participant1JID != null && participant2JID != null) {
search.setParticipants(participant1JID, participant2JID);
} else if (participant1JID != null) {
search.setParticipants(participant1JID);
} else if (participant2JID != null) {
search.setParticipants(participant2JID);
}
start = ParamUtils.getIntParameter(request, "start", 0);
range = 15;
conversations = archiveSearcher.search(search);
numPages = (int) Math.ceil((double) conversations.size() / (double) range);
curPage = (start / range) + 1;
}
boolean isArchiveEnabled = conversationManager.isArchivingEnabled();
%>
<html>
<head>
<title><fmt:message key="archive.search.title" /></title>
<meta name="pageID" content="archive-search"/>
<script src="/js/prototype.js" type="text/javascript"></script>
<script src="/js/scriptaculous.js" type="text/javascript"></script>
<script src="dwr/engine.js" type="text/javascript"></script>
<script src="dwr/util.js" type="text/javascript"></script>
<script src="dwr/interface/conversations.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="scripts/tooltips/domLib.js"></script>
<script type="text/javascript" language="javascript" src="scripts/tooltips/domTT.js"></script>
<style type="text/css">@import url( /js/jscalendar/calendar-win2k-cold-1.css );</style>
<script type="text/javascript" src="/js/jscalendar/calendar.js"></script>
<script type="text/javascript" src="/js/jscalendar/i18n.jsp"></script>
<script type="text/javascript" src="/js/jscalendar/calendar-setup.js"></script>
<script type="text/javascript">
function hover(oRow) {
oRow.style.background = "#A6CAF0";
oRow.style.cursor = "pointer";
}
function noHover(oRow) {
oRow.style.background = "white";
}
function viewConversation(conversationID) {
window.frames['view'].location.href = "conversation-viewer.jsp?conversationID=" + conversationID;
}
function submitFormAgain(start, range){
document.f.start.value = start;
document.f.range.value = range;
document.f.parseRange.value = "true";
document.f.submit();
}
</script>
<style type="text/css">
.small-label {
font-size: 11px;
font-weight: bold;
font-family: Verdana, Arial, sans-serif;
}
.small-label-no-bold {
font-size: 11px;
font-family: Verdana, Arial, sans-serif;
}
.small-label-with-padding {
font-size: 12px;
font-weight: bold;
font-family: Verdana, Arial, sans-serif;
}
.small-text {
font-size: 11px;
font-family: Verdana, Arial, sans-serif;
line-height: 11px;
}
.very-small-label {
font-size: 10px;
font-weight: bold;
font-family: Verdana, Arial, sans-serif;
padding-right:5px;
}
.stat {
margin: 0px 0px 8px 0px;
border: 1px solid #cccccc;
-moz-border-radius: 3px;
}
.stat td table {
margin: 5px 10px 5px 10px;
}
.stat div.verticalrule {
display: block;
width: 1px;
height: 110px;
background-color: #cccccc;
overflow: hidden;
margin-left: 3px;
margin-right: 3px;
}
.conversation-body {
color: black;
font-size: 11px;
font-family: Verdana, Arial, sans-serif;
}
.conversation-label1 {
color: blue;
font-size: 10px;
font-family: Verdana, Arial, sans-serif;
}
.conversation-label2 {
color: red;
font-size: 10px;
font-family: Verdana, Arial, sans-serif;
}
.conversation-label3 {
color: orchid;
font-size: 10px;
font-family: Verdana, Arial, sans-serif;
}
.conversation-label4 {
color: black;
font-size: 10px;
font-family: Verdana, Arial, sans-serif;
}
.conversation-table {
font-family: Verdana, Arial, sans-serif;
font-size: 11px;
}
.conversation-table td {
font-size: 11px;
padding: 5px 5px 5px 5px;
}
.light-gray-border {
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 1px;
}
.light-gray-border-bottom {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -