use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.
the class View method checkUnique.
/* (non-Javadoc)
* @see org.openntf.domino.ext.View#checkUnique(java.lang.Object, org.openntf.domino.Document)
*/
@Override
public boolean checkUnique(final Object key, final Document srcDoc) {
boolean retVal_ = false;
try {
DocumentCollection dc = this.getAllDocumentsByKey(key, true);
for (Document checkDoc : dc) {
if (null == srcDoc) {
return false;
} else {
if (!checkDoc.getUniversalID().equals(srcDoc.getUniversalID())) {
return retVal_;
}
}
}
retVal_ = true;
} catch (Exception e) {
DominoUtils.handleException(e);
}
return retVal_;
}
use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.
the class DocumentIterator method next.
/*
* (non-Javadoc)
*
* @see java.util.Iterator#next()
*/
@Override
public Document next() {
Document result = null;
if (hasNext()) {
currentNoteid_ = Integer.toHexString(getIdArray()[getIndex()]);
setIndex(getIndex() + 1);
// Base.recycle(current_);
try {
Database db = collection_.getAncestorDatabase();
lotus.domino.Document doc = db.getDocumentByID(currentNoteid_);
if (doc instanceof org.openntf.domino.Document) {
result = (org.openntf.domino.Document) doc;
} else {
result = wf_.fromLotus(doc, Document.SCHEMA, db);
}
// current_ = result;
} catch (Throwable t) {
DominoUtils.handleException(t);
}
}
return result;
}
use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.
the class BaseOpenLogItem method writeToLog.
/* (non-Javadoc)
* @see org.openntf.domino.logging.OpenLogItem#writeToLog()
*/
@Override
public boolean writeToLog() {
Database currDb = Factory.getSession(SessionType.CURRENT).getCurrentDatabase();
// Current database may be null from Xots
if (null == currDb) {
if (!StringUtil.equals(getCurrentDatabasePath(), "")) {
reinitialiseSettings();
}
} else {
if (!StringUtil.equals(getCurrentDatabasePath(), Factory.getSession(SessionType.CURRENT).getCurrentDatabase().getFilePath())) {
reinitialiseSettings();
}
}
// exit early if there is no database
Database db = getLogDb();
if (db == null) {
return false;
}
boolean retval = false;
Document logDoc = null;
RichTextItem rtitem = null;
Database docDb = null;
try {
logDoc = db.createDocument();
logDoc.appendItemValue("Form", _logFormName);
Throwable ee = getBase();
if (ee != null) {
StackTraceElement ste = ee.getStackTrace()[0];
if (ee instanceof NotesException) {
logDoc.replaceItemValue("LogErrorNumber", ((NotesException) ee).id);
logDoc.replaceItemValue("LogErrorMessage", ((NotesException) ee).text);
} else {
// Fixed next line
logDoc.replaceItemValue("LogErrorMessage", getMessage());
}
logDoc.replaceItemValue("LogErrorLine", ste.getLineNumber());
logDoc.replaceItemValue("LogFromMethod", ste.getClassName() + "." + ste.getMethodName());
}
if (LogType.TYPE_EVENT.getValue().equals(getEventType())) {
if (!getSuppressEventStack()) {
logDoc.replaceItemValue("LogStackTrace", getStackTrace(ee));
}
} else {
logDoc.replaceItemValue("LogStackTrace", getStackTrace(ee));
}
logDoc.replaceItemValue("LogSeverity", getSeverity().getName());
logDoc.replaceItemValue("LogEventTime", getEventTime());
logDoc.replaceItemValue("LogEventType", getEventType());
logDoc.replaceItemValue("LogMessage", getMessage());
logDoc.replaceItemValue("LogFromDatabase", getCurrentDatabasePath());
logDoc.replaceItemValue("LogFromServer", getThisServer());
logDoc.replaceItemValue("LogFromAgent", getThisAgent());
// Fixed next line
logDoc.replaceItemValue("LogAgentLanguage", "Java");
logDoc.replaceItemValue("LogUserName", Factory.getSession(SessionType.CURRENT).getUserName());
logDoc.replaceItemValue("LogEffectiveName", Factory.getSession(SessionType.CURRENT).getEffectiveUserName());
logDoc.replaceItemValue("LogAccessLevel", getAccessLevel());
logDoc.replaceItemValue("LogUserRoles", getUserRoles());
logDoc.replaceItemValue("LogClientVersion", getClientVersion());
logDoc.replaceItemValue("LogAgentStartTime", getStartTime());
if (getErrDoc() != null) {
docDb = getErrDoc().getParentDatabase();
rtitem = logDoc.createRichTextItem("LogDocInfo");
rtitem.appendText("The document associated with this event is:");
rtitem.addNewLine(1);
rtitem.appendText("Server: " + docDb.getServer());
rtitem.addNewLine(1);
rtitem.appendText("Database: " + docDb.getFilePath());
rtitem.addNewLine(1);
rtitem.appendText("UNID: " + getErrDoc().getUniversalID());
rtitem.addNewLine(1);
rtitem.appendText("Note ID: " + getErrDoc().getNoteID());
rtitem.addNewLine(1);
rtitem.appendText("DocLink: ");
rtitem.appendDocLink(_errDoc, getErrDoc().getUniversalID());
}
// make sure Depositor-level users can add documents too
logDoc.appendItemValue("$PublicAccess", "1");
logDoc.save(true);
retval = true;
} catch (Exception e) {
debugPrint(e);
retval = false;
} finally {
_errDoc = null;
_errDocUnid = null;
}
return retval;
}
use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.
the class BigNoteCollection method getDocument.
public static Document getDocument(final Session session, final String server, final String replid, final String noteid) {
final Database db = session.getDatabase("", "");
db.openByReplicaID(server, replid);
if (db.isOpen()) {
final Document result = db.getDocumentByID(noteid);
return result;
} else {
// TODO handle exception properly
return null;
}
}
use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.
the class DbCache method getDocument.
public Document getDocument(final NoteCoordinate nc) {
Document result = null;
long id = nc.getDbid();
Database db = getDatabase(id);
if (db == null) {
System.out.println("DEBUG: Unable to find database with id " + id + " (" + org.openntf.domino.big.NoteCoordinate.Utils.getReplidFromLong(id) + ")");
}
result = db.getDocumentByUNID(nc.getUNID(), true);
return result;
}
Aggregations