Source Code Cross Referenced for LoadXMLAction.java in  » GIS » GeoServer » org » vfny » geoserver » action » 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 » GIS » GeoServer » org.vfny.geoserver.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver.action;
006:
007:        import org.apache.struts.action.ActionForm;
008:        import org.apache.struts.action.ActionForward;
009:        import org.apache.struts.action.ActionMapping;
010:        import org.geoserver.wfs.WFS;
011:        import org.geotools.validation.xml.XMLReader;
012:        import org.vfny.geoserver.config.validation.ValidationConfig;
013:        import org.vfny.geoserver.global.ConfigurationException;
014:        import org.vfny.geoserver.global.GeoserverDataDirectory;
015:        import org.vfny.geoserver.global.UserContainer;
016:        import org.vfny.geoserver.global.dto.DataDTO;
017:        import org.vfny.geoserver.global.dto.GeoServerDTO;
018:        import org.vfny.geoserver.global.dto.WCSDTO;
019:        import org.vfny.geoserver.global.dto.WFSDTO;
020:        import org.vfny.geoserver.global.dto.WMSDTO;
021:        import org.vfny.geoserver.global.xml.XMLConfigReader;
022:        import java.io.File;
023:        import java.io.IOException;
024:        import java.util.Map;
025:        import java.util.logging.Level;
026:        import javax.servlet.ServletContext;
027:        import javax.servlet.ServletException;
028:        import javax.servlet.http.HttpServletRequest;
029:        import javax.servlet.http.HttpServletResponse;
030:
031:        /**
032:         * Load GeoServer configuration.
033:         *
034:         * <p>
035:         * The existing getServer instances is updated with a call to load(..) based on
036:         * the existing XML configuration files.
037:         * </p>
038:         *
039:         * <p>
040:         * It seems this class also creates the GeoServer instance in a lazy fashion!
041:         * That would mean that if this class cannot load, the application cannot
042:         * load? This could not possibly be the case, because the load action should
043:         * only appear when logged in.
044:         * </p>
045:         *
046:         * <p>
047:         * Load need to remain on the current page, right now it takes us on a wild
048:         * ride back to the welcome screen.
049:         * </p>
050:         *
051:         * <p>
052:         * Q: Does this need to load the Validation Processor as well?
053:         * </p>
054:         * @REVISIT: There seems to be quite a bit of code duplication in this class
055:         *           with GeoServerPlugIn, loading things, especially with the
056:         *           validation stuff.  Anyway we could cut that down?  Have one call
057:         *           the other?  Too close to release to do sucha refactoring but
058:         *           in 1.4 we should. -CH
059:         */
060:        public class LoadXMLAction extends ConfigAction {
061:            public ActionForward execute(ActionMapping mapping,
062:                    ActionForm form, UserContainer user,
063:                    HttpServletRequest request, HttpServletResponse response)
064:                    throws IOException, ServletException {
065:                ActionForward r1 = loadValidation(mapping, form, request,
066:                        response);
067:                ActionForward r2 = loadGeoserver(mapping, form, request,
068:                        response);
069:
070:                getApplicationState().fireChange();
071:                return mapping.findForward("config");
072:            }
073:
074:            private ActionForward loadGeoserver(ActionMapping mapping,
075:                    ActionForm form,
076:                    //UserContainer user,
077:                    HttpServletRequest request, HttpServletResponse response)
078:                    throws IOException, ServletException {
079:                ServletContext sc = request.getSession().getServletContext();
080:
081:                WMSDTO wmsDTO = null;
082:                WFSDTO wfsDTO = null;
083:                WCSDTO wcsDTO = null;
084:                GeoServerDTO geoserverDTO = null;
085:                DataDTO dataDTO = null;
086:
087:                //DJB: changed for geoserver_data_dir    
088:                // File rootDir = new File(sc.getRealPath("/"));
089:                File rootDir = GeoserverDataDirectory
090:                        .getGeoserverDataDirectory();
091:
092:                XMLConfigReader configReader;
093:
094:                try {
095:                    configReader = new XMLConfigReader(rootDir, sc);
096:                } catch (ConfigurationException configException) {
097:                    configException.printStackTrace();
098:
099:                    return mapping.findForward("welcome");
100:
101:                    //throw new ServletException( configException );
102:                }
103:
104:                if (configReader.isInitialized()) {
105:                    // These are on separate lines so we can tell with the
106:                    // stack trace/debugger where things go wrong
107:                    wmsDTO = configReader.getWms();
108:                    wfsDTO = configReader.getWfs();
109:                    wcsDTO = configReader.getWcs();
110:                    geoserverDTO = configReader.getGeoServer();
111:                    dataDTO = configReader.getData();
112:                } else {
113:                    System.err
114:                            .println("Config Reader not initialized for LoadXMLAction.execute().");
115:
116:                    return mapping.findForward("welcome");
117:
118:                    // throw new ServletException( new ConfigurationException( "An error occured loading the initial configuration" ));
119:                }
120:
121:                // Update GeoServer
122:                try {
123:                    getWCS(request).load(wcsDTO);
124:                    getWFS(request).load(wfsDTO);
125:                    getWMS(request).load(wmsDTO);
126:                    getWCS(request).getGeoServer().load(geoserverDTO);
127:                    getWCS(request).getData().load(dataDTO);
128:                    getWFS(request).getGeoServer().load(geoserverDTO);
129:                    getWFS(request).getData().load(dataDTO);
130:                } catch (ConfigurationException configException) {
131:                    configException.printStackTrace();
132:
133:                    return mapping.findForward("welcome");
134:
135:                    //			throw new ServletException( configException );			
136:                }
137:
138:                // Update Config
139:                getGlobalConfig().update(geoserverDTO);
140:                getDataConfig().update(dataDTO);
141:                getWCSConfig().update(wcsDTO);
142:                getWFSConfig().update(wfsDTO);
143:                getWMSConfig().update(wmsDTO);
144:
145:                getApplicationState(request).notifyLoadXML();
146:
147:                // We need to stash the current page?
148:                // or can we use null or something?
149:                //
150:                if (LOGGER.isLoggable(Level.FINER)) {
151:                    LOGGER.finer(new StringBuffer("request: ").append(
152:                            request.getServletPath()).toString());
153:                    LOGGER.finer(new StringBuffer("forward: ").append(
154:                            mapping.getForward()).toString());
155:                }
156:
157:                return mapping.findForward("config");
158:            }
159:
160:            private ActionForward loadValidation(ActionMapping mapping,
161:                    ActionForm form,
162:                    //UserContainer user,
163:                    HttpServletRequest request, HttpServletResponse response)
164:                    throws IOException, ServletException {
165:                ServletContext sc = request.getSession().getServletContext();
166:
167:                WFS wfs = getWFS(request);
168:
169:                if (wfs == null) {
170:                    // lazy creation on load?
171:                    loadGeoserver(mapping, form, request, response);
172:                }
173:
174:                //CH- fixed for data dir, looks like this got missed first time around.
175:                File rootDir = GeoserverDataDirectory
176:                        .getGeoserverDataDirectory();
177:
178:                try {
179:                    File plugInDir = findConfigDir(rootDir, "plugIns");
180:                    File validationDir = findConfigDir(rootDir, "validation");
181:                    Map plugIns = XMLReader.loadPlugIns(plugInDir);
182:                    Map testSuites = XMLReader.loadValidations(validationDir,
183:                            plugIns);
184:                    ValidationConfig vc = new ValidationConfig(plugIns,
185:                            testSuites);
186:                    sc.setAttribute(ValidationConfig.CONFIG_KEY, vc);
187:                } catch (Exception e) {
188:                    // LOG error
189:                    e.printStackTrace();
190:
191:                    return mapping.findForward("config.validation");
192:                }
193:
194:                return mapping.findForward("config.validation");
195:            }
196:
197:            private File findConfigDir(File rootDir, String name)
198:                    throws Exception {
199:                return GeoserverDataDirectory.findConfigDir(rootDir, name);
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.