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;
}
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);
}
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;
}
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;
}
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());
}
}
Aggregations