Source Code Cross Referenced for RecentChangesPlugin.java in  » Portal » Open-Portal » com » ecyrd » jspwiki » plugin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.ecyrd.jspwiki.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:            JSPWiki - a JSP-based WikiWiki clone.
003:
004:            Copyright (C) 2001 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006:            This program is free software; you can redistribute it and/or modify
007:            it under the terms of the GNU Lesser General Public License as published by
008:            the Free Software Foundation; either version 2.1 of the License, or
009:            (at your option) any later version.
010:
011:            This program is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:            GNU Lesser General Public License for more details.
015:
016:            You should have received a copy of the GNU Lesser General Public License
017:            along with this program; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package com.ecyrd.jspwiki.plugin;
021:
022:        import org.apache.log4j.Logger;
023:        import com.ecyrd.jspwiki.*;
024:        import com.ecyrd.jspwiki.attachment.Attachment;
025:        import java.util.*;
026:        import java.io.StringWriter;
027:        import java.text.SimpleDateFormat;
028:
029:        /**
030:         *  Returns the Recent Changes.
031:         *
032:         *  Parameters: since=number of days,
033:         *              format=(compact|full)
034:         *
035:         *  @author Janne Jalkanen
036:         */
037:        public class RecentChangesPlugin implements  WikiPlugin {
038:            /** How many days we show by default. */
039:            private static final int DEFAULT_DAYS = 100 * 365;
040:
041:            private static Logger log = Logger
042:                    .getLogger(RecentChangesPlugin.class);
043:
044:            private boolean isSameDay(Date a, Date b) {
045:                Calendar aa = Calendar.getInstance();
046:                aa.setTime(a);
047:                Calendar bb = Calendar.getInstance();
048:                bb.setTime(b);
049:
050:                return (aa.get(Calendar.YEAR) == bb.get(Calendar.YEAR) && aa
051:                        .get(Calendar.DAY_OF_YEAR) == bb
052:                        .get(Calendar.DAY_OF_YEAR));
053:            }
054:
055:            public String execute(WikiContext context, Map params)
056:                    throws PluginException {
057:                int since = TextUtil.parseIntParameter((String) params
058:                        .get("since"), DEFAULT_DAYS);
059:                int spacing = 4;
060:                boolean showAuthor = true;
061:                WikiEngine engine = context.getEngine();
062:
063:                //
064:                //  Which format we want to see?
065:                //
066:                String format = (String) params.get("format");
067:                if ("compact".equals(params.get("format"))) {
068:                    spacing = 0;
069:                    showAuthor = false;
070:                }
071:
072:                Calendar sincedate = new GregorianCalendar();
073:                sincedate.add(Calendar.DAY_OF_MONTH, -since);
074:
075:                log.debug("Calculating recent changes from "
076:                        + sincedate.getTime());
077:
078:                // FIXME: Should really have a since date on the getRecentChanges
079:                // method.
080:                Collection changes = engine.getRecentChanges();
081:                StringWriter out = new StringWriter();
082:
083:                //
084:                //  This linkProcessor is used to transform links.
085:                //
086:                TranslatorReader linkProcessor = new TranslatorReader(context,
087:                        new java.io.StringReader(""));
088:
089:                if (changes != null) {
090:                    Date olddate = new Date(0);
091:
092:                    SimpleDateFormat fmt = new SimpleDateFormat("dd.MM.yyyy");
093:                    SimpleDateFormat tfmt = new SimpleDateFormat("HH:mm:ss");
094:
095:                    out.write("<table border=\"0\" cellpadding=\"" + spacing
096:                            + "\">\n");
097:
098:                    for (Iterator i = changes.iterator(); i.hasNext();) {
099:                        WikiPage pageref = (WikiPage) i.next();
100:
101:                        Date lastmod = pageref.getLastModified();
102:
103:                        if (lastmod.before(sincedate.getTime())) {
104:                            break;
105:                        }
106:
107:                        if (!isSameDay(lastmod, olddate)) {
108:                            out.write("<tr>\n");
109:                            out.write("  <td colspan=\"2\"><b>"
110:                                    + fmt.format(lastmod) + "</b></td>\n");
111:                            out.write("</tr>\n");
112:                            olddate = lastmod;
113:                        }
114:
115:                        String link = linkProcessor
116:                                .makeLink(
117:                                        (pageref instanceof  Attachment) ? TranslatorReader.ATTACHMENT
118:                                                : TranslatorReader.READ,
119:                                        pageref.getName(), engine
120:                                                .beautifyTitle(pageref
121:                                                        .getName()));
122:
123:                        out.write("<tr>\n");
124:
125:                        out.write("<td width=\"30%\">" + link + "</td>\n");
126:
127:                        if (pageref instanceof  Attachment) {
128:                            out.write("<td>" + tfmt.format(lastmod) + "</td>");
129:                        } else {
130:                            out.write("<td><a href=\""
131:                                    + context.getURL(WikiContext.DIFF, pageref
132:                                            .getName(), "r1=-1") + "\">"
133:                                    + tfmt.format(lastmod) + "</a></td>\n");
134:                        }
135:
136:                        //
137:                        //  Display author information.
138:                        //
139:
140:                        if (showAuthor) {
141:                            String author = pageref.getAuthor();
142:                            String displayAuthor = author;
143:
144:                            if (author != null) {
145:                                displayAuthor = context
146:                                        .getUserCommonName(author);
147:                                if (engine.pageExists(author)) {
148:                                    displayAuthor = linkProcessor.makeLink(
149:                                            TranslatorReader.READ, author,
150:                                            author);
151:                                }
152:                            } else {
153:                                displayAuthor = "unknown";
154:                            }
155:
156:                            out.write("<td>" + displayAuthor + "</td>");
157:                        }
158:
159:                        out.write("</tr>\n");
160:                    }
161:
162:                    out.write("</table>\n");
163:                }
164:
165:                return out.toString();
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.