@Override
public String addUser(String dbName, String username, String password, boolean readOnly) throws ApplicationException {
if (dbName == null) {
throw new DatabaseException(ErrorCodes.DB_NAME_EMPTY, "Database name is null");
}
if (dbName.equals("")) {
throw new DatabaseException(ErrorCodes.DB_NAME_EMPTY, "Database Name Empty");
}
if (username == null) {
throw new DatabaseException(ErrorCodes.USERNAME_IS_EMPTY, "Username is null");
}
if (username.equals("")) {
throw new DatabaseException(ErrorCodes.USERNAME_IS_EMPTY, "Username is empty");
}
if (password == null) {
throw new DatabaseException(ErrorCodes.PASSWORD_IS_EMPTY, "Password is null");
}
if (password.equals("")) {
throw new DatabaseException(ErrorCodes.PASSWORD_IS_EMPTY, "Password is empty");
}
try {
mongoInstance.getDB(dbName).addUser(username, password.toCharArray(), readOnly);
} catch (MongoException e) {
throw new ApplicationException(ErrorCodes.USER_CREATION_EXCEPTION, e.getMessage());