Source Code Cross Referenced for HtmlFragmentAction.java in  » Content-Management-System » TransferCM » com » methodhead » shim » 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 » TransferCM » com.methodhead.shim 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright (C) 2006 Methodhead Software LLC.  All rights reserved.
003:         * 
004:         * This file is part of TransferCM.
005:         * 
006:         * TransferCM is free software; you can redistribute it and/or modify it under the
007:         * terms of the GNU General Public License as published by the Free Software
008:         * Foundation; either version 2 of the License, or (at your option) any later
009:         * version.
010:         * 
011:         * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013:         * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
014:         * details.
015:         * 
016:         * You should have received a copy of the GNU General Public License along with
017:         * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018:         * Fifth Floor, Boston, MA  02110-1301  USA
019:         */
020:
021:        package com.methodhead.shim;
022:
023:        import org.apache.struts.action.Action;
024:        import org.apache.struts.action.ActionMapping;
025:        import org.apache.struts.action.ActionForm;
026:        import org.apache.struts.action.ActionForward;
027:        import org.apache.struts.action.DynaActionForm;
028:        import org.apache.struts.action.ActionMessages;
029:        import org.apache.struts.util.MessageResources;
030:        import org.apache.struts.Globals;
031:        import org.apache.struts.util.LabelValueBean;
032:        import com.methodhead.event.Event;
033:
034:        import javax.servlet.http.HttpServletRequest;
035:        import javax.servlet.http.HttpServletResponse;
036:        import com.methodhead.aikp.AutoIntKeyPersistable;
037:        import com.methodhead.aikp.AikpAction;
038:        import com.methodhead.aikp.IntKey;
039:        import com.methodhead.util.OperationContext;
040:        import com.methodhead.util.StrutsUtil;
041:        import com.methodhead.sitecontext.SiteContext;
042:        import java.util.List;
043:        import java.util.ArrayList;
044:        import java.util.Iterator;
045:        import org.apache.commons.lang.StringUtils;
046:
047:        public class HtmlFragmentAction extends AikpAction {
048:
049:            // constructors /////////////////////////////////////////////////////////////
050:
051:            // constants ////////////////////////////////////////////////////////////////
052:
053:            // classes //////////////////////////////////////////////////////////////////
054:
055:            // methods //////////////////////////////////////////////////////////////////
056:
057:            protected AutoIntKeyPersistable createPersistable(
058:                    OperationContext op) {
059:                HtmlFragment fragment = new HtmlFragment();
060:                fragment.setSiteContext(SiteContext.getContext(op.request));
061:                return fragment;
062:            }
063:
064:            protected void populateForm(DynaActionForm form,
065:                    AutoIntKeyPersistable persistable) {
066:
067:                populateFormProperty("name", form, persistable);
068:                populateFormProperty("value", form, persistable);
069:            }
070:
071:            protected void populatePersistable(
072:                    AutoIntKeyPersistable persistable, DynaActionForm form) {
073:
074:                populatePersistableField("name", persistable, form);
075:                populatePersistableField("value", persistable, form);
076:            }
077:
078:            /**
079:             * Loads all fragments for the site, creates a list of options for them, and
080:             * puts those options in <tt>form.list</tt>.
081:             */
082:            protected ActionForward doList(OperationContext op, Object policy) {
083:
084:                String msg = ((ShimPolicy) policy)
085:                        .isHtmlFragmentListAuthorized(op);
086:                if (msg != null) {
087:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
088:                    return op.mapping.findForward("accessDenied");
089:                }
090:
091:                op.form.set("list", ShimUtils
092:                        .getHtmlFragmentOptions(op.request));
093:
094:                //
095:                // update the action
096:                //
097:                op.form.set("action", "edit");
098:
099:                return op.mapping.findForward("list");
100:            }
101:
102:            /**
103:             * Calls base class function and forwards to
104:             * <tt>/htmlFragment.do&#63;action=list</tt>.
105:             */
106:            protected ActionForward doSaveNew(OperationContext op, Object policy) {
107:
108:                String msg = ((ShimPolicy) policy)
109:                        .isHtmlFragmentSaveNewAuthorized(op);
110:                if (msg != null) {
111:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
112:                    return op.mapping.findForward("accessDenied");
113:                }
114:
115:                super .doSaveNew(op, policy);
116:
117:                Event.log(SiteContext.getContext(op.request), op.user
118:                        .getLogin(), "shim", "Created html fragment \""
119:                        + op.form.get("name") + "\".");
120:
121:                return new ActionForward("/htmlFragment.do?action=list");
122:            }
123:
124:            protected ActionForward doNew(OperationContext op, Object policy) {
125:
126:                String msg = ((ShimPolicy) policy)
127:                        .isHtmlFragmentNewAuthorized(op);
128:                if (msg != null) {
129:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
130:                    return op.mapping.findForward("accessDenied");
131:                }
132:
133:                return super .doNew(op, policy);
134:            }
135:
136:            protected ActionForward doEdit(OperationContext op, Object policy) {
137:
138:                String msg = ((ShimPolicy) policy)
139:                        .isHtmlFragmentEditAuthorized(op);
140:                if (msg != null) {
141:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
142:                    return op.mapping.findForward("accessDenied");
143:                }
144:
145:                return super .doEdit(op, policy);
146:            }
147:
148:            /**
149:             * Calls base class function and forwards to
150:             * <tt>/htmlFragment.do&#63;action=list</tt>.
151:             */
152:            protected ActionForward doSave(OperationContext op, Object policy) {
153:
154:                String msg = ((ShimPolicy) policy)
155:                        .isHtmlFragmentSaveAuthorized(op);
156:                if (msg != null) {
157:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
158:                    return op.mapping.findForward("accessDenied");
159:                }
160:
161:                super .doSave(op, policy);
162:
163:                Event.log(SiteContext.getContext(op.request), op.user
164:                        .getLogin(), "shim", "Saved html fragment \""
165:                        + op.form.get("name") + "\".");
166:
167:                return new ActionForward("/htmlFragment.do?action=list");
168:            }
169:
170:            /**
171:             * Returns a forward to <tt>list</tt>.
172:             */
173:            protected ActionForward doCancelSave(OperationContext op,
174:                    Object policy) {
175:
176:                return new ActionForward("/htmlFragment.do?action=list");
177:            }
178:
179:            /**
180:             * Forwards to <tt>/htmlFragment.do&#63;action=list</tt>.
181:             */
182:            protected ActionForward doDelete(OperationContext op, Object policy) {
183:
184:                String msg = ((ShimPolicy) policy)
185:                        .isHtmlFragmentDeleteAuthorized(op);
186:                if (msg != null) {
187:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
188:                    return op.mapping.findForward("accessDenied");
189:                }
190:
191:                super .doDelete(op, policy);
192:
193:                Event.log(SiteContext.getContext(op.request), op.user
194:                        .getLogin(), "shim", "Deleted html fragment \""
195:                        + op.form.get("name") + "\".");
196:
197:                return new ActionForward("/htmlFragment.do?action=list");
198:            }
199:
200:            /**
201:             * 
202:             */
203:            protected ActionForward doConfirm(OperationContext op, Object policy) {
204:
205:                //
206:                // load the fragment
207:                //
208:                HtmlFragment fragment = (HtmlFragment) createPersistable(op);
209:                fragment.load(new IntKey(op.form.get("id")));
210:
211:                //
212:                // see if any text modules depend on it
213:                //
214:                ShimPolicy shimPolicy = (ShimPolicy) policy;
215:                TextModule textModule = shimPolicy.newTextModule();
216:                List pages = textModule.getDependentPages(fragment);
217:
218:                if (pages.size() > 0) {
219:
220:                    //
221:                    // concatenate page names
222:                    //
223:                    StrutsUtil.addMessage(op.request,
224:                            "shim.htmlFragment.fragmentInUse", StringUtils
225:                                    .join(pages.iterator(), ", "), null, null);
226:
227:                    return op.mapping.getInputForward();
228:                }
229:
230:                return super .doConfirm(op, policy);
231:            }
232:
233:            // properties ///////////////////////////////////////////////////////////////
234:
235:            // attributes ///////////////////////////////////////////////////////////////
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.