Source Code Cross Referenced for RollerPropertiesAction.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » ui » admin » struts » actions » 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 » Blogger System » apache roller 3.1 » org.apache.roller.ui.admin.struts.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:        /*
019:         * RollerPropertiesAction.java
020:         *
021:         * Created on April 21, 2005, 2:48 PM
022:         */
023:
024:        package org.apache.roller.ui.admin.struts.actions;
025:
026:        import java.io.IOException;
027:        import java.util.Iterator;
028:        import java.util.Map;
029:
030:        import javax.servlet.ServletException;
031:        import javax.servlet.http.HttpServletRequest;
032:        import javax.servlet.http.HttpServletResponse;
033:
034:        import org.apache.commons.logging.Log;
035:        import org.apache.commons.logging.LogFactory;
036:        import org.apache.struts.action.ActionError;
037:        import org.apache.struts.action.ActionErrors;
038:        import org.apache.struts.action.ActionForm;
039:        import org.apache.struts.action.ActionForward;
040:        import org.apache.struts.action.ActionMapping;
041:        import org.apache.struts.action.ActionMessage;
042:        import org.apache.struts.action.ActionMessages;
043:        import org.apache.struts.actions.DispatchAction;
044:        import org.apache.roller.RollerException;
045:        import org.apache.roller.RollerPermissionsException;
046:        import org.apache.roller.business.PropertiesManager;
047:        import org.apache.roller.business.Roller;
048:        import org.apache.roller.business.RollerFactory;
049:        import org.apache.roller.pojos.RollerPropertyData;
050:        import org.apache.roller.ui.core.BasePageModel;
051:        import org.apache.roller.ui.core.RollerRequest;
052:        import org.apache.roller.ui.core.RollerSession;
053:
054:        /**
055:         * Struts Action class which handles requests to the Admin Properties page.
056:         *
057:         * @author Allen Gilliland
058:         *
059:         * @struts.action path="/roller-ui/admin/rollerConfig"
060:         *  scope="request" parameter="method"
061:         *
062:         * @struts.action-forward name="rollerProperties.page"
063:         *  path=".rollerProperties"
064:         */
065:        public class RollerPropertiesAction extends DispatchAction {
066:
067:            private static Log mLogger = LogFactory.getFactory().getInstance(
068:                    RollerPropertiesAction.class);
069:
070:            public ActionForward unspecified(ActionMapping mapping,
071:                    ActionForm actionForm, HttpServletRequest request,
072:                    HttpServletResponse response) throws IOException,
073:                    ServletException {
074:
075:                // make "edit" our default action
076:                return this .edit(mapping, actionForm, request, response);
077:            }
078:
079:            public ActionForward edit(ActionMapping mapping,
080:                    ActionForm actionForm, HttpServletRequest request,
081:                    HttpServletResponse response) throws IOException,
082:                    ServletException {
083:
084:                mLogger.debug("Handling edit request");
085:
086:                ActionForward forward = mapping
087:                        .findForward("rollerProperties.page");
088:                try {
089:                    BasePageModel pageModel = new BasePageModel(
090:                            "configForm.title", request, response, mapping);
091:                    request.setAttribute("model", pageModel);
092:                    RollerRequest rreq = RollerRequest
093:                            .getRollerRequest(request);
094:                    RollerSession rollerSession = RollerSession
095:                            .getRollerSession(request);
096:                    if (rollerSession.isGlobalAdminUser()) {
097:
098:                        // just grab our properties map and put it in the request
099:                        Roller mRoller = RollerFactory.getRoller();
100:                        PropertiesManager propsManager = mRoller
101:                                .getPropertiesManager();
102:                        Map props = propsManager.getProperties();
103:                        request.setAttribute("RollerProps", props);
104:
105:                    } else {
106:                        forward = mapping.findForward("access-denied");
107:                    }
108:                } catch (Exception e) {
109:                    mLogger.error("ERROR in action", e);
110:                    throw new ServletException(e);
111:                }
112:                return forward;
113:            }
114:
115:            public ActionForward update(ActionMapping mapping,
116:                    ActionForm actionForm, HttpServletRequest request,
117:                    HttpServletResponse response) throws IOException,
118:                    ServletException {
119:
120:                mLogger.debug("Handling update request");
121:
122:                ActionForward forward = mapping
123:                        .findForward("rollerProperties.page");
124:                ActionErrors errors = new ActionErrors();
125:                try {
126:                    RollerRequest rreq = RollerRequest
127:                            .getRollerRequest(request);
128:                    RollerSession rollerSession = RollerSession
129:                            .getRollerSession(request);
130:                    BasePageModel pageModel = new BasePageModel(
131:                            "configForm.title", request, response, mapping);
132:                    request.setAttribute("model", pageModel);
133:                    if (rollerSession.isGlobalAdminUser()) {
134:
135:                        // just grab our properties map and put it in the request
136:                        Roller mRoller = RollerFactory.getRoller();
137:                        PropertiesManager propsManager = mRoller
138:                                .getPropertiesManager();
139:                        Map props = propsManager.getProperties();
140:                        request.setAttribute("RollerProps", props);
141:
142:                        // only set values for properties that are already defined
143:                        String propName = null;
144:                        RollerPropertyData updProp = null;
145:                        String incomingProp = null;
146:                        Iterator propsIT = props.keySet().iterator();
147:                        while (propsIT.hasNext()) {
148:                            propName = (String) propsIT.next();
149:                            updProp = (RollerPropertyData) props.get(propName);
150:                            incomingProp = request.getParameter(updProp
151:                                    .getName());
152:
153:                            mLogger.debug("Checking property [" + propName
154:                                    + "]");
155:
156:                            // some special treatment for booleans
157:                            // this is a bit hacky since we are assuming that any prop
158:                            // with a value of "true" or "false" is meant to be a boolean
159:                            // it may not always be the case, but we should be okay for now
160:                            if (updProp.getValue() != null // null check needed w/Oracle
161:                                    && (updProp.getValue().equals("true") || updProp
162:                                            .getValue().equals("false"))) {
163:
164:                                if (incomingProp == null
165:                                        || !incomingProp.equals("on"))
166:                                    incomingProp = "false";
167:                                else
168:                                    incomingProp = "true";
169:                            }
170:
171:                            // only work on props that were submitted with the request
172:                            if (incomingProp != null) {
173:                                mLogger.debug("Setting new value for ["
174:                                        + propName + "]");
175:
176:                                // NOTE: the old way had some locale sensitive way to do this??
177:                                updProp.setValue(incomingProp.trim());
178:                            }
179:                        }
180:
181:                        // save it
182:                        propsManager.saveProperties(props);
183:                        RollerFactory.getRoller().flush();
184:
185:                        // this operation causes OutOfMemory exceptions on sites with 
186:                        // lots of referers so i am disabling it until it's 
187:                        // not as dangerous -- Allen G
188:                        //mRoller.getRefererManager().applyRefererFilters();
189:
190:                        ActionMessages uiMessages = new ActionMessages();
191:                        uiMessages.add(null, new ActionMessage(
192:                                "weblogEdit.changesSaved"));
193:                        saveMessages(request, uiMessages);
194:
195:                    } else {
196:                        forward = mapping.findForward("access-denied");
197:                    }
198:
199:                } catch (RollerPermissionsException e) {
200:                    errors.add(null, new ActionError(
201:                            "error.permissions.deniedSave"));
202:                    saveErrors(request, errors);
203:                    forward = mapping.findForward("access-denied");
204:
205:                } catch (RollerException e) {
206:                    mLogger.error(e);
207:                    errors.add(ActionErrors.GLOBAL_ERROR,
208:                            new ActionError("error.update.rollerConfig", e
209:                                    .getClass().getName()));
210:                    saveErrors(request, errors);
211:                }
212:
213:                return forward;
214:            }
215:
216:        }
ww___w___.ja___v___a___2__s__.c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.