Source Code Cross Referenced for SiteContextAction.java in  » Content-Management-System » TransferCM » com » methodhead » sitecontext » 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.sitecontext 
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.sitecontext;
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.DynaActionForm;
027:        import org.apache.struts.validator.DynaValidatorForm;
028:        import org.apache.struts.action.ActionForward;
029:        import com.methodhead.auth.AuthAction;
030:
031:        import javax.servlet.http.HttpServletRequest;
032:        import javax.servlet.http.HttpServletResponse;
033:
034:        import com.methodhead.auth.AuthUtil;
035:        import com.methodhead.auth.AuthUser;
036:        import com.methodhead.util.OperationContext;
037:        import com.methodhead.MhfPolicy;
038:        import com.methodhead.util.StrutsUtil;
039:        import java.util.Collections;
040:        import java.util.List;
041:        import java.util.Iterator;
042:        import org.apache.commons.lang.StringUtils;
043:        import com.methodhead.aikp.AikpAction;
044:        import com.methodhead.aikp.IntKey;
045:        import com.methodhead.aikp.AutoIntKeyPersistable;
046:        import com.methodhead.event.Event;
047:
048:        public class SiteContextAction extends AikpAction {
049:
050:            // constructors /////////////////////////////////////////////////////////////
051:
052:            // constants ////////////////////////////////////////////////////////////////
053:
054:            // classes //////////////////////////////////////////////////////////////////
055:
056:            // methods //////////////////////////////////////////////////////////////////
057:
058:            /**
059:             * NOT UNIT TESTED Returns a new <tt>SiteContext</tt>.
060:             */
061:            protected AutoIntKeyPersistable createPersistable(
062:                    OperationContext op) {
063:                return new SiteContext();
064:            }
065:
066:            /**
067:             * Updates site context's domains from <tt>form.domains</tt>.
068:             */
069:            protected void populatePersistable(
070:                    AutoIntKeyPersistable persistable, DynaActionForm form) {
071:
072:                super .populatePersistable(persistable, form);
073:
074:                SiteContext siteContext = (SiteContext) persistable;
075:
076:                siteContext.getDomains().clear();
077:                siteContext.getDomains().addAll((List) form.get("domains"));
078:            }
079:
080:            /**
081:             * Joins the site context's domain names to a newline-separated string and
082:             * sets <tt>form.domainsText</tt> to it.
083:             */
084:            protected void populateForm(DynaActionForm form,
085:                    AutoIntKeyPersistable persistable) {
086:
087:                super .populateForm(form, persistable);
088:
089:                SiteContext siteContext = (SiteContext) persistable;
090:
091:                form.set("domainsText", StringUtils.join(siteContext
092:                        .getDomains().iterator(), "\n"));
093:            }
094:
095:            /**
096:             * Fully loads each site context loaded by the default behavior and sorts the
097:             * resulting list.
098:             */
099:            protected ActionForward doList(OperationContext op, Object policy) {
100:
101:                String msg = ((SiteContextPolicy) policy)
102:                        .isSiteContextListAuthorized(op);
103:                if (msg != null) {
104:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
105:                    return op.mapping.findForward("accessDenied");
106:                }
107:
108:                ActionForward forward = super .doList(op, policy);
109:
110:                List list = (List) op.form.get("list");
111:                for (Iterator iter = list.iterator(); iter.hasNext();) {
112:                    SiteContext siteContext = (SiteContext) iter.next();
113:                    siteContext.load(new IntKey(siteContext.get("id")));
114:                }
115:
116:                Collections.sort(list);
117:
118:                return forward;
119:            }
120:
121:            /**
122:             * Performs policy check and event logging.
123:             */
124:            protected ActionForward doDelete(OperationContext op, Object policy) {
125:
126:                String msg = ((SiteContextPolicy) policy)
127:                        .isSiteContextDeleteAuthorized(op);
128:                if (msg != null) {
129:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
130:                    return op.mapping.findForward("accessDenied");
131:                }
132:
133:                //
134:                // get the site context so we can get the name to log
135:                //
136:                SiteContext siteContext = (SiteContext) createPersistable(op);
137:                siteContext.load(new IntKey(op.form.get("id")));
138:
139:                ActionForward forward = super .doDelete(op, policy);
140:
141:                Event.log(SiteContext.getContext(op.request), op.user
142:                        .getLogin(), "shim", "Deleted site context \""
143:                        + siteContext.getDomains().get(0) + "\".");
144:
145:                return forward;
146:            }
147:
148:            /**
149:             * Performs policy check and event logging.
150:             */
151:            protected ActionForward doSaveNew(OperationContext op, Object policy) {
152:
153:                String msg = ((SiteContextPolicy) policy)
154:                        .isSiteContextSaveNewAuthorized(op);
155:                if (msg != null) {
156:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
157:                    return op.mapping.findForward("accessDenied");
158:                }
159:
160:                ActionForward forward = super .doSaveNew(op, policy);
161:
162:                SiteContext siteContext = (SiteContext) createPersistable(op);
163:                siteContext.load(new IntKey(op.form.get("id")));
164:
165:                Event.log(SiteContext.getContext(op.request), op.user
166:                        .getLogin(), "shim", "Created site context \""
167:                        + siteContext.getDomains().get(0) + "\".");
168:
169:                return forward;
170:            }
171:
172:            /**
173:             * Performs policy check and event logging.
174:             */
175:            protected ActionForward doEdit(OperationContext op, Object policy) {
176:
177:                String msg = ((SiteContextPolicy) policy)
178:                        .isSiteContextEditAuthorized(op);
179:                if (msg != null) {
180:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
181:                    return op.mapping.findForward("accessDenied");
182:                }
183:
184:                return super .doEdit(op, policy);
185:            }
186:
187:            /**
188:             * Performs policy check and event logging.
189:             */
190:            protected ActionForward doNew(OperationContext op, Object policy) {
191:
192:                String msg = ((SiteContextPolicy) policy)
193:                        .isSiteContextNewAuthorized(op);
194:                if (msg != null) {
195:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
196:                    return op.mapping.findForward("accessDenied");
197:                }
198:
199:                return super .doNew(op, policy);
200:            }
201:
202:            /**
203:             * Performs policy check and event logging.
204:             */
205:            protected ActionForward doSave(OperationContext op, Object policy) {
206:
207:                String msg = ((SiteContextPolicy) policy)
208:                        .isSiteContextSaveAuthorized(op);
209:                if (msg != null) {
210:                    StrutsUtil.addMessage(op.request, msg, null, null, null);
211:                    return op.mapping.findForward("accessDenied");
212:                }
213:
214:                ActionForward forward = super .doSave(op, policy);
215:
216:                SiteContext siteContext = (SiteContext) createPersistable(op);
217:                siteContext.load(new IntKey(op.form.get("id")));
218:
219:                Event.log(SiteContext.getContext(op.request), op.user
220:                        .getLogin(), "shim", "Updated site context \""
221:                        + siteContext.getDomains().get(0) + "\".");
222:
223:                return forward;
224:            }
225:
226:            /**
227:             * Returns the <tt>list</tt> forward.
228:             */
229:            protected ActionForward doCancelSave(OperationContext op,
230:                    Object policy) {
231:
232:                return new ActionForward("/siteContext.do?action=list");
233:            }
234:
235:            // properties ///////////////////////////////////////////////////////////////
236:
237:            // attributes ///////////////////////////////////////////////////////////////
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.