01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2003 Janne Jalkanen (Janne.Jalkanen@iki.fi)
05:
06: This program is free software; you can redistribute it and/or modify
07: it under the terms of the GNU Lesser General Public License as published by
08: the Free Software Foundation; either version 2.1 of the License, or
09: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package com.ecyrd.jspwiki.plugin;
21:
22: import com.ecyrd.jspwiki.*;
23: import java.util.*;
24:
25: /**
26: * This is a plugin for the administrator: It allows him to see in a single
27: * glance who is editing what.
28: *
29: * @author Janne Jalkanen
30: * @since 2.0.22.
31: */
32: public class ListLocksPlugin implements WikiPlugin {
33: public String execute(WikiContext context, Map params)
34: throws PluginException {
35: StringBuffer result = new StringBuffer();
36:
37: PageManager mgr = context.getEngine().getPageManager();
38: List locks = mgr.getActiveLocks();
39:
40: result.append("<table class=\"wikitable\">\n");
41: result.append("<tr>\n");
42: result
43: .append("<th>Page</th><th>Locked by</th><th>Acquired</th><th>Expires</th>\n");
44: result.append("</tr>");
45:
46: if (locks.size() == 0) {
47: result
48: .append("<tr><td colspan=\"4\" class=\"odd\">No locks exist currently.</td></tr>\n");
49: } else {
50: int rowNum = 1;
51: for (Iterator i = locks.iterator(); i.hasNext();) {
52: PageLock lock = (PageLock) i.next();
53:
54: result.append(rowNum % 2 != 0 ? "<tr class=\"odd\">"
55: : "<tr>");
56: result.append("<td>" + lock.getPage() + "</td>");
57: result.append("<td>" + lock.getLocker() + "</td>");
58: result.append("<td>" + lock.getAcquisitionTime()
59: + "</td>");
60: result.append("<td>" + lock.getExpiryTime() + "</td>");
61: result.append("</tr>\n");
62: rowNum++;
63: }
64: }
65:
66: result.append("</table>");
67:
68: return result.toString();
69: }
70:
71: }
|