Package tigase.mongodb
Class MongoRepository
- java.lang.Object
-
- tigase.db.AbstractAuthRepositoryWithCredentials
-
- tigase.mongodb.MongoRepository
-
- All Implemented Interfaces:
tigase.db.AuthRepository,tigase.db.DataSourceAware<MongoDataSource>,tigase.db.Repository,tigase.db.UserRepository,tigase.db.util.RepositoryVersionAware,MongoRepositoryVersionAware
public class MongoRepository extends tigase.db.AbstractAuthRepositoryWithCredentials implements tigase.db.UserRepository, tigase.db.DataSourceAware<MongoDataSource>, MongoRepositoryVersionAware
MongoRepository is implementation of UserRepository and AuthRepository which supports MongoDB data store.- Author:
- andrzej
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface tigase.db.AuthRepository
tigase.db.AuthRepository.AccountStatus, tigase.db.AuthRepository.DefaultCredentials, tigase.db.AuthRepository.SingleCredential
-
Nested classes/interfaces inherited from interface tigase.db.Repository
tigase.db.Repository.Meta, tigase.db.Repository.SchemaId
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoCreateUserprotected static java.lang.StringDOMAIN_KEYprotected static java.lang.StringID_KEYprotected static java.lang.StringNODES_COLLECTIONprotected static java.lang.StringUSER_CREDENTIALS_COLLECTIONprotected static java.lang.StringUSERS_COLLECTION
-
Constructor Summary
Constructors Constructor Description MongoRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String[] list)voidaddUser(tigase.xmpp.jid.BareJID user)voidaddUser(tigase.xmpp.jid.BareJID user, java.lang.String password)protected byte[]calculateHash(java.lang.String user)protected byte[]generateId(tigase.xmpp.jid.BareJID user)tigase.db.AuthRepository.AccountStatusgetAccountStatus(tigase.xmpp.jid.BareJID user)java.util.Collection<java.lang.String>getCredentialIds(tigase.xmpp.jid.BareJID user)tigase.auth.credentials.CredentialsgetCredentials(tigase.xmpp.jid.BareJID user, java.lang.String credentialId)java.lang.StringgetData(tigase.xmpp.jid.BareJID user, java.lang.String key)java.lang.StringgetData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key)java.lang.StringgetData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String def)java.lang.String[]getDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key)java.util.Map<java.lang.String,java.lang.String>getDataMap(tigase.xmpp.jid.BareJID user, java.lang.String subnode)<T> java.util.Map<java.lang.String,T>getDataMap(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.util.function.Function<java.lang.String,T> converter)java.lang.String[]getKeys(tigase.xmpp.jid.BareJID user)java.lang.String[]getKeys(tigase.xmpp.jid.BareJID user, java.lang.String subnode)java.lang.StringgetResourceUri()java.lang.String[]getSubnodes(tigase.xmpp.jid.BareJID user)java.lang.String[]getSubnodes(tigase.xmpp.jid.BareJID user, java.lang.String subnode)java.util.List<tigase.xmpp.jid.BareJID>getUsers()longgetUsersCount()longgetUsersCount(java.lang.String domain)longgetUserUID(tigase.xmpp.jid.BareJID user)Deprecated.voidinitRepository(java.lang.String resource_uri, java.util.Map<java.lang.String,java.lang.String> params)Deprecated.voidloggedIn(tigase.xmpp.jid.BareJID jid)voidlogout(tigase.xmpp.jid.BareJID user)booleanotherAuth(java.util.Map<java.lang.String,java.lang.Object> authProps)voidqueryAuth(java.util.Map<java.lang.String,java.lang.Object> authProps)protected <T> java.util.List<T>readAllDistinctValuesForField(com.mongodb.client.MongoCollection<org.bson.Document> collection, java.lang.String field, org.bson.Document crit)voidremoveCredential(tigase.xmpp.jid.BareJID user, java.lang.String credentialId)voidremoveData(tigase.xmpp.jid.BareJID user, java.lang.String key)voidremoveData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key)voidremoveSubnode(tigase.xmpp.jid.BareJID user, java.lang.String subnode)voidremoveUser(tigase.xmpp.jid.BareJID user)voidsetAccountStatus(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status)voidsetData(tigase.xmpp.jid.BareJID user, java.lang.String key, java.lang.String value)voidsetData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String value)voidsetDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String[] list)voidsetDataSource(MongoDataSource dataSource)voidupdateCredential(tigase.xmpp.jid.BareJID user, java.lang.String credentialId, java.lang.String password)voidupdatePassword(tigase.xmpp.jid.BareJID user, java.lang.String password)tigase.db.util.SchemaLoader.ResultupdateSchema(java.util.Optional<tigase.util.Version> oldVersion, tigase.util.Version newVersion)booleanuserExists(tigase.xmpp.jid.BareJID user)-
Methods inherited from class tigase.db.AbstractAuthRepositoryWithCredentials
getCredentialsDecoder, getCredentialsEncoder, getPassword, isMechanismSupported, setCredentialsCodecs
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface tigase.db.AuthRepository
getUsernames, isUserDisabled, setUserDisabled
-
Methods inherited from interface tigase.mongodb.MongoRepositoryVersionAware
getVersion
-
-
-
-
Field Detail
-
USERS_COLLECTION
protected static final java.lang.String USERS_COLLECTION
- See Also:
- Constant Field Values
-
USER_CREDENTIALS_COLLECTION
protected static final java.lang.String USER_CREDENTIALS_COLLECTION
- See Also:
- Constant Field Values
-
NODES_COLLECTION
protected static final java.lang.String NODES_COLLECTION
- See Also:
- Constant Field Values
-
ID_KEY
protected static final java.lang.String ID_KEY
- See Also:
- Constant Field Values
-
DOMAIN_KEY
protected static final java.lang.String DOMAIN_KEY
- See Also:
- Constant Field Values
-
autoCreateUser
@ConfigField(desc="Auto create user", alias="autoCreateUser=") protected boolean autoCreateUser
-
-
Method Detail
-
addDataList
public void addDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String[] list) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
addDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserExistsException, tigase.db.TigaseDBException- Specified by:
addUserin interfacetigase.db.UserRepository- Throws:
tigase.db.UserExistsExceptiontigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user, java.lang.String password) throws tigase.db.UserExistsException, tigase.db.TigaseDBException- Specified by:
addUserin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserExistsExceptiontigase.db.TigaseDBException
-
calculateHash
protected byte[] calculateHash(java.lang.String user) throws tigase.db.TigaseDBException- Throws:
tigase.db.TigaseDBException
-
generateId
protected byte[] generateId(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException- Throws:
tigase.db.TigaseDBException
-
getAccountStatus
public tigase.db.AuthRepository.AccountStatus getAccountStatus(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException- Specified by:
getAccountStatusin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
getCredentials
public tigase.auth.credentials.Credentials getCredentials(tigase.xmpp.jid.BareJID user, java.lang.String credentialId) throws tigase.db.TigaseDBException- Specified by:
getCredentialsin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
getData
public java.lang.String getData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String def) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getData
public java.lang.String getData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getData
public java.lang.String getData(tigase.xmpp.jid.BareJID user, java.lang.String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getDataMap
public java.util.Map<java.lang.String,java.lang.String> getDataMap(tigase.xmpp.jid.BareJID user, java.lang.String subnode) throws tigase.db.TigaseDBException- Specified by:
getDataMapin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getDataMap
public <T> java.util.Map<java.lang.String,T> getDataMap(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.util.function.Function<java.lang.String,T> converter) throws tigase.db.TigaseDBException- Specified by:
getDataMapin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getDataList
public java.lang.String[] getDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getKeys
public java.lang.String[] getKeys(tigase.xmpp.jid.BareJID user, java.lang.String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getKeysin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getKeys
public java.lang.String[] getKeys(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getKeysin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getResourceUri
public java.lang.String getResourceUri()
- Specified by:
getResourceUriin interfacetigase.db.AuthRepository- Specified by:
getResourceUriin interfacetigase.db.UserRepository
-
getSubnodes
public java.lang.String[] getSubnodes(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getSubnodesin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getSubnodes
public java.lang.String[] getSubnodes(tigase.xmpp.jid.BareJID user, java.lang.String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
getSubnodesin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getCredentialIds
public java.util.Collection<java.lang.String> getCredentialIds(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException- Specified by:
getCredentialIdsin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
getUserUID
@Deprecated public long getUserUID(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBExceptionDeprecated.Should be removed as only relational DB are using this and it is not required by any other code- Specified by:
getUserUIDin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getUsers
public java.util.List<tigase.xmpp.jid.BareJID> getUsers() throws tigase.db.TigaseDBException- Specified by:
getUsersin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getUsersCount
public long getUsersCount()
- Specified by:
getUsersCountin interfacetigase.db.AuthRepository- Specified by:
getUsersCountin interfacetigase.db.UserRepository
-
getUsersCount
public long getUsersCount(java.lang.String domain)
- Specified by:
getUsersCountin interfacetigase.db.AuthRepository- Specified by:
getUsersCountin interfacetigase.db.UserRepository
-
initRepository
@Deprecated public void initRepository(java.lang.String resource_uri, java.util.Map<java.lang.String,java.lang.String> params) throws tigase.db.DBInitExceptionDeprecated.- Specified by:
initRepositoryin interfacetigase.db.Repository- Throws:
tigase.db.DBInitException
-
loggedIn
public void loggedIn(tigase.xmpp.jid.BareJID jid) throws tigase.db.TigaseDBException- Specified by:
loggedInin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
logout
public void logout(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
logoutin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
otherAuth
public boolean otherAuth(java.util.Map<java.lang.String,java.lang.Object> authProps) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException, tigase.db.AuthorizationException- Specified by:
otherAuthin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBExceptiontigase.db.AuthorizationException
-
queryAuth
public void queryAuth(java.util.Map<java.lang.String,java.lang.Object> authProps)
- Specified by:
queryAuthin interfacetigase.db.AuthRepository
-
readAllDistinctValuesForField
protected <T> java.util.List<T> readAllDistinctValuesForField(com.mongodb.client.MongoCollection<org.bson.Document> collection, java.lang.String field, org.bson.Document crit) throws com.mongodb.MongoException- Throws:
com.mongodb.MongoException
-
removeCredential
public void removeCredential(tigase.xmpp.jid.BareJID user, java.lang.String credentialId) throws tigase.db.TigaseDBException- Specified by:
removeCredentialin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
removeData
public void removeData(tigase.xmpp.jid.BareJID user, java.lang.String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
removeDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeData
public void removeData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
removeDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeSubnode
public void removeSubnode(tigase.xmpp.jid.BareJID user, java.lang.String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
removeSubnodein interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeUser
public void removeUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
removeUserin interfacetigase.db.AuthRepository- Specified by:
removeUserin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setAccountStatus
public void setAccountStatus(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status) throws tigase.db.TigaseDBException- Specified by:
setAccountStatusin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
setData
public void setData(tigase.xmpp.jid.BareJID user, java.lang.String key, java.lang.String value) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
setDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setData
public void setData(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String value) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
setDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setDataList
public void setDataList(tigase.xmpp.jid.BareJID user, java.lang.String subnode, java.lang.String key, java.lang.String[] list) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
setDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setDataSource
public void setDataSource(MongoDataSource dataSource)
- Specified by:
setDataSourcein interfacetigase.db.DataSourceAware<MongoDataSource>
-
updateCredential
public void updateCredential(tigase.xmpp.jid.BareJID user, java.lang.String credentialId, java.lang.String password) throws tigase.db.TigaseDBException- Specified by:
updateCredentialin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
updatePassword
public void updatePassword(tigase.xmpp.jid.BareJID user, java.lang.String password) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException- Specified by:
updatePasswordin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
updateSchema
public tigase.db.util.SchemaLoader.Result updateSchema(java.util.Optional<tigase.util.Version> oldVersion, tigase.util.Version newVersion) throws tigase.db.TigaseDBException- Specified by:
updateSchemain interfacetigase.db.util.RepositoryVersionAware- Throws:
tigase.db.TigaseDBException
-
userExists
public boolean userExists(tigase.xmpp.jid.BareJID user)
- Specified by:
userExistsin interfacetigase.db.UserRepository
-
-