Source Code Cross Referenced for DBViewerPortlet.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » console » internaldb » 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 » EJB Server geronimo » plugins » org.apache.geronimo.console.internaldb 
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.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.console.internaldb;
017:
018:        import java.io.IOException;
019:
020:        import javax.portlet.ActionRequest;
021:        import javax.portlet.ActionResponse;
022:        import javax.portlet.PortletConfig;
023:        import javax.portlet.PortletException;
024:        import javax.portlet.PortletRequestDispatcher;
025:        import javax.portlet.RenderRequest;
026:        import javax.portlet.RenderResponse;
027:        import javax.portlet.WindowState;
028:
029:        import org.apache.geronimo.console.BasePortlet;
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:
033:        public class DBViewerPortlet extends BasePortlet {
034:
035:            private final static Log log = LogFactory
036:                    .getLog(DBViewerPortlet.class);
037:
038:            private static final int RDBMS_DERBY = 1;
039:
040:            private static final int RDBMS_MSSQL = 2;
041:
042:            private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerMaximized.jsp";
043:
044:            private static final String HELPVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerHelp.jsp";
045:
046:            private static final String LISTDATABASES_JSP = "/WEB-INF/view/internaldb/listDatabases.jsp";
047:
048:            private static final String LISTTABLES_JSP = "/WEB-INF/view/internaldb/listTables.jsp";
049:
050:            private static final String VIEWTABLECONTENTS_JSP = "/WEB-INF/view/internaldb/viewTableContents.jsp";
051:
052:            private static final String LISTDB_ACTION = "listDatabases";
053:
054:            private static final String LISTTBLS_ACTION = "listTables";
055:
056:            private static final String VIEWTBLCONTENTS_ACTION = "viewTableContents";
057:
058:            private static DBViewerHelper helper = new DBViewerHelper();
059:
060:            private PortletRequestDispatcher maximizedView;
061:
062:            private PortletRequestDispatcher helpView;
063:
064:            private PortletRequestDispatcher listDatabasesView;
065:
066:            private PortletRequestDispatcher listTablesView;
067:
068:            private PortletRequestDispatcher viewTableContentsView;
069:
070:            public void processAction(ActionRequest actionRequest,
071:                    ActionResponse actionResponse) throws PortletException,
072:                    IOException {
073:                // getting parameters here because it fails on doView()
074:                String action = actionRequest.getParameter("action");
075:                String db = actionRequest.getParameter("db");
076:                String tbl = actionRequest.getParameter("tbl");
077:                String viewTables = actionRequest.getParameter("viewTables");
078:                String rdbms = actionRequest.getParameter("rdbms");
079:                // pass them to the render request
080:                if (action != null) {
081:                    actionResponse.setRenderParameter("action", action);
082:                }
083:                if (db != null) {
084:                    actionResponse.setRenderParameter("db", db);
085:                }
086:                if (tbl != null) {
087:                    actionResponse.setRenderParameter("tbl", tbl);
088:                }
089:                if (viewTables != null) {
090:                    actionResponse.setRenderParameter("viewTables", viewTables);
091:                }
092:                if (rdbms != null) {
093:                    actionResponse.setRenderParameter("rdbms", rdbms);
094:                }
095:            }
096:
097:            protected void doView(RenderRequest renderRequest,
098:                    RenderResponse renderResponse) throws IOException,
099:                    PortletException {
100:                if (WindowState.MINIMIZED
101:                        .equals(renderRequest.getWindowState())) {
102:                    return;
103:                }
104:                String action = renderRequest.getParameter("action");
105:                String db = renderRequest.getParameter("db");
106:                String tbl = renderRequest.getParameter("tbl");
107:                String viewTables = renderRequest.getParameter("viewTables");
108:                String rdbms = renderRequest.getParameter("rdbms");
109:                int rdbmsParam = (rdbms == null ? RDBMS_DERBY : Integer
110:                        .parseInt(rdbms));
111:
112:                if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
113:                    if (rdbmsParam == RDBMS_DERBY) {
114:                        // Check is database & table is valid
115:                        if (LISTTBLS_ACTION.equals(action)
116:                                || VIEWTBLCONTENTS_ACTION.equals(action)) {
117:                            if (!helper.isDBValid(DerbyConnectionUtil
118:                                    .getDerbyHome(), db)) {
119:                                // DB not valid
120:                                log.error("Database is not valid: " + db);
121:                                action = "";
122:                            }
123:                        }
124:                        if (VIEWTBLCONTENTS_ACTION.equals(action)) {
125:                            if (!helper.isTblValid(db, tbl)) {
126:                                // Table not valid
127:                                log.error("Table is not valid: " + tbl);
128:                                action = "";
129:                            }
130:                        }
131:                    }
132:
133:                    renderRequest.setAttribute("rdbms", rdbms);
134:                    if (LISTTBLS_ACTION.equals(action)) {
135:                        renderRequest.setAttribute("db", db);
136:                        renderRequest.setAttribute("viewTables", viewTables);
137:                        renderRequest.setAttribute("ds", DerbyConnectionUtil
138:                                .getDataSource(db));
139:                        listTablesView.include(renderRequest, renderResponse);
140:                    } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
141:                        renderRequest.setAttribute("db", db);
142:                        renderRequest.setAttribute("tbl", tbl);
143:                        renderRequest.setAttribute("viewTables", viewTables);
144:                        renderRequest.setAttribute("ds", DerbyConnectionUtil
145:                                .getDataSource(db));
146:                        viewTableContentsView.include(renderRequest,
147:                                renderResponse);
148:                    } else {
149:                        renderRequest.setAttribute("databases", helper
150:                                .getDerbyDatabases(DerbyConnectionUtil
151:                                        .getDerbyHome()));
152:                        listDatabasesView
153:                                .include(renderRequest, renderResponse);
154:                    }
155:                } else {
156:                    maximizedView.include(renderRequest, renderResponse);
157:                }
158:            }
159:
160:            protected void doHelp(RenderRequest renderRequest,
161:                    RenderResponse renderResponse) throws PortletException,
162:                    IOException {
163:                helpView.include(renderRequest, renderResponse);
164:            }
165:
166:            public void init(PortletConfig portletConfig)
167:                    throws PortletException {
168:                super .init(portletConfig);
169:                maximizedView = portletConfig.getPortletContext()
170:                        .getRequestDispatcher(MAXIMIZEDVIEW_JSP);
171:                helpView = portletConfig.getPortletContext()
172:                        .getRequestDispatcher(HELPVIEW_JSP);
173:                listDatabasesView = portletConfig.getPortletContext()
174:                        .getRequestDispatcher(LISTDATABASES_JSP);
175:                listTablesView = portletConfig.getPortletContext()
176:                        .getRequestDispatcher(LISTTABLES_JSP);
177:                viewTableContentsView = portletConfig.getPortletContext()
178:                        .getRequestDispatcher(VIEWTABLECONTENTS_JSP);
179:            }
180:
181:            public void destroy() {
182:                maximizedView = null;
183:                helpView = null;
184:                listDatabasesView = null;
185:                listTablesView = null;
186:                viewTableContentsView = null;
187:                super.destroy();
188:            }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.