Search in sources :

Example 6 with Session

use of lotus.domino.Session in project openliberty-domino by OpenNTF.

the class IdentityServlet method isValidGroup.

public String isValidGroup(String groupSecurityName) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        tempDoc.replaceItemValue("GroupName", groupSecurityName);
        // $NON-NLS-1$
        List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; GroupName; 'ListName')) ", tempDoc);
        return String.valueOf(!result.isEmpty());
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 7 with Session

use of lotus.domino.Session in project openliberty-domino by OpenNTF.

the class IdentityServlet method getUserSecurityName.

private String getUserSecurityName(String uniqueUserId) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        tempDoc.replaceItemValue("Username", uniqueUserId);
        // $NON-NLS-1$
        List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; Username; 'FullName')) ", tempDoc);
        if (!result.isEmpty()) {
            return (String) result.get(0);
        } else {
            // $NON-NLS-1$
            return "";
        }
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 8 with Session

use of lotus.domino.Session in project openliberty-domino by OpenNTF.

the class IdentityServlet method getUniqueUserId.

private String getUniqueUserId(String userSecurityName) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        tempDoc.replaceItemValue("Username", userSecurityName);
        // $NON-NLS-1$
        List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; Username; 'ShortName')) ", tempDoc);
        if (!result.isEmpty()) {
            return (String) result.get(0);
        } else {
            // $NON-NLS-1$
            return "";
        }
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 9 with Session

use of lotus.domino.Session in project openliberty-domino by OpenNTF.

the class IdentityServlet method getUsersForGroup.

@SuppressWarnings("unchecked")
public String getUsersForGroup(String groupSecurityName, int limit) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // TODO Look up and expand group
        // TODO work with multiple group-allowed directories
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        tempDoc.replaceItemValue("GroupName", groupSecurityName);
        // $NON-NLS-1$
        List<String> members = session.evaluate(" @Text(@Trim(@Unique(@Sort(@DbLookup(''; '':'names.nsf'; '$VIMGroups'; GroupName; 'Members'))))) ", tempDoc);
        // $NON-NLS-1$
        return String.join("\n", members);
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 10 with Session

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

the class LegacyCollectionTest method run.

@Override
public void run() {
    try {
        System.out.println("Starting NotesRunner");
        Session session = NotesFactory.createSession();
        Long sessId = getLotusId(session);
        sessionid.set(sessId);
        Database db = session.getDatabase("", "names.nsf");
        System.out.println("Db id:" + getLotusId(db));
        int i = 0;
        try {
            lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
            System.out.println("All Collection has " + allDocs.getCount() + " documents");
            int[] nids = new int[allDocs.getCount()];
            lotus.domino.Document doc = allDocs.getFirstDocument();
            lotus.domino.Document nextDoc = null;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            System.out.println("noteid array has " + nids.length + " entries");
            allDocs.recycle();
            // lotus.domino.DocumentCollection newColl = db.getModifiedDocuments(session.createDateTime(new java.util.Date()));
            lotus.domino.DocumentCollection newColl = db.getAllUnreadDocuments();
            System.out.println("New Coll has " + newColl.getCount() + " documents");
            // lotus.domino.DocumentCollection emptyColl = db.createDocumentCollection();
            newColl.intersect(nids[0]);
            System.out.println("New Coll has " + newColl.getCount() + " documents");
            for (int nid : nids) {
                newColl.merge(nid);
            }
            System.out.println("Merged Collection has " + newColl.getCount() + " documents");
            newColl.recycle();
        } catch (Throwable t) {
            t.printStackTrace();
            System.out.println("Exception at loop point " + i);
        }
        session.recycle();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    System.out.println("FINI!");
}
Also used : Database(lotus.domino.Database) Session(lotus.domino.Session)

Aggregations

Session (lotus.domino.Session)24 Database (lotus.domino.Database)18 Document (lotus.domino.Document)12 NotesException (lotus.domino.NotesException)8 View (lotus.domino.View)4 ViewEntry (lotus.domino.ViewEntry)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Vector (java.util.Vector)2 ExecutionException (java.util.concurrent.ExecutionException)2 DateTime (lotus.domino.DateTime)2 DocumentCollection (lotus.domino.DocumentCollection)2 Name (lotus.domino.Name)2 NoteCollection (lotus.domino.NoteCollection)2 ViewNavigator (lotus.domino.ViewNavigator)2 NotesAPIException (com.ibm.designer.domino.napi.NotesAPIException)1 NotesSession (com.ibm.designer.domino.napi.NotesSession)1 HttpService (com.ibm.designer.runtime.domino.adapter.HttpService)1 ModuleClassLoader (com.ibm.domino.xsp.module.nsf.ModuleClassLoader)1 Sort (jakarta.nosql.Sort)1