Search in sources :

Example 6 with DbDirectory

use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.

the class DGraph method getProxyStoreDelegate.

@Override
public Object getProxyStoreDelegate(final DElementStore store, final Object provisionalKey) {
    Object result = null;
    Session session = Factory.getSession(SessionType.CURRENT);
    if (provisionalKey instanceof CharSequence) {
        String key = provisionalKey.toString();
        String server = "";
        if (key.contains("!!")) {
            // TODO NTF parse key string to find server name in form of 'Server!!path.nsf'
            server = "";
        // key = key;	//TODO NTF parse again
        }
        DbDirectory dir = session.getDbDirectory(server);
        result = dir.openDatabase(key);
        if (result == null) {
            // System.out.println("Creating NSF for proxy delegate: " + key);
            Session localSession = Factory.getSession(SessionType.NATIVE);
            localSession.setFixEnable(Fixes.CREATE_DB, true);
            DbDirectory localDir = localSession.getDbDirectory(server);
            Database newDb = localDir.createDatabase(key, true);
            if (newDb.isOpen()) {
                // System.out.println("Configuring NSF...");
                newDb.setCategories("graph2");
                newDb.setFolderReferencesEnabled(false);
                newDb.setTitle("Auto-generated for " + key);
                // System.out.println("Configuring view...");
                for (org.openntf.domino.View v : newDb.getViews()) {
                    v.setName("NONE");
                    v.setSelectionFormula("SELECT @False");
                }
            } else {
                System.out.println("Db not open");
            }
            result = newDb;
        // System.out.println("New NSF complete");
        }
        store.setProxyStoreKey(((Database) result).getReplicaID());
    } else {
    // TODO NTF Unimplemented
    }
    return result;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) Session(org.openntf.domino.Session)

Example 7 with DbDirectory

use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.

the class IMDBTest method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.CURRENT);
    session.setFixEnable(Fixes.REPLACE_ITEM_NULL, true);
    session.setFixEnable(Fixes.REMOVE_ITEM, true);
    session.setFixEnable(Fixes.CREATE_DB, true);
    DbDirectory dir = session.getDbDirectory("");
    Database moviesDb = dir.createDatabase("imdb/movies.nsf", true);
    // importMovies(moviesDb);
    // importPlots(moviesDb);
    importGenres(moviesDb);
// Database actorsDb = dir.createDatabase("imdb/actors.nsf", true);
// Database directorsDb = dir.createDatabase("imdb/directors.nsf", true);
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) Session(org.openntf.domino.Session)

Example 8 with DbDirectory

use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.

the class XotsNsfScanner method scan.

/**
 * Scans all databases on the specified server
 */
public List<ScheduleData> scan() {
    // Returns a XotsSessionType.NATIVE
    Session session = Factory.getSession(SessionType.CURRENT);
    DbDirectory dir = session.getDbDirectory(getServerName());
    dir.setDirectoryType(DbDirectory.Type.DATABASE);
    List<Future<List<ScheduleData>>> futures = new ArrayList<Future<List<ScheduleData>>>();
    for (Database db : dir) {
        try {
            Future<List<ScheduleData>> future = scanDatabase(db);
            if (future != null) {
                futures.add(future);
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    List<ScheduleData> ret = new ArrayList<ScheduleData>();
    for (Future<List<ScheduleData>> future : futures) {
        try {
            ret.addAll(future.get());
        } catch (Exception e) {
        // exceptions should already been logged
        }
    }
    setChanged();
    notifyObservers(null);
    return ret;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) ScheduleData(org.openntf.domino.xots.ScheduleData) ArrayList(java.util.ArrayList) Database(org.openntf.domino.Database) Future(java.util.concurrent.Future) ArrayList(java.util.ArrayList) List(java.util.List) UserAccessException(org.openntf.domino.exceptions.UserAccessException) FileNotFoundException(java.io.FileNotFoundException) Session(org.openntf.domino.Session)

Example 9 with DbDirectory

use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.

the class DGraph method getStoreDelegate.

@Override
public Object getStoreDelegate(final DElementStore store, final Object provisionalKey) {
    Object result = null;
    Session session = Factory.getSession(SessionType.CURRENT);
    if (provisionalKey instanceof CharSequence) {
        String key = provisionalKey.toString();
        String server = "";
        if (key.contains("!!")) {
            // TODO NTF parse key string to find server name in form of 'Server!!path.nsf'
            server = "";
        // key = key;	//TODO NTF parse again
        }
        DbDirectory dir = session.getDbDirectory(server);
        result = dir.openDatabase(key);
        if (result == null) {
            // System.out.println("Creating NSF for delegate: " + key);
            Session localSession = Factory.getSession(SessionType.NATIVE);
            localSession.setFixEnable(Fixes.CREATE_DB, true);
            DbDirectory localDir = localSession.getDbDirectory(server);
            Database newDb = localDir.createDatabase(key, true);
            if (newDb != null && newDb.isOpen()) {
                // System.out.println("Configuring NSF...");
                newDb.setCategories("graph2");
                newDb.setFolderReferencesEnabled(false);
                newDb.setTitle("Auto-generated for " + key);
                // System.out.println("Configuring view...");
                ACL acl = newDb.getACL();
                acl.addRole("Admin");
                acl.createACLEntry("Anonymous", Level.NOACCESS);
                acl.save();
                org.openntf.domino.View v = newDb.createView("NONE");
                v.setSelectionFormula("SELECT @False");
            } else {
                System.out.println("Database not created for key: " + key);
            }
            result = newDb;
        // System.out.println("New NSF complete");
        }
        store.setStoreKey(((Database) result).getReplicaID());
    } else {
    // TODO NTF Unimplemented
    }
    return result;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) ACL(org.openntf.domino.ACL) Session(org.openntf.domino.Session)

Example 10 with DbDirectory

use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.

the class DominoDbDirectoryTest method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.CURRENT);
    DbDirectory dir = session.getDbDirectory(null);
    dir.setDirectoryType(DbDirectory.Type.TEMPLATE);
    for (Database db : dir) {
        System.out.println(db.getApiPath() + ": " + db.getSize());
    }
    dir.setDirectoryType(DbDirectory.Type.DATABASE);
    for (Database db : dir) {
        System.out.println(db.getApiPath() + ": " + db.getSize());
    }
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) Session(org.openntf.domino.Session)

Aggregations

DbDirectory (org.openntf.domino.DbDirectory)19 Database (org.openntf.domino.Database)17 Session (org.openntf.domino.Session)11 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 Test (org.junit.Test)1 ACL (org.openntf.domino.ACL)1 Document (org.openntf.domino.Document)1 View (org.openntf.domino.View)1 IndexDatabase (org.openntf.domino.big.IndexDatabase)1 AboutDocument (org.openntf.domino.design.AboutDocument)1 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)1 UserAccessException (org.openntf.domino.exceptions.UserAccessException)1 ScheduleData (org.openntf.domino.xots.ScheduleData)1