MongoRepository

public class MongoRepository extends AbstractAuthRepositoryWithCredentials implements UserRepository, DataSourceAware<MongoDataSource>, MongoRepositoryVersionAware

MongoRepository is implementation of UserRepository and AuthRepository which supports MongoDB data store.

Author:andrzej

Fields

DOMAIN_KEY

protected static final String DOMAIN_KEY

ID_KEY

protected static final String ID_KEY

NODES_COLLECTION

protected static final String NODES_COLLECTION

USERS_COLLECTION

protected static final String USERS_COLLECTION

USER_CREDENTIALS_COLLECTION

protected static final String USER_CREDENTIALS_COLLECTION

autoCreateUser

protected boolean autoCreateUser

Methods

addDataList

public void addDataList(BareJID user, String subnode, String key, String[] list)

addUser

public void addUser(BareJID user)

addUser

public void addUser(BareJID user, String password)

calculateHash

protected byte[] calculateHash(String user)

generateId

protected byte[] generateId(BareJID user)

getAccountStatus

public AccountStatus getAccountStatus(BareJID user)

getActiveUsersCountIn

public long getActiveUsersCountIn(Duration duration)

getCredentialIds

public Collection<String> getCredentialIds(BareJID user)

getCredentials

public Credentials getCredentials(BareJID user, String credentialId)

getData

public String getData(BareJID user, String subnode, String key, String def)

getData

public String getData(BareJID user, String subnode, String key)

getData

public String getData(BareJID user, String key)

getDataList

public String[] getDataList(BareJID user, String subnode, String key)

getDataMap

public Map<String, String> getDataMap(BareJID user, String subnode)

getDataMap

public <T> Map<String, T> getDataMap(BareJID user, String subnode, Function<String, T> converter)

getKeys

public String[] getKeys(BareJID user, String subnode)

getKeys

public String[] getKeys(BareJID user)

getResourceUri

public String getResourceUri()

getSubnodes

public String[] getSubnodes(BareJID user)

getSubnodes

public String[] getSubnodes(BareJID user, String subnode)

getUserUID

public long getUserUID(BareJID user)

Should be removed as only relational DB are using this and it is not required by any other code {@inheritDoc}

getUsers

public List<BareJID> getUsers()

getUsersCount

public long getUsersCount()

getUsersCount

public long getUsersCount(String domain)

initRepository

public void initRepository(String resource_uri, Map<String, String> params)

loggedIn

public void loggedIn(BareJID jid)

logout

public void logout(BareJID user)

otherAuth

public boolean otherAuth(Map<String, Object> authProps)

queryAuth

public void queryAuth(Map<String, Object> authProps)

readAllDistinctValuesForField

protected <T> List<T> readAllDistinctValuesForField(MongoCollection<Document> collection, String field, Document crit)

removeCredential

public void removeCredential(BareJID user, String credentialId)

removeData

public void removeData(BareJID user, String key)

removeData

public void removeData(BareJID user, String subnode, String key)

removeSubnode

public void removeSubnode(BareJID user, String subnode)

removeUser

public void removeUser(BareJID user)

setAccountStatus

public void setAccountStatus(BareJID user, AccountStatus status)

setData

public void setData(BareJID user, String key, String value)

setData

public void setData(BareJID user, String subnode, String key, String value)

setDataList

public void setDataList(BareJID user, String subnode, String key, String[] list)

setDataSource

public void setDataSource(MongoDataSource dataSource)

updateCredential

public void updateCredential(BareJID user, String credentialId, String password)

updatePassword

public void updatePassword(BareJID user, String password)

updateSchema

public SchemaLoader.Result updateSchema(Optional<Version> oldVersion, Version newVersion)

userExists

public boolean userExists(BareJID user)