Search in sources :

Example 1 with DatabaseMetaData

use of org.openntf.domino.helpers.DatabaseMetaData in project org.openntf.domino by OpenNTF.

the class DbDirectory method toArray.

/**
 * Returns an array containing all of the databases in this directory
 */
@Override
public Object[] toArray() {
    Object[] ret = new Object[size()];
    int i = 0;
    for (DatabaseMetaData metaData : getMetaDataSet()) {
        Database db = getFactory().create(Database.SCHEMA, getAncestorSession(), metaData);
        ret[i++] = db;
    }
    return ret;
}
Also used : Database(org.openntf.domino.Database) DatabaseMetaData(org.openntf.domino.helpers.DatabaseMetaData)

Example 2 with DatabaseMetaData

use of org.openntf.domino.helpers.DatabaseMetaData in project org.openntf.domino by OpenNTF.

the class DbDirectory method initialize.

private void initialize(final lotus.domino.DbDirectory delegate) {
    dbMetaDataSet_ = new ConcurrentSkipListSet<DatabaseMetaData>(comparator_);
    // boolean isExtended = type_ == Type.REPLICA_CANDIDATE || isDateSorted_;
    // ||  type_ == Type.REPLICA_CANDIDATE; CHECKME: Is there really an issue with REPLICA_CANDIDATE
    boolean isExtended = isSortByLastModified();
    try {
        lotus.domino.Database rawdb = null;
        try {
            int type = type_.getValue();
            rawdb = delegate.getFirstDatabase(type);
        } catch (NotesException ne) {
            log_.log(Level.WARNING, "For some reason getting the first database reported an exception: " + ne.text + "  Attempting to move along...");
            rawdb = delegate.getNextDatabase();
        }
        while (rawdb != null) {
            // remember, if the database was open or not!
            boolean wasOpen = rawdb.isOpen();
            // try to open the DB for extended infos
            if (isExtended) {
                try {
                    rawdb.open();
                } catch (NotesException tmp) {
                    log_.log(Level.FINE, "Unable to read extended infos from database: " + rawdb.getServer() + "!!" + rawdb.getFilePath());
                }
            }
            dbMetaDataSet_.add(new DatabaseMetaData(rawdb));
            if (wasOpen) {
                getFactory().fromLotus(rawdb, Database.SCHEMA, getAncestorSession());
            } else {
                Base.s_recycle(rawdb);
            }
            rawdb = delegate.getNextDatabase();
        }
        Base.s_recycle(delegate);
    } catch (NotesException ne) {
        ne.printStackTrace();
    }
// try {
// 
// delegate.setHonorShowInOpenDatabaseDialog(isHonorOpenDialog_);
// 
// 
// // Trying to iterate multiple times over the DbDirectory
// for (int i = 0; i < 16; i++) {
// int cnt = 0;
// rawdb = delegate.getFirstDatabase(1245 + (i % 4));
// while (rawdb != null) {
// cnt++;
// try {
// rawdb.open();
// } catch (NotesException ne) {
// }
// rawdb.recycle();
// rawdb = delegate.getNextDatabase();
// }
// System.out.println("iteration " + i + " DBs: " + cnt);
// }
// 
// try {
// rawdb = delegate.getFirstDatabase(type_.getValue());
// } catch (NotesException ne) {
// log_.log(Level.WARNING, "For some reason getting the first database reported an exception: " + ne.text
// + "  Attempting to move along...");
// rawdb = delegate.getNextDatabase();
// }
// lotus.domino.Database nextdb;
// Database db;
// boolean accessible = false;
// lotus.domino.Database firstDb = rawdb;
// while (rawdb != null) {
// nextdb = delegate.getNextDatabase();
// 
// // RPr: the dbDirectory really sucks...
// // Problem 1: Normally the dbDirectory provides "closed" databases
// // this means, you get also database objects you do not have access to. If we try to get such a database later by apiPath from the session
// // it will fail!
// //
// // Problem 2: Sometimes you will get the same database objects that were opened somwhere else in your code. This means if you recycle
// // the db while you are iterating, this will invalidate the db that was somewhere else opened!
// 
// // TODO RPr: Should we do that with factory
// // YES, we MUST do this in the factory, otherwise we will get errors like: PANIC! Why are we recaching a lotus object" because there are
// // two openntf.domino instances for the same cpp id
// db = getFactory().fromLotus(rawdb, Database.SCHEMA, null);
// 
// // And we MUST NOT use this constructor, as it recycles the delegate (which means that we close databases, that we have opened somewhere else in our code)
// //db = new org.openntf.domino.impl.Database(rawdb, this, isExtended);
// 
// if (type_ == Type.REPLICA_CANDIDATE) {
// if (org.openntf.domino.Database.Utils.isReplicaCandidate(db))
// dbHolderSet_.add(new DatabaseMetaData(db));
// } else if (type_ == Type.TEMPLATE) {
// if (org.openntf.domino.Database.Utils.isTemplate(db))
// dbHolderSet_.add(new DatabaseMetaData(db));
// } else if (type_ == Type.DATABASE) {
// if (org.openntf.domino.Database.Utils.isDatabase(db))
// dbHolderSet_.add(new DatabaseMetaData(db));
// } else if (type_ == Type.XOTS_DATABASE) {
// if (org.openntf.domino.Database.Utils.isXotsDatabase(db))
// dbHolderSet_.add(new DatabaseMetaData(db));
// } else {
// if (org.openntf.domino.Database.Utils.isTemplateCandidate(db))
// dbHolderSet_.add(new DatabaseMetaData(db));
// }
// // the "db" object will get out of scope here, so that it can get recycled through the GC
// rawdb = nextdb;
// }
// Base.s_recycle(delegate);
// } catch (NotesException ne) {
// ne.printStackTrace();
// }
// isInitialized_ = true;
}
Also used : NotesException(lotus.domino.NotesException) DatabaseMetaData(org.openntf.domino.helpers.DatabaseMetaData)

Aggregations

DatabaseMetaData (org.openntf.domino.helpers.DatabaseMetaData)2 NotesException (lotus.domino.NotesException)1 Database (org.openntf.domino.Database)1