Package com.xpn.xwiki.user.api
Class XWikiUser
- java.lang.Object
-
- com.xpn.xwiki.user.api.XWikiUser
-
public class XWikiUser extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static LocalDocumentReference
ACCOUNT_VALIDATION_DOCUMENT_REFERENCE
static String
ACTIVE_PROPERTY
The name of the property that store the active status of the user.static String
EMAIL_CHECKED_PROPERTY
The name of the property that store the information if an email was checked for the user.
-
Constructor Summary
Constructors Constructor Description XWikiUser(String user)
Deprecated.since 11.6RC1 useXWikiUser(DocumentReference)
.XWikiUser(String user, boolean main)
Deprecated.since 11.6RC1 useXWikiUser(DocumentReference, boolean)
.XWikiUser(DocumentReference userReference)
Create a XWikiUser from its document reference and infer if the user is global or not based on the wiki part of this reference.XWikiUser(DocumentReference userReference, boolean main)
Create a XWikiUser from its document reference and set the main flag.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object obj)
boolean
exists(XWikiContext context)
String
getFullName()
String
getUser()
Deprecated.since 11.6RC1 usegetFullName()
.DocumentReference
getUserReference()
boolean
isDisabled(XWikiContext context)
boolean
isEmailChecked(XWikiContext context)
boolean
isMain()
See if the user is global (i.e.boolean
isUserInGroup(String groupName, XWikiContext context)
Check if the user belongs to a group or not.void
setDisabled(boolean disable, XWikiContext context)
void
setEmailChecked(boolean checked, XWikiContext context)
void
setMain(boolean main)
void
setUser(String user)
String
toString()
-
-
-
Field Detail
-
ACTIVE_PROPERTY
public static final String ACTIVE_PROPERTY
The name of the property that store the active status of the user.- Since:
- 11.8RC1
- See Also:
- Constant Field Values
-
EMAIL_CHECKED_PROPERTY
public static final String EMAIL_CHECKED_PROPERTY
The name of the property that store the information if an email was checked for the user.- Since:
- 11.8RC1
- See Also:
- Constant Field Values
-
ACCOUNT_VALIDATION_DOCUMENT_REFERENCE
public static final LocalDocumentReference ACCOUNT_VALIDATION_DOCUMENT_REFERENCE
-
-
Constructor Detail
-
XWikiUser
public XWikiUser(DocumentReference userReference)
Create a XWikiUser from its document reference and infer if the user is global or not based on the wiki part of this reference. SeeisMain()
for more information.- Parameters:
userReference
- the document reference of the user.- Since:
- 11.6RC1
-
XWikiUser
public XWikiUser(DocumentReference userReference, boolean main)
Create a XWikiUser from its document reference and set the main flag. (seeisMain()
).- Parameters:
userReference
- the document reference of the user.main
- true if the user is global (i.e. registered in the main wiki)- Since:
- 11.6RC1
-
XWikiUser
@Deprecated public XWikiUser(String user)
Deprecated.since 11.6RC1 useXWikiUser(DocumentReference)
.Create a XWikiUser for the given user.- Parameters:
user
- the full name of the user on the formXWiki.Foo
.
-
XWikiUser
@Deprecated public XWikiUser(String user, boolean main)
Deprecated.since 11.6RC1 useXWikiUser(DocumentReference, boolean)
.Create a XWikiUser for the given user.- Parameters:
user
- the full name of the user on the formXWiki.Foo
.main
- true if the user is global (i.e. registered in the main wiki)
-
-
Method Detail
-
getUser
@Deprecated public String getUser()
Deprecated.since 11.6RC1 usegetFullName()
.- Returns:
- user fullname
-
getFullName
public String getFullName()
- Returns:
- the fullname of the user like
XWiki.Foo
.
-
getUserReference
public DocumentReference getUserReference()
-
isEmailChecked
public boolean isEmailChecked(XWikiContext context)
- Parameters:
context
- used to retrieve the user document.- Returns:
- true if the user is email have been checked before. This always returns true if the user is the guest or superadmin user.
- Since:
- 11.8RC1
-
setEmailChecked
public void setEmailChecked(boolean checked, XWikiContext context)
- Parameters:
checked
- true if the email address was checked for the user. False if it wasn't checked.context
- used to retrieve the user document.- Since:
- 11.8RC1
-
isDisabled
public boolean isDisabled(XWikiContext context)
- Parameters:
context
- used to retrieve the user document.- Returns:
- true if the user is disabled (i.e. its active property is set to 0). This always returns false if the user is the guest or superadmin user.
- Since:
- 11.6RC1
-
setDisabled
public void setDisabled(boolean disable, XWikiContext context)
- Parameters:
disable
- true if the user disabled the account. False to enable the account.context
- used to retrieve the user document.- Since:
- 11.6RC1
-
exists
public boolean exists(XWikiContext context)
- Parameters:
context
- used to retrieve the user document.- Returns:
- true if the user exists.
- Since:
- 11.6RC1
-
setUser
public void setUser(String user)
-
isUserInGroup
public boolean isUserInGroup(String groupName, XWikiContext context) throws XWikiException
Check if the user belongs to a group or not. This method only check direct membership (no recursive checking) in the current wiki.- Parameters:
groupName
- The group to check.context
- The currentcontext
.- Returns:
true
if the user does belong to the specified group, false otherwise or if an exception occurs.- Throws:
XWikiException
- If an error occurs when checking the groups.- Since:
- 1.3
-
isMain
public boolean isMain()
See if the user is global (i.e. registered in the main wiki) or local to a virtual wiki.- Returns:
true
if the user is global, false otherwise or if an exception occurs.
-
setMain
public void setMain(boolean main)
-
-