openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1807517 - in /openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql: ./ sdbcx/ sdbcx/descriptors/
Date Wed, 06 Sep 2017 18:55:31 GMT
Author: damjan
Date: Wed Sep  6 18:55:30 2017
New Revision: 1807517

URL: http://svn.apache.org/viewvc?rev=1807517&view=rev
Log:
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


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/PostgresqlTable.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/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/OIndex.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
    openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.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/sdbcx/descriptors/SdbcxDescriptorContainer.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=1807517&r1=1807516&r2=1807517&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  6 18:55:30 2017
@@ -24,6 +24,7 @@ package com.sun.star.sdbcx.comp.postgres
 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 O
                 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 O
                 names.add(name);
             }
             return new PostgresqlTables(lock, metadata, this, names);
+        } catch (ElementExistException elementExistException) {
         } catch (SQLException sqlException) {
         } finally {
             CompHelper.disposeComponent(results);

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
Wed Sep  6 18:55:30 2017
@@ -95,6 +95,8 @@ public class PostgresqlTable extends OTa
         try {
             List<ColumnDescription> 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 OTa
         try {
             List<String> indexes = new SqlTableHelper().readIndexes(getConnection().getMetaData(),
catalogName, schemaName, getName(), this);
             return new OIndexContainer(lock, indexes, isCaseSensitive(), this);
+        } catch (ElementExistException elementExistException) {
+            return null;
         } catch (SQLException sqlException) {
             return null;
         }
@@ -116,6 +120,8 @@ public class PostgresqlTable extends OTa
             Map<String, OKey> keys = new SqlTableHelper().readKeys(
                     getConnection().getMetaData(), catalogName, schemaName, getName(), isCaseSensitive(),
this);
             return OKeyContainer.create(isCaseSensitive(), keys, this);
+        } catch (ElementExistException elementExistException) {
+            return null;
         } catch (SQLException sqlException) {
             return null;
         }

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=1807517&r1=1807516&r2=1807517&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  6 18:55:30 2017
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -48,7 +49,7 @@ public class PostgresqlTables extends OC
     private XDatabaseMetaData metadata;
     private PostgresqlCatalog catalog;
     
-    public PostgresqlTables(Object lock, XDatabaseMetaData metadata, PostgresqlCatalog catalog,
List<String> names) {
+    public PostgresqlTables(Object lock, XDatabaseMetaData metadata, PostgresqlCatalog catalog,
List<String> names) throws ElementExistException {
         super(lock, true, names);
         this.metadata = metadata;
         this.catalog = catalog;

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=1807517&r1=1807516&r2=1807517&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  6 18:55:30 2017
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.sdbc.ColumnValue;
 import com.sun.star.sdbc.DataType;
@@ -50,7 +51,8 @@ public class OColumnContainer extends OC
         public int dataType;
     }
     
-    public OColumnContainer(Object lock, boolean isCaseSensitive, List<ColumnDescription>
columnDescriptions, OTable table, XDatabaseMetaData metadata) {
+    public OColumnContainer(Object lock, boolean isCaseSensitive, List<ColumnDescription>
columnDescriptions, OTable table, XDatabaseMetaData metadata)
+            throws ElementExistException {
         super(lock, isCaseSensitive, toColumnNames(columnDescriptions));
         this.table = table;
         this.metadata = metadata;

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=1807517&r1=1807516&r2=1807517&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  6 18:55:30 2017
@@ -23,10 +23,8 @@ package com.sun.star.sdbcx.comp.postgres
 
 import java.util.ArrayList;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.TreeMap;
 
 import com.sun.star.beans.UnknownPropertyException;
@@ -63,34 +61,25 @@ import com.sun.star.uno.Type;
 import com.sun.star.util.XRefreshListener;
 import com.sun.star.util.XRefreshable;
 
+/**
+ * Base class for a lazy-loaded collection of database objects. 
+ */
 public abstract class OContainer extends WeakBase implements
         XNameAccess, XIndexAccess, XEnumerationAccess,
         XContainer, XColumnLocate, XRefreshable, XDataDescriptorFactory,
         XAppend, XDrop, XServiceInfo {
 
-    private static String[] services = new String[] {
+    private static final String[] services = new String[] {
             "com.sun.star.sdbcx.Container"
     };
     
     protected final Object lock;
     private final boolean isCaseSensitive;
-    private TreeMap<String,HashMap<Long,XPropertySet>> entriesByNameAndId;
-    private ArrayList<PropertyInfo> entriesByIndex;
-    private long nextId;
+    private TreeMap<String,XPropertySet> entriesByName;
+    private ArrayList<String> namesByIndex;
     private InterfaceContainer containerListeners = new InterfaceContainer();
     private InterfaceContainer refreshListeners = new InterfaceContainer();
 
-    /// Names aren't necessarily unique, we have to de-duplicate by id. 
-    private static class PropertyInfo {
-        String name;
-        long id;
-
-        PropertyInfo(String name, long id) {
-            this.name = name;
-            this.id = id;
-        }
-    }
-    
     private Comparator<String> caseSensitiveComparator = new Comparator<String>()
{
         @Override
         public int compare(String x, String y) {
@@ -102,21 +91,21 @@ public abstract class OContainer extends
         }
     };
 
-    public OContainer(Object lock, boolean isCaseSensitive, List<String> names) {
+    public OContainer(Object lock, boolean isCaseSensitive) {
         this.lock = lock;
         this.isCaseSensitive = isCaseSensitive;
-        this.entriesByNameAndId = new TreeMap<String,HashMap<Long,XPropertySet>>(caseSensitiveComparator);
-        this.entriesByIndex = new ArrayList<>(names.size());
+        this.entriesByName = new TreeMap<>(caseSensitiveComparator);
+        this.namesByIndex = new ArrayList<>();
+    }
+    
+    public OContainer(Object lock, boolean isCaseSensitive, List<String> names) throws
ElementExistException {
+        this(lock, isCaseSensitive);
         for (String name : names) {
-            HashMap<Long,XPropertySet> entriesById = entriesByNameAndId.get(name);
-            if (entriesById == null) {
-                entriesById = new HashMap<>();
-                entriesByNameAndId.put(name, entriesById);
+            if (entriesByName.containsKey(name)) {
+                throw new ElementExistException(name, this);
             }
-            entriesById.put(nextId, null);
-            
-            entriesByIndex.add(new PropertyInfo(name, nextId));
-            ++nextId;
+            entriesByName.put(name, null);
+            namesByIndex.add(name);
         }
     }
     
@@ -128,13 +117,11 @@ public abstract class OContainer extends
         refreshListeners.disposeAndClear(event);
         
         synchronized (lock) {
-            for (Map<Long,XPropertySet> entriesById : entriesByNameAndId.values())
{
-                for (XPropertySet propertySet : entriesById.values()) {
-                    CompHelper.disposeComponent(propertySet);
-                }
+            for (XPropertySet value : entriesByName.values()) {
+                CompHelper.disposeComponent(value);
             }
-            entriesByNameAndId.clear();
-            entriesByIndex.clear();
+            entriesByName.clear();
+            namesByIndex.clear();
         }
     }
 
@@ -164,7 +151,7 @@ public abstract class OContainer extends
     @Override
     public Object getByIndex(int index) throws IndexOutOfBoundsException, WrappedTargetException
{
         synchronized (lock) {
-            if (index < 0 || index >= entriesByIndex.size()) {
+            if (index < 0 || index >= namesByIndex.size()) {
                 throw new IndexOutOfBoundsException(Integer.toString(index), this);
             }
             return getObject(index);
@@ -174,7 +161,7 @@ public abstract class OContainer extends
     @Override
     public int getCount() {
         synchronized (lock) {
-            return entriesByIndex.size();
+            return namesByIndex.size();
         }
     }
     
@@ -183,14 +170,14 @@ public abstract class OContainer extends
     @Override
     public boolean hasByName(String name) {
         synchronized (lock) {
-            return entriesByNameAndId.containsKey(name);
+            return entriesByName.containsKey(name);
         }
     }
 
     @Override
     public Object getByName(String name) throws NoSuchElementException, WrappedTargetException
{
         synchronized (lock) {
-            if (!entriesByNameAndId.containsKey(name)) {
+            if (!entriesByName.containsKey(name)) {
                 String error = SharedResources.getInstance().getResourceStringWithSubstitution(
                         Resources.STR_NO_ELEMENT_NAME, "$name$", name);
                 throw new NoSuchElementException(error, this);
@@ -202,12 +189,8 @@ public abstract class OContainer extends
     @Override
     public String[] getElementNames() {
         synchronized (lock) {
-            String[] names = new String[entriesByIndex.size()];
-            int next = 0;
-            for (PropertyInfo propertyInfo : entriesByIndex) {
-                names[next++] = propertyInfo.name;
-            }
-            return names;
+            String[] names = new String[namesByIndex.size()];
+            return namesByIndex.toArray(names);
         }
     }
     
@@ -215,15 +198,13 @@ public abstract class OContainer extends
     
     @Override
     public void refresh() {
-        Iterator iterator;
+        Iterator<?> iterator;
         synchronized (lock) {
-            for (Map<Long,XPropertySet> entriesById : entriesByNameAndId.values())
{
-                for (XPropertySet propertySet : entriesById.values()) {
-                    CompHelper.disposeComponent(propertySet);
-                }
+            for (XPropertySet value : entriesByName.values()) {
+                CompHelper.disposeComponent(value);
             }
-            entriesByNameAndId.clear();
-            entriesByIndex.clear();
+            entriesByName.clear();
+            namesByIndex.clear();
 
             impl_refresh();
             
@@ -249,12 +230,12 @@ public abstract class OContainer extends
     
     @Override
     public void appendByDescriptor(XPropertySet descriptor) throws SQLException, ElementExistException
{
-        Iterator iterator;
+        Iterator<?> iterator;
         ContainerEvent event;
         synchronized (lock) {
             String name = getNameForObject(descriptor);
             
-            if (entriesByNameAndId.containsKey(name)) {
+            if (entriesByName.containsKey(name)) {
                 throw new ElementExistException(name, this);
             }
             
@@ -264,13 +245,10 @@ public abstract class OContainer extends
             }
             
             name = getNameForObject(newlyCreated);
-            HashMap<Long,XPropertySet> entriesById = entriesByNameAndId.get(name);
-            if (entriesById == null) { // this may happen when the derived class included
it itself
-                entriesById = new HashMap<>();
-                entriesById.put(nextId, newlyCreated);
-                entriesByNameAndId.put(name, entriesById);
-                entriesByIndex.add(new PropertyInfo(name, nextId));
-                nextId++;
+            XPropertySet value = entriesByName.get(name);
+            if (value == null) { // this may happen when the derived class included it itself
+                entriesByName.put(name, newlyCreated);
+                namesByIndex.add(name);
             }
             
             // notify our container listeners
@@ -289,7 +267,7 @@ public abstract class OContainer extends
     @Override
     public void dropByName(String name) throws SQLException, NoSuchElementException {
         synchronized (lock) {
-            if (!entriesByNameAndId.containsKey(name)) {
+            if (!entriesByName.containsKey(name)) {
                 throw new NoSuchElementException(name, this);
             }
             dropImpl(indexOf(name));
@@ -299,7 +277,7 @@ public abstract class OContainer extends
     @Override
     public void dropByIndex(int index) throws SQLException, IndexOutOfBoundsException {
         synchronized (lock) {
-            if (index < 0 || index >= entriesByIndex.size()) {
+            if (index < 0 || index >= namesByIndex.size()) {
                 throw new IndexOutOfBoundsException(Integer.toString(index), this);
             }
             dropImpl(index);
@@ -312,20 +290,16 @@ public abstract class OContainer extends
     }
 
     private void dropImpl(int index, boolean reallyDrop) throws SQLException {
-        PropertyInfo propertyInfo = entriesByIndex.get(index);
+        String name = namesByIndex.get(index);
         if (reallyDrop) {
-            dropObject(index, propertyInfo.name);
-        }
-        HashMap<Long,XPropertySet> entriesById = entriesByNameAndId.get(propertyInfo.name);
-        XPropertySet propertySet = entriesById.remove(propertyInfo.id);
-        if (entriesById.isEmpty()) {
-            entriesByNameAndId.remove(propertyInfo.name);
+            dropObject(index, name);
         }
+        namesByIndex.remove(index);
+        XPropertySet propertySet = entriesByName.remove(name);
         CompHelper.disposeComponent(propertySet);
-        entriesByIndex.remove(index);
         
-        ContainerEvent event = new ContainerEvent(this, propertyInfo.name, null, null);
-        for (Iterator iterator = containerListeners.iterator(); iterator.hasNext(); ) {
+        ContainerEvent event = new ContainerEvent(this, name, null, null);
+        for (Iterator<?> iterator = containerListeners.iterator(); iterator.hasNext();
) {
             XContainerListener listener = (XContainerListener) iterator.next();
             listener.elementRemoved(event);
         }
@@ -335,7 +309,7 @@ public abstract class OContainer extends
     
     @Override
     public int findColumn(String name) throws SQLException {
-        if (!entriesByNameAndId.containsKey(name)) {
+        if (!entriesByName.containsKey(name)) {
             String error = SharedResources.getInstance().getResourceStringWithSubstitution(
                     Resources.STR_UNKNOWN_COLUMN_NAME, "$columnname$", name);
             throw new SQLException(error, this, StandardSQLState.SQL_COLUMN_NOT_FOUND.text(),
0, null);
@@ -369,7 +343,7 @@ public abstract class OContainer extends
     @Override
     public boolean hasElements() {
         synchronized (lock) {
-            return !entriesByNameAndId.isEmpty();
+            return !entriesByName.isEmpty();
         }
     }
     
@@ -388,8 +362,8 @@ public abstract class OContainer extends
     }
     
     protected int indexOf(String name) {
-        for (int i = 0; i < entriesByIndex.size(); i++) {
-            if (entriesByIndex.get(i).name.equals(name)) {
+        for (int i = 0; i < namesByIndex.size(); i++) {
+            if (namesByIndex.get(i).equals(name)) {
                 return i;
             }
         }
@@ -402,12 +376,11 @@ public abstract class OContainer extends
      * @return ObjectType
      */
     protected Object getObject(int index) throws WrappedTargetException {
-        PropertyInfo propertyInfo = entriesByIndex.get(index);
-        HashMap<Long,XPropertySet> entriesById = entriesByNameAndId.get(propertyInfo.name);
-        XPropertySet propertySet = entriesById.get(propertyInfo.id);
+        String name = namesByIndex.get(index);
+        XPropertySet propertySet = entriesByName.get(name);
         if (propertySet == null) {
             try {
-                propertySet = createObject(propertyInfo.name);
+                propertySet = createObject(name);
             } catch (SQLException e) {
                 try {
                     dropImpl(index, false);
@@ -415,7 +388,7 @@ public abstract class OContainer extends
                 }
                 throw new WrappedTargetException(e.getMessage(), this, e);
             }
-            entriesById.put(propertyInfo.id, propertySet);
+            entriesByName.put(name, propertySet);
         }
         return propertySet;
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
Wed Sep  6 18:55:30 2017
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.PropertyAttribute;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbcx.XColumnsSupplier;
@@ -45,7 +46,7 @@ public class OIndex extends ODescriptor
     private OContainer columns;
     
     protected OIndex(Object lock, String name, boolean isCaseSensitive, String catalogName,
-            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, List<String>
columnNames, OTable table) {
+            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, List<String>
columnNames, OTable table) throws ElementExistException {
         super(lock, name, isCaseSensitive);
         this.catalogName = catalogName;
         this.isUnique = isUnique;
@@ -57,7 +58,7 @@ public class OIndex extends ODescriptor
     }
     
     public static OIndex create(String name, boolean isCaseSensitive, String catalogName,
-            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, List<String>
columnNames, OTable table) {
+            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, List<String>
columnNames, OTable table) throws ElementExistException {
         final Object lock = new Object();
         return new OIndex(lock, name, isCaseSensitive, catalogName, isUnique, isPrimaryKeyIndex,
isClustered, columnNames, table);
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
Wed Sep  6 18:55:30 2017
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -40,7 +41,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OIndexColumnContainer extends OContainer {
     private OIndex index;
     
-    public OIndexColumnContainer(Object lock, OIndex index, List<String> columnNames)
{
+    public OIndexColumnContainer(Object lock, OIndex index, List<String> columnNames)
throws ElementExistException {
         super(lock, true, columnNames);
         this.index = index;
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
Wed Sep  6 18:55:30 2017
@@ -26,6 +26,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XIndexAccess;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.IndexOutOfBoundsException;
@@ -50,7 +51,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OIndexContainer extends OContainer {
     protected OTable table;
     
-    public OIndexContainer(Object lock, List<String> names, boolean isCaseSensitive,
OTable table) {
+    public OIndexContainer(Object lock, List<String> names, boolean isCaseSensitive,
OTable table) throws ElementExistException {
         super(lock, isCaseSensitive, names);
         this.table = table;
     }
@@ -113,7 +114,7 @@ public class OIndexContainer extends OCo
                 CompHelper.disposeComponent(results);
             }
             return ret;
-        } catch (WrappedTargetException | UnknownPropertyException | IllegalArgumentException
exception) {
+        } catch (WrappedTargetException | UnknownPropertyException | IllegalArgumentException
| ElementExistException exception) {
             throw new SQLException("Error", this, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, exception);
         }
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
Wed Sep  6 18:55:30 2017
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.PropertyAttribute;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.lang.DisposedException;
 import com.sun.star.sdbc.SQLException;
@@ -54,7 +55,7 @@ public class OKey extends ODescriptor
     }
     
     protected OKey(Object lock, String name, boolean isCaseSensitive, String referencedTable,
int type,
-            int updateRule, int deleteRule, List<String> columnNames, OTable table)
{
+            int updateRule, int deleteRule, List<String> columnNames, OTable table)
throws ElementExistException {
         super(lock, name, isCaseSensitive);
         this.referencedTable = referencedTable;
         this.type = type;
@@ -66,7 +67,7 @@ public class OKey extends ODescriptor
     }
     
     public static OKey create(String name, boolean isCaseSensitive, String referencedTable,
int type,
-            int updateRule, int deleteRule, List<String> columnNames, OTable table)
{
+            int updateRule, int deleteRule, List<String> columnNames, OTable table)
throws ElementExistException {
         final Object lock = new Object();
         return new OKey(lock, name, isCaseSensitive, referencedTable, type, updateRule, deleteRule,
columnNames, table);
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
Wed Sep  6 18:55:30 2017
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -39,7 +40,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OKeyColumnContainer extends OContainer {
     private OKey key;
     
-    public OKeyColumnContainer(Object lock, OKey key, List<String> columnNames) {
+    public OKeyColumnContainer(Object lock, OKey key, List<String> columnNames) throws
ElementExistException {
         super(lock, true, columnNames);
         this.key = key;
     }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
Wed Sep  6 18:55:30 2017
@@ -29,6 +29,7 @@ import java.util.Map;
 import com.sun.star.beans.PropertyVetoException;
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XIndexAccess;
 import com.sun.star.container.XNamed;
 import com.sun.star.lang.IllegalArgumentException;
@@ -54,7 +55,7 @@ public class OKeyContainer extends OCont
     private OTable table;
     private Map<String,OKey> keys;
     
-    protected OKeyContainer(Object lock, boolean isCaseSensitive, List<String> names,
Map<String,OKey> keys, OTable table) {
+    protected OKeyContainer(Object lock, boolean isCaseSensitive, List<String> names,
Map<String,OKey> keys, OTable table) throws ElementExistException {
         super(lock, isCaseSensitive, names);
         System.out.println("Keys.size()=" + keys.size());
         for (Map.Entry<String,OKey> entry : keys.entrySet()) {
@@ -77,7 +78,7 @@ public class OKeyContainer extends OCont
         this.table = table;
     }
     
-    public static OKeyContainer create(boolean isCaseSensitive, Map<String,OKey> keys,
OTable table) {
+    public static OKeyContainer create(boolean isCaseSensitive, Map<String,OKey> keys,
OTable table) throws ElementExistException {
         final Object lock = new Object();
         String[] names = new String[keys.size()];
         keys.keySet().toArray(names);
@@ -211,6 +212,7 @@ public class OKeyContainer extends OCont
         } catch (IllegalArgumentException illegalArgumentException) {
         } catch (IndexOutOfBoundsException indexOutOfBoundsException) {
         } catch (PropertyVetoException propertyVetoException) {
+        } catch (ElementExistException elementExistException) {
         }
         return null;
     }

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=1807517&r1=1807516&r2=1807517&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  6 18:55:30 2017
@@ -28,6 +28,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import com.sun.star.container.ElementExistException;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbc.XDatabaseMetaData;
 import com.sun.star.sdbc.XResultSet;
@@ -37,6 +38,7 @@ import com.sun.star.sdbcx.comp.postgresq
 import com.sun.star.sdbcx.comp.postgresql.util.ComposeRule;
 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;
 
@@ -165,6 +167,8 @@ public class SqlTableHelper {
                 key = OKey.create(pkName, isCaseSensitive, "", KeyType.PRIMARY, 0, 0, columns,
table);
             }
             return key;
+        } catch (ElementExistException elementExistException) {
+            throw new SQLException("Error", this, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, elementExistException);
         } finally {
             CompHelper.disposeComponent(results);
         }
@@ -221,6 +225,8 @@ public class SqlTableHelper {
                     keys.put(oldFkName, key);
                 }
             }
+        } catch (ElementExistException elementExistException) {
+            throw new SQLException("Error", this, StandardSQLState.SQL_GENERAL_ERROR.text(),
0, elementExistException);
         } finally {
             CompHelper.disposeComponent(results);
         }

Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java?rev=1807517&r1=1807516&r2=1807517&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
(original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
Wed Sep  6 18:55:30 2017
@@ -21,8 +21,6 @@
 
 package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors;
 
-import java.util.Collections;
-
 import com.sun.star.beans.XPropertySet;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbcx.comp.postgresql.sdbcx.OContainer;
@@ -32,7 +30,7 @@ import com.sun.star.sdbcx.comp.postgresq
 
 public abstract class SdbcxDescriptorContainer extends OContainer {
     public SdbcxDescriptorContainer(Object lock, boolean isCaseSensitive) {
-        super(lock, isCaseSensitive, Collections.<String>emptyList());
+        super(lock, isCaseSensitive);
     }
     
     @Override



Mime
View raw message