[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2018-12-03 Thread Libreoffice Gerrit user
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java  
  |3 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassLoaderAndClass.java
 |   46 +++
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassMap.java
|  150 ++
 3 files changed, 198 insertions(+), 1 deletion(-)

New commits:
commit 40424188a15d5253b23ff5a7f96a472ffa899534
Author: Damjan Jovanovic 
AuthorDate: Mon Dec 3 17:03:12 2018 +
Commit: Damjan Jovanovic 
CommitDate: Mon Dec 3 17:03:12 2018 +

Refactor classloading in the postgresql driver.

Patch by: me

diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java
index f4fb4298ae6f..7535cb6f67b1 100644
--- 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java
+++ 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java
@@ -20,6 +20,7 @@
  */
 package com.sun.star.comp.sdbc;
 
+import com.sun.star.comp.sdbc.classloading.ClassMap;
 import java.util.Iterator;
 import java.util.Properties;
 
@@ -31,7 +32,7 @@ import 
org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
 
 import com.sun.star.beans.NamedValue;
 import com.sun.star.beans.PropertyValue;
-import com.sun.star.comp.sdbc.ClassMap.ClassLoaderAndClass;
+import com.sun.star.comp.sdbc.classloading.ClassLoaderAndClass;
 import com.sun.star.comp.sdbc.ConnectionLog.ObjectType;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.lang.IllegalArgumentException;
diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassLoaderAndClass.java
 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassLoaderAndClass.java
new file mode 100644
index ..c3946c8c5bd9
--- /dev/null
+++ 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassLoaderAndClass.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * 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.
+ *
+ */
+
+package com.sun.star.comp.sdbc.classloading;
+
+/**
+ *
+ * @author dacha
+ */
+public class ClassLoaderAndClass {
+
+private final ClassLoader classLoader;
+private final Class classObject;
+
+public ClassLoaderAndClass(ClassLoader classLoader, Class classObject) {
+this.classLoader = classLoader;
+this.classObject = classObject;
+}
+
+public ClassLoader getClassLoader() {
+return classLoader;
+}
+
+public Class getClassObject() {
+return classObject;
+}
+
+}
diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassMap.java
 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassMap.java
new file mode 100644
index ..b8a03af52858
--- /dev/null
+++ 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/classloading/ClassMap.java
@@ -0,0 +1,150 @@
+/**
+ *
+ * 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.
+ *
+ */
+package com.sun.star.comp.sdbc.classloading;
+
+import java.lang.ref.WeakReference;

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2018-05-04 Thread Damjan Jovanovic
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java 
  |2 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java   
  |4 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
  |4 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java 
  |2 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java   
  |4 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java
  |4 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java
 |1 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java
  |4 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLConnection.java  
  |   78 +-
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLDatabaseMetaData.java
  |7 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLPreparedStatement.java
 |1 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLRef.java 
  |2 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLResultSetMetaData.java
 |4 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLStatement.java   
  |3 
 
connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLStatementBase.java
 |1 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ReaderInputStream.java  
  |2 
 connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/Tools.java  
  |   52 ++
 17 files changed, 93 insertions(+), 82 deletions(-)

New commits:
commit 87e19c1cab7e6dd9ddd7cefdc670afd5ecb69df5
Author: Damjan Jovanovic 
Date:   Sat May 5 03:59:10 2018 +

Move the PropertyValue helper methods to the tools class for now.

Some "@Override" and "final" cleanups as per NetBeans.

Patch by: me

diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
index 07e8b6762d66..5336ba0e7312 100644
--- 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
+++ 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 
 public class BoundedInputStream extends InputStream {
-private InputStream is;
+private final InputStream is;
 private long remaining;
 
 public BoundedInputStream(InputStream is, long max) {
diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
index fda4063ecdae..6bdd506af263 100644
--- a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
+++ b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
@@ -59,8 +59,8 @@ import com.sun.star.util.XMacroExpander;
  */
 public class ClassMap {
 public static class ClassLoaderAndClass {
-private ClassLoader classLoader;
-private Class classObject;
+private final ClassLoader classLoader;
+private final Class classObject;
 
 public ClassLoaderAndClass(ClassLoader classLoader, Class 
classObject) {
 this.classLoader = classLoader;
diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
index 4feef8dac6ba..43bf01a7599a 100644
--- 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
+++ 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
@@ -21,8 +21,8 @@
 package com.sun.star.comp.sdbc;
 
 public class ContextClassLoaderScope implements AutoCloseable {
-private Thread currentThread;
-private ClassLoader oldClassLoader;
+private final Thread currentThread;
+private final ClassLoader oldClassLoader;
 
 public ContextClassLoaderScope(ClassLoader classLoader) {
 currentThread = Thread.currentThread();
diff --git 
a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java 
b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
index 350c2a00c52d..6749bf874b32 100644
--- a/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
+++ b/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
@@ -44,7 +44,7 @@ public class JDBCDriver extends ComponentBase implements 
XServiceInfo, XDriver {
 "com.sun.star.sdbc.Driver"
 };
 private XComponentContext context;
-private ResourceBasedEventLogger logger;
+private final ResourceBasedEventLogger logger;
 
 public static XSingleComponentFactory __getComponentFactory(String 
implName) {
 

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java connectivity/prj scp2/source

2017-10-26 Thread Damjan Jovanovic
 connectivity/java/dbtools/build.xml
  |  249 +
 connectivity/java/dbtools/makefile.mk  
  |   41 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/comphelper/CompHelper.java
 |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/comphelper/OArrayEnumeration.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OCatalog.java
|7 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OColumn.java
 |   13 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OColumnContainer.java
|   15 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OContainer.java
  |   15 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/ODescriptor.java
 |   11 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OIndexColumn.java
|   11 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OIndexContainer.java
 |   15 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OKey.java
|   13 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OKeyColumnContainer.java
 |9 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OKeyContainer.java
   |   13 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/OTable.java
  |7 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/SqlTableHelper.java
  |   13 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxColumnDescriptor.java
   |   11 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxDescriptorContainer.java
|   11 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java
 |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java
|9 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java
   |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java
 |5 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/ComposeRule.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/DBTypeConversion.java
 |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/DbTools.java
  |7 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/ISQLStatementHelper.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/MapToXNameAccessAdapter.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/ORowSetValue.java
 |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/Osl.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/PropertyIds.java
  |2 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/SharedResources.java
  |6 
 
connectivity/java/dbtools/src/org/apache/openoffice/comp/sdbc/dbtools/util/StandardSQLState.java
 |2 
 connectivity/java/sdbc_postgresql/build.xml
  |   11 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/DatabaseMetaDataResultSet.java
  |  481 ++
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
  |7 
 

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2017-10-25 Thread Damjan Jovanovic
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
 |   22 +++--
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
|   39 +++---
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
  |   10 ++
 3 files changed, 39 insertions(+), 32 deletions(-)

New commits:
commit 35810eb91bd3514c1b5234a5ae4ae0d04fcb3b46
Author: Damjan Jovanovic 
Date:   Thu Oct 26 00:42:42 2017 +

Base expects the containers returned by X(Tables/Views/Groups/Users)Supplier

to be the same throughout the lifetime of the catalog!!

Patch by: me

diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
index 1845ec849033..f67d95606a8c 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
@@ -40,7 +40,7 @@ public class PostgresqlCatalog extends OCatalog {
 }
 
 @Override
-public OContainer refreshTables() {
+public void refreshTables() {
 XResultSet results = null;
 try {
 // Using { "VIEW", "TABLE", "%" } shows INFORMATION_SCHEMA and 
others, but it also shows indexes :-(
@@ -52,7 +52,11 @@ public class PostgresqlCatalog extends OCatalog {
 System.out.println("Table " + name);
 names.add(name);
 }
-return new PostgresqlTables(this, metadata, this, names);
+if (tables == null) {
+tables = new PostgresqlTables(this, metadata, this, names);
+} else {
+tables.refill(names);
+}
 } catch (ElementExistException | SQLException exception) {
 throw new com.sun.star.uno.RuntimeException("Error", exception);
 } finally {
@@ -61,7 +65,7 @@ public class PostgresqlCatalog extends OCatalog {
 }
 
 @Override
-public OContainer refreshViews() {
+public void refreshViews() {
 XResultSet results = null;
 try {
 results = metadata.getTables(Any.VOID, "%", "%", new String[] { 
"VIEW" });
@@ -71,7 +75,11 @@ public class PostgresqlCatalog extends OCatalog {
 String name = buildName(row);
 names.add(name);
 }
-return new PostgresqlViews(this, metadata, this, names);
+if (views == null) {
+views = new PostgresqlViews(this, metadata, this, names);
+} else {
+views.refill(names);
+}
 } catch (ElementExistException | SQLException exception) {
 throw new com.sun.star.uno.RuntimeException("Error", exception);
 } finally {
@@ -80,13 +88,11 @@ public class PostgresqlCatalog extends OCatalog {
 }
 
 @Override
-public OContainer refreshGroups() {
-return null;
+public void refreshGroups() {
 }
 
 @Override
-public OContainer refreshUsers() {
-return null;
+public void refreshUsers() {
 }
 
 synchronized OContainer getTablesInternal() {
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
index f6c4026bdbb2..e91cac8f2772 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
@@ -34,6 +34,9 @@ import com.sun.star.sdbcx.XViewsSupplier;
 import com.sun.star.sdbcx.comp.postgresql.util.ComposeRule;
 import com.sun.star.sdbcx.comp.postgresql.util.DbTools;
 
+/** Base expects the containers returned by 
X(Tables/Views/Groups/Users)Supplier
+ * to be the same throughout the lifetime of the catalog!!
+ */
 public abstract class OCatalog extends ComponentBase
 implements XTablesSupplier, XViewsSupplier, XUsersSupplier, 
XGroupsSupplier, XServiceInfo {
 
@@ -96,7 +99,7 @@ public abstract class OCatalog extends ComponentBase
 public synchronized XNameAccess getTables() {
 checkDisposed();
 if (tables == null) {
-tables = refreshTables();
+refreshTables();
 }
 return tables;
 }
@@ -105,7 +108,7 @@ public abstract class OCatalog extends ComponentBase
 public synchronized XNameAccess getViews() {
 checkDisposed();
 if (views == null) {
-views = refreshViews();
+refreshViews();
 }
 return views;
 }
@@ -114,7 +117,7 @@ public abstract class OCatalog extends ComponentBase
 public synchronized XNameAccess getGroups() {
 

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2017-09-20 Thread Damjan Jovanovic
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
  |5 -
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
   |5 -
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
 |   20 ++
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
 |1 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
   |   32 +-
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OTable.java
   |4 -
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
   |   17 ++---
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
   |   15 ++--
 8 files changed, 64 insertions(+), 35 deletions(-)

New commits:
commit 91af6fa89dd7eee302c59fcf110c3c19e157ab35
Author: Damjan Jovanovic 
Date:   Wed Sep 20 05:10:08 2017 +

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

diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
index 80039c7255c9..ad66cf6de697 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
@@ -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 OCatalog {
 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 names = new ArrayList<>();
 while (results.next()) {
@@ -63,7 +64,7 @@ public class PostgresqlCatalog extends OCatalog {
 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 names = new ArrayList<>();
 while (results.next()) {
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
index ed0f97d3cdf6..885cca5cdc3b 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
@@ -41,6 +41,7 @@ import com.sun.star.sdbcx.comp.postgresql.util.DbTools;
 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 OContainer {
 @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 

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2017-09-19 Thread Damjan Jovanovic
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
   |6 -
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
  |   38 ++
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java
 |6 -
 3 files changed, 31 insertions(+), 19 deletions(-)

New commits:
commit 268b9efd71b0c1799f7d76bb10962c6904768679
Author: Damjan Jovanovic 
Date:   Tue Sep 19 23:31:29 2017 +

When an unknown column is passed to ColumnContainer, which it will be when

a new column is created, re-read it from the database.

Strings in UNO can't be null. Ensure this is the case in Column and
SdbcxColumnDescriptor.

Patch by: me

diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
index aad4d3182f83..4149c1b2c55e 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
@@ -40,9 +40,9 @@ public class OColumn extends ODescriptor implements XNamed, 
XDataDescriptorFacto
 "com.sun.star.sdbcx.Column"
 };
 
-private String typeName;
-private String description;
-private String defaultValue;
+private String typeName = "";
+private String description = "";
+private String defaultValue = "";
 private int isNullable;
 private int precision;
 private int scale;
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
index 5ac10788385b..67f0162f2755 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
@@ -79,6 +79,23 @@ public class OColumnContainer extends OContainer {
 boolean isAutoIncrement = false;
 boolean isCurrency = false;
 int dataType = DataType.OTHER;
+
+ColumnDescription columnDescription = columnDescriptions.get(name);
+if (columnDescription == null) {
+// could be a recently added column. Refresh:
+List newColumns = new 
SqlTableHelper().readColumns(metadata, table.catalogName, table.schemaName, 
table.getName());
+for (ColumnDescription newColumnDescription : newColumns) {
+if (newColumnDescription.columnName.equals(name)) {
+columnDescriptions.put(name, newColumnDescription);
+break;
+}
+}
+columnDescription = columnDescriptions.get(name);
+}
+if (columnDescription == null) {
+throw new SQLException("No column " + name + " found");
+}
+
 ExtraColumnInfo columnInfo = extraColumnInfo.get(name);
 if (columnInfo == null) {
 String composedName = 
DbTools.composeTableNameForSelect(metadata.getConnection(), table);
@@ -91,20 +108,15 @@ public class OColumnContainer extends OContainer {
 isCurrency = columnInfo.isCurrency;
 dataType = columnInfo.dataType;
 }
-ColumnDescription columnDescription = columnDescriptions.get(name);
-if (columnDescription != null) {
-XNameAccess primaryKeyColumns = 
DbTools.getPrimaryKeyColumns(UnoRuntime.queryInterface(XPropertySet.class, 
table));
-int nullable = columnDescription.nullable;
-if (nullable != ColumnValue.NO_NULLS && primaryKeyColumns != null 
&& primaryKeyColumns.hasByName(name)) {
-nullable = ColumnValue.NO_NULLS;
-}
-return new OColumn(name, columnDescription.typeName, 
columnDescription.defaultValue, columnDescription.remarks,
-nullable, columnDescription.columnSize, 
columnDescription.decimalDigits, columnDescription.type,
-isAutoIncrement, false, isCurrency, isCaseSensitive());
-} else {
-// FIXME: do something like the C++ implementation does?
-throw new SQLException();
+
+XNameAccess primaryKeyColumns = 
DbTools.getPrimaryKeyColumns(UnoRuntime.queryInterface(XPropertySet.class, 
table));
+int nullable = columnDescription.nullable;
+if (nullable != ColumnValue.NO_NULLS && primaryKeyColumns != null && 
primaryKeyColumns.hasByName(name)) {
+nullable = ColumnValue.NO_NULLS;
 }
+return new OColumn(name, columnDescription.typeName, 
columnDescription.defaultValue, columnDescription.remarks,
+ 

[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java

2017-09-06 Thread Damjan Jovanovic
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
  |3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
|6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
   |3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
 |4 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
   |  135 --
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
   |5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
|3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
  |5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
 |5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
  |3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
|6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
   |6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
 |4 
 13 files changed, 92 insertions(+), 96 deletions(-)

New commits:
commit 827782b060326fd43080d610dd43025f9dc71d90
Author: Damjan Jovanovic 
Date:   Wed Sep 6 18:55:30 2017 +

Simplify the Java OContainer by requiring unique names, something C++

should probably also do as append and co check uniqueness explicitly.
This does however complicate the client code, as we have to throw
exceptions when we dedect duplication on the initial names we are
initialized with.

Patch by: me

diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
index 638b8f31c947..d9f400192494 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
@@ -24,6 +24,7 @@ package com.sun.star.sdbcx.comp.postgresql;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.sun.star.container.ElementExistException;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbc.XResultSet;
 import com.sun.star.sdbc.XRow;
@@ -52,6 +53,7 @@ public class PostgresqlCatalog extends OCatalog {
 names.add(name);
 }
 return new PostgresqlTables(lock, metadata, this, names);
+} catch (ElementExistException elementExistException) {
 } catch (SQLException sqlException) {
 } finally {
 CompHelper.disposeComponent(results);
@@ -71,6 +73,7 @@ public class PostgresqlCatalog extends OCatalog {
 names.add(name);
 }
 return new PostgresqlTables(lock, metadata, this, names);
+} catch (ElementExistException elementExistException) {
 } catch (SQLException sqlException) {
 } finally {
 CompHelper.disposeComponent(results);
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
index 426bded92625..c5a285c7514e 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
@@ -95,6 +95,8 @@ public class PostgresqlTable extends OTable {
 try {
 List columns = new 
SqlTableHelper().readColumns(getConnection().getMetaData(), catalogName, 
schemaName, getName());
 return new OColumnContainer(lock, isCaseSensitive(), columns, 
this, getConnection().getMetaData());
+} catch (ElementExistException elementExistException) {
+return null;
 } catch (SQLException sqlException) {
 return null;
 }
@@ -105,6 +107,8 @@ public class PostgresqlTable extends OTable {
 try {
 List indexes = new 
SqlTableHelper().readIndexes(getConnection().getMetaData(), catalogName, 
schemaName, getName(), this);
 return new OIndexContainer(lock, indexes, isCaseSensitive(), this);
+