Users Module

Version 12.2 by Jean-Vincent Drean on 2010/08/04 11:29

The need is to develop the Users module of the XWiki platform, i.e. the module that provides the APIs allowing to manage XWiki Users.

Requirements & Use cases

We display lists of users in multiple places: user administration, user directory (to be commited), user suggests, rights UI.

  • UC1: Being able to restrict the list of users to local users in a wiki instance
  • UC2: Being able to restrict the list of users to global users in a wiki instance
  • UC2: Being able to mix local and global users in the lists available in a wiki instance

Implementation Proposal

Configuration (xwiki.properties)

#-# [Since 2.5M1]
#-# Define at which level users and groups should be handled in the farm. Available modes: 
#-#
#-# mixed (default):
#-# - user registration available in the main wiki and local wikis
#-# - users from the current wiki and the main wiki will be displayed in the rights interface and user suggests
#-# - user administration is present in all the wikis
#-#
#-# local:
#-# - user registration available in the main wiki and local wikis
#-# - only users from the current wiki will be displayed in the rights interface and user suggests
#-# - user administration is present in all the wikis
#-#
#-# global:
#-# - user registration available in the main wiki only, the register link in local wikis will point to the main wiki
#-# - only users from the main wiki will be displayed in the rights interface and user suggests
#-# - user administration is present in the main wiki only
core.virtual.users=mixed

Users Component

Hierarchy:

|- xwiki-users/
|-- xwiki-users-api/
|-- xwiki-users-default/ : some standard implementations
           * default (proxy that determine the implementation to use from the configuration)
           * global (only global users)
           * local (only local users)
           * mixed (both global and local users)

Minimalistic UserManager API (starting point meant to be extended in the future):

/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.users;

import java.util.List;

import org.xwiki.model.reference.DocumentReference;

/**
 * User Manager interface.  
 * 
 * @version $Id: $
 */
public interface UserManager
{
    /**
     * Get users documents references.
     * 
     * @param limit Number of references to get
     * @param offset The offset to use in the results set 
     * @return A list of users documents references
     */
    List<DocumentReference> getUsers(int limit, int offset);
    
    /**
     * Get users documents references for users matching the given text fragment. The matching is performed on three
     * different fields: the name of the user document itself, the user firstname and the user lastname.
     * 
     * @param limit Number of references to get
     * @param offset The offset to use in the results set 
     * @return A list of users documents references matching the given text fragment
     */
    List<DocumentReference> getUsers(String match, int limit, int offset);
    
    /**
     * @return The number of users.
     */
    int getUsersNumber();
}

Get Connected