openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1808968 - in /openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql: ./ sdbcx/ util/
Date Wed, 20 Sep 2017 05:10:09 GMT
Author: damjan
Date: Wed Sep 20 05:10:08 2017
New Revision: 1808968

URL: http://svn.apache.org/viewvc?rev=1808968&view=rev
Log:
Revert r1808599; apparently we really do need Any.VOID instead of Java's
null. Also fix one more place where this is the problem.
(I wonder why. Seems like something that could be improved.)

Fix "Refresh Tables", which was making all tables disappear. Apparently
we needed to actually re-read our tables, and deal with the fact that the
OCatalog is disposed after the return. Further development is ongoing.

Also make other null strings into empty strings like UNO requires.

Patch by: me


Modified:
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
Wed Sep 20 05:10:08 2017
@@ -31,6 +31,7 @@ import com.sun.star.sdbc.XRow;
 import com.sun.star.sdbcx.comp.postgresql.comphelper.CompHelper;
 import com.sun.star.sdbcx.comp.postgresql.sdbcx.OCatalog;
 import com.sun.star.sdbcx.comp.postgresql.sdbcx.OContainer;
+import com.sun.star.uno.Any;
 import com.sun.star.uno.UnoRuntime;
 
 public class PostgresqlCatalog extends OCatalog {
@@ -43,7 +44,7 @@ public class PostgresqlCatalog extends O
         XResultSet results = null;
         try {
             // Using { "VIEW", "TABLE", "%" } shows INFORMATION_SCHEMA and others, but it
also shows indexes :-(
-            results = metadata.getTables(null, "%", "%", new String[] { "VIEW", "TABLE" });
+            results = metadata.getTables(Any.VOID, "%", "%", new String[] { "VIEW", "TABLE"
});
             XRow row = UnoRuntime.queryInterface(XRow.class, results);
             List<String> names = new ArrayList<>();
             while (results.next()) {
@@ -63,7 +64,7 @@ public class PostgresqlCatalog extends O
     public OContainer refreshViews() {
         XResultSet results = null;
         try {
-            results = metadata.getTables(null, "%", "%", new String[] { "VIEW" });
+            results = metadata.getTables(Any.VOID, "%", "%", new String[] { "VIEW" });
             XRow row = UnoRuntime.queryInterface(XRow.class, results);
             List<String> names = new ArrayList<>();
             while (results.next()) {

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
Wed Sep 20 05:10:08 2017
@@ -41,6 +41,7 @@ import com.sun.star.sdbcx.comp.postgresq
 import com.sun.star.sdbcx.comp.postgresql.util.DbTools.NameComponents;
 import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds;
 import com.sun.star.sdbcx.comp.postgresql.util.StandardSQLState;
+import com.sun.star.uno.Any;
 import com.sun.star.uno.AnyConverter;
 import com.sun.star.uno.UnoRuntime;
 
@@ -57,7 +58,7 @@ public class PostgresqlTables extends OC
     @Override
     public XPropertySet createObject(String name) throws SQLException {
         NameComponents nameComponents = DbTools.qualifiedNameComponents(metadata, name, ComposeRule.InDataManipulation);
-        Object queryCatalog = nameComponents.getCatalog().isEmpty() ? null : nameComponents.getCatalog();
+        Object queryCatalog = nameComponents.getCatalog().isEmpty() ? Any.VOID : nameComponents.getCatalog();
         XPropertySet ret = null;
         XResultSet results = null;
         try {
@@ -111,7 +112,7 @@ public class PostgresqlTables extends OC
 
     @Override
     public void impl_refresh() {
-        catalog.refreshTables();
+        catalog.refreshObjects();
     }
 
     @Override

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
Wed Sep 20 05:10:08 2017
@@ -128,6 +128,26 @@ public abstract class OCatalog extends C
         return users;
     }
     
+    public synchronized void refreshObjects() {
+        checkDisposed();
+        if (tables != null) {
+            tables.dispose();
+            tables = null;
+        }
+        if (views != null) {
+            views.dispose();
+            views = null;
+        }
+        if (groups != null) {
+            groups.dispose();
+            groups = null;
+        }
+        if (users != null) {
+            users.dispose();
+            users = null;
+        }
+    }
+    
     /**
      * Builds the name which should be used to access the object later on in the collection.
      * Will only be called in fillNames.

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
Wed Sep 20 05:10:08 2017
@@ -127,6 +127,7 @@ public class OColumnContainer extends OC
     @Override
     protected void impl_refresh() {
         extraColumnInfo.clear();
+        // FIXME: won't help
         table.refreshColumns();
     }
     

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
Wed Sep 20 05:10:08 2017
@@ -210,6 +210,10 @@ public abstract class OContainer extends
             
             iterator = refreshListeners.iterator();
         }
+        if (iterator == null) {
+            // early disposal
+            return;
+        }
         EventObject event = new EventObject(this);
         while (iterator.hasNext()) {
             XRefreshListener listener = (XRefreshListener) iterator.next();
@@ -217,6 +221,20 @@ public abstract class OContainer extends
         }
     }
 
+    @Override
+    public void addRefreshListener(XRefreshListener listener) {
+        synchronized (lock) {
+            refreshListeners.add(listener);
+        }
+    }
+    
+    @Override
+    public void removeRefreshListener(XRefreshListener listener) {
+        synchronized (lock) {
+            refreshListeners.remove(listener);
+        }
+    }
+    
     // XDataDescriptorFactory
     
     @Override
@@ -347,20 +365,6 @@ public abstract class OContainer extends
         }
     }
     
-    @Override
-    public void addRefreshListener(XRefreshListener listener) {
-        synchronized (lock) {
-            refreshListeners.add(listener);
-        }
-    }
-    
-    @Override
-    public void removeRefreshListener(XRefreshListener listener) {
-        synchronized (lock) {
-            refreshListeners.remove(listener);
-        }
-    }
-    
     protected int indexOf(String name) {
         for (int i = 0; i < namesByIndex.size(); i++) {
             if (namesByIndex.get(i).equals(name)) {

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java
Wed Sep 20 05:10:08 2017
@@ -48,8 +48,8 @@ public abstract class OTable extends ODe
     private XConnection connection;
     protected String catalogName;
     protected String schemaName;
-    protected String description;
-    protected String type;
+    protected String description = "";
+    protected String type = "";
     
     protected OContainer keys;
     protected OContainer columns;

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
Wed Sep 20 05:10:08 2017
@@ -39,6 +39,7 @@ import com.sun.star.sdbcx.comp.postgresq
 import com.sun.star.sdbcx.comp.postgresql.util.DbTools;
 import com.sun.star.sdbcx.comp.postgresql.util.Osl;
 import com.sun.star.sdbcx.comp.postgresql.util.StandardSQLState;
+import com.sun.star.uno.Any;
 import com.sun.star.uno.UnoRuntime;
 
 public class SqlTableHelper {
@@ -69,13 +70,13 @@ public class SqlTableHelper {
         }
     }
     
-    public List<ColumnDescription> readColumns(XDatabaseMetaData metadata, String catalog,
String schema, String table) throws SQLException {
-        String catalogName = catalog;
-        if (catalog.isEmpty()) {
-            catalogName = null;
+    public List<ColumnDescription> readColumns(XDatabaseMetaData metadata, String catalogName,
String schema, String table) throws SQLException {
+        Object catalog = Any.VOID;
+        if (!catalogName.isEmpty()) {
+            catalog = catalogName;
         }
         
-        XResultSet results = metadata.getColumns(catalogName, schema, table, "%");
+        XResultSet results = metadata.getColumns(catalog, schema, table, "%");
         List<ColumnDescription> columnDescriptions = collectColumnDescriptions(results);
         sanitizeColumnDescriptions(columnDescriptions);
 
@@ -142,7 +143,7 @@ public class SqlTableHelper {
     
     private OKey readPrimaryKey(XDatabaseMetaData metadata,
             String catalogName, String schemaName, String tableName, boolean isCaseSensitive,
OTable table) throws SQLException {
-        Object catalog = null;
+        Object catalog = Any.VOID;
         if (!catalogName.isEmpty()) {
             catalog = catalogName;
         }
@@ -175,7 +176,7 @@ public class SqlTableHelper {
     
     private void readForeignKeys(XDatabaseMetaData metadata,
             String catalogName, String schemaName, String tableName, boolean isCaseSensitive,
Map<String, OKey> keys, OTable table) throws SQLException {
-        Object catalog = null;
+        Object catalog = Any.VOID;
         if (!catalogName.isEmpty()) {
             catalog = catalogName;
         }
@@ -232,7 +233,7 @@ public class SqlTableHelper {
     }
     
     public ArrayList<String> readIndexes(XDatabaseMetaData metadata, String catalogName,
String schemaName, String tableName, OTable table) throws SQLException {
-        Object catalog = null;
+        Object catalog = Any.VOID;
         if (!catalogName.isEmpty()) {
             catalog = catalogName;
         }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java?rev=1808968&r1=1808967&r2=1808968&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
Wed Sep 20 05:10:08 2017
@@ -55,6 +55,7 @@ import com.sun.star.sdbcx.XColumnsSuppli
 import com.sun.star.sdbcx.XKeysSupplier;
 import com.sun.star.sdbcx.comp.postgresql.comphelper.CompHelper;
 import com.sun.star.sdbcx.comp.postgresql.sdbcx.OColumnContainer.ExtraColumnInfo;
+import com.sun.star.uno.Any;
 import com.sun.star.uno.AnyConverter;
 import com.sun.star.uno.UnoRuntime;
 
@@ -301,7 +302,7 @@ public class DbTools {
             }
             return nameComponents;
         } catch (IllegalArgumentException | WrappedTargetException | UnknownPropertyException
exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }
     
@@ -443,7 +444,7 @@ public class DbTools {
             
             return String.format("CREATE TABLE %s (%s", composedName, columnText.toString());
         } catch (IllegalArgumentException | WrappedTargetException | UnknownPropertyException
| IndexOutOfBoundsException exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }
     
@@ -566,7 +567,7 @@ public class DbTools {
             
             return sql.toString();
         } catch (IllegalArgumentException | WrappedTargetException | UnknownPropertyException
exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }
     
@@ -645,7 +646,7 @@ public class DbTools {
             }
             return sql.toString();
         } catch (IllegalArgumentException | WrappedTargetException | UnknownPropertyException
| IndexOutOfBoundsException exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }
     
@@ -705,7 +706,7 @@ public class DbTools {
             }
             return columns;
         } catch (IllegalArgumentException | WrappedTargetException | UnknownPropertyException
| PropertyVetoException exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         } finally {
             CompHelper.disposeComponent(statement);
         }
@@ -737,7 +738,7 @@ public class DbTools {
             }
             return keyColumns;
         } catch (IndexOutOfBoundsException | IllegalArgumentException | WrappedTargetException
| UnknownPropertyException exception) {
-            throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+            throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }
     
@@ -754,7 +755,7 @@ public class DbTools {
                 XPropertySet columnProperties = AnyConverter.toObject(XPropertySet.class,
sourceColumns.getByIndex(i));
                 destinationAppend.appendByDescriptor(columnProperties);
             } catch (WrappedTargetException | IndexOutOfBoundsException | IllegalArgumentException
| ElementExistException exception) {
-                throw new SQLException("Error", null, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
+                throw new SQLException("Error", Any.VOID, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
             }
         }
     }



Mime
View raw message