You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dw...@apache.org on 2008/09/29 20:09:17 UTC
svn commit: r700193 - in
/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main:
java/org/apache/geronimo/console/internaldb/ resources/
webapp/WEB-INF/view/internaldb/
Author: dwoods
Date: Mon Sep 29 11:09:17 2008
New Revision: 700193
URL: http://svn.apache.org/viewvc?rev=700193&view=rev
Log:
GERONIMO-4225 Allow Run SQL portlet run sql against any configured data source. Thanks to Michal Borowiecki for the patch.
Added:
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp (with props)
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp (with props)
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp (with props)
Modified:
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java Mon Sep 29 11:09:17 2008
@@ -18,9 +18,20 @@
package org.apache.geronimo.console.internaldb;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Vector;
+import org.apache.geronimo.console.util.KernelManagementHelper;
+import org.apache.geronimo.console.util.ManagementHelper;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
+
public class DBViewerHelper {
private static final String SYS_TBL_PREFIX = "SYS.";
@@ -28,6 +39,34 @@
private static final int COUNT_COL = 1;
/**
+ * List the databases having datasources deployed.
+ *
+ * @param derbySysHome
+ * @return
+ */
+ public Collection<String> getDataSourceNames() {
+
+ List<String> databaseNames = new ArrayList<String>();
+
+ Kernel kernel = KernelRegistry.getSingleKernel();
+ ManagementHelper helper = new KernelManagementHelper(kernel);
+ ResourceAdapterModule[] modules = helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0], "javax.sql.DataSource");
+ for (ResourceAdapterModule module : modules) {
+ org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[] databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
+ for (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory db : databases) {
+ try {
+ AbstractName dbName = kernel.getAbstractNameFor(db);
+ String datasourceName = (String)dbName.getName().get(NameFactory.J2EE_NAME);
+ databaseNames.add(datasourceName);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ return databaseNames;
+ }
+
+ /**
* List the databases given the derby home directory.
*
* @param derbySysHome
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java Mon Sep 29 11:09:17 2008
@@ -40,16 +40,20 @@
private static final int RDBMS_MSSQL = 2;
- private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerMaximized.jsp";
-
private static final String HELPVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerHelp.jsp";
private static final String LISTDATABASES_JSP = "/WEB-INF/view/internaldb/listDatabases.jsp";
+ private static final String LISTDATABASES_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/listDatabasesMaximized.jsp";
+
private static final String LISTTABLES_JSP = "/WEB-INF/view/internaldb/listTables.jsp";
+ private static final String LISTTABLES_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/listTablesMaximized.jsp";
+
private static final String VIEWTABLECONTENTS_JSP = "/WEB-INF/view/internaldb/viewTableContents.jsp";
+ private static final String VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp";
+
private static final String LISTDB_ACTION = "listDatabases";
private static final String LISTTBLS_ACTION = "listTables";
@@ -58,8 +62,6 @@
private static DBViewerHelper helper = new DBViewerHelper();
- private PortletRequestDispatcher maximizedView;
-
private PortletRequestDispatcher helpView;
private PortletRequestDispatcher listDatabasesView;
@@ -68,6 +70,12 @@
private PortletRequestDispatcher viewTableContentsView;
+ private PortletRequestDispatcher listDatabasesMaximizedView;
+
+ private PortletRequestDispatcher listTablesMaximizedView;
+
+ private PortletRequestDispatcher viewTableContentsMaximizedView;
+
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws PortletException, IOException {
// getting parameters here because it fails on doView()
@@ -106,47 +114,56 @@
String rdbms = renderRequest.getParameter("rdbms");
int rdbmsParam = (rdbms == null ? RDBMS_DERBY : Integer.parseInt(rdbms));
- if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
- if (rdbmsParam == RDBMS_DERBY) {
- // Check is database & table is valid
- if (LISTTBLS_ACTION.equals(action)
- || VIEWTBLCONTENTS_ACTION.equals(action)) {
- if (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
- // DB not valid
- log.error("Database is not valid: " + db);
- action = "";
- }
+ if (rdbmsParam == RDBMS_DERBY) {
+ // Check is database & table is valid
+ if (LISTTBLS_ACTION.equals(action)
+ || VIEWTBLCONTENTS_ACTION.equals(action)) {
+ if (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
+ // DB not valid
+ log.error("Database is not valid: " + db);
+ action = "";
}
- if (VIEWTBLCONTENTS_ACTION.equals(action)) {
- if (!helper.isTblValid(db, tbl)) {
- // Table not valid
- log.error("Table is not valid: " + tbl);
- action = "";
- }
+ }
+ if (VIEWTBLCONTENTS_ACTION.equals(action)) {
+ if (!helper.isTblValid(db, tbl)) {
+ // Table not valid
+ log.error("Table is not valid: " + tbl);
+ action = "";
}
}
+ }
- renderRequest.setAttribute("rdbms", rdbms);
- if (LISTTBLS_ACTION.equals(action)) {
- renderRequest.setAttribute("db", db);
- renderRequest.setAttribute("viewTables", viewTables);
- renderRequest.setAttribute("ds", DerbyConnectionUtil
- .getDataSource(db));
- listTablesView.include(renderRequest, renderResponse);
- } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
- renderRequest.setAttribute("db", db);
- renderRequest.setAttribute("tbl", tbl);
- renderRequest.setAttribute("viewTables", viewTables);
- renderRequest.setAttribute("ds", DerbyConnectionUtil
- .getDataSource(db));
- viewTableContentsView.include(renderRequest, renderResponse);
+ renderRequest.setAttribute("rdbms", rdbms);
+ if (LISTTBLS_ACTION.equals(action)) {
+ renderRequest.setAttribute("db", db);
+ renderRequest.setAttribute("viewTables", viewTables);
+ renderRequest.setAttribute("ds", DerbyConnectionUtil
+ .getDataSourceForDataBaseName(db));
+
+ if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
+ listTablesView.include(renderRequest, renderResponse);
} else {
- renderRequest.setAttribute("databases", helper
- .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
- listDatabasesView.include(renderRequest, renderResponse);
+ listTablesMaximizedView.include(renderRequest, renderResponse);
+ }
+ } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
+ renderRequest.setAttribute("db", db);
+ renderRequest.setAttribute("tbl", tbl);
+ renderRequest.setAttribute("viewTables", viewTables);
+ renderRequest.setAttribute("ds", DerbyConnectionUtil
+ .getDataSourceForDataBaseName(db));
+ if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
+ viewTableContentsView.include(renderRequest, renderResponse);
+ } else {
+ viewTableContentsMaximizedView.include(renderRequest, renderResponse);
}
} else {
- maximizedView.include(renderRequest, renderResponse);
+ renderRequest.setAttribute("databases", helper
+ .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
+ if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
+ listDatabasesView.include(renderRequest, renderResponse);
+ } else {
+ listDatabasesMaximizedView.include(renderRequest, renderResponse);
+ }
}
}
@@ -157,8 +174,6 @@
public void init(PortletConfig portletConfig) throws PortletException {
super.init(portletConfig);
- maximizedView = portletConfig.getPortletContext().getRequestDispatcher(
- MAXIMIZEDVIEW_JSP);
helpView = portletConfig.getPortletContext().getRequestDispatcher(
HELPVIEW_JSP);
listDatabasesView = portletConfig.getPortletContext()
@@ -167,14 +182,22 @@
.getRequestDispatcher(LISTTABLES_JSP);
viewTableContentsView = portletConfig.getPortletContext()
.getRequestDispatcher(VIEWTABLECONTENTS_JSP);
+ listDatabasesMaximizedView = portletConfig.getPortletContext()
+ .getRequestDispatcher(LISTDATABASES_MAXIMIZEDVIEW_JSP);
+ listTablesMaximizedView = portletConfig.getPortletContext()
+ .getRequestDispatcher(LISTTABLES_MAXIMIZEDVIEW_JSP);
+ viewTableContentsMaximizedView = portletConfig.getPortletContext()
+ .getRequestDispatcher(VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP);
}
public void destroy() {
- maximizedView = null;
helpView = null;
listDatabasesView = null;
listTablesView = null;
viewTableContentsView = null;
+ listDatabasesMaximizedView = null;
+ listTablesMaximizedView = null;
+ viewTableContentsMaximizedView = null;
super.destroy();
}
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java Mon Sep 29 11:09:17 2008
@@ -166,7 +166,7 @@
public static Connection getSystemDBConnection() throws SQLException {
DataSource ds = null;
try {
- ds = getDataSource(SYSTEM_DB);
+ ds = getDataSourceForDataBaseName(SYSTEM_DB);
return ds.getConnection();
} catch (Exception e) {
throw new SQLException(e.getMessage());
@@ -174,12 +174,27 @@
}
/**
- * Get the datasource if dbName is == SYSTEM_DB, otherwise returns null.
+ * Get a connaction to a named datasource
+ *
+ * @param dbName
+ * @return
+ * @throws SQLException
+ */
+ public static Connection getDataSourceConnection(String dataSourceName) throws SQLException{
+ try {
+ return getDataSource(dataSourceName).getConnection();
+ } catch (Exception e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Get the datasource if dbName is == SYSTEM_DB, otherwise finds the datasource among JCAManagedConnectionFactories, otherwise returns null.
*
* @param dbName
* @return datasource
*/
- public static DataSource getDataSource(String dbName) {
+ public static DataSource getDataSourceForDataBaseName(String dbName) {
try {
if (SYSTEM_DATASOURCE_NAME!=null && SYSTEM_DB.equalsIgnoreCase(dbName)) {
return (DataSource) KernelRegistry.getSingleKernel().invoke(
@@ -210,4 +225,42 @@
return null;
}
+ /**
+ * Get the datasource if dbName is == SYSTEM_DB, otherwise finds the datasource among JCAManagedConnectionFactories, otherwise returns null.
+ *
+ * @param dbName
+ * @return datasource
+ */
+ public static DataSource getDataSource(String dsName) {
+ try {
+ if (SYSTEM_DATASOURCE_NAME!=null && ((String)SYSTEM_DATASOURCE_NAME.getName().get(NameFactory.J2EE_NAME)).equalsIgnoreCase(dsName)) {
+ return (DataSource) KernelRegistry.getSingleKernel().invoke(
+ SYSTEM_DATASOURCE_NAME, "$getResource");
+ }
+ } catch (Exception e) {
+ log.error("Problem getting datasource " + dsName, e);
+ }
+
+ Kernel kernel = KernelRegistry.getSingleKernel();
+ ManagementHelper helper = new KernelManagementHelper(kernel);
+ ResourceAdapterModule[] modules = helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0], "javax.sql.DataSource");
+ for (ResourceAdapterModule module : modules) {
+ org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[] databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
+ for (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory db : databases) {
+ try {
+ AbstractName dbName = kernel.getAbstractNameFor(db);
+ String datasourceName = (String)dbName.getName().get(NameFactory.J2EE_NAME);
+ if(dsName.equalsIgnoreCase(datasourceName)) {
+ AbstractName tempDbName = helper.getNameFor(db);
+ return (DataSource) KernelRegistry.getSingleKernel().invoke(
+ tempDbName, "$getResource");
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ return null;
+ }
+
}
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java Mon Sep 29 11:09:17 2008
@@ -132,19 +132,20 @@
return result;
}
- public String runSQL(String dbName, String sql) {
+ public String runSQL(String dsName, String sql) {
String result = SQL_SUCCESS_MSG;
if ((sql == null) || (sql.trim().length() == 0)) {
result = SQL_EMPTY_MSG;
return result;
}
+
Connection conn = null;
Statement s = null;
try {
- conn = DerbyConnectionUtil.getDerbyConnection(dbName);
+ conn = DerbyConnectionUtil.getDataSourceConnection(dsName);
conn.setAutoCommit(false);
s = conn.createStatement();
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java Mon Sep 29 11:09:17 2008
@@ -60,6 +60,8 @@
private PortletRequestDispatcher helpView;
private Collection databases;
+
+ private Collection<String> dataSourceNames;
private String action;
@@ -108,33 +110,36 @@
}
String singleSelectStmt;
- if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
- databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
- renderRequest.setAttribute("databases", databases);
- if (RUNSQL_ACTION.equals(action)) {
- // check if it's a single Select statement
- if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';') == -1)
- && sqlStmts.trim().toUpperCase().startsWith("SELECT")
- && RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
- singleSelectStmt = sqlStmts.trim();
- // set action result to blank so it won't display
- actionResult = "";
- } else {
- singleSelectStmt = "";
- }
- renderRequest.setAttribute("useDB", useDB);
- renderRequest
- .setAttribute("singleSelectStmt", singleSelectStmt);
- renderRequest.setAttribute("ds", DerbyConnectionUtil
- .getDataSource(useDB));
- }
- if ((action != null) && (action.trim().length() > 0)) {
- renderRequest.setAttribute("actionResult", actionResult);
- //set action to null so that subsequent renders of portlet
- // won't display
- //action result if there is no action to process
- action = null;
+ databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
+ dataSourceNames = dbHelper.getDataSourceNames();
+ renderRequest.setAttribute("databases", databases);
+ renderRequest.setAttribute("dataSourceNames", dataSourceNames);
+ renderRequest.setAttribute("sqlStmts", sqlStmts);
+ renderRequest.setAttribute("useDB", useDB);
+ if (RUNSQL_ACTION.equals(action)) {
+ // check if it's a single Select statement
+ if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';') == -1)
+ && sqlStmts.trim().toUpperCase().startsWith("SELECT")
+ && RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
+ singleSelectStmt = sqlStmts.trim();
+ // set action result to blank so it won't display
+ actionResult = "";
+ } else {
+ singleSelectStmt = "";
}
+ renderRequest
+ .setAttribute("singleSelectStmt", singleSelectStmt);
+ renderRequest.setAttribute("ds", DerbyConnectionUtil
+ .getDataSource(useDB));
+ }
+ if ((action != null) && (action.trim().length() > 0)) {
+ renderRequest.setAttribute("actionResult", actionResult);
+ //set action to null so that subsequent renders of portlet
+ // won't display
+ //action result if there is no action to process
+ action = null;
+ }
+ if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
normalView.include(renderRequest, renderResponse);
} else {
maximizedView.include(renderRequest, renderResponse);
@@ -155,6 +160,7 @@
helpView = portletConfig.getPortletContext().getRequestDispatcher(
HELPVIEW_JSP);
databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
+ dataSourceNames = dbHelper.getDataSourceNames();
}
public void destroy() {
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties Mon Sep 29 11:09:17 2008
@@ -199,7 +199,7 @@
internaldb.common.tableTypes = Table Types
internaldb.common.tables = Tables
internaldb.common.timeDateFunctions = Time Date Functions
-internaldb.common.useDB = Use DB
+internaldb.common.useDB = Use DataSource
internaldb.common.userName = Username
internaldb.common.viewContents = View Contents
internaldb.common.viewDatabases = View Databases
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp Mon Sep 29 11:09:17 2008
@@ -1,17 +0,0 @@
-<%--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---%>
-<%@ include file="listDatabases.jsp" %>
Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp?rev=700193&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp (added)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp Mon Sep 29 11:09:17 2008
@@ -0,0 +1,17 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ include file="listDatabases.jsp" %>
Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp?rev=700193&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp (added)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp Mon Sep 29 11:09:17 2008
@@ -0,0 +1,17 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ include file="listTables.jsp" %>
Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp?rev=700193&r1=700192&r2=700193&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp (original)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp Mon Sep 29 11:09:17 2008
@@ -67,15 +67,15 @@
<td><div align="right"><fmt:message key="internaldb.common.useDB"/>:</div></td>
<td>
<select name="useDB">
- <c:forEach var="db" items="${databases}" varStatus="status">
- <option value="${db}">${db}</option>
+ <c:forEach var="dsName" items="${dataSourceNames}" varStatus="status">
+ <option value="${dsName}"<c:if test="${useDB==dsName}"> selected="selected"</c:if>>${dsName}</option>
</c:forEach>
</select>
<input type="submit" value="Run SQL" onClick="return <portlet:namespace/>validateForm3();"></td>
</tr>
<tr>
<td></td>
- <td><div align="left"><fmt:message key="internaldb.common.SQLCommands"/>:</td>
+ <td><div align="left"><fmt:message key="internaldb.common.SQLCommands"/>:</div></td>
</tr>
<tr>
<td></td>
@@ -113,17 +113,6 @@
<%-- Display query result from single select statement --%>
<c:if test="${!empty singleSelectStmt}">
-<%-- Datasource --%>
-<c:if test="${ds == null}">
- <%-- Create the connection manually --%>
- <sql:setDataSource
- var="ds"
- driver="org.apache.derby.jdbc.EmbeddedDriver"
- url="jdbc:derby:${useDB};create=true"
- user=""
- password=""
- />
-</c:if>
<%-- Select statement --%>
<sql:transaction dataSource="${ds}">
Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp?rev=700193&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp (added)
+++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp Mon Sep 29 11:09:17 2008
@@ -0,0 +1,17 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ include file="viewTableContents.jsp" %>
Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Re: svn commit: r700193 - in /geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main:
java/org/apache/geronimo/console/internaldb/ resources/ webapp/WEB-INF/view/internaldb/
Posted by Donald Woods <dw...@apache.org>.
Yep, I think that was the case.
-Donald
David Jencks wrote:
>
> On Mar 4, 2009, at 12:52 PM, Joe Bohn wrote:
>
>>
>> I know this is going way back in time ... but any idea why this change
>> deleted the content of dbViewerMaximized.jsp but kept the empty file
>> around?
>
> That's easy to do when you run patch -p0 which can empty files but not
> run svn rm on them.
>>
>>
>> I discovered this when checking for source headers. This file is
>> flagged because it doesn't contain a header - but more than that it
>> doesn't contain anything at all.
>>
>> I presume we can delete the entire file. Does anybody know of any
>> reason why we should not do this?
>>
>> There are a few other instances of similar files that we need to deal
>> with as well.
>
> I expect the *Maximized.jsp were never referenced and the patch author
> deleted them but did not succeed in conveying the need to run svn rm to
> the patch applier.
>
> thanks
> david jencks
>
>>
>>
>> Joe
>>
>> dwoods@apache.org wrote:
>>> Author: dwoods
>>> Date: Mon Sep 29 11:09:17 2008
>>> New Revision: 700193
>>> URL: http://svn.apache.org/viewvc?rev=700193&view=rev
>>> Log:
>>> GERONIMO-4225 Allow Run SQL portlet run sql against any configured
>>> data source. Thanks to Michal Borowiecki for the patch.
>>> Added:
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
>>> (with props)
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
>>> (with props)
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
>>> (with props)
>>> Modified:
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
>>>
>>>
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>>>
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
>>> Mon Sep 29 11:09:17 2008
>>> @@ -18,9 +18,20 @@
>>> package org.apache.geronimo.console.internaldb;
>>> import java.io.File;
>>> +import java.util.ArrayList;
>>> import java.util.Collection;
>>> +import java.util.List;
>>> import java.util.Vector;
>>> +import org.apache.geronimo.console.util.KernelManagementHelper;
>>> +import org.apache.geronimo.console.util.ManagementHelper;
>>> +import org.apache.geronimo.console.util.PortletManager;
>>> +import org.apache.geronimo.gbean.AbstractName;
>>> +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
>>> +import org.apache.geronimo.kernel.Kernel;
>>> +import org.apache.geronimo.kernel.KernelRegistry;
>>> +import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
>>> +
>>> public class DBViewerHelper {
>>> private static final String SYS_TBL_PREFIX = "SYS.";
>>> @@ -28,6 +39,34 @@
>>> private static final int COUNT_COL = 1;
>>> /**
>>> + * List the databases having datasources deployed.
>>> + *
>>> + * @param derbySysHome
>>> + * @return
>>> + */
>>> + public Collection<String> getDataSourceNames() {
>>> +
>>> + List<String> databaseNames = new ArrayList<String>();
>>> +
>>> + Kernel kernel = KernelRegistry.getSingleKernel();
>>> + ManagementHelper helper = new KernelManagementHelper(kernel);
>>> + ResourceAdapterModule[] modules =
>>> helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0],
>>> "javax.sql.DataSource");
>>> + for (ResourceAdapterModule module : modules) {
>>> +
>>> org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[]
>>> databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
>>> + for
>>> (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory
>>> db : databases) {
>>> + try {
>>> + AbstractName dbName =
>>> kernel.getAbstractNameFor(db);
>>> + String datasourceName =
>>> (String)dbName.getName().get(NameFactory.J2EE_NAME);
>>> + databaseNames.add(datasourceName);
>>> + } catch (Exception ignored) {
>>> + }
>>> + }
>>> + }
>>> +
>>> + return databaseNames;
>>> + }
>>> + + /**
>>> * List the databases given the derby home directory.
>>> *
>>> * @param derbySysHome
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
>>> Mon Sep 29 11:09:17 2008
>>> @@ -40,16 +40,20 @@
>>> private static final int RDBMS_MSSQL = 2;
>>> - private static final String MAXIMIZEDVIEW_JSP =
>>> "/WEB-INF/view/internaldb/dbViewerMaximized.jsp";
>>> -
>>> private static final String HELPVIEW_JSP =
>>> "/WEB-INF/view/internaldb/dbViewerHelp.jsp";
>>> private static final String LISTDATABASES_JSP =
>>> "/WEB-INF/view/internaldb/listDatabases.jsp";
>>> + private static final String LISTDATABASES_MAXIMIZEDVIEW_JSP =
>>> "/WEB-INF/view/internaldb/listDatabasesMaximized.jsp";
>>> +
>>> private static final String LISTTABLES_JSP =
>>> "/WEB-INF/view/internaldb/listTables.jsp";
>>> + private static final String LISTTABLES_MAXIMIZEDVIEW_JSP =
>>> "/WEB-INF/view/internaldb/listTablesMaximized.jsp";
>>> +
>>> private static final String VIEWTABLECONTENTS_JSP =
>>> "/WEB-INF/view/internaldb/viewTableContents.jsp";
>>> + private static final String VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP
>>> = "/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp";
>>> +
>>> private static final String LISTDB_ACTION = "listDatabases";
>>> private static final String LISTTBLS_ACTION = "listTables";
>>> @@ -58,8 +62,6 @@
>>> private static DBViewerHelper helper = new DBViewerHelper();
>>> - private PortletRequestDispatcher maximizedView;
>>> -
>>> private PortletRequestDispatcher helpView;
>>> private PortletRequestDispatcher listDatabasesView;
>>> @@ -68,6 +70,12 @@
>>> private PortletRequestDispatcher viewTableContentsView;
>>> + private PortletRequestDispatcher listDatabasesMaximizedView;
>>> +
>>> + private PortletRequestDispatcher listTablesMaximizedView;
>>> +
>>> + private PortletRequestDispatcher viewTableContentsMaximizedView;
>>> +
>>> public void processAction(ActionRequest actionRequest,
>>> ActionResponse actionResponse) throws
>>> PortletException, IOException {
>>> // getting parameters here because it fails on doView()
>>> @@ -106,47 +114,56 @@
>>> String rdbms = renderRequest.getParameter("rdbms");
>>> int rdbmsParam = (rdbms == null ? RDBMS_DERBY :
>>> Integer.parseInt(rdbms));
>>> - if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> - if (rdbmsParam == RDBMS_DERBY) {
>>> - // Check is database & table is valid
>>> - if (LISTTBLS_ACTION.equals(action)
>>> - || VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> - if
>>> (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
>>> - // DB not valid
>>> - log.error("Database is not valid: " + db);
>>> - action = "";
>>> - }
>>> + if (rdbmsParam == RDBMS_DERBY) {
>>> + // Check is database & table is valid
>>> + if (LISTTBLS_ACTION.equals(action)
>>> + || VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> + if
>>> (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
>>> + // DB not valid
>>> + log.error("Database is not valid: " + db);
>>> + action = "";
>>> }
>>> - if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> - if (!helper.isTblValid(db, tbl)) {
>>> - // Table not valid
>>> - log.error("Table is not valid: " + tbl);
>>> - action = "";
>>> - }
>>> + }
>>> + if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> + if (!helper.isTblValid(db, tbl)) {
>>> + // Table not valid
>>> + log.error("Table is not valid: " + tbl);
>>> + action = "";
>>> }
>>> }
>>> + }
>>> - renderRequest.setAttribute("rdbms", rdbms);
>>> - if (LISTTBLS_ACTION.equals(action)) {
>>> - renderRequest.setAttribute("db", db);
>>> - renderRequest.setAttribute("viewTables", viewTables);
>>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> - .getDataSource(db));
>>> - listTablesView.include(renderRequest, renderResponse);
>>> - } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> - renderRequest.setAttribute("db", db);
>>> - renderRequest.setAttribute("tbl", tbl);
>>> - renderRequest.setAttribute("viewTables", viewTables);
>>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> - .getDataSource(db));
>>> - viewTableContentsView.include(renderRequest,
>>> renderResponse);
>>> + renderRequest.setAttribute("rdbms", rdbms);
>>> + if (LISTTBLS_ACTION.equals(action)) {
>>> + renderRequest.setAttribute("db", db);
>>> + renderRequest.setAttribute("viewTables", viewTables);
>>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> + .getDataSourceForDataBaseName(db));
>>> +
>>> + if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> + listTablesView.include(renderRequest, renderResponse);
>>> } else {
>>> - renderRequest.setAttribute("databases", helper
>>> -
>>> .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
>>> - listDatabasesView.include(renderRequest,
>>> renderResponse);
>>> + listTablesMaximizedView.include(renderRequest,
>>> renderResponse);
>>> + }
>>> + } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>>> + renderRequest.setAttribute("db", db);
>>> + renderRequest.setAttribute("tbl", tbl);
>>> + renderRequest.setAttribute("viewTables", viewTables);
>>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> + .getDataSourceForDataBaseName(db));
>>> + if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> + viewTableContentsView.include(renderRequest,
>>> renderResponse);
>>> + } else {
>>> +
>>> viewTableContentsMaximizedView.include(renderRequest, renderResponse);
>>> }
>>> } else {
>>> - maximizedView.include(renderRequest, renderResponse);
>>> + renderRequest.setAttribute("databases", helper
>>> +
>>> .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
>>> + if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> + listDatabasesView.include(renderRequest,
>>> renderResponse);
>>> + } else {
>>> + listDatabasesMaximizedView.include(renderRequest,
>>> renderResponse);
>>> + }
>>> }
>>> }
>>> @@ -157,8 +174,6 @@
>>> public void init(PortletConfig portletConfig) throws
>>> PortletException {
>>> super.init(portletConfig);
>>> - maximizedView =
>>> portletConfig.getPortletContext().getRequestDispatcher(
>>> - MAXIMIZEDVIEW_JSP);
>>> helpView =
>>> portletConfig.getPortletContext().getRequestDispatcher(
>>> HELPVIEW_JSP);
>>> listDatabasesView = portletConfig.getPortletContext()
>>> @@ -167,14 +182,22 @@
>>> .getRequestDispatcher(LISTTABLES_JSP);
>>> viewTableContentsView = portletConfig.getPortletContext()
>>> .getRequestDispatcher(VIEWTABLECONTENTS_JSP);
>>> + listDatabasesMaximizedView = portletConfig.getPortletContext()
>>> + .getRequestDispatcher(LISTDATABASES_MAXIMIZEDVIEW_JSP);
>>> + listTablesMaximizedView = portletConfig.getPortletContext()
>>> + .getRequestDispatcher(LISTTABLES_MAXIMIZEDVIEW_JSP);
>>> + viewTableContentsMaximizedView =
>>> portletConfig.getPortletContext()
>>> +
>>> .getRequestDispatcher(VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP);
>>> }
>>> public void destroy() {
>>> - maximizedView = null;
>>> helpView = null;
>>> listDatabasesView = null;
>>> listTablesView = null;
>>> viewTableContentsView = null;
>>> + listDatabasesMaximizedView = null;
>>> + listTablesMaximizedView = null;
>>> + viewTableContentsMaximizedView = null;
>>> super.destroy();
>>> }
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
>>> Mon Sep 29 11:09:17 2008
>>> @@ -166,7 +166,7 @@
>>> public static Connection getSystemDBConnection() throws
>>> SQLException {
>>> DataSource ds = null;
>>> try {
>>> - ds = getDataSource(SYSTEM_DB);
>>> + ds = getDataSourceForDataBaseName(SYSTEM_DB);
>>> return ds.getConnection();
>>> } catch (Exception e) {
>>> throw new SQLException(e.getMessage());
>>> @@ -174,12 +174,27 @@
>>> }
>>> /**
>>> - * Get the datasource if dbName is == SYSTEM_DB, otherwise
>>> returns null.
>>> + * Get a connaction to a named datasource
>>> + * + * @param dbName
>>> + * @return
>>> + * @throws SQLException + */
>>> + public static Connection getDataSourceConnection(String
>>> dataSourceName) throws SQLException{
>>> + try {
>>> + return getDataSource(dataSourceName).getConnection();
>>> + } catch (Exception e) {
>>> + throw new SQLException(e.getMessage());
>>> + }
>>> + }
>>> +
>>> + /**
>>> + * Get the datasource if dbName is == SYSTEM_DB, otherwise finds
>>> the datasource among JCAManagedConnectionFactories, otherwise returns
>>> null.
>>> *
>>> * @param dbName
>>> * @return datasource
>>> */
>>> - public static DataSource getDataSource(String dbName) {
>>> + public static DataSource getDataSourceForDataBaseName(String
>>> dbName) {
>>> try {
>>> if (SYSTEM_DATASOURCE_NAME!=null &&
>>> SYSTEM_DB.equalsIgnoreCase(dbName)) {
>>> return (DataSource)
>>> KernelRegistry.getSingleKernel().invoke(
>>> @@ -210,4 +225,42 @@
>>> return null;
>>> }
>>> + /**
>>> + * Get the datasource if dbName is == SYSTEM_DB, otherwise finds
>>> the datasource among JCAManagedConnectionFactories, otherwise returns
>>> null.
>>> + *
>>> + * @param dbName
>>> + * @return datasource
>>> + */
>>> + public static DataSource getDataSource(String dsName) {
>>> + try {
>>> + if (SYSTEM_DATASOURCE_NAME!=null &&
>>> ((String)SYSTEM_DATASOURCE_NAME.getName().get(NameFactory.J2EE_NAME)).equalsIgnoreCase(dsName))
>>> {
>>> + return (DataSource)
>>> KernelRegistry.getSingleKernel().invoke(
>>> + SYSTEM_DATASOURCE_NAME, "$getResource");
>>> + }
>>> + } catch (Exception e) {
>>> + log.error("Problem getting datasource " + dsName, e);
>>> + }
>>> + + Kernel kernel = KernelRegistry.getSingleKernel();
>>> + ManagementHelper helper = new KernelManagementHelper(kernel);
>>> + ResourceAdapterModule[] modules =
>>> helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0],
>>> "javax.sql.DataSource");
>>> + for (ResourceAdapterModule module : modules) {
>>> +
>>> org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[]
>>> databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
>>> + for
>>> (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory
>>> db : databases) {
>>> + try {
>>> + AbstractName dbName =
>>> kernel.getAbstractNameFor(db);
>>> + String datasourceName =
>>> (String)dbName.getName().get(NameFactory.J2EE_NAME);
>>> + if(dsName.equalsIgnoreCase(datasourceName)) {
>>> + AbstractName tempDbName =
>>> helper.getNameFor(db);
>>> + return (DataSource)
>>> KernelRegistry.getSingleKernel().invoke(
>>> + tempDbName, "$getResource");
>>> + }
>>> + } catch (Exception ignored) {
>>> + }
>>> + }
>>> + }
>>> + + return null;
>>> + }
>>> +
>>> }
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
>>> Mon Sep 29 11:09:17 2008
>>> @@ -132,19 +132,20 @@
>>> return result;
>>> }
>>> - public String runSQL(String dbName, String sql) {
>>> + public String runSQL(String dsName, String sql) {
>>> String result = SQL_SUCCESS_MSG;
>>> if ((sql == null) || (sql.trim().length() == 0)) {
>>> result = SQL_EMPTY_MSG;
>>> return result;
>>> }
>>> + Connection conn = null;
>>> Statement s = null;
>>> try {
>>> - conn = DerbyConnectionUtil.getDerbyConnection(dbName);
>>> + conn = DerbyConnectionUtil.getDataSourceConnection(dsName);
>>> conn.setAutoCommit(false);
>>> s = conn.createStatement();
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
>>> Mon Sep 29 11:09:17 2008
>>> @@ -60,6 +60,8 @@
>>> private PortletRequestDispatcher helpView;
>>> private Collection databases;
>>> + + private Collection<String> dataSourceNames;
>>> private String action;
>>> @@ -108,33 +110,36 @@
>>> }
>>> String singleSelectStmt;
>>> - if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> - databases =
>>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>>> - renderRequest.setAttribute("databases", databases);
>>> - if (RUNSQL_ACTION.equals(action)) {
>>> - // check if it's a single Select statement
>>> - if ((sqlStmts != null) &&
>>> (sqlStmts.trim().indexOf(';') == -1)
>>> - &&
>>> sqlStmts.trim().toUpperCase().startsWith("SELECT")
>>> - &&
>>> RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
>>> - singleSelectStmt = sqlStmts.trim();
>>> - // set action result to blank so it won't display
>>> - actionResult = "";
>>> - } else {
>>> - singleSelectStmt = "";
>>> - }
>>> - renderRequest.setAttribute("useDB", useDB);
>>> - renderRequest
>>> - .setAttribute("singleSelectStmt",
>>> singleSelectStmt);
>>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> - .getDataSource(useDB));
>>> - }
>>> - if ((action != null) && (action.trim().length() > 0)) {
>>> - renderRequest.setAttribute("actionResult",
>>> actionResult);
>>> - //set action to null so that subsequent renders of
>>> portlet
>>> - // won't display
>>> - //action result if there is no action to process
>>> - action = null;
>>> + databases =
>>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>>> + dataSourceNames = dbHelper.getDataSourceNames();
>>> + renderRequest.setAttribute("databases", databases);
>>> + renderRequest.setAttribute("dataSourceNames", dataSourceNames);
>>> + renderRequest.setAttribute("sqlStmts", sqlStmts);
>>> + renderRequest.setAttribute("useDB", useDB);
>>> + if (RUNSQL_ACTION.equals(action)) {
>>> + // check if it's a single Select statement
>>> + if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';')
>>> == -1)
>>> + &&
>>> sqlStmts.trim().toUpperCase().startsWith("SELECT")
>>> + &&
>>> RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
>>> + singleSelectStmt = sqlStmts.trim();
>>> + // set action result to blank so it won't display
>>> + actionResult = "";
>>> + } else {
>>> + singleSelectStmt = "";
>>> }
>>> + renderRequest
>>> + .setAttribute("singleSelectStmt",
>>> singleSelectStmt);
>>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>>> + .getDataSource(useDB));
>>> + }
>>> + if ((action != null) && (action.trim().length() > 0)) {
>>> + renderRequest.setAttribute("actionResult", actionResult);
>>> + //set action to null so that subsequent renders of portlet
>>> + // won't display
>>> + //action result if there is no action to process
>>> + action = null;
>>> + }
>>> + if
>>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>>> normalView.include(renderRequest, renderResponse);
>>> } else {
>>> maximizedView.include(renderRequest, renderResponse);
>>> @@ -155,6 +160,7 @@
>>> helpView =
>>> portletConfig.getPortletContext().getRequestDispatcher(
>>> HELPVIEW_JSP);
>>> databases =
>>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>>> + dataSourceNames = dbHelper.getDataSourceNames();
>>> }
>>> public void destroy() {
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
>>> Mon Sep 29 11:09:17 2008
>>> @@ -199,7 +199,7 @@
>>> internaldb.common.tableTypes = Table Types
>>> internaldb.common.tables = Tables
>>> internaldb.common.timeDateFunctions = Time Date Functions
>>> -internaldb.common.useDB = Use DB
>>> +internaldb.common.useDB = Use DataSource
>>> internaldb.common.userName = Username
>>> internaldb.common.viewContents = View Contents
>>> internaldb.common.viewDatabases = View Databases
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
>>> Mon Sep 29 11:09:17 2008
>>> @@ -1,17 +0,0 @@
>>> -<%--
>>> - Licensed to the Apache Software Foundation (ASF) under one or more
>>> - contributor license agreements. See the NOTICE file distributed
>>> with
>>> - this work for additional information regarding copyright ownership.
>>> - The ASF licenses this file to You under the Apache License,
>>> Version 2.0
>>> - (the "License"); you may not use this file except in compliance with
>>> - the License. You may obtain a copy of the License at
>>> -
>>> - http://www.apache.org/licenses/LICENSE-2.0
>>> -
>>> - Unless required by applicable law or agreed to in writing, software
>>> - distributed under the License is distributed on an "AS IS" BASIS,
>>> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> - See the License for the specific language governing permissions and
>>> - limitations under the License.
>>> ---%>
>>> -<%@ include file="listDatabases.jsp" %>
>>> Added:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp?rev=700193&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
>>> (added)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
>>> Mon Sep 29 11:09:17 2008
>>> @@ -0,0 +1,17 @@
>>> +<%--
>>> + Licensed to the Apache Software Foundation (ASF) under one or more
>>> + contributor license agreements. See the NOTICE file distributed
>>> with
>>> + this work for additional information regarding copyright ownership.
>>> + The ASF licenses this file to You under the Apache License,
>>> Version 2.0
>>> + (the "License"); you may not use this file except in compliance with
>>> + the License. You may obtain a copy of the License at
>>> +
>>> + http://www.apache.org/licenses/LICENSE-2.0
>>> +
>>> + Unless required by applicable law or agreed to in writing, software
>>> + distributed under the License is distributed on an "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> + See the License for the specific language governing permissions and
>>> + limitations under the License.
>>> +--%>
>>> +<%@ include file="listDatabases.jsp" %>
>>> Propchange:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> svn:eol-style = native
>>> Added:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp?rev=700193&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
>>> (added)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
>>> Mon Sep 29 11:09:17 2008
>>> @@ -0,0 +1,17 @@
>>> +<%--
>>> + Licensed to the Apache Software Foundation (ASF) under one or more
>>> + contributor license agreements. See the NOTICE file distributed
>>> with
>>> + this work for additional information regarding copyright ownership.
>>> + The ASF licenses this file to You under the Apache License,
>>> Version 2.0
>>> + (the "License"); you may not use this file except in compliance with
>>> + the License. You may obtain a copy of the License at
>>> +
>>> + http://www.apache.org/licenses/LICENSE-2.0
>>> +
>>> + Unless required by applicable law or agreed to in writing, software
>>> + distributed under the License is distributed on an "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> + See the License for the specific language governing permissions and
>>> + limitations under the License.
>>> +--%>
>>> +<%@ include file="listTables.jsp" %>
>>> Propchange:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> svn:eol-style = native
>>> Modified:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp?rev=700193&r1=700192&r2=700193&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>>> (original)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>>> Mon Sep 29 11:09:17 2008
>>> @@ -67,15 +67,15 @@
>>> <td><div align="right"><fmt:message
>>> key="internaldb.common.useDB"/>:</div></td>
>>> <td>
>>> <select name="useDB">
>>> - <c:forEach var="db" items="${databases}" varStatus="status">
>>> - <option value="${db}">${db}</option>
>>> + <c:forEach var="dsName" items="${dataSourceNames}"
>>> varStatus="status">
>>> + <option value="${dsName}"<c:if test="${useDB==dsName}">
>>> selected="selected"</c:if>>${dsName}</option>
>>> </c:forEach>
>>> </select>
>>> <input type="submit" value="Run SQL" onClick="return
>>> <portlet:namespace/>validateForm3();"></td>
>>> </tr>
>>> <tr>
>>> <td></td>
>>> - <td><div align="left"><fmt:message
>>> key="internaldb.common.SQLCommands"/>:</td>
>>> + <td><div align="left"><fmt:message
>>> key="internaldb.common.SQLCommands"/>:</div></td>
>>> </tr>
>>> <tr>
>>> <td></td>
>>> @@ -113,17 +113,6 @@
>>> <%-- Display query result from single select statement --%>
>>> <c:if test="${!empty singleSelectStmt}">
>>> -<%-- Datasource --%>
>>> -<c:if test="${ds == null}">
>>> - <%-- Create the connection manually --%>
>>> - <sql:setDataSource
>>> - var="ds"
>>> - driver="org.apache.derby.jdbc.EmbeddedDriver"
>>> - url="jdbc:derby:${useDB};create=true"
>>> - user=""
>>> - password=""
>>> - />
>>> -</c:if>
>>> <%-- Select statement --%>
>>> <sql:transaction dataSource="${ds}">
>>> Added:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp?rev=700193&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
>>> (added)
>>> +++
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
>>> Mon Sep 29 11:09:17 2008
>>> @@ -0,0 +1,17 @@
>>> +<%--
>>> + Licensed to the Apache Software Foundation (ASF) under one or more
>>> + contributor license agreements. See the NOTICE file distributed
>>> with
>>> + this work for additional information regarding copyright ownership.
>>> + The ASF licenses this file to You under the Apache License,
>>> Version 2.0
>>> + (the "License"); you may not use this file except in compliance with
>>> + the License. You may obtain a copy of the License at
>>> +
>>> + http://www.apache.org/licenses/LICENSE-2.0
>>> +
>>> + Unless required by applicable law or agreed to in writing, software
>>> + distributed under the License is distributed on an "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> + See the License for the specific language governing permissions and
>>> + limitations under the License.
>>> +--%>
>>> +<%@ include file="viewTableContents.jsp" %>
>>> Propchange:
>>> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> svn:eol-style = native
>>
>
>
Re: svn commit: r700193 - in /geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main: java/org/apache/geronimo/console/internaldb/ resources/ webapp/WEB-INF/view/internaldb/
Posted by David Jencks <da...@yahoo.com>.
On Mar 4, 2009, at 12:52 PM, Joe Bohn wrote:
>
> I know this is going way back in time ... but any idea why this
> change deleted the content of dbViewerMaximized.jsp but kept the
> empty file around?
That's easy to do when you run patch -p0 which can empty files but not
run svn rm on them.
>
>
> I discovered this when checking for source headers. This file is
> flagged because it doesn't contain a header - but more than that it
> doesn't contain anything at all.
>
> I presume we can delete the entire file. Does anybody know of any
> reason why we should not do this?
>
> There are a few other instances of similar files that we need to
> deal with as well.
I expect the *Maximized.jsp were never referenced and the patch author
deleted them but did not succeed in conveying the need to run svn rm
to the patch applier.
thanks
david jencks
>
>
> Joe
>
> dwoods@apache.org wrote:
>> Author: dwoods
>> Date: Mon Sep 29 11:09:17 2008
>> New Revision: 700193
>> URL: http://svn.apache.org/viewvc?rev=700193&view=rev
>> Log:
>> GERONIMO-4225 Allow Run SQL portlet run sql against any configured
>> data source. Thanks to Michal Borowiecki for the patch.
>> Added:
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listDatabasesMaximized.jsp (with props)
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listTablesMaximized.jsp (with props)
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp (with props)
>> Modified:
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerHelper.java
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerPortlet.java
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DerbyConnectionUtil.java
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLHelper.java
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLPortlet.java
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/resources/systemdatabase.properties
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> dbViewerMaximized.jsp
>> geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerHelper.java
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerHelper.java (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerHelper.java Mon Sep 29 11:09:17 2008
>> @@ -18,9 +18,20 @@
>> package org.apache.geronimo.console.internaldb;
>> import java.io.File;
>> +import java.util.ArrayList;
>> import java.util.Collection;
>> +import java.util.List;
>> import java.util.Vector;
>> +import org.apache.geronimo.console.util.KernelManagementHelper;
>> +import org.apache.geronimo.console.util.ManagementHelper;
>> +import org.apache.geronimo.console.util.PortletManager;
>> +import org.apache.geronimo.gbean.AbstractName;
>> +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
>> +import org.apache.geronimo.kernel.Kernel;
>> +import org.apache.geronimo.kernel.KernelRegistry;
>> +import
>> org.apache.geronimo.management.geronimo.ResourceAdapterModule;
>> +
>> public class DBViewerHelper {
>> private static final String SYS_TBL_PREFIX = "SYS.";
>> @@ -28,6 +39,34 @@
>> private static final int COUNT_COL = 1;
>> /**
>> + * List the databases having datasources deployed.
>> + *
>> + * @param derbySysHome
>> + * @return
>> + */
>> + public Collection<String> getDataSourceNames() {
>> +
>> + List<String> databaseNames = new ArrayList<String>();
>> +
>> + Kernel kernel = KernelRegistry.getSingleKernel();
>> + ManagementHelper helper = new
>> KernelManagementHelper(kernel);
>> + ResourceAdapterModule[] modules =
>> helper.getOutboundRAModules(helper.getDomains()
>> [0].getServerInstances()[0], "javax.sql.DataSource");
>> + for (ResourceAdapterModule module : modules) {
>> +
>> org
>> .apache.geronimo.management.geronimo.JCAManagedConnectionFactory[]
>> databases = helper.getOutboundFactories(module,
>> "javax.sql.DataSource");
>> + for
>> (org
>> .apache.geronimo.management.geronimo.JCAManagedConnectionFactory
>> db : databases) {
>> + try {
>> + AbstractName dbName =
>> kernel.getAbstractNameFor(db);
>> + String datasourceName =
>> (String)dbName.getName().get(NameFactory.J2EE_NAME);
>> + databaseNames.add(datasourceName);
>> + } catch (Exception ignored) {
>> + }
>> + }
>> + }
>> +
>> + return databaseNames;
>> + }
>> + + /**
>> * List the databases given the derby home directory.
>> *
>> * @param derbySysHome
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerPortlet.java
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerPortlet.java (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DBViewerPortlet.java Mon Sep 29 11:09:17 2008
>> @@ -40,16 +40,20 @@
>> private static final int RDBMS_MSSQL = 2;
>> - private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/
>> internaldb/dbViewerMaximized.jsp";
>> -
>> private static final String HELPVIEW_JSP = "/WEB-INF/view/
>> internaldb/dbViewerHelp.jsp";
>> private static final String LISTDATABASES_JSP = "/WEB-INF/view/
>> internaldb/listDatabases.jsp";
>> + private static final String LISTDATABASES_MAXIMIZEDVIEW_JSP =
>> "/WEB-INF/view/internaldb/listDatabasesMaximized.jsp";
>> +
>> private static final String LISTTABLES_JSP = "/WEB-INF/view/
>> internaldb/listTables.jsp";
>> + private static final String LISTTABLES_MAXIMIZEDVIEW_JSP = "/
>> WEB-INF/view/internaldb/listTablesMaximized.jsp";
>> +
>> private static final String VIEWTABLECONTENTS_JSP = "/WEB-INF/
>> view/internaldb/viewTableContents.jsp";
>> + private static final String
>> VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp";
>> +
>> private static final String LISTDB_ACTION = "listDatabases";
>> private static final String LISTTBLS_ACTION = "listTables";
>> @@ -58,8 +62,6 @@
>> private static DBViewerHelper helper = new DBViewerHelper();
>> - private PortletRequestDispatcher maximizedView;
>> -
>> private PortletRequestDispatcher helpView;
>> private PortletRequestDispatcher listDatabasesView;
>> @@ -68,6 +70,12 @@
>> private PortletRequestDispatcher viewTableContentsView;
>> + private PortletRequestDispatcher listDatabasesMaximizedView;
>> +
>> + private PortletRequestDispatcher listTablesMaximizedView;
>> +
>> + private PortletRequestDispatcher viewTableContentsMaximizedView;
>> +
>> public void processAction(ActionRequest actionRequest,
>> ActionResponse actionResponse) throws
>> PortletException, IOException {
>> // getting parameters here because it fails on doView()
>> @@ -106,47 +114,56 @@
>> String rdbms = renderRequest.getParameter("rdbms");
>> int rdbmsParam = (rdbms == null ? RDBMS_DERBY :
>> Integer.parseInt(rdbms));
>> - if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> - if (rdbmsParam == RDBMS_DERBY) {
>> - // Check is database & table is valid
>> - if (LISTTBLS_ACTION.equals(action)
>> - || VIEWTBLCONTENTS_ACTION.equals(action)) {
>> - if (!
>> helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
>> - // DB not valid
>> - log.error("Database is not valid: " + db);
>> - action = "";
>> - }
>> + if (rdbmsParam == RDBMS_DERBY) {
>> + // Check is database & table is valid
>> + if (LISTTBLS_ACTION.equals(action)
>> + || VIEWTBLCONTENTS_ACTION.equals(action)) {
>> + if (!
>> helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
>> + // DB not valid
>> + log.error("Database is not valid: " + db);
>> + action = "";
>> }
>> - if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>> - if (!helper.isTblValid(db, tbl)) {
>> - // Table not valid
>> - log.error("Table is not valid: " + tbl);
>> - action = "";
>> - }
>> + }
>> + if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>> + if (!helper.isTblValid(db, tbl)) {
>> + // Table not valid
>> + log.error("Table is not valid: " + tbl);
>> + action = "";
>> }
>> }
>> + }
>> - renderRequest.setAttribute("rdbms", rdbms);
>> - if (LISTTBLS_ACTION.equals(action)) {
>> - renderRequest.setAttribute("db", db);
>> - renderRequest.setAttribute("viewTables",
>> viewTables);
>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>> - .getDataSource(db));
>> - listTablesView.include(renderRequest,
>> renderResponse);
>> - } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>> - renderRequest.setAttribute("db", db);
>> - renderRequest.setAttribute("tbl", tbl);
>> - renderRequest.setAttribute("viewTables",
>> viewTables);
>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>> - .getDataSource(db));
>> - viewTableContentsView.include(renderRequest,
>> renderResponse);
>> + renderRequest.setAttribute("rdbms", rdbms);
>> + if (LISTTBLS_ACTION.equals(action)) {
>> + renderRequest.setAttribute("db", db);
>> + renderRequest.setAttribute("viewTables", viewTables);
>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>> + .getDataSourceForDataBaseName(db));
>> +
>> + if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> + listTablesView.include(renderRequest, renderResponse);
>> } else {
>> - renderRequest.setAttribute("databases", helper
>> - .getDerbyDatabases
>> (DerbyConnectionUtil.getDerbyHome()));
>> - listDatabasesView.include(renderRequest,
>> renderResponse);
>> + listTablesMaximizedView.include(renderRequest,
>> renderResponse);
>> + }
>> + } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
>> + renderRequest.setAttribute("db", db);
>> + renderRequest.setAttribute("tbl", tbl);
>> + renderRequest.setAttribute("viewTables", viewTables);
>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>> + .getDataSourceForDataBaseName(db));
>> + if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> + viewTableContentsView.include(renderRequest,
>> renderResponse);
>> + } else {
>> + viewTableContentsMaximizedView.include(renderRequest,
>> renderResponse);
>> }
>> } else {
>> - maximizedView.include(renderRequest, renderResponse);
>> + renderRequest.setAttribute("databases", helper
>> +
>> .getDerbyDatabases
>> (DerbyConnectionUtil.getDerbyHome()));
>> + if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> + listDatabasesView.include(renderRequest,
>> renderResponse);
>> + } else {
>> + listDatabasesMaximizedView.include(renderRequest,
>> renderResponse);
>> + }
>> }
>> }
>> @@ -157,8 +174,6 @@
>> public void init(PortletConfig portletConfig) throws
>> PortletException {
>> super.init(portletConfig);
>> - maximizedView =
>> portletConfig.getPortletContext().getRequestDispatcher(
>> - MAXIMIZEDVIEW_JSP);
>> helpView =
>> portletConfig.getPortletContext().getRequestDispatcher(
>> HELPVIEW_JSP);
>> listDatabasesView = portletConfig.getPortletContext()
>> @@ -167,14 +182,22 @@
>> .getRequestDispatcher(LISTTABLES_JSP);
>> viewTableContentsView = portletConfig.getPortletContext()
>> .getRequestDispatcher(VIEWTABLECONTENTS_JSP);
>> + listDatabasesMaximizedView =
>> portletConfig.getPortletContext()
>> + .getRequestDispatcher(LISTDATABASES_MAXIMIZEDVIEW_JSP);
>> + listTablesMaximizedView = portletConfig.getPortletContext()
>> + .getRequestDispatcher(LISTTABLES_MAXIMIZEDVIEW_JSP);
>> + viewTableContentsMaximizedView = portletConfig.getPortletContext()
>> +
>> .getRequestDispatcher(VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP);
>> }
>> public void destroy() {
>> - maximizedView = null;
>> helpView = null;
>> listDatabasesView = null;
>> listTablesView = null;
>> viewTableContentsView = null;
>> + listDatabasesMaximizedView = null;
>> + listTablesMaximizedView = null;
>> + viewTableContentsMaximizedView = null;
>> super.destroy();
>> }
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DerbyConnectionUtil.java
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DerbyConnectionUtil.java (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> DerbyConnectionUtil.java Mon Sep 29 11:09:17 2008
>> @@ -166,7 +166,7 @@
>> public static Connection getSystemDBConnection() throws
>> SQLException {
>> DataSource ds = null;
>> try {
>> - ds = getDataSource(SYSTEM_DB);
>> + ds = getDataSourceForDataBaseName(SYSTEM_DB);
>> return ds.getConnection();
>> } catch (Exception e) {
>> throw new SQLException(e.getMessage());
>> @@ -174,12 +174,27 @@
>> }
>> /**
>> - * Get the datasource if dbName is == SYSTEM_DB, otherwise
>> returns null.
>> + * Get a connaction to a named datasource
>> + * + * @param dbName
>> + * @return
>> + * @throws SQLException + */
>> + public static Connection getDataSourceConnection(String
>> dataSourceName) throws SQLException{
>> + try {
>> + return getDataSource(dataSourceName).getConnection();
>> + } catch (Exception e) {
>> + throw new SQLException(e.getMessage());
>> + }
>> + }
>> +
>> + /**
>> + * Get the datasource if dbName is == SYSTEM_DB, otherwise
>> finds the datasource among JCAManagedConnectionFactories, otherwise
>> returns null.
>> *
>> * @param dbName
>> * @return datasource
>> */
>> - public static DataSource getDataSource(String dbName) {
>> + public static DataSource getDataSourceForDataBaseName(String
>> dbName) {
>> try {
>> if (SYSTEM_DATASOURCE_NAME!=null &&
>> SYSTEM_DB.equalsIgnoreCase(dbName)) {
>> return (DataSource)
>> KernelRegistry.getSingleKernel().invoke(
>> @@ -210,4 +225,42 @@
>> return null;
>> }
>> + /**
>> + * Get the datasource if dbName is == SYSTEM_DB, otherwise
>> finds the datasource among JCAManagedConnectionFactories, otherwise
>> returns null.
>> + *
>> + * @param dbName
>> + * @return datasource
>> + */
>> + public static DataSource getDataSource(String dsName) {
>> + try {
>> + if (SYSTEM_DATASOURCE_NAME!=null &&
>> ((String
>> )SYSTEM_DATASOURCE_NAME
>> .getName().get(NameFactory.J2EE_NAME)).equalsIgnoreCase(dsName)) {
>> + return (DataSource)
>> KernelRegistry.getSingleKernel().invoke(
>> + SYSTEM_DATASOURCE_NAME, "$getResource");
>> + }
>> + } catch (Exception e) {
>> + log.error("Problem getting datasource " + dsName, e);
>> + }
>> + + Kernel kernel = KernelRegistry.getSingleKernel();
>> + ManagementHelper helper = new
>> KernelManagementHelper(kernel);
>> + ResourceAdapterModule[] modules =
>> helper.getOutboundRAModules(helper.getDomains()
>> [0].getServerInstances()[0], "javax.sql.DataSource");
>> + for (ResourceAdapterModule module : modules) {
>> +
>> org
>> .apache.geronimo.management.geronimo.JCAManagedConnectionFactory[]
>> databases = helper.getOutboundFactories(module,
>> "javax.sql.DataSource");
>> + for
>> (org
>> .apache.geronimo.management.geronimo.JCAManagedConnectionFactory
>> db : databases) {
>> + try {
>> + AbstractName dbName =
>> kernel.getAbstractNameFor(db);
>> + String datasourceName =
>> (String)dbName.getName().get(NameFactory.J2EE_NAME);
>> + if(dsName.equalsIgnoreCase(datasourceName)) {
>> + AbstractName tempDbName =
>> helper.getNameFor(db);
>> + return (DataSource)
>> KernelRegistry.getSingleKernel().invoke(
>> + tempDbName, "$getResource");
>> + }
>> + } catch (Exception ignored) {
>> + }
>> + }
>> + }
>> + + return null;
>> + }
>> +
>> }
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLHelper.java
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLHelper.java (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLHelper.java Mon Sep 29 11:09:17 2008
>> @@ -132,19 +132,20 @@
>> return result;
>> }
>> - public String runSQL(String dbName, String sql) {
>> + public String runSQL(String dsName, String sql) {
>> String result = SQL_SUCCESS_MSG;
>> if ((sql == null) || (sql.trim().length() == 0)) {
>> result = SQL_EMPTY_MSG;
>> return result;
>> }
>> + Connection conn = null;
>> Statement s = null;
>> try {
>> - conn = DerbyConnectionUtil.getDerbyConnection(dbName);
>> + conn =
>> DerbyConnectionUtil.getDataSourceConnection(dsName);
>> conn.setAutoCommit(false);
>> s = conn.createStatement();
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLPortlet.java
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLPortlet.java (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/java/org/apache/geronimo/console/internaldb/
>> RunSQLPortlet.java Mon Sep 29 11:09:17 2008
>> @@ -60,6 +60,8 @@
>> private PortletRequestDispatcher helpView;
>> private Collection databases;
>> + + private Collection<String> dataSourceNames;
>> private String action;
>> @@ -108,33 +110,36 @@
>> }
>> String singleSelectStmt;
>> - if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> - databases =
>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>> - renderRequest.setAttribute("databases", databases);
>> - if (RUNSQL_ACTION.equals(action)) {
>> - // check if it's a single Select statement
>> - if ((sqlStmts != null) &&
>> (sqlStmts.trim().indexOf(';') == -1)
>> - &&
>> sqlStmts.trim().toUpperCase().startsWith("SELECT")
>> - &&
>> RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
>> - singleSelectStmt = sqlStmts.trim();
>> - // set action result to blank so it won't
>> display
>> - actionResult = "";
>> - } else {
>> - singleSelectStmt = "";
>> - }
>> - renderRequest.setAttribute("useDB", useDB);
>> - renderRequest
>> - .setAttribute("singleSelectStmt",
>> singleSelectStmt);
>> - renderRequest.setAttribute("ds", DerbyConnectionUtil
>> - .getDataSource(useDB));
>> - }
>> - if ((action != null) && (action.trim().length() > 0)) {
>> - renderRequest.setAttribute("actionResult",
>> actionResult);
>> - //set action to null so that subsequent renders of
>> portlet
>> - // won't display
>> - //action result if there is no action to process
>> - action = null;
>> + databases =
>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>> + dataSourceNames = dbHelper.getDataSourceNames();
>> + renderRequest.setAttribute("databases", databases);
>> + renderRequest.setAttribute("dataSourceNames",
>> dataSourceNames);
>> + renderRequest.setAttribute("sqlStmts", sqlStmts);
>> + renderRequest.setAttribute("useDB", useDB);
>> + if (RUNSQL_ACTION.equals(action)) {
>> + // check if it's a single Select statement
>> + if ((sqlStmts != null) &&
>> (sqlStmts.trim().indexOf(';') == -1)
>> + &&
>> sqlStmts.trim().toUpperCase().startsWith("SELECT")
>> + &&
>> RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
>> + singleSelectStmt = sqlStmts.trim();
>> + // set action result to blank so it won't display
>> + actionResult = "";
>> + } else {
>> + singleSelectStmt = "";
>> }
>> + renderRequest
>> + .setAttribute("singleSelectStmt",
>> singleSelectStmt);
>> + renderRequest.setAttribute("ds", DerbyConnectionUtil
>> + .getDataSource(useDB));
>> + }
>> + if ((action != null) && (action.trim().length() > 0)) {
>> + renderRequest.setAttribute("actionResult",
>> actionResult);
>> + //set action to null so that subsequent renders of
>> portlet
>> + // won't display
>> + //action result if there is no action to process
>> + action = null;
>> + }
>> + if
>> (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
>> normalView.include(renderRequest, renderResponse);
>> } else {
>> maximizedView.include(renderRequest, renderResponse);
>> @@ -155,6 +160,7 @@
>> helpView =
>> portletConfig.getPortletContext().getRequestDispatcher(
>> HELPVIEW_JSP);
>> databases =
>> dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
>> + dataSourceNames = dbHelper.getDataSourceNames();
>> }
>> public void destroy() {
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/resources/systemdatabase.properties
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/resources/systemdatabase.properties (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/resources/systemdatabase.properties Mon Sep 29
>> 11:09:17 2008
>> @@ -199,7 +199,7 @@
>> internaldb.common.tableTypes = Table Types
>> internaldb.common.tables = Tables
>> internaldb.common.timeDateFunctions = Time Date Functions
>> -internaldb.common.useDB = Use DB
>> +internaldb.common.useDB = Use DataSource
>> internaldb.common.userName = Username
>> internaldb.common.viewContents = View Contents
>> internaldb.common.viewDatabases = View Databases
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/
>> dbViewerMaximized.jsp
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> dbViewerMaximized.jsp (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> dbViewerMaximized.jsp Mon Sep 29 11:09:17 2008
>> @@ -1,17 +0,0 @@
>> -<%--
>> - Licensed to the Apache Software Foundation (ASF) under one or
>> more
>> - contributor license agreements. See the NOTICE file
>> distributed with
>> - this work for additional information regarding copyright
>> ownership.
>> - The ASF licenses this file to You under the Apache License,
>> Version 2.0
>> - (the "License"); you may not use this file except in compliance
>> with
>> - the License. You may obtain a copy of the License at
>> -
>> - http://www.apache.org/licenses/LICENSE-2.0
>> -
>> - Unless required by applicable law or agreed to in writing,
>> software
>> - distributed under the License is distributed on an "AS IS" BASIS,
>> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> - See the License for the specific language governing permissions
>> and
>> - limitations under the License.
>> ---%>
>> -<%@ include file="listDatabases.jsp" %>
>> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listDatabasesMaximized.jsp
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp?rev=700193&view=auto
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listDatabasesMaximized.jsp (added)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listDatabasesMaximized.jsp Mon Sep 29 11:09:17 2008
>> @@ -0,0 +1,17 @@
>> +<%--
>> + Licensed to the Apache Software Foundation (ASF) under one or
>> more
>> + contributor license agreements. See the NOTICE file
>> distributed with
>> + this work for additional information regarding copyright
>> ownership.
>> + The ASF licenses this file to You under the Apache License,
>> Version 2.0
>> + (the "License"); you may not use this file except in compliance
>> with
>> + the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> software
>> + distributed under the License is distributed on an "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + See the License for the specific language governing permissions
>> and
>> + limitations under the License.
>> +--%>
>> +<%@ include file="listDatabases.jsp" %>
>> Propchange: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listDatabasesMaximized.jsp
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listTablesMaximized.jsp
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp?rev=700193&view=auto
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listTablesMaximized.jsp (added)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listTablesMaximized.jsp Mon Sep 29 11:09:17 2008
>> @@ -0,0 +1,17 @@
>> +<%--
>> + Licensed to the Apache Software Foundation (ASF) under one or
>> more
>> + contributor license agreements. See the NOTICE file
>> distributed with
>> + this work for additional information regarding copyright
>> ownership.
>> + The ASF licenses this file to You under the Apache License,
>> Version 2.0
>> + (the "License"); you may not use this file except in compliance
>> with
>> + the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> software
>> + distributed under the License is distributed on an "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + See the License for the specific language governing permissions
>> and
>> + limitations under the License.
>> +--%>
>> +<%@ include file="listTables.jsp" %>
>> Propchange: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/
>> listTablesMaximized.jsp
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>> Modified: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/
>> runSQLNormal.jsp
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp?rev=700193&r1=700192&r2=700193&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>> (original)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>> Mon Sep 29 11:09:17 2008
>> @@ -67,15 +67,15 @@
>> <td><div align="right"><fmt:message
>> key="internaldb.common.useDB"/>:</div></td>
>> <td>
>> <select name="useDB">
>> - <c:forEach var="db" items="${databases}" varStatus="status">
>> - <option value="${db}">${db}</option>
>> + <c:forEach var="dsName" items="${dataSourceNames}"
>> varStatus="status">
>> + <option value="${dsName}"<c:if test="${useDB==dsName}">
>> selected="selected"</c:if>>${dsName}</option>
>> </c:forEach>
>> </select>
>> <input type="submit" value="Run SQL" onClick="return
>> <portlet:namespace/>validateForm3();"></td>
>> </tr>
>> <tr>
>> <td></td>
>> - <td><div align="left"><fmt:message
>> key="internaldb.common.SQLCommands"/>:</td>
>> + <td><div align="left"><fmt:message
>> key="internaldb.common.SQLCommands"/>:</div></td>
>> </tr>
>> <tr>
>> <td></td>
>> @@ -113,17 +113,6 @@
>> <%-- Display query result from single select statement --%>
>> <c:if test="${!empty singleSelectStmt}">
>> -<%-- Datasource --%>
>> -<c:if test="${ds == null}">
>> - <%-- Create the connection manually --%>
>> - <sql:setDataSource
>> - var="ds"
>> - driver="org.apache.derby.jdbc.EmbeddedDriver"
>> - url="jdbc:derby:${useDB};create=true"
>> - user=""
>> - password=""
>> - />
>> -</c:if>
>> <%-- Select statement --%>
>> <sql:transaction dataSource="${ds}">
>> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp
>> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp?rev=700193&view=auto
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp (added)
>> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-
>> portlets/src/main/webapp/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp Mon Sep 29 11:09:17 2008
>> @@ -0,0 +1,17 @@
>> +<%--
>> + Licensed to the Apache Software Foundation (ASF) under one or
>> more
>> + contributor license agreements. See the NOTICE file
>> distributed with
>> + this work for additional information regarding copyright
>> ownership.
>> + The ASF licenses this file to You under the Apache License,
>> Version 2.0
>> + (the "License"); you may not use this file except in compliance
>> with
>> + the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> software
>> + distributed under the License is distributed on an "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + See the License for the specific language governing permissions
>> and
>> + limitations under the License.
>> +--%>
>> +<%@ include file="viewTableContents.jsp" %>
>> Propchange: geronimo/server/branches/2.1/plugins/system-database/
>> sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/
>> viewTableContentsMaximized.jsp
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>
Re: svn commit: r700193 - in /geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main:
java/org/apache/geronimo/console/internaldb/ resources/ webapp/WEB-INF/view/internaldb/
Posted by Joe Bohn <jo...@earthlink.net>.
I know this is going way back in time ... but any idea why this change
deleted the content of dbViewerMaximized.jsp but kept the empty file
around?
I discovered this when checking for source headers. This file is
flagged because it doesn't contain a header - but more than that it
doesn't contain anything at all.
I presume we can delete the entire file. Does anybody know of any
reason why we should not do this?
There are a few other instances of similar files that we need to deal
with as well.
Joe
dwoods@apache.org wrote:
> Author: dwoods
> Date: Mon Sep 29 11:09:17 2008
> New Revision: 700193
>
> URL: http://svn.apache.org/viewvc?rev=700193&view=rev
> Log:
> GERONIMO-4225 Allow Run SQL portlet run sql against any configured data source. Thanks to Michal Borowiecki for the patch.
>
> Added:
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp (with props)
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp (with props)
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp (with props)
> Modified:
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
> geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerHelper.java Mon Sep 29 11:09:17 2008
> @@ -18,9 +18,20 @@
> package org.apache.geronimo.console.internaldb;
>
> import java.io.File;
> +import java.util.ArrayList;
> import java.util.Collection;
> +import java.util.List;
> import java.util.Vector;
>
> +import org.apache.geronimo.console.util.KernelManagementHelper;
> +import org.apache.geronimo.console.util.ManagementHelper;
> +import org.apache.geronimo.console.util.PortletManager;
> +import org.apache.geronimo.gbean.AbstractName;
> +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
> +import org.apache.geronimo.kernel.Kernel;
> +import org.apache.geronimo.kernel.KernelRegistry;
> +import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
> +
> public class DBViewerHelper {
>
> private static final String SYS_TBL_PREFIX = "SYS.";
> @@ -28,6 +39,34 @@
> private static final int COUNT_COL = 1;
>
> /**
> + * List the databases having datasources deployed.
> + *
> + * @param derbySysHome
> + * @return
> + */
> + public Collection<String> getDataSourceNames() {
> +
> + List<String> databaseNames = new ArrayList<String>();
> +
> + Kernel kernel = KernelRegistry.getSingleKernel();
> + ManagementHelper helper = new KernelManagementHelper(kernel);
> + ResourceAdapterModule[] modules = helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0], "javax.sql.DataSource");
> + for (ResourceAdapterModule module : modules) {
> + org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[] databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
> + for (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory db : databases) {
> + try {
> + AbstractName dbName = kernel.getAbstractNameFor(db);
> + String datasourceName = (String)dbName.getName().get(NameFactory.J2EE_NAME);
> + databaseNames.add(datasourceName);
> + } catch (Exception ignored) {
> + }
> + }
> + }
> +
> + return databaseNames;
> + }
> +
> + /**
> * List the databases given the derby home directory.
> *
> * @param derbySysHome
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DBViewerPortlet.java Mon Sep 29 11:09:17 2008
> @@ -40,16 +40,20 @@
>
> private static final int RDBMS_MSSQL = 2;
>
> - private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerMaximized.jsp";
> -
> private static final String HELPVIEW_JSP = "/WEB-INF/view/internaldb/dbViewerHelp.jsp";
>
> private static final String LISTDATABASES_JSP = "/WEB-INF/view/internaldb/listDatabases.jsp";
>
> + private static final String LISTDATABASES_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/listDatabasesMaximized.jsp";
> +
> private static final String LISTTABLES_JSP = "/WEB-INF/view/internaldb/listTables.jsp";
>
> + private static final String LISTTABLES_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/listTablesMaximized.jsp";
> +
> private static final String VIEWTABLECONTENTS_JSP = "/WEB-INF/view/internaldb/viewTableContents.jsp";
>
> + private static final String VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp";
> +
> private static final String LISTDB_ACTION = "listDatabases";
>
> private static final String LISTTBLS_ACTION = "listTables";
> @@ -58,8 +62,6 @@
>
> private static DBViewerHelper helper = new DBViewerHelper();
>
> - private PortletRequestDispatcher maximizedView;
> -
> private PortletRequestDispatcher helpView;
>
> private PortletRequestDispatcher listDatabasesView;
> @@ -68,6 +70,12 @@
>
> private PortletRequestDispatcher viewTableContentsView;
>
> + private PortletRequestDispatcher listDatabasesMaximizedView;
> +
> + private PortletRequestDispatcher listTablesMaximizedView;
> +
> + private PortletRequestDispatcher viewTableContentsMaximizedView;
> +
> public void processAction(ActionRequest actionRequest,
> ActionResponse actionResponse) throws PortletException, IOException {
> // getting parameters here because it fails on doView()
> @@ -106,47 +114,56 @@
> String rdbms = renderRequest.getParameter("rdbms");
> int rdbmsParam = (rdbms == null ? RDBMS_DERBY : Integer.parseInt(rdbms));
>
> - if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> - if (rdbmsParam == RDBMS_DERBY) {
> - // Check is database & table is valid
> - if (LISTTBLS_ACTION.equals(action)
> - || VIEWTBLCONTENTS_ACTION.equals(action)) {
> - if (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
> - // DB not valid
> - log.error("Database is not valid: " + db);
> - action = "";
> - }
> + if (rdbmsParam == RDBMS_DERBY) {
> + // Check is database & table is valid
> + if (LISTTBLS_ACTION.equals(action)
> + || VIEWTBLCONTENTS_ACTION.equals(action)) {
> + if (!helper.isDBValid(DerbyConnectionUtil.getDerbyHome(), db)) {
> + // DB not valid
> + log.error("Database is not valid: " + db);
> + action = "";
> }
> - if (VIEWTBLCONTENTS_ACTION.equals(action)) {
> - if (!helper.isTblValid(db, tbl)) {
> - // Table not valid
> - log.error("Table is not valid: " + tbl);
> - action = "";
> - }
> + }
> + if (VIEWTBLCONTENTS_ACTION.equals(action)) {
> + if (!helper.isTblValid(db, tbl)) {
> + // Table not valid
> + log.error("Table is not valid: " + tbl);
> + action = "";
> }
> }
> + }
>
> - renderRequest.setAttribute("rdbms", rdbms);
> - if (LISTTBLS_ACTION.equals(action)) {
> - renderRequest.setAttribute("db", db);
> - renderRequest.setAttribute("viewTables", viewTables);
> - renderRequest.setAttribute("ds", DerbyConnectionUtil
> - .getDataSource(db));
> - listTablesView.include(renderRequest, renderResponse);
> - } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
> - renderRequest.setAttribute("db", db);
> - renderRequest.setAttribute("tbl", tbl);
> - renderRequest.setAttribute("viewTables", viewTables);
> - renderRequest.setAttribute("ds", DerbyConnectionUtil
> - .getDataSource(db));
> - viewTableContentsView.include(renderRequest, renderResponse);
> + renderRequest.setAttribute("rdbms", rdbms);
> + if (LISTTBLS_ACTION.equals(action)) {
> + renderRequest.setAttribute("db", db);
> + renderRequest.setAttribute("viewTables", viewTables);
> + renderRequest.setAttribute("ds", DerbyConnectionUtil
> + .getDataSourceForDataBaseName(db));
> +
> + if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> + listTablesView.include(renderRequest, renderResponse);
> } else {
> - renderRequest.setAttribute("databases", helper
> - .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
> - listDatabasesView.include(renderRequest, renderResponse);
> + listTablesMaximizedView.include(renderRequest, renderResponse);
> + }
> + } else if (VIEWTBLCONTENTS_ACTION.equals(action)) {
> + renderRequest.setAttribute("db", db);
> + renderRequest.setAttribute("tbl", tbl);
> + renderRequest.setAttribute("viewTables", viewTables);
> + renderRequest.setAttribute("ds", DerbyConnectionUtil
> + .getDataSourceForDataBaseName(db));
> + if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> + viewTableContentsView.include(renderRequest, renderResponse);
> + } else {
> + viewTableContentsMaximizedView.include(renderRequest, renderResponse);
> }
> } else {
> - maximizedView.include(renderRequest, renderResponse);
> + renderRequest.setAttribute("databases", helper
> + .getDerbyDatabases(DerbyConnectionUtil.getDerbyHome()));
> + if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> + listDatabasesView.include(renderRequest, renderResponse);
> + } else {
> + listDatabasesMaximizedView.include(renderRequest, renderResponse);
> + }
> }
> }
>
> @@ -157,8 +174,6 @@
>
> public void init(PortletConfig portletConfig) throws PortletException {
> super.init(portletConfig);
> - maximizedView = portletConfig.getPortletContext().getRequestDispatcher(
> - MAXIMIZEDVIEW_JSP);
> helpView = portletConfig.getPortletContext().getRequestDispatcher(
> HELPVIEW_JSP);
> listDatabasesView = portletConfig.getPortletContext()
> @@ -167,14 +182,22 @@
> .getRequestDispatcher(LISTTABLES_JSP);
> viewTableContentsView = portletConfig.getPortletContext()
> .getRequestDispatcher(VIEWTABLECONTENTS_JSP);
> + listDatabasesMaximizedView = portletConfig.getPortletContext()
> + .getRequestDispatcher(LISTDATABASES_MAXIMIZEDVIEW_JSP);
> + listTablesMaximizedView = portletConfig.getPortletContext()
> + .getRequestDispatcher(LISTTABLES_MAXIMIZEDVIEW_JSP);
> + viewTableContentsMaximizedView = portletConfig.getPortletContext()
> + .getRequestDispatcher(VIEWTABLECONTENTS_MAXIMIZEDVIEW_JSP);
> }
>
> public void destroy() {
> - maximizedView = null;
> helpView = null;
> listDatabasesView = null;
> listTablesView = null;
> viewTableContentsView = null;
> + listDatabasesMaximizedView = null;
> + listTablesMaximizedView = null;
> + viewTableContentsMaximizedView = null;
> super.destroy();
> }
>
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/DerbyConnectionUtil.java Mon Sep 29 11:09:17 2008
> @@ -166,7 +166,7 @@
> public static Connection getSystemDBConnection() throws SQLException {
> DataSource ds = null;
> try {
> - ds = getDataSource(SYSTEM_DB);
> + ds = getDataSourceForDataBaseName(SYSTEM_DB);
> return ds.getConnection();
> } catch (Exception e) {
> throw new SQLException(e.getMessage());
> @@ -174,12 +174,27 @@
> }
>
> /**
> - * Get the datasource if dbName is == SYSTEM_DB, otherwise returns null.
> + * Get a connaction to a named datasource
> + *
> + * @param dbName
> + * @return
> + * @throws SQLException
> + */
> + public static Connection getDataSourceConnection(String dataSourceName) throws SQLException{
> + try {
> + return getDataSource(dataSourceName).getConnection();
> + } catch (Exception e) {
> + throw new SQLException(e.getMessage());
> + }
> + }
> +
> + /**
> + * Get the datasource if dbName is == SYSTEM_DB, otherwise finds the datasource among JCAManagedConnectionFactories, otherwise returns null.
> *
> * @param dbName
> * @return datasource
> */
> - public static DataSource getDataSource(String dbName) {
> + public static DataSource getDataSourceForDataBaseName(String dbName) {
> try {
> if (SYSTEM_DATASOURCE_NAME!=null && SYSTEM_DB.equalsIgnoreCase(dbName)) {
> return (DataSource) KernelRegistry.getSingleKernel().invoke(
> @@ -210,4 +225,42 @@
> return null;
> }
>
> + /**
> + * Get the datasource if dbName is == SYSTEM_DB, otherwise finds the datasource among JCAManagedConnectionFactories, otherwise returns null.
> + *
> + * @param dbName
> + * @return datasource
> + */
> + public static DataSource getDataSource(String dsName) {
> + try {
> + if (SYSTEM_DATASOURCE_NAME!=null && ((String)SYSTEM_DATASOURCE_NAME.getName().get(NameFactory.J2EE_NAME)).equalsIgnoreCase(dsName)) {
> + return (DataSource) KernelRegistry.getSingleKernel().invoke(
> + SYSTEM_DATASOURCE_NAME, "$getResource");
> + }
> + } catch (Exception e) {
> + log.error("Problem getting datasource " + dsName, e);
> + }
> +
> + Kernel kernel = KernelRegistry.getSingleKernel();
> + ManagementHelper helper = new KernelManagementHelper(kernel);
> + ResourceAdapterModule[] modules = helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0], "javax.sql.DataSource");
> + for (ResourceAdapterModule module : modules) {
> + org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[] databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
> + for (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory db : databases) {
> + try {
> + AbstractName dbName = kernel.getAbstractNameFor(db);
> + String datasourceName = (String)dbName.getName().get(NameFactory.J2EE_NAME);
> + if(dsName.equalsIgnoreCase(datasourceName)) {
> + AbstractName tempDbName = helper.getNameFor(db);
> + return (DataSource) KernelRegistry.getSingleKernel().invoke(
> + tempDbName, "$getResource");
> + }
> + } catch (Exception ignored) {
> + }
> + }
> + }
> +
> + return null;
> + }
> +
> }
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLHelper.java Mon Sep 29 11:09:17 2008
> @@ -132,19 +132,20 @@
> return result;
> }
>
> - public String runSQL(String dbName, String sql) {
> + public String runSQL(String dsName, String sql) {
> String result = SQL_SUCCESS_MSG;
>
> if ((sql == null) || (sql.trim().length() == 0)) {
> result = SQL_EMPTY_MSG;
> return result;
> }
> +
>
> Connection conn = null;
> Statement s = null;
> try {
>
> - conn = DerbyConnectionUtil.getDerbyConnection(dbName);
> + conn = DerbyConnectionUtil.getDataSourceConnection(dsName);
> conn.setAutoCommit(false);
>
> s = conn.createStatement();
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/internaldb/RunSQLPortlet.java Mon Sep 29 11:09:17 2008
> @@ -60,6 +60,8 @@
> private PortletRequestDispatcher helpView;
>
> private Collection databases;
> +
> + private Collection<String> dataSourceNames;
>
> private String action;
>
> @@ -108,33 +110,36 @@
> }
>
> String singleSelectStmt;
> - if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> - databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
> - renderRequest.setAttribute("databases", databases);
> - if (RUNSQL_ACTION.equals(action)) {
> - // check if it's a single Select statement
> - if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';') == -1)
> - && sqlStmts.trim().toUpperCase().startsWith("SELECT")
> - && RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
> - singleSelectStmt = sqlStmts.trim();
> - // set action result to blank so it won't display
> - actionResult = "";
> - } else {
> - singleSelectStmt = "";
> - }
> - renderRequest.setAttribute("useDB", useDB);
> - renderRequest
> - .setAttribute("singleSelectStmt", singleSelectStmt);
> - renderRequest.setAttribute("ds", DerbyConnectionUtil
> - .getDataSource(useDB));
> - }
> - if ((action != null) && (action.trim().length() > 0)) {
> - renderRequest.setAttribute("actionResult", actionResult);
> - //set action to null so that subsequent renders of portlet
> - // won't display
> - //action result if there is no action to process
> - action = null;
> + databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
> + dataSourceNames = dbHelper.getDataSourceNames();
> + renderRequest.setAttribute("databases", databases);
> + renderRequest.setAttribute("dataSourceNames", dataSourceNames);
> + renderRequest.setAttribute("sqlStmts", sqlStmts);
> + renderRequest.setAttribute("useDB", useDB);
> + if (RUNSQL_ACTION.equals(action)) {
> + // check if it's a single Select statement
> + if ((sqlStmts != null) && (sqlStmts.trim().indexOf(';') == -1)
> + && sqlStmts.trim().toUpperCase().startsWith("SELECT")
> + && RunSQLHelper.SQL_SUCCESS_MSG.equals(actionResult)) {
> + singleSelectStmt = sqlStmts.trim();
> + // set action result to blank so it won't display
> + actionResult = "";
> + } else {
> + singleSelectStmt = "";
> }
> + renderRequest
> + .setAttribute("singleSelectStmt", singleSelectStmt);
> + renderRequest.setAttribute("ds", DerbyConnectionUtil
> + .getDataSource(useDB));
> + }
> + if ((action != null) && (action.trim().length() > 0)) {
> + renderRequest.setAttribute("actionResult", actionResult);
> + //set action to null so that subsequent renders of portlet
> + // won't display
> + //action result if there is no action to process
> + action = null;
> + }
> + if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
> normalView.include(renderRequest, renderResponse);
> } else {
> maximizedView.include(renderRequest, renderResponse);
> @@ -155,6 +160,7 @@
> helpView = portletConfig.getPortletContext().getRequestDispatcher(
> HELPVIEW_JSP);
> databases = dbHelper.getDerbyDatabases(DerbyConnectionUtil.getDerbyHome());
> + dataSourceNames = dbHelper.getDataSourceNames();
> }
>
> public void destroy() {
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/resources/systemdatabase.properties Mon Sep 29 11:09:17 2008
> @@ -199,7 +199,7 @@
> internaldb.common.tableTypes = Table Types
> internaldb.common.tables = Tables
> internaldb.common.timeDateFunctions = Time Date Functions
> -internaldb.common.useDB = Use DB
> +internaldb.common.useDB = Use DataSource
> internaldb.common.userName = Username
> internaldb.common.viewContents = View Contents
> internaldb.common.viewDatabases = View Databases
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/dbViewerMaximized.jsp Mon Sep 29 11:09:17 2008
> @@ -1,17 +0,0 @@
> -<%--
> - Licensed to the Apache Software Foundation (ASF) under one or more
> - contributor license agreements. See the NOTICE file distributed with
> - this work for additional information regarding copyright ownership.
> - The ASF licenses this file to You under the Apache License, Version 2.0
> - (the "License"); you may not use this file except in compliance with
> - the License. You may obtain a copy of the License at
> -
> - http://www.apache.org/licenses/LICENSE-2.0
> -
> - Unless required by applicable law or agreed to in writing, software
> - distributed under the License is distributed on an "AS IS" BASIS,
> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - See the License for the specific language governing permissions and
> - limitations under the License.
> ---%>
> -<%@ include file="listDatabases.jsp" %>
>
> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp?rev=700193&view=auto
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp (added)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp Mon Sep 29 11:09:17 2008
> @@ -0,0 +1,17 @@
> +<%--
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +--%>
> +<%@ include file="listDatabases.jsp" %>
>
> Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listDatabasesMaximized.jsp
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp?rev=700193&view=auto
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp (added)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp Mon Sep 29 11:09:17 2008
> @@ -0,0 +1,17 @@
> +<%--
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +--%>
> +<%@ include file="listTables.jsp" %>
>
> Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/listTablesMaximized.jsp
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Modified: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp?rev=700193&r1=700192&r2=700193&view=diff
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp (original)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/runSQLNormal.jsp Mon Sep 29 11:09:17 2008
> @@ -67,15 +67,15 @@
> <td><div align="right"><fmt:message key="internaldb.common.useDB"/>:</div></td>
> <td>
> <select name="useDB">
> - <c:forEach var="db" items="${databases}" varStatus="status">
> - <option value="${db}">${db}</option>
> + <c:forEach var="dsName" items="${dataSourceNames}" varStatus="status">
> + <option value="${dsName}"<c:if test="${useDB==dsName}"> selected="selected"</c:if>>${dsName}</option>
> </c:forEach>
> </select>
> <input type="submit" value="Run SQL" onClick="return <portlet:namespace/>validateForm3();"></td>
> </tr>
> <tr>
> <td></td>
> - <td><div align="left"><fmt:message key="internaldb.common.SQLCommands"/>:</td>
> + <td><div align="left"><fmt:message key="internaldb.common.SQLCommands"/>:</div></td>
> </tr>
> <tr>
> <td></td>
> @@ -113,17 +113,6 @@
>
> <%-- Display query result from single select statement --%>
> <c:if test="${!empty singleSelectStmt}">
> -<%-- Datasource --%>
> -<c:if test="${ds == null}">
> - <%-- Create the connection manually --%>
> - <sql:setDataSource
> - var="ds"
> - driver="org.apache.derby.jdbc.EmbeddedDriver"
> - url="jdbc:derby:${useDB};create=true"
> - user=""
> - password=""
> - />
> -</c:if>
>
> <%-- Select statement --%>
> <sql:transaction dataSource="${ds}">
>
> Added: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
> URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp?rev=700193&view=auto
> ==============================================================================
> --- geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp (added)
> +++ geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp Mon Sep 29 11:09:17 2008
> @@ -0,0 +1,17 @@
> +<%--
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +--%>
> +<%@ include file="viewTableContents.jsp" %>
>
> Propchange: geronimo/server/branches/2.1/plugins/system-database/sysdb-portlets/src/main/webapp/WEB-INF/view/internaldb/viewTableContentsMaximized.jsp
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
>
>