Search in sources :

Example 1 with UserAuthorityDetails

use of org.alfresco.web.bean.groups.GroupsDialog.UserAuthorityDetails in project acs-community-packaging by Alfresco.

the class AddUsersDialog method addSelectedUsers.

// ------------------------------------------------------------------------------
// Event handlers
/**
 * Add the selected User to the list for adding to a Group
 */
public void addSelectedUsers(ActionEvent event) {
    UIGenericPicker picker = (UIGenericPicker) event.getComponent().findComponent("picker");
    String[] results = picker.getSelectedResults();
    if (results != null) {
        for (int i = 0; i < results.length; i++) {
            String authority = results[i];
            // check for same authority so not added twice
            boolean foundExisting = false;
            for (int n = 0; n < this.usersForGroup.size(); n++) {
                UserAuthorityDetails wrapper = this.usersForGroup.get(n);
                if (authority.equals(wrapper.getAuthority())) {
                    foundExisting = true;
                    break;
                }
            }
            if (foundExisting == false) {
                StringBuilder label = new StringBuilder(48);
                // build a display label showing the user person name
                if (this.getPersonService().personExists(authority) == true) {
                    // found a Person with a User authority
                    NodeRef ref = this.getPersonService().getPerson(authority);
                    String firstName = (String) getNodeService().getProperty(ref, ContentModel.PROP_FIRSTNAME);
                    String lastName = (String) getNodeService().getProperty(ref, ContentModel.PROP_LASTNAME);
                    // build a sensible label for display
                    label.append(firstName != null ? firstName : "").append(' ').append(lastName != null ? lastName : "");
                    // add a wrapper object with the details to the results list for display
                    UserAuthorityDetails userDetails = new UserAuthorityDetails(label.toString(), authority);
                    this.usersForGroup.add(userDetails);
                }
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UserAuthorityDetails(org.alfresco.web.bean.groups.GroupsDialog.UserAuthorityDetails) UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker)

Aggregations

NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 UserAuthorityDetails (org.alfresco.web.bean.groups.GroupsDialog.UserAuthorityDetails)1 UIGenericPicker (org.alfresco.web.ui.common.component.UIGenericPicker)1