Class FileCrudOperations<V extends AbstractEntity & UpdatableEntity,M>
java.lang.Object
org.keycloak.models.map.storage.file.FileCrudOperations<V,M>
- All Implemented Interfaces:
HasRealmId,CrudOperations<V,M>
public abstract class FileCrudOperations<V extends AbstractEntity & UpdatableEntity,M>
extends Object
implements CrudOperations<V,M>, HasRealmId
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanParseFile(Path p) protected abstract voidcheckIsSafeToModify(Path path) Hook to validate that it is safe to modify the file identified by the suppliedPath.Creates an object in the storage.booleanDeletes object with the givenkeyfrom the storage, if exists, no-op otherwise.longdelete(QueryParameters<M> queryParameters) Deletes objects that match the given criteria.determineKeyFromValue(V value) Returns escaped ID - relative file name in the file system with path separatorID_COMPONENT_SEPARATOR.determineKeyFromValue(V value, String lastIdComponentIfUnset) longgetCount(QueryParameters<M> queryParameters) Returns the number of objects satisfying givencriteriafrom the storage.protected abstract FileTimegetLastModifiedTime(Path path) Hook to obtain the last modified time of the file identified by the suppliedPath.protected PathgetPathForEscapedId(String escapedId) protected PathgetPathForEscapedId(String[] escapedIdPathArray) static <V extends AbstractEntity & UpdatableEntity,M>
Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<String, V, M>> getPredicates(Class<V> entityClass) Returns realm ID of the entity.protected abstract StringgetTxId()protected VReturns object with the givenkeyfrom the storage ornullif object does not exist.read(QueryParameters<M> queryParameters) Returns stream of objects satisfying givencriteriafrom the storage.protected abstract voidregisterRenameOnCommit(Path tempSp, Path sp) protected abstract booleanremoveIfExists(Path sp) voidsetRealmId(String realmId) Sets the realm ID of this object.protected abstract voidUpdates the object with the key of thevalue's ID in the storage if it already exists.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.map.storage.CrudOperations
exists, exists
-
Field Details
-
SEARCHABLE_FIELD_REALM_ID_FIELD_NAME
-
FILE_SUFFIX
- See Also:
-
DUMP_SETTINGS
public static final org.snakeyaml.engine.v2.api.DumpSettings DUMP_SETTINGS -
ID_COMPONENT_SEPARATOR
- See Also:
-
-
Constructor Details
-
FileCrudOperations
-
-
Method Details
-
getPredicates
public static <V extends AbstractEntity & UpdatableEntity,M> Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<String, getPredicatesV, M>> (Class<V> entityClass) -
getPathForEscapedId
-
getPathForEscapedId
-
canParseFile
-
parse
-
create
Description copied from interface:CrudOperationsCreates an object in the storage.
ID of thevaluemay be prescribed in id of thevalue. If the id isnullor its format is not matching the store internal format for ID, then thevalue's ID will be generated and returned in the id of the return value.- Specified by:
createin interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
value- Entity to create in the store- Returns:
- Entity representing the
valuein the store. It may or may not be the same instance asvalue - See Also:
-
determineKeyFromValue
-
determineKeyFromValue
Returns escaped ID - relative file name in the file system with path separatorID_COMPONENT_SEPARATOR.- Specified by:
determineKeyFromValuein interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
value- ObjectforCreate- Whether this is for create operation (true) or- Returns:
-
read
Description copied from interface:CrudOperationsReturns object with the givenkeyfrom the storage ornullif object does not exist.
IfVimplementsExpirableEntitythis method should not return entities that are expired. SeeExpirableEntityJavaDoc for more details. TODO: Consider returningOptional<V>instead.- Specified by:
readin interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
key- Key of the object. Must not benull.- Returns:
- See description
-
createCriteriaBuilder
-
read
Description copied from interface:CrudOperationsReturns stream of objects satisfying givencriteriafrom the storage. The criteria are specified in the given criteria builder based on model properties.
IfVimplementsExpirableEntitythis method should not return entities that are expired. SeeExpirableEntityJavaDoc for more details.- Specified by:
readin interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Stream of objects. Never returns
null.
-
update
Description copied from interface:CrudOperationsUpdates the object with the key of thevalue's ID in the storage if it already exists.- Specified by:
updatein interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
value- Updated value- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
- See Also:
-
delete
Description copied from interface:CrudOperationsDeletes object with the givenkeyfrom the storage, if exists, no-op otherwise.- Specified by:
deletein interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Returns:
- Returns
trueif the object has been deleted or result cannot be determined,falseotherwise.
-
delete
Description copied from interface:CrudOperationsDeletes objects that match the given criteria.- Specified by:
deletein interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of removed objects (might return
-1if not supported)
-
getCount
Description copied from interface:CrudOperationsReturns the number of objects satisfying givencriteriafrom the storage. The criteria are specified in the given criteria builder based on model properties.- Specified by:
getCountin interfaceCrudOperations<V extends AbstractEntity & UpdatableEntity,M> - Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of objects. Never returns
null.
-
getRealmId
Description copied from interface:HasRealmIdReturns realm ID of the entity.- Specified by:
getRealmIdin interfaceHasRealmId- Returns:
- See description
-
setRealmId
Description copied from interface:HasRealmIdSets the realm ID of this object.- Specified by:
setRealmIdin interfaceHasRealmId- Parameters:
realmId- Realm ID.
-
touch
- Throws:
IOException
-
removeIfExists
-
registerRenameOnCommit
-
getTxId
-
getLastModifiedTime
Hook to obtain the last modified time of the file identified by the suppliedPath. -
checkIsSafeToModify
Hook to validate that it is safe to modify the file identified by the suppliedPath. The primary goal is to identify if other transactions have modified the file after it was read by the current transaction, preventing updates to a stale entity.- Parameters:
path- thePathto the file that is to be modified.
-