Package com.evolveum.midpoint.repo.sqale
Class UriCache
java.lang.Object
com.evolveum.midpoint.repo.sqale.UriCache
Component hiding details of how QNames are stored in 
QUri.
 Following prefixes are used for its methods:
 * `get` returns URI or ID for ID or URI, may return null, accesses DB if not found (multi-node safety);
 * `search` like `get` but returns UNKNOWN_ID instead of null, used for query predicates,
 accesses DB if not found (multi-node safety);
 * `resolve` returns URI/ID for ID/URI or throws exception if not found, this is for situations
 where the entry for URI is expected to exist already, accesses DB if not found in cache (multi-node safety);
 * finally, processCacheableUri(Object) accesses the database if the URI is not found
 in the cache in order to write it there.
 URIs are stored either as is when provided as a String or using QNameUtil.qNameToUri(QName)
 when provided as a QName.
 This component does not know anything about relations (represented as QName-s), but these are
 systematically normalized before they get here (if not, it's surely a bug).
 [NOTE]
 URI is added in the database in its own separate transaction.
 It is tempting to add cached URI as part of the existing transaction, but when the provided
 transaction is rolled back, the cache still thinks the URI row is already there.
 This could be avoided if the runtime maps were updated *only* after the row was successfully
 read from the DB in other operations - which beats the purposes of those fast operations.
 Instead, we risk adding the row that is not used, it is no harm; it will likely be used later.- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intUnknown id placeholder, not actually in DB but returned when URI is not in the cache and returning `null` or throwing exception would not make sense.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription@Nullable IntegerReturns ID for string, possiblynull- does not work with underlying database.@Nullable IntegerReturns ID for QName, possiblynull- does not work with underlying database.Returns URI string for ID ornull- does not work with underlying database.voidinitialize(Supplier<JdbcSession> jdbcSessionSupplier) Initializes the URI cache.@Nullable IntegerprocessCacheableUri(@Nullable Object uri) Returns ID for URI creating new cache row in DB as needed.@NotNull StringresolveToUri(Integer id) Returns URI string for ID or throws exception - does not work with underlying database.@NotNull IntegerresolveUriToId(@NotNull String uri) Returns ID for QName or throws exception - does not work with underlying database.@NotNull IntegerresolveUriToId(@NotNull QName qName) Returns ID for QName or throws exception - does not work with underlying database.@NotNull IntegerReturns ID for provided URI value of `QName/String/Object#toString`.@NotNull IntegerReturns ID for string orUNKNOWN_ID- does not work with underlying database.
- 
Field Details- 
UNKNOWN_IDpublic static final int UNKNOWN_IDUnknown id placeholder, not actually in DB but returned when URI is not in the cache and returning `null` or throwing exception would not make sense. Typical case is using it for query predicate when searching for unknown URI should result in a condition comparing URI ID attribute (e.g. relationId) to id that will not be found. This is completely transient and can be changed if the need arises.- See Also:
 
 
- 
- 
Constructor Details- 
UriCachepublic UriCache()
 
- 
- 
Method Details- 
initializeInitializes the URI cache. ProvidedJdbcSessionsupplier will be used for later writes as well.
- 
getIdReturns ID for QName, possiblynull- does not work with underlying database.
- 
resolveUriToIdReturns ID for QName or throws exception - does not work with underlying database.
- 
getIdReturns ID for string, possiblynull- does not work with underlying database.
- 
searchIdReturns ID for provided URI value of `QName/String/Object#toString`.
- 
searchIdReturns ID for string orUNKNOWN_ID- does not work with underlying database.
- 
resolveUriToIdReturns ID for QName or throws exception - does not work with underlying database.
- 
getUriReturns URI string for ID ornull- does not work with underlying database.
- 
resolveToUriReturns URI string for ID or throws exception - does not work with underlying database.
- 
processCacheableUriReturns ID for URI creating new cache row in DB as needed. Returns null for null URI parameter.
 
-