org.keycloak.connections.mongo.impl

## Class MongoStoreImpl

- java.lang.Object
- - org.keycloak.connections.mongo.impl.MongoStoreImpl

- All Implemented Interfaces:
    MongoStore

      public class MongoStoreImpl
      extends Object
      implements MongoStore

  Author:
    Marek Posolda

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MongoStoreImpl(com.mongodb.DB database, Class<?>[] managedEntityTypes)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAppObjectConverter(Mapper<?,?> mapper)`
    `void` | `addDBObjectConverter(Mapper<?,?> mapper)`
    `protected <T extends MongoIdentifiableEntity> List<T>` | `convertCursor(Class<T> type, com.mongodb.DBCursor cursor, MongoStoreInvocationContext context)`
    `protected <T extends MongoIdentifiableEntity> T` | `convertDBObjectToEntity(Class<T> type, com.mongodb.DBObject dbObject, MongoStoreInvocationContext context)`
    `static ModelException` | `convertException(com.mongodb.MongoException e)`
    `<T extends MongoIdentifiableEntity> int` | `countEntities(Class<T> type, com.mongodb.DBObject query, MongoStoreInvocationContext context)`
    `protected void` | `dropDatabase()`
    `protected com.mongodb.DBCollection` | `getDBCollectionForType(Class<?> type)`
    `EntityInfo` | `getEntityInfo(Class<?> entityClass)`
    `void` | `insertEntity(MongoIdentifiableEntity entity, MongoStoreInvocationContext context)` Insert new entity
    `<T extends MongoIdentifiableEntity> List<T>` | `loadEntities(Class<T> type, com.mongodb.DBObject query, com.mongodb.DBObject sort, int firstResult, int maxResults, MongoStoreInvocationContext context)`
    `<T extends MongoIdentifiableEntity> List<T>` | `loadEntities(Class<T> type, com.mongodb.DBObject query, MongoStoreInvocationContext context)`
    `<T extends MongoIdentifiableEntity> T` | `loadEntity(Class<T> type, String id, MongoStoreInvocationContext context)`
    `<T extends MongoIdentifiableEntity> T` | `loadSingleEntity(Class<T> type, com.mongodb.DBObject query, MongoStoreInvocationContext context)`
    `<S> boolean` | `pullItemFromList(MongoIdentifiableEntity entity, String listPropertyName, S itemToPull, MongoStoreInvocationContext context)`
    `<S> boolean` | `pushItemToList(MongoIdentifiableEntity entity, String listPropertyName, S itemToPush, boolean skipIfAlreadyPresent, MongoStoreInvocationContext context)`
    `int` | `removeEntities(Class<? extends MongoIdentifiableEntity> type, com.mongodb.DBObject query, boolean callback, MongoStoreInvocationContext context)`
    `boolean` | `removeEntity(Class<? extends MongoIdentifiableEntity> type, String id, MongoStoreInvocationContext context)`
    `boolean` | `removeEntity(MongoIdentifiableEntity entity, MongoStoreInvocationContext context)`
    `<T extends MongoIdentifiableEntity> int` | `updateEntities(Class<T> type, com.mongodb.DBObject query, com.mongodb.DBObject update, MongoStoreInvocationContext context)` Bulk update of more entities of some type
    `void` | `updateEntity(MongoIdentifiableEntity entity, MongoStoreInvocationContext context)` Update existing entity

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MongoStoreImpl

          public MongoStoreImpl(com.mongodb.DB database,
                                Class<?>[] managedEntityTypes)

  - ### Method Detail

    - #### dropDatabase

          protected void dropDatabase()

    - #### insertEntity

          public void insertEntity(MongoIdentifiableEntity entity,
                                   MongoStoreInvocationContext context)

      Description copied from interface: `MongoStore`
      Insert new entity
      Specified by:
        `insertEntity` in interface `MongoStore`
      Parameters:
        `entity` - to insert

    - #### convertException

          public static ModelException convertException(com.mongodb.MongoException e)

    - #### updateEntity

          public void updateEntity(MongoIdentifiableEntity entity,
                                   MongoStoreInvocationContext context)

      Description copied from interface: `MongoStore`
      Update existing entity
      Specified by:
        `updateEntity` in interface `MongoStore`
      Parameters:
        `entity` - to update

    - #### updateEntities

          public <T extends MongoIdentifiableEntity> int updateEntities(Class<T> type,
                                                                        com.mongodb.DBObject query,
                                                                        com.mongodb.DBObject update,
                                                                        MongoStoreInvocationContext context)

      Description copied from interface: `MongoStore`
      Bulk update of more entities of some type
      Specified by:
        `updateEntities` in interface `MongoStore`
      Returns:
        count of updated entities

    - #### loadEntity

          public <T extends MongoIdentifiableEntity> T loadEntity(Class<T> type,
                                                                  String id,
                                                                  MongoStoreInvocationContext context)

      Specified by:
        `loadEntity` in interface `MongoStore`

    - #### loadSingleEntity

          public <T extends MongoIdentifiableEntity> T loadSingleEntity(Class<T> type,
                                                                        com.mongodb.DBObject query,
                                                                        MongoStoreInvocationContext context)

      Specified by:
        `loadSingleEntity` in interface `MongoStore`

    - #### loadEntities

          public <T extends MongoIdentifiableEntity> List<T> loadEntities(Class<T> type,
                                                                          com.mongodb.DBObject query,
                                                                          MongoStoreInvocationContext context)

      Specified by:
        `loadEntities` in interface `MongoStore`
      Returns:
        query result or empty list if no results available for the query. Doesn't return null

    - #### loadEntities

          public <T extends MongoIdentifiableEntity> List<T> loadEntities(Class<T> type,
                                                                          com.mongodb.DBObject query,
                                                                          com.mongodb.DBObject sort,
                                                                          int firstResult,
                                                                          int maxResults,
                                                                          MongoStoreInvocationContext context)

      Specified by:
        `loadEntities` in interface `MongoStore`
      Returns:
        query result or empty list if no results available for the query. Doesn't return null

    - #### countEntities

          public <T extends MongoIdentifiableEntity> int countEntities(Class<T> type,
                                                                       com.mongodb.DBObject query,
                                                                       MongoStoreInvocationContext context)

      Specified by:
        `countEntities` in interface `MongoStore`

    - #### removeEntity

          public boolean removeEntity(MongoIdentifiableEntity entity,
                                      MongoStoreInvocationContext context)

      Specified by:
        `removeEntity` in interface `MongoStore`

    - #### removeEntity

          public boolean removeEntity(Class<? extends MongoIdentifiableEntity> type,
                                      String id,
                                      MongoStoreInvocationContext context)

      Specified by:
        `removeEntity` in interface `MongoStore`

    - #### removeEntities

          public int removeEntities(Class<? extends MongoIdentifiableEntity> type,
                                    com.mongodb.DBObject query,
                                    boolean callback,
                                    MongoStoreInvocationContext context)

      Specified by:
        `removeEntities` in interface `MongoStore`
        `callback` - if true, then store will first load all entities, then call "afterRemove" for every entity. If false, the entities are removed directly without load and calling "afterRemove" callback false has better performance (especially if we are going to remove big number of entities)
      Returns:
        count of removed entities

    - #### pushItemToList

          public <S> boolean pushItemToList(MongoIdentifiableEntity entity,
                                            String listPropertyName,
                                            S itemToPush,
                                            boolean skipIfAlreadyPresent,
                                            MongoStoreInvocationContext context)

      Specified by:
        `pushItemToList` in interface `MongoStore`

    - #### pullItemFromList

          public <S> boolean pullItemFromList(MongoIdentifiableEntity entity,
                                              String listPropertyName,
                                              S itemToPull,
                                              MongoStoreInvocationContext context)

      Specified by:
        `pullItemFromList` in interface `MongoStore`

    - #### addAppObjectConverter

          public void addAppObjectConverter(Mapper<?,?> mapper)

    - #### addDBObjectConverter

          public void addDBObjectConverter(Mapper<?,?> mapper)

    - #### getEntityInfo

          public EntityInfo getEntityInfo(Class<?> entityClass)

    - #### convertCursor

          protected <T extends MongoIdentifiableEntity> List<T> convertCursor(Class<T> type,
                                                                              com.mongodb.DBCursor cursor,
                                                                              MongoStoreInvocationContext context)

    - #### convertDBObjectToEntity

          protected <T extends MongoIdentifiableEntity> T convertDBObjectToEntity(Class<T> type,
                                                                                  com.mongodb.DBObject dbObject,
                                                                                  MongoStoreInvocationContext context)

    - #### getDBCollectionForType

          protected com.mongodb.DBCollection getDBCollectionForType(Class<?> type)

Copyright © 2016 JBoss by Red Hat. All rights reserved.