Search in sources :

Example 26 with Database

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

the class IdentityServlet method getUserDisplayName.

private String getUserDisplayName(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; 'FullName')) ", tempDoc);
        if (!result.isEmpty()) {
            Name name = session.createName((String) result.get(0));
            return name.getCommon();
        } else {
            // $NON-NLS-1$
            return "";
        }
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session) Name(lotus.domino.Name)

Example 27 with Database

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

the class IdentityServlet method getGroups.

@SuppressWarnings("unchecked")
public String getGroups(String pattern, int limit) 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$
        List<String> groups = session.evaluate(" @Trim(@Sort(@Unique(@NameLookup([NoCache]:[Exhaustive]; ''; 'ListName')))) ", tempDoc);
        // $NON-NLS-1$
        return String.join("\n", groups);
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 28 with Database

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

the class IdentityServlet method getUsers.

@SuppressWarnings("unchecked")
private String getUsers(String pattern, int limit) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // TODO change API to avoid 64k trouble
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        List<String> users = session.evaluate(" @Trim(@Sort(@Unique(@NameLookup([NoCache]:[Exhaustive]; ''; 'FullName')))) ", tempDoc);
        // $NON-NLS-1$
        return String.join("\n", users);
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 29 with Database

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

the class DominoRunner method run.

@Override
public void run() {
    try {
        System.out.println("Starting NotesRunner");
        Session session = NotesFactory.createSession();
        sessionid.set(getLotusId(session));
        Database db = session.getDatabase("", "log.nsf");
        getLotusId(db);
        Name name = null;
        int i = 0;
        try {
            for (i = 0; i <= 100000; i++) {
                name = session.createName(UUID.randomUUID().toString());
                getLotusId(name);
                DateTime dt = session.createDateTime(new Date());
                getLotusId(dt);
                DateTime end = session.createDateTime(new Date());
                getLotusId(end);
                DateRange dr = session.createDateRange(dt, end);
                getLotusId(dr);
                Document doc = db.createDocument();
                getLotusId(doc);
                Item i1 = doc.replaceItemValue("Foo", dr);
                getLotusId(i1);
                Item i2 = doc.replaceItemValue("Bar", dr.getText());
                getLotusId(i2);
                Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime());
                getLotusId(i3);
                lotus.domino.ColorObject color = session.createColorObject();
                getLotusId(color);
                color.setRGB(128, 128, 128);
                Item i4 = doc.replaceItemValue("color", color.getNotesColor());
                getLotusId(i4);
                i1.recycle();
                i2.recycle();
                i3.recycle();
                i4.recycle();
                DateTime create = doc.getCreated();
                getLotusId(create);
                String lc = create.getLocalTime();
                if (i % 10000 == 0) {
                    System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " " + "Local time is " + lc + "  " + dr.getText());
                }
                dr.recycle();
                doc.recycle();
                dt.recycle();
                end.recycle();
                create.recycle();
                color.recycle();
                if (name != null)
                    name.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 : Document(lotus.domino.Document) DateTime(lotus.domino.DateTime) Date(java.util.Date) Name(lotus.domino.Name) Item(lotus.domino.Item) DateRange(lotus.domino.DateRange) Database(lotus.domino.Database) Session(lotus.domino.Session)

Example 30 with Database

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

the class NotesRunner method run3.

public void run3(final Session session) throws NotesException {
    Database db = session.getDatabase("", "index.ntf");
    NoteCollection nc = db.createNoteCollection(false);
    nc.setSelectIcon(true);
    nc.setSelectAcl(true);
    nc.selectAllDesignElements(true);
    nc.buildCollection();
    DxlExporter export = session.createDxlExporter();
    export.setForceNoteFormat(true);
    export.setRichTextOption(DxlExporter.DXLRICHTEXTOPTION_RAW);
    String dxl = export.exportDxl(nc);
    nc.recycle();
    export.recycle();
    db.recycle();
    try {
        PrintWriter out = new PrintWriter("c:\\data\\index.dxl");
        out.println(dxl);
        out.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : DxlExporter(lotus.domino.DxlExporter) NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) PrintWriter(java.io.PrintWriter)

Aggregations

Database (lotus.domino.Database)32 Session (lotus.domino.Session)18 Document (lotus.domino.Document)16 NotesException (lotus.domino.NotesException)13 DocumentCollection (lotus.domino.DocumentCollection)5 NoteCollection (lotus.domino.NoteCollection)5 View (lotus.domino.View)4 IOException (java.io.IOException)3 Vector (java.util.Vector)3 DateTime (lotus.domino.DateTime)3 DominoQuery (lotus.domino.DominoQuery)3 Item (lotus.domino.Item)3 ViewEntry (lotus.domino.ViewEntry)3 DominoDocument (com.ibm.xsp.model.domino.wrapped.DominoDocument)2 Document (jakarta.nosql.document.Document)2 URI (java.net.URI)2 Path (java.nio.file.Path)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 ACL (lotus.domino.ACL)2