Search in sources :

Example 96 with Session

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

the class OpenntfDominoImplicitObjectFactory method createImplicitObjects.

/**
 * Creates the "cheap" objects
 */
@Override
public void createImplicitObjects(final FacesContextEx ctx) {
    if (!implicitsDone_) {
        implicitsDone_ = true;
        if (!ODAPlatform.isAPIEnabled(null))
            return;
        Session session = Factory.getSession(SessionType.CURRENT);
        Database db = session.getCurrentDatabase();
        Map<String, Object> ecMap = TypedUtil.getRequestMap(ctx.getExternalContext());
        // $NON-NLS-1$
        ecMap.put("openSession", session);
        // $NON-NLS-1$
        ecMap.put("openDatabase", db);
        // Attach NSA
        if (ODAPlatform.isAppFlagSet("nsa")) {
            // $NON-NLS-1$
            Application app = ctx.getApplication();
            if (app instanceof ApplicationEx) {
                NSA.INSTANCE.registerApplication((ApplicationEx) app);
                NSA.INSTANCE.registerSession((ApplicationEx) app, (HttpSession) ctx.getExternalContext().getSession(true));
            }
        }
    }
}
Also used : ApplicationEx(com.ibm.xsp.application.ApplicationEx) Database(org.openntf.domino.Database) Application(javax.faces.application.Application) HttpSession(javax.servlet.http.HttpSession) Session(org.openntf.domino.Session)

Example 97 with Session

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

the class AbstractXPageSessionFactory method wrapSession.

protected Session wrapSession(final lotus.domino.Session raw, final boolean selfCreated) {
    Session sess = Factory.getWrapperFactory().fromLotus(raw, Session.SCHEMA, null);
    sess.setNoRecycle(!selfCreated);
    boolean allFix = true;
    AutoMime autoMime = AutoMime.WRAP_32K;
    boolean mimeFriendly = true;
    boolean viewExactMatch = false;
    if (NotesContext.getCurrentUnchecked() != null) {
        allFix = ODAPlatform.isAppAllFix(null);
        autoMime = ODAPlatform.getAppAutoMime(null);
        mimeFriendly = ODAPlatform.isAppMimeFriendly(null);
        viewExactMatch = ODAPlatform.isAppViewExactMatch(null);
    }
    if (allFix) {
        for (Fixes fix : Fixes.values()) {
            if (fix.isKhan()) {
                sess.setFixEnable(fix, true);
            }
        }
    }
    sess.setAutoMime(autoMime);
    sess.setViewExactMatch(viewExactMatch);
    if (mimeFriendly) {
        sess.setConvertMIME(false);
    }
    if (selfCreated && currentApiPath_ != null) {
        Database db = sess.getCurrentDatabase();
        if (db == null) {
            db = sess.getDatabase(currentApiPath_);
            setCurrentDatabase(sess, db);
        }
    }
    return sess;
}
Also used : Fixes(org.openntf.domino.ext.Session.Fixes) Database(org.openntf.domino.Database) AutoMime(org.openntf.domino.AutoMime) Session(org.openntf.domino.Session)

Example 98 with Session

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

the class DasCurrentSessionFactory method createSession.

/**
 * returns the current Das-Session
 *
 * @throws
 */
@Override
public Session createSession() {
    if (request_ == null || request_.getUserPrincipal() == null) {
        lotus.domino.Session rawSession = ContextInfo.getUserSession();
        if (rawSession == null) {
            NativeSessionFactory nsf = new NativeSessionFactory(null);
            Session result = nsf.createSession();
            Factory.setCurrentToSession(result);
            return result;
        }
        try {
            lotus.domino.Database rawDb = rawSession.getCurrentDatabase();
            if (rawDb != null) {
                if (StringUtil.isEmpty(rawDb.getServer())) {
                    currentApiPath_ = rawDb.getFilePath();
                } else {
                    // $NON-NLS-1$
                    currentApiPath_ = rawDb.getServer() + "!!" + rawDb.getFilePath();
                }
            }
        } catch (NotesException e) {
            DominoUtils.handleException(e);
        }
        return wrapSession(rawSession, false);
    } else {
        String name = request_.getUserPrincipal().getName();
        Session session = createSession(name);
        Factory.setCurrentToSession(session);
        return session;
    }
}
Also used : NotesException(lotus.domino.NotesException) NativeSessionFactory(org.openntf.domino.session.NativeSessionFactory) Session(org.openntf.domino.Session)

Example 99 with Session

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

the class LocalNoteList method getDatabase.

protected Database getDatabase() {
    if (db_ == null) {
        String replid = getReplidFromLong(replid_);
        Session session = Factory.getSession(SessionType.CURRENT);
        DbDirectory dir = session.getDbDirectory(serverName_);
        db_ = dir.openDatabaseByReplicaID(replid);
    }
    return db_;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Session(org.openntf.domino.Session)

Example 100 with Session

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

the class NoteCoordinate method getDatabase.

protected Database getDatabase(final String server) {
    String replid = getReplidFromLong(db);
    Session session = Factory.getSession(SessionType.CURRENT);
    DbDirectory dir = session.getDbDirectory(server);
    return dir.openDatabaseByReplicaID(replid);
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Session(org.openntf.domino.Session)

Aggregations

Session (org.openntf.domino.Session)101 Database (org.openntf.domino.Database)73 Document (org.openntf.domino.Document)28 Test (org.junit.Test)25 View (org.openntf.domino.View)20 DbDirectory (org.openntf.domino.DbDirectory)11 ArrayList (java.util.ArrayList)10 DocumentCollection (org.openntf.domino.DocumentCollection)7 Vector (java.util.Vector)5 ViewEntry (org.openntf.domino.ViewEntry)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 NotesException (lotus.domino.NotesException)4 Item (org.openntf.domino.Item)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Agent (org.openntf.domino.Agent)3 NoteCollection (org.openntf.domino.NoteCollection)3