Search in sources :

Example 1 with ACLEntry

use of lotus.domino.ACLEntry in project org.openntf.xsp.jakartaee by OpenNTF.

the class PostInstallFactory method getServices.

@Override
public HttpService[] getServices(LCDEnvironment env) {
    System.out.println("postinstall start");
    try {
        Session session = NotesFactory.createSession();
        try {
            for (String nsfName : NSFS) {
                Database database = session.getDatabase("", nsfName);
                if (database == null || !database.isOpen()) {
                    throw new RuntimeException("Could not find " + nsfName);
                }
                ACL acl = database.getACL();
                ACLEntry anon = acl.getEntry("Anonymous");
                if (anon == null) {
                    anon = acl.createACLEntry("Anonymous", ACL.LEVEL_AUTHOR);
                } else {
                    anon.setLevel(ACL.LEVEL_AUTHOR);
                }
                ACLEntry admin = acl.createACLEntry("CN=Jakarta EE Test/O=OpenNTFTest", ACL.LEVEL_MANAGER);
                try {
                    admin.enableRole("[Admin]");
                } catch (NotesException e) {
                // Failing here is fine, in case the NSF doesn't have the role
                }
                acl.save();
                database.getView("Persons");
                session.sendConsoleCommand("", "load updall " + nsfName);
            }
            session.sendConsoleCommand("", "tell http osgi diag");
        } finally {
            session.recycle();
        }
    } catch (NotesException e) {
        e.printStackTrace();
    } finally {
        System.out.println("Done with postinstall");
    }
    return new HttpService[0];
}
Also used : NotesException(lotus.domino.NotesException) ACLEntry(lotus.domino.ACLEntry) HttpService(com.ibm.designer.runtime.domino.adapter.HttpService) Database(lotus.domino.Database) ACL(lotus.domino.ACL) Session(lotus.domino.Session)

Example 2 with ACLEntry

use of lotus.domino.ACLEntry in project org.openntf.xsp.jakartaee by OpenNTF.

the class DefaultDominoDocumentCollectionManager method getQrpDatabase.

private Database getQrpDatabase(Session session, Database database) throws NotesException {
    String server = database.getServer();
    String filePath = database.getFilePath();
    try {
        // $NON-NLS-1$
        String fileName = md5(server + filePath) + ".nsf";
        Path tempDir = getTempDirectory();
        Path dest = tempDir.resolve(getClass().getPackage().getName());
        Files.createDirectories(dest);
        Path dbPath = dest.resolve(fileName);
        // $NON-NLS-1$
        Database qrp = session.getDatabase("", dbPath.toString());
        if (!qrp.isOpen()) {
            qrp.recycle();
            DbDirectory dbDir = session.getDbDirectory(null);
            // TODO encrypt when the API allows
            qrp = dbDir.createDatabase(dbPath.toString(), true);
            ACL acl = qrp.getACL();
            ACLEntry entry = acl.createACLEntry(session.getEffectiveUserName(), ACL.LEVEL_MANAGER);
            entry.setCanDeleteDocuments(true);
            acl.save();
        }
        return qrp;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : Path(java.nio.file.Path) DbDirectory(lotus.domino.DbDirectory) ACLEntry(lotus.domino.ACLEntry) Database(lotus.domino.Database) ACL(lotus.domino.ACL) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Aggregations

ACL (lotus.domino.ACL)2 ACLEntry (lotus.domino.ACLEntry)2 Database (lotus.domino.Database)2 HttpService (com.ibm.designer.runtime.domino.adapter.HttpService)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Path (java.nio.file.Path)1 DbDirectory (lotus.domino.DbDirectory)1 NotesException (lotus.domino.NotesException)1 Session (lotus.domino.Session)1