private void adaptNewSetsMembership() throws ServerException {
        Connection conn = null;
        boolean startedTransaction = false;

        Iterator<SetInfo> newUserDefinedSetInfosIterator =
            this.newUserDefinedSetsMap.values().iterator();
        while (newUserDefinedSetInfosIterator.hasNext()) {
            SetInfo curentSetInfo = newUserDefinedSetInfosIterator.next();
            String curentSpec = curentSetInfo.getSetSpec();
            Vector<String> resourceIds =
                _driver.retrieveIdsForSetQuery(curentSpec);
            if (resourceIds != null) {
                try {
                    conn = RecordCache.getConnection();
                    conn.setAutoCommit(false);
                    startedTransaction = true;
                    String path = _disk.write(curentSetInfo);
                    _db.addNewUserDefinedSet(conn, curentSpec, path);
                    if (resourceIds.size() > 0) {
                        _db.putSetMembership(conn, curentSpec, resourceIds);
                    }
                    conn.commit();
                }
                catch (Throwable th) {
                    _LOG.error("Adapt set membership for set spec "
                        + curentSpec + " aborted.");

                    if (startedTransaction) {
                        _LOG.error("Start to roll back the transaction.");
                        try {
                            conn.rollback();
                        }
                        catch (SQLException e) {
                            _LOG.error(
                                "Failed to roll back failed transaction", e);
                        }
                    }

                }
                finally {
                    if (conn != null) {
                        try {
                            if (startedTransaction)
                                conn.setAutoCommit(false);
                        }
                        catch (SQLException e) {
                            _LOG.error("Failed to set autoCommit to false", e);
                        }
                        finally {
                            RecordCache.releaseConnection(conn);
                        }
                    }
                }
            }
            else {
                _LOG.error("Missing result of search query for set spec "
                    + curentSpec);
                throw new RepositoryException(
                    "Missing result of search query for set spec " + curentSpec);
            }

        }

    }