Search code examples
javaxpageslotus-domino

Access for Users added to Groups via Java Code not correctly computed


When editing groupmembers via Java triggered from an Xpage, the changes are neglected when calculation db access until the group is manualy saved in the Domino Directory. The group is located in a assistence direcotry

For a xpage-application i want a poweruser to be able to modify groups via a xpage:

Upon safe the xpages gets the corresponding document from the domino directory DB, writes the list of members into the "Members"-item and saves the document(see code bellow).

The group is used to grant author-access to a DB. When trying to access the Db with a newly added user, the access is denied until i open the group-document manualy via the Notes-Client, change to edit mode and safe it(without changing any data). Same when using a just deleted user, it will still get access. After saving the group by hand, everything works immediatly.

Tried it with new groups(created document, set all items and saved it) and allreay existing ones(get existing,working group and change it), no difference

//Group is a very basic bean that holds the data changed by the user on the
//xpage. no logic, just getters/setters

public void save(Group group) {
            if (group.getID().equals("")) {
//new Group
                doc = pnab.createDocument();
                doc.replaceItemValue("Form", "Group");
                doc.replaceItemValue("Type", "Group");
                doc.replaceItemValue("Grouptype", "2");
                doc.replaceItemValue("Grouptitle", "2");
                doc.replaceItemValue("ListCategory", con.getName());
                doc.replaceItemValue("$ConflictAction", "1");
                doc.replaceItemValue("$Group_Main", "0");
                doc.replaceItemValue("DocumentAccess", "[Groupmodifier]");
                doc.getFirstItem("DocumentAccess").setAuthors(true);
                replaceValues(group, doc);
                doc.save();
                group.setID(doc.getUniversalID());
            } else {
//existing group
                doc = pnab.getDocumentByUNID(group.getID());
                replaceValues(group, doc);
                doc.save();
            }
    }
private void replaceValues(Group group, Document doc) throws NotesException {
        doc.replaceItemValue("comment", group.getComment());
        doc.replaceItemValue("ListName", group.getNotesName());
        Vector<String> members=new Vector<String>(group.getMembers());
        Collections.sort(members, new StringComparator(true)); // sorts the memberlist alphabetical, ignores case
        doc.replaceItemValue("Members", members);
    }

I'm assuming there need to be some updates made/caches cleared etc. Any advice what to do/where to look?

Allready investigated the groups-form from the Dominodirectoy-template, nothing special there. Also checked the NotesGroupManager LS-Libary from openNTF.org, also nothing special. Might be a java specific problem


Solution

  • Add property Names to your members item:

    Item itemMembers = doc.replaceItemValue("Members", members);
    itemMembers.setNames(true);
    

    It converts members' entries into valid Names values that can be handled by Domino for access rights.