use of org.openntf.domino.Database in project org.openntf.domino by OpenNTF.
the class NoteCoordinate method getView.
public View getView() {
Database database = getDatabase("");
Document doc = getDocument("");
return database.getView(doc);
}
use of org.openntf.domino.Database in project org.openntf.domino by OpenNTF.
the class ConfigurationObject method syncCache.
/**
* Syncs the <code>cache_<code> with the backend document. must be called from a proper initialized thread!
*/
public void syncCache() {
Database odaDb_ = Configuration.getOdaDb();
if (odaDb_ == null) {
// we don't have an ODA-DB. so it's useless to query it again;
// do not read the doc again before Sun Aug 17 17:12:55 EST 292278994
nextDocAccess = Long.MAX_VALUE;
return;
}
synchronized (dirty_) {
// Create the document, if cache is dirty;
Document doc = getDocument(true);
if (doc == null)
return;
// write back all dirty keys to the document
if (!dirty_.isEmpty()) {
for (String dirtyKey : dirty_) {
doc.put(dirtyKey, cache_.get(dirtyKey));
}
doc.save();
dirty_.clear();
}
// read all keys from the document that are specified in the schema
Object[] s = schema();
for (int i = 0; i < s.length; i += 2) {
cache_.put((String) s[i], doc.getItemValue((String) s[i], (Class<?>) s[i + 1]));
}
}
}
use of org.openntf.domino.Database in project org.openntf.domino by OpenNTF.
the class DatabaseTransaction method rollback.
/**
* Discard all cached updates - updated documents are reverted back to their original state and documents marked for removal are kept in
* Database. This transaction is then closed and a new one needs to be {@link org.openntf.domino.Database#startTransaction() started}.
*/
public void rollback() {
// TODO - NTF release locks
Queue<DatabaseDescendant> uq = getUpdateQueue();
// synchronized (uq) {
DatabaseDescendant next = uq.poll();
while (next != null) {
if (next instanceof org.openntf.domino.Document) {
org.openntf.domino.Document doc = (org.openntf.domino.Document) next;
doc.rollback();
if (isDocLock(doc)) {
doc.unlock();
}
}
// TODO NTF - Implement other database objects
next = uq.poll();
}
// }
Queue<DatabaseDescendant> rq = getRemoveQueue();
// synchronized (rq) {
/*DatabaseDescendant*/
next = rq.poll();
while (next != null) {
if (next instanceof org.openntf.domino.Document) {
org.openntf.domino.Document doc = (org.openntf.domino.Document) next;
doc.rollback();
if (isDocLock(doc)) {
doc.unlock();
}
}
// TODO NTF - Implement other database objects
next = rq.poll();
}
// }
for (Database db : databases_) {
db.closeTransaction();
}
}
use of org.openntf.domino.Database in project org.openntf.domino by OpenNTF.
the class DatabaseTransaction method commit.
// public boolean isCommitting() {
// return isCommitting_;
// }
/**
* Writes all cached updates to Documents - updated documents are saved and documents marked for removal will be removed. This
* transaction is then closed and a new one needs to be {@link org.openntf.domino.Database#startTransaction() started}.
*/
public void commit() {
// System.out.println("Committing transaction with update size " + getUpdateQueue().size());
isCommitting_ = true;
Queue<DatabaseDescendant> uq = getUpdateQueue();
// synchronized (uq) {
DatabaseDescendant next = uq.poll();
while (next != null) {
if (next instanceof Document) {
boolean result = ((Document) next).save();
if (!result) {
// System.out.println("Transaction document save failed.");
// TODO NTF - take some action to indicate that the save failed, potentially cancelling the transaction
} else {
if (isDocLock(next)) {
((Document) next).unlock();
}
}
}
// TODO NTF - Implement other database objects
next = uq.poll();
}
// }
Queue<DatabaseDescendant> rq = getRemoveQueue();
// synchronized (rq) {
/*DatabaseDescendant*/
next = rq.poll();
while (next != null) {
if (next instanceof org.openntf.domino.Document) {
org.openntf.domino.Document doc = (org.openntf.domino.Document) next;
if (isDocLock(doc)) {
doc.unlock();
}
doc.forceDelegateRemove();
}
// TODO NTF - Implement other database objects
next = rq.poll();
}
// }
for (Database db : databases_) {
db.closeTransaction();
}
// database_.closeTransaction();
}
use of org.openntf.domino.Database in project org.openntf.domino by OpenNTF.
the class AbstractSessionFactory method wrapSession.
protected Session wrapSession(final lotus.domino.Session raw, final boolean selfCreated) {
WrapperFactory wf = Factory.getWrapperFactory();
org.openntf.domino.Session sess = wf.fromLotus(raw, Session.SCHEMA, wf);
sess.setNoRecycle(!selfCreated);
Fixes[] fixes = Factory.getThreadConfig().fixes;
if (fixes != null) {
for (Fixes fix : fixes) {
if (fix.isKhan()) {
sess.setFixEnable(fix, true);
}
}
}
sess.setAutoMime(Factory.getThreadConfig().autoMime);
sess.setConvertMIME(false);
if (selfCreated && currentApiPath_ != null) {
Database db = sess.getCurrentDatabase();
if (db == null) {
db = sess.getDatabase(currentApiPath_);
setCurrentDatabase(sess, db);
}
}
return sess;
}
Aggregations