Package tigase.xmpp
Class RepositoryAccess
java.lang.Object
tigase.xmpp.RepositoryAccess
- Direct Known Subclasses:
XMPPResourceConnection
Describe class RepositoryAccess here.
Created: Tue Oct 24 10:38:41 2006
Created: Tue Oct 24 10:38:41 2006
- Author:
- Artur Hefczyc
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthRepositoryprotected AuthorizationCurrent authorization state - initialy session iNOT_AUTHORIZED.protected VHostItemprotected booleanprotected static final Stringprotected static final String -
Constructor Summary
ConstructorsConstructorDescriptionRepositoryAccess(UserRepository rep, AuthRepository auth) Creates a newRepositoryAccessinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataList(String subnode, String key, String[] list) voidaddOfflineDataList(String subnode, String key, String[] list) voidaddPublicDataList(String subnode, String key, String[] list) getAuthenticationToken(String xmpp_sessionId) final AuthorizationGets the value of authStateabstract BareJIDReturns user JID but without resource part.getDatamethod is a twin sister (brother?) ofsetData(String, String, String)method.String[]getDataGroups(String subnode) This method retrieves list of all direct subnodes for given node.String[]getDataKeys(String subnode) This method returns all data keys available in permanent storage in given node.String[]getDataList(String subnode, String key) This method allows to retrieve list of values associated with one key.getOfflineData(String subnode, String key, String def) String[]getOfflineDataList(String subnode, String key) getPublicData(String subnode, String key, String def) String[]getPublicDataList(String subnode, String key) abstract StringbooleanbooleanThis method allows you test this session if it already has been authorized.protected abstract voidlogin()voidlogout()voidvoidremoveData(String subnode, String key) voidremoveDataGroup(String subnode) Removes the last data node given in subnode path as parameter to this method.voidremoveOfflineData(String subnode, String key) voidremoveOfflineDataGroup(String subnode) voidremovePublicData(String subnode, String key) voidremovePublicDataGroup(String subnode) voidThis method stores given data in permanent storage in given point of hierarchy of data base.voidsetDataList(String subnode, String key, String[] list) This method allows to store list of values under one key ID reference.voidvoidsetOfflineData(String subnode, String key, String value) voidsetOfflineDataList(String subnode, String key, String[] list) voidsetPublicData(String subnode, String key, String value) voidsetPublicDataList(String subnode, String key, String[] list) voidunregister(String name_param) Deprecated.
-
Field Details
-
NO_ACCESS_TO_REP_MSG
- See Also:
-
NOT_AUTHORIZED_MSG
- See Also:
-
authRepo
-
authState
Current authorization state - initialy session iNOT_AUTHORIZED. It becomesAUTHORIZED -
domain
-
is_anonymous
protected boolean is_anonymous
-
-
Constructor Details
-
RepositoryAccess
Creates a newRepositoryAccessinstance.
-
-
Method Details
-
addDataList
public void addDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException -
addOfflineDataList
public void addOfflineDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException -
addPublicDataList
public void addPublicDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException -
logout
- Throws:
NotAuthorizedException
-
queryAuth
- Throws:
TigaseDBException
-
changeRegistration
public Authorization changeRegistration(String name_param, String pass_param, Map<String, String> registr_params) throws NotAuthorizedException, TigaseDBException, TigaseStringprepException -
removeData
-
removeDataGroup
Removes the last data node given in subnode path as parameter to this method. All subnodes are moved as well an all data stored as(key, val)are removed as well. Changes are commited to repository immediatelly and there is no way to undo this operation so use it with care.- Parameters:
subnode- aStringvalue of path to node which has to be removed.- Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
removeOfflineData
public void removeOfflineData(String subnode, String key) throws NotAuthorizedException, TigaseDBException -
removeOfflineDataGroup
-
removePublicData
public void removePublicData(String subnode, String key) throws NotAuthorizedException, TigaseDBException -
removePublicDataGroup
-
getAuthenticationToken
public String getAuthenticationToken(String xmpp_sessionId) throws NotAuthorizedException, TigaseDBException -
getAuthState
Gets the value of authState- Returns:
- the value of authState
-
getBareJID
Returns user JID but without resource part. This is real user ID not session ID. To retrieve session ID - full JID refer togetJID()method.
If session has not been authorized yet this method throwsNotAuthorizedException.- Returns:
- a
Stringvalue of user ID - this is user JID without resource part. To obtain full user JID please refer togetJIDmethod. - Throws:
NotAuthorizedException- when this session has not been authorized yet and some parts of user JID are not known yet.
-
getData
public String getData(String subnode, String key, String def) throws NotAuthorizedException, TigaseDBException getDatamethod is a twin sister (brother?) ofsetData(String, String, String)method. It allows you to retrieve data stored with above method. It is data stored in given node with given key identifier. If there are no data associated with given key or given node does not exist givendefvalue is returned.- Parameters:
subnode- aStringvalue is path to node where pair(key, value)are stored.key- aStringvalue of key ID for data to retrieve.def- aStringvalue of default returned if there is nothing stored with given key.defcan be set to any value you wish to have back as default value ornullif you want to have backnullif no data was found. If you setdeftonullit has exactly the same effect as if you usegetData(String)method.- Returns:
- a
Stringvalue of data found for given key ordefif there was no data associated with given key. - Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
getDataGroups
This method retrieves list of all direct subnodes for given node. It works in similar way aslsunix command ordirunder DOS/Windows systems.- Parameters:
subnode- aStringvalue of path to node for which we want to retrieve list of direct subnodes.- Returns:
- a
String[]array of direct subnodes names for given node. - Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
getDataKeys
This method returns all data keys available in permanent storage in given node. There is not though any information what kind of data is stored with this key. This is up to user (developer) to determine what data type is associated with key and what is it's meaning.- Parameters:
subnode- aStringvalue pointing to specific subnode in user reposiotry where data have to be stored.- Returns:
- a
String[]array containing all data keys found in given subnode. - Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
getDataList
public String[] getDataList(String subnode, String key) throws NotAuthorizedException, TigaseDBException This method allows to retrieve list of values associated with one key. As it is possible to store many values with one key there are a few methods which provides this functionality. If given key does not exists in given subnodenullis returned.- Parameters:
subnode- aStringvalue pointing to specific subnode in user reposiotry where data have to be stored.key- aStringvalue of data key ID.- Returns:
- a
String[]array containing all values found for given key. - Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
getDomain
-
setDomain
- Throws:
TigaseStringprepException
-
getDomainAsJID
-
getOfflineData
public String getOfflineData(String subnode, String key, String def) throws NotAuthorizedException, TigaseDBException -
getOfflineDataList
public String[] getOfflineDataList(String subnode, String key) throws NotAuthorizedException, TigaseDBException -
getPublicData
public String getPublicData(String subnode, String key, String def) throws NotAuthorizedException, TigaseDBException -
getPublicDataList
public String[] getPublicDataList(String subnode, String key) throws NotAuthorizedException, TigaseDBException -
getUserName
- Throws:
NotAuthorizedException
-
isAnonymous
public boolean isAnonymous() -
isAuthorized
public boolean isAuthorized()This method allows you test this session if it already has been authorized. Iftrueis returned as method result it means session has already been authorized, iffalsehowever session is still not authorized.- Returns:
- a
booleanvalue which informs whether this session has been already authorized or not.
-
setData
public void setData(String subnode, String key, String value) throws NotAuthorizedException, TigaseDBException This method stores given data in permanent storage in given point of hierarchy of data base. This method is similar tosetData(String, String)and differs in one additional parameter which point to user data base subnode where data must be stored. It helps to organize user data in more logical hierarchy.
User data is kind of tree where you can store data in each tree node. The most relevant sample might be structure like typical file system or XML like or LDAP data base. The first implementation is actually done as XML file to make it easier test application and deploy simple installation where there is no more users than 1000.
To find out more about user repository refer toUserRepositoryinterface for general info and toXMLRepositoryfor detailed explanation regarding XML implementation of user repository.
Thussubnodeis kind of path to data node. If you specifynullor empty node data will be stored in root user node. This has exactly the same effect as you callsetData(String, String). If you want to store data in different node you must just specify node path like you do it to directory on most file systems:
/roster
Or, if you need access deeper node:
/just/like/path/to/file
If given node does not yet exist it will be automaticaly created with all nodes in given path so there is no need for developer to perform additional action to create node. There is, however methodremoveDataGroup(String)for deleting specified node as nodes are not automaticaly deleted.- Parameters:
subnode- aStringvalue pointing to specific subnode in user reposiotry where data have to be stored.key- aStringvalue of data key ID.value- aStringactual data stored in user repository.- Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
setDataList
public void setDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException This method allows to store list of values under one key ID reference. It is often necessary to keep set of values which can be refered by one key. As an example might be list of groups for specific buddy in roster. There is no actual need to store each group with separate key because we usually need to acces whole list of groups.- Parameters:
subnode- aStringvalue pointing to specific subnode in user reposiotry where data have to be stored.key- aStringvalue of data key ID.list- aString[]keeping list of actual data to be stored in user repository.- Throws:
NotAuthorizedException- is thrown when session has not been authorized yet and there is no access to permanent storage.TigaseDBException- See Also:
-
setOfflineData
public void setOfflineData(String subnode, String key, String value) throws NotAuthorizedException, TigaseDBException -
setOfflineDataList
public void setOfflineDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException -
setPublicData
public void setPublicData(String subnode, String key, String value) throws NotAuthorizedException, TigaseDBException -
setPublicDataList
public void setPublicDataList(String subnode, String key, String[] list) throws NotAuthorizedException, TigaseDBException -
setRegistration
public void setRegistration(String name_param, String pass_param, Map<String, String> registr_params) throws TigaseDBException, TigaseStringprepException -
unregister
@Deprecated public Authorization unregister(String name_param) throws NotAuthorizedException, TigaseDBException, TigaseStringprepException Deprecated. -
login
protected abstract void login()
-