Class WikiUserManagerScriptService

java.lang.Object
org.xwiki.wiki.user.script.WikiUserManagerScriptService
All Implemented Interfaces:
org.xwiki.script.service.ScriptService

@Component @Named("wiki.user") @Singleton public class WikiUserManagerScriptService extends Object implements org.xwiki.script.service.ScriptService
Script service to manage how the user are supported in a wiki.
Since:
5.3M2
Version:
$Id: 2b2c5821d85a84a68db2397e6d9ed646f48a7919 $
  • Constructor Details

    • WikiUserManagerScriptService

      public WikiUserManagerScriptService()
  • Method Details

    • getLastError

      public Exception getLastError()
      Get the error generated while performing the previously called action.
      Returns:
      an eventual exception or null if no exception was thrown
    • getUserScope

      public UserScope getUserScope()
      Returns:
      the user scope
    • getUserScope

      public UserScope getUserScope(String wikiId)
      Parameters:
      wikiId - Id of the wiki to test
      Returns:
      the user scope
    • setUserScope

      public boolean setUserScope(String wikiId, String scope)
      Parameters:
      wikiId - Id of the wiki to change
      scope - scope to set
      Returns:
      true if it succeed
    • getMembershipType

      public MembershipType getMembershipType()
      Returns:
      the membership type of the current wiki
    • getMembershipType

      public MembershipType getMembershipType(String wikiId)
      Parameters:
      wikiId - Id of the wiki to test
      Returns:
      the membership type of the specified wiki
    • setMembershipType

      public boolean setMembershipType(String wikiId, String type)
      Parameters:
      wikiId - Id of the wiki to change
      type - the membership type to set
      Returns:
      true if it succeed
    • getMembers

      public Collection<String> getMembers(String wikiId)
      Parameters:
      wikiId - if the the wiki
      Returns:
      the list of all the members (global users) or null if something failed.
    • isMember

      public Boolean isMember(String userId, String wikiId)
      To know if a user is a member of a wiki.
      Parameters:
      userId - Id of the user
      wikiId - Id of the wiki
      Returns:
      if the user is a member of the specified wiki or null if some problems occur
    • addMember

      public boolean addMember(String userId, String wikiId)
      Add a user as a member.
      Parameters:
      userId - UserID to add
      wikiId - Id of the wiki
      Returns:
      true if it succeed
    • addMembers

      public boolean addMembers(Collection<String> userIds, String wikiId)
      Add a list of users as a members.
      Parameters:
      userIds - List of userID to add
      wikiId - Id of the wiki
      Returns:
      true if it succeed
    • removeMember

      public boolean removeMember(String userId, String wikiId)
      Remove a member.
      Parameters:
      userId - UserID to remove
      wikiId - Id the the wiki
      Returns:
      true if it succeed
    • getCandidacy

      public MemberCandidacy getCandidacy(String wikiId, int candidacyId)
      Get the specified candidacy.
      Parameters:
      wikiId - Id of the wiki concerned by the candidacy
      candidacyId - id of the candidacy
      Returns:
      the candidacy or null if problems occur
    • getAllInvitations

      public Collection<MemberCandidacy> getAllInvitations(String wikiId)
      Get all the invitations to join a wiki.
      Parameters:
      wikiId - id of the wiki to join
      Returns:
      a list of invitations to join this wiki or null if some problems occur
    • hasPendingInvitation

      public Boolean hasPendingInvitation(org.xwiki.model.reference.DocumentReference user, String wikiId)
      Parameters:
      user - DocumentReference to the user to test
      wikiId - id of the wiki to test
      Returns:
      either or not the user has a pending invitation to join the wiki, null if some problems occur
    • hasPendingRequest

      public Boolean hasPendingRequest(org.xwiki.model.reference.DocumentReference user, String wikiId)
      Parameters:
      user - DocumentReference to the user to test
      wikiId - id of the wiki to test
      Returns:
      either or not the user has a pending request to join the wiki, null if some problems occur
    • getAllRequests

      public Collection<MemberCandidacy> getAllRequests(String wikiId)
      Get all the join requests for a wiki that the current user has the right to see.
      Parameters:
      wikiId - id of the wiki to join
      Returns:
      a list of join request for this wiki or null if some problems occur
    • join

      public boolean join(String userId, String wikiId)
      Join a wiki.
      Parameters:
      userId - userId to add to the wiki
      wikiId - id of the wiki
      Returns:
      true if it succeed
    • leave

      public boolean leave(String userId, String wikiId)
      Leave a wiki.
      Parameters:
      userId - userId to remove from the wiki
      wikiId - id of the wiki
      Returns:
      true if it succeed
    • askToJoin

      public MemberCandidacy askToJoin(String userId, String wikiId, String message)
      Perform a request to join a wiki.
      Parameters:
      userId - UserID of the requester
      wikiId - Id of the wiki to join
      message - Message that motivates the request
      Returns:
      the generated candidacy
    • acceptRequest

      public boolean acceptRequest(MemberCandidacy request, String message, String privateComment)
      Accept the request to join the wiki.
      Parameters:
      request - request to accept
      message - message about the acceptance
      privateComment - private comment that only the administrator can see
      Returns:
      true if it succeed
    • refuseRequest

      public boolean refuseRequest(MemberCandidacy request, String message, String privateComment)
      Refuse the request to join the wiki.
      Parameters:
      request - request to refuse
      message - message about the refusal
      privateComment - private comment that only the administrator can see
      Returns:
      true if it succeed
    • cancelCandidacy

      public boolean cancelCandidacy(MemberCandidacy candidacy)
      Cancel a candidacy.
      Parameters:
      candidacy - Candidacy to cancel
      Returns:
      true if it succeed
    • invite

      public MemberCandidacy invite(String userId, String wikiId, String message)
      Invite a global user to a wiki.
      Parameters:
      userId - Id of the user to add
      wikiId - Id of the wiki to join
      message - MemberCandidacy message
      Returns:
      The generated invitation or null if problems occur
    • acceptInvitation

      public boolean acceptInvitation(MemberCandidacy invitation, String message)
      Accept the invitation to join a wiki.
      Parameters:
      invitation - invitation to accept
      message - message that goes along the acceptance
      Returns:
      true if it succeed
    • refuseInvitation

      public boolean refuseInvitation(MemberCandidacy invitation, String message)
      Refuse the invitation to join a wiki.
      Parameters:
      invitation - invitation to refuse
      message - message that goes along the refusal
      Returns:
      true if it succeed