Source Code Cross Referenced for CompassIndexController.java in  » Search-Engine » compass-2.0 » org » compass » spring » web » mvc » 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 » Search Engine » compass 2.0 » org.compass.spring.web.mvc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004-2006 the original author or authors.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not 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.
015:         */
016:
017:        package org.compass.spring.web.mvc;
018:
019:        import java.util.HashMap;
020:        import javax.servlet.http.HttpServletRequest;
021:        import javax.servlet.http.HttpServletResponse;
022:
023:        import org.springframework.util.StringUtils;
024:        import org.springframework.validation.BindException;
025:        import org.springframework.web.servlet.ModelAndView;
026:
027:        /**
028:         * A general Spring's MVC Controller that perform the index operation of
029:         * <code>CompassGps</code>.
030:         * <p>
031:         * Will perform the index operation if the
032:         * {@link org.compass.spring.web.mvc.CompassIndexCommand} <code>doIndex</code>
033:         * property is set to true.
034:         * <p>
035:         * The controller has two views to be set, the <code>indexView</code>, which
036:         * is the view that holds the screen which the user will initiate the index
037:         * operation, and the <code>indexResultsView</code>, which will show the
038:         * results of the index operation.
039:         * <p>
040:         * The results of the index operation will be saved under the
041:         * <code>indexResultsName</code>, which defaults to "indexResults".
042:         * 
043:         * @author kimchy
044:         */
045:        public class CompassIndexController extends
046:                AbstractCompassGpsCommandController {
047:
048:            private String indexView;
049:
050:            private String indexResultsView;
051:
052:            private String indexResultsName = "indexResults";
053:
054:            public CompassIndexController() {
055:                setCommandClass(CompassIndexCommand.class);
056:            }
057:
058:            public void afterPropertiesSet() throws Exception {
059:                super .afterPropertiesSet();
060:                if (indexView == null) {
061:                    throw new IllegalArgumentException(
062:                            "Must set the indexView property");
063:                }
064:                if (indexResultsView == null) {
065:                    throw new IllegalArgumentException(
066:                            "Must set the indexResultsView property");
067:                }
068:            }
069:
070:            protected ModelAndView handle(HttpServletRequest request,
071:                    HttpServletResponse response, Object command,
072:                    BindException errors) throws Exception {
073:                CompassIndexCommand indexCommand = (CompassIndexCommand) command;
074:
075:                if (!StringUtils.hasText(indexCommand.getDoIndex())
076:                        || !indexCommand.getDoIndex().equalsIgnoreCase("true")) {
077:                    return new ModelAndView(getIndexView(), getCommandName(),
078:                            indexCommand);
079:                }
080:
081:                long time = System.currentTimeMillis();
082:
083:                getCompassGps().index();
084:
085:                time = System.currentTimeMillis() - time;
086:                CompassIndexResults indexResults = new CompassIndexResults(time);
087:                HashMap data = new HashMap();
088:                data.put(getCommandName(), indexCommand);
089:                data.put(getIndexResultsName(), indexResults);
090:                return new ModelAndView(getIndexResultsView(), data);
091:            }
092:
093:            /**
094:             * Returns the view that holds the screen which the user will initiate the
095:             * index operation.
096:             */
097:            public String getIndexView() {
098:                return indexView;
099:            }
100:
101:            /**
102:             * Sets the view that holds the screen which the user will initiate the
103:             * index operation.
104:             */
105:            public void setIndexView(String indexView) {
106:                this .indexView = indexView;
107:            }
108:
109:            /**
110:             * Returns the name of the results that the {@link CompassIndexResults} will
111:             * be saved under. Defaults to "indexResults".
112:             */
113:            public String getIndexResultsName() {
114:                return indexResultsName;
115:            }
116:
117:            /**
118:             * Sets the name of the results that the {@link CompassIndexResults} will be
119:             * saved under. Defaults to "indexResults".
120:             * 
121:             * @param indexResultsName
122:             */
123:            public void setIndexResultsName(String indexResultsName) {
124:                this .indexResultsName = indexResultsName;
125:            }
126:
127:            /**
128:             * Returns the view which will show the results of the index operation.
129:             */
130:            public String getIndexResultsView() {
131:                return indexResultsView;
132:            }
133:
134:            /**
135:             * Sets the view which will show the results of the index operation.
136:             * 
137:             * @param indexResultsView
138:             */
139:            public void setIndexResultsView(String indexResultsView) {
140:                this.indexResultsView = indexResultsView;
141:            }
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.