Source Code Cross Referenced for BlogAdminModule.java in  » Content-Management-System » openedit » org » openedit » blog » modules » 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 » Content Management System » openedit » org.openedit.blog.modules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Jan 13, 2006
003:         */
004:        package org.openedit.blog.modules;
005:
006:        import java.io.IOException;
007:        import java.io.StringWriter;
008:
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:
012:        import com.openedit.BaseWebPageRequest;
013:        import com.openedit.OpenEditException;
014:        import com.openedit.WebPageRequest;
015:        import com.openedit.WebServer;
016:        import com.openedit.blog.BlogEntry;
017:        import com.openedit.blog.Notify;
018:        import com.openedit.modules.BaseModule;
019:        import com.openedit.modules.email.PostMail;
020:        import com.openedit.modules.email.TemplateWebEmail;
021:        import com.openedit.modules.html.Tidy;
022:        import com.openedit.page.Page;
023:        import com.openedit.page.PageRequestKeys;
024:        import com.openedit.page.PageStreamer;
025:        import com.openedit.util.URLUtilities;
026:
027:        public class BlogAdminModule extends BaseModule {
028:            private static final Log log = LogFactory
029:                    .getLog(BlogAdminModule.class);
030:            private PostMail postMail;
031:
032:            public void cancelNotification(WebPageRequest inReq) {
033:                Notify notify = getNotify(inReq);
034:                notify.cancel();
035:                inReq.removeSessionValue("notify");
036:                log.info("Canceled job");
037:            }
038:
039:            public Notify getNotify(WebPageRequest inReq) {
040:                Notify notify = (Notify) inReq.getSessionValue("notify");
041:                if (notify == null) {
042:                    notify = new Notify();
043:                    notify.setUserManager(getUserManager());
044:                    notify.setRootDirectory(getRoot());
045:                    notify.setPageManager(getPageManager());
046:                    inReq.putSessionValue("notify", notify);
047:                }
048:                return notify;
049:            }
050:
051:            public void sendNotification(WebPageRequest inReq)
052:                    throws OpenEditException, IOException {
053:                Notify notify = getNotify(inReq);
054:                if (notify.isKeepRunning()) {
055:                    //already running
056:                    return;
057:                }
058:
059:                String[] groupnames = inReq.getRequestParameters("groupnames");
060:                if (groupnames != null && groupnames.length > 0) {
061:                    notify.setGroupNames(groupnames);
062:
063:                    TemplateWebEmail mailer = postMail.getTemplateWebEmail();
064:                    mailer.setPageManager(getPageManager());
065:
066:                    String from = inReq.getRequestParameter("author");
067:                    String server = inReq.getRequestParameter("server");
068:                    String subject = inReq.getRequestParameter("title");
069:                    //String path = inReq.getRequestParameter("editPath");
070:                    BlogModule module = (BlogModule) getModule("BlogModule");
071:                    BlogEntry entry = module.getEntry(inReq);
072:                    mailer.setFrom(from);
073:                    mailer.setSubject(subject);
074:                    mailer.setMailTemplatePath(entry.getPath());
075:                    Page content = getPageManager().getPage(entry.getPath());
076:
077:                    String uselayout = cleanLink(inReq
078:                            .getRequestParameter("uselayout"), inReq);
079:                    if (uselayout != null) {
080:                        String results = renderUserLayout(inReq, content,
081:                                uselayout);
082:                        mailer.setMessage(results);
083:
084:                        String addplaintext = inReq
085:                                .getRequestParameter("addplaintext");
086:                        if (addplaintext != null
087:                                && addplaintext.equalsIgnoreCase("true")) {
088:                            String alternative = content.getContent();
089:                            alternative = new Tidy().removeHtml(alternative);
090:                            mailer.setAlternativeMessage(alternative);
091:                        }
092:                    } else {
093:                        mailer.setMailTemplatePage(content);
094:                    }
095:
096:                    //mailer.setMailTemplatePage(template);	
097:                    notify.sendEmail(mailer, inReq.getWriter());
098:                } else {
099:                    inReq.getWriter().write("Error: No groups selected");
100:                }
101:            }
102:
103:            private String cleanLink(String inRequestParameter,
104:                    WebPageRequest inReq) {
105:                if (inRequestParameter != null) {
106:                    String home = (String) inReq.getPageValue("home");
107:                    if (home != null && home.length() > 0) {
108:                        inRequestParameter = inRequestParameter.substring(home
109:                                .length(), inRequestParameter.length());
110:                    }
111:                }
112:                return inRequestParameter;
113:            }
114:
115:            public void renderPreview(WebPageRequest inReq)
116:                    throws OpenEditException {
117:                String uselayout = cleanLink(inReq
118:                        .getRequestParameter("uselayout"), inReq);
119:                BlogModule module = (BlogModule) getModule("BlogModule");
120:                BlogEntry entry = module.getEntry(inReq);
121:
122:                Page content = getPageManager().getPage(entry.getPath());
123:                String preview = null;
124:
125:                if (uselayout != null) {
126:                    preview = renderUserLayout(inReq, content, uselayout);
127:                } else {
128:                    preview = content.getContent(); //TODO: Use a notify render for a true preview
129:                }
130:                inReq.putPageValue("preview", preview);
131:            }
132:
133:            protected String renderUserLayout(WebPageRequest inReq,
134:                    Page content, String uselayout) throws OpenEditException {
135:                WebServer webserver = (WebServer) getBeanFactory().getBean(
136:                        "WebServer");
137:                BaseWebPageRequest req = (BaseWebPageRequest) inReq
138:                        .copy(content);
139:                req.putPageValue(PageRequestKeys.LAYOUTOVERRIDE, uselayout);
140:                req.putPageValue(PageRequestKeys.INNERLAYOUTOVERRIDE,
141:                        Page.BLANK_LAYOUT); //TODO: Find nicer way
142:                req.putPageValue(PageRequestKeys.CONTENT, content);
143:                req.putProtectedPageValue(PageRequestKeys.PAGE, content);
144:                req.setEditable(false);
145:                req.putPageValue(PageRequestKeys.OUTPUT_WRITER,
146:                        new StringWriter());
147:                PageStreamer stream = webserver.getOpenEditEngine()
148:                        .createPageStreamer(content, req);
149:                stream.render();
150:                String fcontent = req.getWriter().toString();
151:                return fcontent;
152:            }
153:
154:            public void fixLinks(WebPageRequest inReq) throws OpenEditException {
155:                URLUtilities utils = (URLUtilities) inReq
156:                        .getPageValue(PageRequestKeys.URL_UTILITIES);
157:                if (utils != null) {
158:                    String base = utils.siteRoot() + utils.relativeHomePrefix();
159:                    Notify notify = getNotify(inReq);
160:                    String path = inReq.getRequestParameter("editPath");
161:                    Page template = getPageManager().getPage(path);
162:                    notify.fixLinks(template, base);
163:                    inReq.putPageValue("message", "Links have been set to "
164:                            + base);
165:                }
166:
167:            }
168:
169:            public PostMail getPostMail() {
170:                return postMail;
171:            }
172:
173:            public void setPostMail(PostMail postMail) {
174:                this.postMail = postMail;
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.