Package org.jivesoftware.openfire.vcard
Class VCardManager
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.vcard.VCardManager
-
- All Implemented Interfaces:
Module
,ServerFeaturesProvider
public class VCardManager extends BasicModule implements ServerFeaturesProvider
Manages VCard information for users.- Author:
- Matt Tucker
-
-
Field Summary
Fields Modifier and Type Field Description static SystemProperty<Class>
VCARD_PROVIDER
-
Constructor Summary
Constructors Constructor Description VCardManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteVCard(String username)
Deletes the user's vCard from the user account.Iterator<String>
getFeatures()
Returns an Iterator (of String) with the supported features by the server.static VCardManager
getInstance()
static VCardProvider
getProvider()
Returns the currently-installed VCardProvider.org.dom4j.Element
getVCard(String username)
Returns the vCard of a given user or null if none was defined before.String
getVCardProperty(String username, String name)
Returns the user's vCard information for a given vcard property name.void
initialize(XMPPServer server)
Initializes the basic module.void
reset()
Resets the manager state.void
setVCard(String username, org.dom4j.Element vCardElement)
Sets the user's vCard information.void
start()
Starts the basic module.void
stop()
Stops the basic module.-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName
-
-
-
-
Field Detail
-
VCARD_PROVIDER
public static final SystemProperty<Class> VCARD_PROVIDER
-
-
Method Detail
-
getInstance
public static VCardManager getInstance()
-
getProvider
public static VCardProvider getProvider()
Returns the currently-installed VCardProvider. Warning: in virtually all cases the vcard provider should not be used directly. Instead, the appropriate methods in VCardManager should be called. Direct access to the vcard provider is only provided for special-case logic.- Returns:
- the current VCardProvider.
-
getVCardProperty
public String getVCardProperty(String username, String name)
Returns the user's vCard information for a given vcard property name. If the property has no defined text then an empty string will be returned. However, if the property does not exist then anull
value will be answered. Advanced user systems can use vCard information to link to user directory information or store other relevant user information.Note that many elements in the vCard may have the same path so the returned value in that case will be the first found element. For instance, "ADR:STREET" may be present in many addresses of the user. Use
getVCard(String)
to get the whole vCard of the user.- Parameters:
username
- The username of the user to return his vCard property.name
- The name of the vcard property to retrieve encoded with ':' to denote the path.- Returns:
- The vCard value found
-
setVCard
public void setVCard(String username, org.dom4j.Element vCardElement) throws Exception
Sets the user's vCard information. The new vCard information will be persistent. Advanced user systems can use vCard information to link to user directory information or store other relevant user information.- Parameters:
username
- The username of the user to set his new vCard.vCardElement
- The DOM element sent by the user as his new vCard.- Throws:
Exception
- if an error occurred while storing the new vCard.
-
deleteVCard
public void deleteVCard(String username)
Deletes the user's vCard from the user account.- Parameters:
username
- The username of the user to delete his vCard.- Throws:
UnsupportedOperationException
- If the provider is read-only and the data cannot be deleted, this exception is thrown
-
getVCard
public org.dom4j.Element getVCard(String username)
Returns the vCard of a given user or null if none was defined before. Changes to the returned vCard will not be stored in the database. Use the returned vCard as a read-only vCard.- Parameters:
username
- Username (not full JID) whose vCard to retrieve.- Returns:
- the vCard of a given user.
-
initialize
public void initialize(XMPPServer server)
Description copied from class:BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initialize
in interfaceModule
- Overrides:
initialize
in classBasicModule
- Parameters:
server
- the server hosting this module.
-
start
public void start()
Description copied from class:BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
start
in interfaceModule
- Overrides:
start
in classBasicModule
-
stop
public void stop()
Description copied from class:BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
- Specified by:
stop
in interfaceModule
- Overrides:
stop
in classBasicModule
-
reset
public void reset()
Resets the manager state. The cache where loaded vCards are stored will be flushed.
-
getFeatures
public Iterator<String> getFeatures()
Description copied from interface:ServerFeaturesProvider
Returns an Iterator (of String) with the supported features by the server. The features to include are the features offered and supported protocols by the SERVER. The idea is that different modules may provide their features that will ultimately be part of the features offered by the server.- Specified by:
getFeatures
in interfaceServerFeaturesProvider
- Returns:
- an Iterator (of String) with the supported features by the server.
-
-