Search in sources :

Example 6 with Document

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_;
}
Also used : DocumentCollection(org.openntf.domino.DocumentCollection) Document(org.openntf.domino.Document) InvalidClassException(java.io.InvalidClassException) BackendBridgeSanityCheckException(org.openntf.domino.exceptions.BackendBridgeSanityCheckException) NotesException(lotus.domino.NotesException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with Document

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;
}
Also used : Database(org.openntf.domino.Database) Document(org.openntf.domino.Document)

Example 8 with Document

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;
}
Also used : NotesException(lotus.domino.NotesException) RichTextItem(org.openntf.domino.RichTextItem) Database(org.openntf.domino.Database) Document(org.openntf.domino.Document) NotesException(lotus.domino.NotesException)

Example 9 with Document

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;
    }
}
Also used : Database(org.openntf.domino.Database) Document(org.openntf.domino.Document)

Example 10 with Document

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;
}
Also used : Database(org.openntf.domino.Database) Document(org.openntf.domino.Document)

Aggregations

Document (org.openntf.domino.Document)112 Database (org.openntf.domino.Database)48 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)31 Session (org.openntf.domino.Session)28 Map (java.util.Map)20 HashSet (java.util.HashSet)15 LinkedHashMap (java.util.LinkedHashMap)15 DocumentCollection (org.openntf.domino.DocumentCollection)15 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 Item (org.openntf.domino.Item)13 Set (java.util.Set)12 ArrayList (java.util.ArrayList)11 Date (java.util.Date)9 HashMap (java.util.HashMap)9 View (org.openntf.domino.View)9 Collection (java.util.Collection)8 UserAccessException (org.openntf.domino.exceptions.UserAccessException)8 Serializable (java.io.Serializable)7 Test (org.junit.Test)7 NotesException (lotus.domino.NotesException)6