Search in sources :

Example 1 with ACL

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

the class DGraph method getStoreDelegate.

@Override
public Object getStoreDelegate(final DElementStore store, final Object provisionalKey) {
    Object result = null;
    Session session = Factory.getSession(SessionType.CURRENT);
    if (provisionalKey instanceof CharSequence) {
        String key = provisionalKey.toString();
        String server = "";
        if (key.contains("!!")) {
            // TODO NTF parse key string to find server name in form of 'Server!!path.nsf'
            server = "";
        // key = key;	//TODO NTF parse again
        }
        DbDirectory dir = session.getDbDirectory(server);
        result = dir.openDatabase(key);
        if (result == null) {
            // System.out.println("Creating NSF for delegate: " + key);
            Session localSession = Factory.getSession(SessionType.NATIVE);
            localSession.setFixEnable(Fixes.CREATE_DB, true);
            DbDirectory localDir = localSession.getDbDirectory(server);
            Database newDb = localDir.createDatabase(key, true);
            if (newDb != null && newDb.isOpen()) {
                // System.out.println("Configuring NSF...");
                newDb.setCategories("graph2");
                newDb.setFolderReferencesEnabled(false);
                newDb.setTitle("Auto-generated for " + key);
                // System.out.println("Configuring view...");
                ACL acl = newDb.getACL();
                acl.addRole("Admin");
                acl.createACLEntry("Anonymous", Level.NOACCESS);
                acl.save();
                org.openntf.domino.View v = newDb.createView("NONE");
                v.setSelectionFormula("SELECT @False");
            } else {
                System.out.println("Database not created for key: " + key);
            }
            result = newDb;
        // System.out.println("New NSF complete");
        }
        store.setStoreKey(((Database) result).getReplicaID());
    } else {
    // TODO NTF Unimplemented
    }
    return result;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) ACL(org.openntf.domino.ACL) Session(org.openntf.domino.Session)

Example 2 with ACL

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

the class AclIterator method getNext.

private ACLEntry getNext() {
    if (nextEntry_ == null) {
        ACLEntry currentEntry = getCurrentEntry();
        ACL acl = getAcl();
        try {
            if (currentEntry == null) {
                if (isDone()) {
                    nextEntry_ = null;
                } else {
                    nextEntry_ = acl.getFirstEntry();
                }
            } else {
                nextEntry_ = acl.getNextEntry(currentEntry);
            }
        } catch (Throwable t) {
            DominoUtils.handleException(t);
        }
    }
    return nextEntry_;
}
Also used : ACLEntry(org.openntf.domino.ACLEntry) ACL(org.openntf.domino.ACL)

Aggregations

ACL (org.openntf.domino.ACL)2 ACLEntry (org.openntf.domino.ACLEntry)1 Database (org.openntf.domino.Database)1 DbDirectory (org.openntf.domino.DbDirectory)1 Session (org.openntf.domino.Session)1