Class SqaleRepositoryService
- java.lang.Object
-
- com.evolveum.midpoint.repo.sqale.SqaleServiceBase
-
- com.evolveum.midpoint.repo.sqale.SqaleRepositoryService
-
- All Implemented Interfaces:
RepositoryService
public class SqaleRepositoryService extends SqaleServiceBase implements RepositoryService
Repository implementation based on SQL, JDBC and Querydsl without any ORM. Typical structure of main public methods: - Argument checks. - Debug log. This can be postponed after operation result creation, if more complex log is needed. - CreateOperationResult
from provided parent, immediately followed by try/catch/finally. SeeaddObject(com.evolveum.midpoint.prism.PrismObject<T>, com.evolveum.midpoint.repo.api.RepoAddOptions, com.evolveum.midpoint.schema.result.OperationResult)
for example. - More arg checks if necessary, fast fail scenarios. - Call to `executeMethodName(...)` where perf monitor is initialized followed by try/catch/finally. SeeexecuteAddObject(com.evolveum.midpoint.prism.PrismObject<T>)
for example. Always try to keep startingJdbcSession
in try-with-resource construct. Positive flows require explicitJdbcSession.commit()
otherwise the changes are rolled back.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.evolveum.midpoint.repo.api.RepositoryService
RepositoryService.ModificationsSupplier<T extends ObjectType>
-
-
Field Summary
Fields Modifier and Type Field Description static int
INITIAL_VERSION_NUMBER
static String
INITIAL_VERSION_STRING
-
Fields inherited from class com.evolveum.midpoint.repo.sqale.SqaleServiceBase
logger, opNamePrefix, performanceMonitor, REPOSITORY_IMPL_NAME, sqlPerformanceMonitorsCollection, sqlRepoContext
-
Fields inherited from interface com.evolveum.midpoint.repo.api.RepositoryService
ADD_DIAGNOSTIC_INFORMATION, ADD_OBJECT, ADVANCE_SEQUENCE, CLASS_NAME_WITH_DOT, COUNT_CONTAINERS, COUNT_OBJECTS, DELETE_OBJECT, EXECUTE_QUERY_DIAGNOSTICS, GET_OBJECT, GET_VERSION, HAS_CONFLICT, KEY_DIAG_DATA, KEY_ORIGINAL_OBJECT, LOGGER, MODIFY_OBJECT, MODIFY_OBJECT_DYNAMICALLY, OP_ADD_DIAGNOSTIC_INFORMATION, OP_ADD_OBJECT, OP_ADD_OBJECT_OVERWRITE, OP_ADVANCE_SEQUENCE, OP_COUNT_CONTAINERS, OP_COUNT_OBJECTS, OP_COUNT_REFERENCES, OP_DELETE_OBJECT, OP_EXECUTE_QUERY_DIAGNOSTICS, OP_FETCH_EXT_ITEMS, OP_GET_OBJECT, OP_GET_VERSION, OP_HAS_CONFLICT, OP_IS_ANCESTOR, OP_IS_DESCENDANT, OP_MODIFY_OBJECT, OP_MODIFY_OBJECT_DYNAMICALLY, OP_REPOSITORY_SELF_TEST, OP_RETURN_UNUSED_VALUES_TO_SEQUENCE, OP_SEARCH_CONTAINERS, OP_SEARCH_OBJECTS, OP_SEARCH_OBJECTS_ITERATIVE, OP_SEARCH_OBJECTS_ITERATIVE_PAGE, OP_SEARCH_REFERENCES, OP_SEARCH_REFERENCES_ITERATIVE, OP_SEARCH_REFERENCES_ITERATIVE_PAGE, OP_TEST_ORG_CLOSURE_CONSISTENCY, RETURN_UNUSED_VALUES_TO_SEQUENCE, SEARCH_CONTAINERS, SEARCH_OBJECTS, SEARCH_OBJECTS_ITERATIVE
-
-
Constructor Summary
Constructors Constructor Description SqaleRepositoryService(SqaleRepoContext repositoryContext, SqlPerformanceMonitorsCollection sqlPerformanceMonitorsCollection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ObjectType>
voidaddDiagnosticInformation(Class<T> type, String oid, DiagnosticInformationType information, OperationResult parentResult)
Adds a diagnostic information, honoring cleanup rules (deleting obsolete records).<T extends ObjectType>
@NotNull StringaddObject(@NotNull PrismObject<T> object, @Nullable RepoAddOptions options, @NotNull OperationResult parentResult)
Add new object.long
advanceSequence(String oid, OperationResult parentResult)
This operation is guaranteed to be atomic.void
applyFullTextSearchConfiguration(FullTextSearchConfigurationType fullTextSearch)
<T extends Containerable>
intcountContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
<T extends ObjectType>
intcountObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
Returns the number of objects that match specified criteria.int
countReferences(@Nullable ObjectQuery query, @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult)
Reference count - currently supporting roleMembershipRef and linkRef search.ConflictWatcher
createAndRegisterConflictWatcher(@NotNull String oid)
<T extends ObjectType>
@NotNull DeleteObjectResultdeleteObject(Class<T> type, String oid, OperationResult parentResult)
Deletes object with specified OID.ModifyObjectResult<SimulationResultType>
deleteSimulatedProcessedObjects(String oid, @Nullable String transactionId, OperationResult parentResult)
int
executeCountReferences(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options)
RepositoryQueryDiagResponse
executeQueryDiagnostics(RepositoryQueryDiagRequest request, OperationResult parentResult)
A bit of hack - execute arbitrary query, e.g.FullTextSearchConfigurationType
getFullTextSearchConfiguration()
<T extends ObjectType>
@NotNull PrismObject<T>getObject(Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
Returns object for provided OID.@NotNull String
getRepositoryType()
Returns short type identifier of the repository implementation.<T extends ObjectType>
StringgetVersion(Class<T> type, String oid, OperationResult parentResult)
Returns object version for provided OID.boolean
hasConflict(ConflictWatcher watcher, OperationResult parentResult)
<O extends ObjectType>
booleanisAncestor(PrismObject<O> object, String descendantOrgOid)
Returns `true` if the `object` is above organization identified with `descendantOrgOid`.<O extends ObjectType>
booleanisDescendant(PrismObject<O> object, String ancestorOrgOid)
Returns `true` if the `object` is under the organization identified with `ancestorOrgOid`.<T extends ObjectType>
@NotNull ModifyObjectResult<T>modifyObject(@NotNull Class<T> type, @NotNull String oid, @NotNull Collection<? extends ItemDelta<?,?>> modifications, @NotNull OperationResult parentResult)
Modifies object using relative change description.<T extends ObjectType>
@NotNull ModifyObjectResult<T>modifyObject(@NotNull Class<T> type, @NotNull String oid, @NotNull Collection<? extends ItemDelta<?,?>> modifications, @Nullable ModificationPrecondition<T> precondition, @Nullable RepoModifyOptions options, @NotNull OperationResult parentResult)
<T extends ObjectType>
@NotNull ModifyObjectResult<T>modifyObject(@NotNull Class<T> type, @NotNull String oid, @NotNull Collection<? extends ItemDelta<?,?>> modifications, @Nullable RepoModifyOptions options, @NotNull OperationResult parentResult)
<T extends ObjectType>
@NotNull ModifyObjectResult<T>modifyObjectDynamically(@NotNull Class<T> type, @NotNull String oid, @Nullable Collection<SelectorOptions<GetOperationOptions>> getOptions, @NotNull RepositoryService.ModificationsSupplier<T> modificationsSupplier, @Nullable RepoModifyOptions modifyOptions, @NotNull OperationResult parentResult)
Modifies an object dynamically.void
postInit(OperationResult parentResult)
void
repositorySelfTest(OperationResult parentResult)
Runs a short, non-destructive repository self test.void
returnUnusedValuesToSequence(String oid, Collection<Long> unusedValues, OperationResult parentResult)
The sequence may ignore the values, e.g.<T extends Containerable>
SearchResultList<T>searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
Search for "sub-object" structures, i.e.<T extends ObjectType>
@NotNull SearchResultList<PrismObject<T>>searchObjects(@NotNull Class<T> type, ObjectQuery query, @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult)
Search for objects in the repository.<T extends ObjectType>
SearchResultMetadatasearchObjectsIterative(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, boolean strictlySequential, OperationResult parentResult)
Search for objects in the repository in an iterative fashion.@NotNull SearchResultList<ObjectReferenceType>
searchReferences(@NotNull ObjectQuery query, @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult)
Reference search - currently supporting roleMembershipRef and linkRef search.SearchResultMetadata
searchReferencesIterative(@Nullable ObjectQuery query, @NotNull ObjectHandler<ObjectReferenceType> handler, @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult)
Executes iterative reference search using the provided `handler` to process each references.<O extends ObjectType>
booleanselectorMatches(ObjectSelectorType objectSelector, PrismObject<O> object, boolean fullInformationAvailable, ObjectFilterExpressionEvaluator filterEvaluator, Trace logger, String logMessagePrefix)
boolean
supports(@NotNull Class<? extends ObjectType> type)
Returns `true` if the given object type is supported.void
testOrgClosureConsistency(boolean repairIfNecessary, OperationResult parentResult)
Checks a closure for consistency, repairing any problems found.void
unregisterConflictWatcher(ConflictWatcher watcher)
-
Methods inherited from class com.evolveum.midpoint.repo.sqale.SqaleServiceBase
destroy, getPerformanceMonitor, getRepositoryDiag, handledGeneralException, logSearchInputParameters, prismContext, recordFatalError, registerOperationFinish, registerOperationStart, registerOperationStart, repositoryConfiguration, sqlRepoContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.repo.api.RepositoryService
getPerformanceMonitor, getRepositoryDiag, isNative, searchShadowOwner, selectorMatches, supportsMarks
-
-
-
-
Field Detail
-
INITIAL_VERSION_NUMBER
public static final int INITIAL_VERSION_NUMBER
- See Also:
- Constant Field Values
-
INITIAL_VERSION_STRING
public static final String INITIAL_VERSION_STRING
-
-
Constructor Detail
-
SqaleRepositoryService
public SqaleRepositoryService(SqaleRepoContext repositoryContext, SqlPerformanceMonitorsCollection sqlPerformanceMonitorsCollection)
-
-
Method Detail
-
getObject
@NotNull public <T extends ObjectType> @NotNull PrismObject<T> getObject(Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
Description copied from interface:RepositoryService
Returns object for provided OID. Must fail if object with the OID does not exist.- Specified by:
getObject
in interfaceRepositoryService
oid
- OID of the object to getparentResult
- parent OperationResult (in/out)- Returns:
- Object fetched from repository
- Throws:
ObjectNotFoundException
- requested object does not existSchemaException
- error dealing with storage schema
-
getVersion
public <T extends ObjectType> String getVersion(Class<T> type, String oid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
Description copied from interface:RepositoryService
Returns object version for provided OID.Must fail if object with the OID does not exist.
This is a supposed to be a very lightweight and cheap operation. It is used to support efficient caching of expensive objects.
- Specified by:
getVersion
in interfaceRepositoryService
oid
- OID of the object to getparentResult
- parent OperationResult (in/out)- Returns:
- Object version
- Throws:
ObjectNotFoundException
- requested object does not existSchemaException
- error dealing with storage schema
-
addObject
@NotNull public <T extends ObjectType> @NotNull String addObject(@NotNull @NotNull PrismObject<T> object, @Nullable @Nullable RepoAddOptions options, @NotNull @NotNull OperationResult parentResult) throws ObjectAlreadyExistsException, SchemaException
Description copied from interface:RepositoryService
Add new object. The OID provided in the input message may be empty. In that case the OID will be assigned by the implementation of this method and it will be provided as return value. This operation should fail if such object already exists (if object with the provided OID already exists). Overwrite is possible ifRepoAddOptions.isOverwrite()
is true, but only for the object of the same type. The operation may fail if provided OID is in an unusable format for the storage. Generating own OIDs and providing them to this method is not recommended for normal operation. Should be atomic. Should not allow creation of two objects with the same OID (even if created in parallel). The operation may fail if the object to be created does not conform to the underlying schema of the storage system or the schema enforced by the implementation. Note: no need for explicit type parameter here. The object parameter contains the information.- Specified by:
addObject
in interfaceRepositoryService
- Parameters:
object
- object to createparentResult
- parent OperationResult (in/out)- Returns:
- OID assigned to the created object
- Throws:
ObjectAlreadyExistsException
- object with specified identifiers already exists, cannot addSchemaException
- error dealing with storage schema, e.g. schema violation
-
modifyObject
@NotNull public <T extends ObjectType> @NotNull ModifyObjectResult<T> modifyObject(@NotNull @NotNull Class<T> type, @NotNull @NotNull String oid, @NotNull @NotNull Collection<? extends ItemDelta<?,?>> modifications, @NotNull @NotNull OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
Description copied from interface:RepositoryService
Modifies object using relative change description.
Must fail if user with provided OID does not exist. Must fail if any of the described changes cannot be applied. Should be atomic.If two or more modify operations are executed in parallel, the operations should be merged. In case that the operations are in conflict (e.g. one operation adding a value and the other removing the same value), the result is not deterministic.
The operation may fail if the modified object does not conform to the underlying schema of the storage system or the schema enforced by the implementation.
TODO: optimistic locking
Note: the precondition is checked only if actual modification is going to take place (not e.g. if the list of modifications is empty).
- Specified by:
modifyObject
in interfaceRepositoryService
parentResult
- parent OperationResult (in/out)- Throws:
ObjectNotFoundException
- specified object does not existSchemaException
- resulting object would violate the schemaObjectAlreadyExistsException
- if resulting object would have name which already exists in another object of the same type
-
modifyObject
@NotNull public <T extends ObjectType> @NotNull ModifyObjectResult<T> modifyObject(@NotNull @NotNull Class<T> type, @NotNull @NotNull String oid, @NotNull @NotNull Collection<? extends ItemDelta<?,?>> modifications, @Nullable @Nullable RepoModifyOptions options, @NotNull @NotNull OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
- Specified by:
modifyObject
in interfaceRepositoryService
- Throws:
ObjectNotFoundException
SchemaException
ObjectAlreadyExistsException
-
modifyObject
@NotNull public <T extends ObjectType> @NotNull ModifyObjectResult<T> modifyObject(@NotNull @NotNull Class<T> type, @NotNull @NotNull String oid, @NotNull @NotNull Collection<? extends ItemDelta<?,?>> modifications, @Nullable @Nullable ModificationPrecondition<T> precondition, @Nullable @Nullable RepoModifyOptions options, @NotNull @NotNull OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, PreconditionViolationException
- Specified by:
modifyObject
in interfaceRepositoryService
- Throws:
ObjectNotFoundException
SchemaException
ObjectAlreadyExistsException
PreconditionViolationException
-
modifyObjectDynamically
@NotNull public <T extends ObjectType> @NotNull ModifyObjectResult<T> modifyObjectDynamically(@NotNull @NotNull Class<T> type, @NotNull @NotNull String oid, @Nullable @Nullable Collection<SelectorOptions<GetOperationOptions>> getOptions, @NotNull @NotNull RepositoryService.ModificationsSupplier<T> modificationsSupplier, @Nullable @Nullable RepoModifyOptions modifyOptions, @NotNull @NotNull OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
Description copied from interface:RepositoryService
Modifies an object dynamically. This means that the deltas are not provided by the caller, but computed by specified supplier, based on the current object state. This is to allow more complex atomic modifications with low overhead: Instead of calling getObject + compute deltas + modifyObject (with precondition that the object has not changed in the meanwhile) + repeating if the precondition fails, we now simply use modifyObjectDynamically that does all of this within a single DB transaction. BEWARE: Do not use unless really needed. Use modifyObject method instead.- Specified by:
modifyObjectDynamically
in interfaceRepositoryService
- Parameters:
type
- Type of the object to modifyoid
- OID of the object to modifygetOptions
- Options to use when getting the original object statemodificationsSupplier
- Supplier of the modifications (item deltas) to be applied on the objectmodifyOptions
- Options to be used when modifying the objectparentResult
- Operation result into which we put our result- Throws:
ObjectNotFoundException
SchemaException
ObjectAlreadyExistsException
-
deleteSimulatedProcessedObjects
public ModifyObjectResult<SimulationResultType> deleteSimulatedProcessedObjects(String oid, @Nullable @Nullable String transactionId, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
- Specified by:
deleteSimulatedProcessedObjects
in interfaceRepositoryService
- Throws:
SchemaException
ObjectNotFoundException
-
deleteObject
@NotNull public <T extends ObjectType> @NotNull DeleteObjectResult deleteObject(Class<T> type, String oid, OperationResult parentResult) throws ObjectNotFoundException
Description copied from interface:RepositoryService
Deletes object with specified OID.
Must fail if object with specified OID does not exist. Should be atomic.
- Specified by:
deleteObject
in interfaceRepositoryService
oid
- OID of object to deleteparentResult
- parent OperationResult (in/out)- Throws:
ObjectNotFoundException
- specified object does not exist
-
countObjects
public <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Returns the number of objects that match specified criteria.
If no search criteria specified, count of all objects of specified type is returned.
Should fail if object type is wrong. Should fail if unknown property is specified in the query.
- Specified by:
countObjects
in interfaceRepositoryService
query
- search queryparentResult
- parent OperationResult (in/out)- Returns:
- count of objects of specified type that match search criteria (subject to paging)
- Throws:
SchemaException
- unknown property used in search query
-
searchObjects
@NotNull public <T extends ObjectType> @NotNull SearchResultList<PrismObject<T>> searchObjects(@NotNull @NotNull Class<T> type, ObjectQuery query, @Nullable @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull @NotNull OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Search for objects in the repository.
If no search criteria specified, list of all objects of specified type is returned.
Searches through all object types. Returns a list of objects that match search criteria.
Returns empty list if object type is correct but there are no objects of that type. The ordering of the results is not significant and may be arbitrary unless sorting in the paging is used.
Should fail if object type is wrong. Should fail if unknown property is specified in the query.
- Specified by:
searchObjects
in interfaceRepositoryService
query
- search queryparentResult
- parent OperationResult (in/out)- Returns:
- all objects of specified type that match search criteria (subject to paging)
- Throws:
SchemaException
- unknown property used in search query
-
searchObjectsIterative
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, boolean strictlySequential, OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Search for objects in the repository in an iterative fashion. Searches through all object types. Calls a specified handler for each object found. If no search criteria specified, list of all objects of specified type is returned. Searches through all object types. Returns a list of objects that match search criteria. Returns empty list if object type is correct but there are no objects of that type. The ordering of the results is not significant and may be arbitrary unless sorting in the paging is used. Should fail if object type is wrong. Should fail if unknown property is specified in the query. [NOTE] ==== New repository uses single reliable iteration method similar to strictly sequential paging and supports custom ordering (currently only one). New repository ignores strictlySequential parameter and related get options completely. In old repository there are three iteration methods (see IterationMethodType): - SINGLE_TRANSACTION: Fetches objects in single DB transaction. Not supported for all DBMSs. - SIMPLE_PAGING: Uses the "simple paging" method: takes objects (e.g.) numbered 0 to 49, then 50 to 99, then 100 to 149, and so on. The disadvantage is that if the order of objects is changed during operation (e.g. by inserting/deleting some of them) then some objects can be processed multiple times, where others can be skipped. - STRICTLY_SEQUENTIAL_PAGING: Uses the "strictly sequential paging" method: sorting returned objects by OID. This is (almost) reliable in such a way that no object would be skipped. However, custom paging cannot be used in this mode. If GetOperationOptions.iterationMethod is specified, it is used without any further considerations. Otherwise, the repository configuration determines whether to use SINGLE_TRANSACTION or a paging. In the latter case, strictlySequential flag determines between SIMPLE_PAGING (if false) and STRICTLY_SEQUENTIAL_PAGING (if true). If explicit GetOperationOptions.iterationMethod is not provided, and paging is prescribed, and strictlySequential flag is true and client-provided paging conflicts with the paging used by the iteration method, a warning is issued, and iteration method is switched to SIMPLE_PAGING. ==== Sources of conflicts: - ordering is specified - offset is specified (limit is not a problem)- Specified by:
searchObjectsIterative
in interfaceRepositoryService
query
- search queryhandler
- result handlerstrictlySequential
- takes care not to skip any object nor to process objects more than onceparentResult
- parent OperationResult (in/out)- Returns:
- summary information about the search result
- Throws:
SchemaException
- unknown property used in search query
-
countContainers
public <T extends Containerable> int countContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
- Specified by:
countContainers
in interfaceRepositoryService
-
searchContainers
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Search for "sub-object" structures, i.e. containers.- Specified by:
searchContainers
in interfaceRepositoryService
- Throws:
SchemaException
-
countReferences
public int countReferences(@Nullable @Nullable ObjectQuery query, @Nullable @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull @NotNull OperationResult parentResult)
Description copied from interface:RepositoryService
Reference count - currently supporting roleMembershipRef and linkRef search. SeeRepositoryService.searchReferences(ObjectQuery, Collection, OperationResult)
for more details.- Specified by:
countReferences
in interfaceRepositoryService
- Parameters:
query
- mandatory query
-
executeCountReferences
public int executeCountReferences(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options) throws RepositoryException
- Throws:
RepositoryException
-
searchReferences
@NotNull public @NotNull SearchResultList<ObjectReferenceType> searchReferences(@NotNull @NotNull ObjectQuery query, @Nullable @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull @NotNull OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Reference search - currently supporting roleMembershipRef and linkRef search. This returns reference objects extracted from the actual object(s) that own them, but selection of which (and cardinality of the result list) is based on a repository search. Query must not be null and its filter must be: * either a OWNER-BY filter, * or AND filter containing exactly one OWNER-BY filter and optionally one or more REF filters with empty path (self).- Specified by:
searchReferences
in interfaceRepositoryService
- Parameters:
query
- mandatory query with exactly one root OWNER-BY and additional REF filters- Throws:
SchemaException
-
searchReferencesIterative
public SearchResultMetadata searchReferencesIterative(@Nullable @Nullable ObjectQuery query, @NotNull @NotNull ObjectHandler<ObjectReferenceType> handler, @Nullable @Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull @NotNull OperationResult parentResult) throws SchemaException
Description copied from interface:RepositoryService
Executes iterative reference search using the provided `handler` to process each references.- Specified by:
searchReferencesIterative
in interfaceRepositoryService
- Parameters:
query
- search queryhandler
- result handleroptions
- get options to use for the searchparentResult
- parent OperationResult (in/out)- Returns:
- summary information about the search result
- Throws:
SchemaException
-
isDescendant
public <O extends ObjectType> boolean isDescendant(PrismObject<O> object, String ancestorOrgOid)
Description copied from interface:RepositoryService
Returns `true` if the `object` is under the organization identified with `ancestorOrgOid`. The `object` can either be an Org or any other object in which case all the targets of its `parentOrgRefs` are tested. Examples (from the perspective of the first parameter): * User belonging to Org with `ancestorOrgOid` returns true. * Organization under Org with `ancestorOrgOid` returns true (in any depth). * User belonging to Org under another Org with `ancestorOrgOid` returns true (any depth). * Organization with `ancestorOrgOid` returns `false`, as it is not considered to be its own descendant.- Specified by:
isDescendant
in interfaceRepositoryService
- Parameters:
object
- object of any type tested to belong under Org with `ancestorOrgOid`ancestorOrgOid
- identifier of ancestor organization
-
isAncestor
public <O extends ObjectType> boolean isAncestor(PrismObject<O> object, String descendantOrgOid)
Description copied from interface:RepositoryService
Returns `true` if the `object` is above organization identified with `descendantOrgOid`. Despite type parameter, only `PrismObject` can return `true`. Examples (from the perspective of the first parameter): * Any other type than `Org` used for `object` returns `false`. * Organization being a parent of another organization with `descendantOrgOid` returns `true`. This means that Organization with `descendantOrgOid` has `parentOrgRef` to `object`. * Organization higher in the organization hierarchy than Org with `descendantOrgOid` returns `true`, for any number of levels between them as long as it's possible to traverse from Org identified by `descendantOrgOid` to `object` using any number of `parentOrgRefs`. * Organization with `descendantOrgOid` returns `false`, as it is not considered to be its own ancestor. - Specified by:
isAncestor
in interfaceRepositoryService
- Parameters:
object
- potential ancestor organizationdescendantOrgOid
- identifier of potential descendant organization
-
advanceSequence
public long advanceSequence(String oid, OperationResult parentResult) throws ObjectNotFoundException
Description copied from interface:RepositoryService
This operation is guaranteed to be atomic. If two threads or even two nodes request a value from the same sequence at the same time then different values will be returned.- Specified by:
advanceSequence
in interfaceRepositoryService
- Parameters:
oid
- sequence OIDparentResult
- Operation result- Returns:
- next unallocated counter value
- Throws:
ObjectNotFoundException
- the sequence does not exist
-
returnUnusedValuesToSequence
public void returnUnusedValuesToSequence(String oid, Collection<Long> unusedValues, OperationResult parentResult) throws ObjectNotFoundException
Description copied from interface:RepositoryService
The sequence may ignore the values, e.g. if value re-use is disabled or when the list of unused values is full. In such a case the values will be ignored silently and no error is indicated.- Specified by:
returnUnusedValuesToSequence
in interfaceRepositoryService
- Parameters:
oid
- sequence OIDunusedValues
- values to returnparentResult
- Operation result- Throws:
ObjectNotFoundException
-
getRepositoryType
@NotNull public @NotNull String getRepositoryType()
Description copied from interface:RepositoryService
Returns short type identifier of the repository implementation. This should be the same asRepositoryDiag.getImplementationShortName()
.- Specified by:
getRepositoryType
in interfaceRepositoryService
-
repositorySelfTest
public void repositorySelfTest(OperationResult parentResult)
Description copied from interface:RepositoryService
Runs a short, non-destructive repository self test. This methods should never throw a (checked) exception. All the results should be recorded under the provided result structure (including fatal errors).This should implement ONLY self-tests that are IMPLEMENTATION-SPECIFIC. It must not implement self-tests that are generic and applies to all repository implementations. Such self-tests must be implemented in higher layers.
If the repository has no self-tests then the method should return immediately without changing the result structure. It must not throw an exception in this case.
- Specified by:
repositorySelfTest
in interfaceRepositoryService
-
testOrgClosureConsistency
public void testOrgClosureConsistency(boolean repairIfNecessary, OperationResult parentResult)
Description copied from interface:RepositoryService
Checks a closure for consistency, repairing any problems found. This methods should never throw a (checked) exception. All the results should be in the returned result structure (including fatal errors).The current implementation expects closure to be of reasonable size - so it could be fetched into main memory as well as recomputed online (perhaps up to ~250K entries). In future, this method will be reimplemented.
BEWARE, this method locks out the M_ORG_CLOSURE table, so org-related operations would wait until it completes.
TODO this method is SQL service specific; it should be generalized/fixed somehow.
- Specified by:
testOrgClosureConsistency
in interfaceRepositoryService
-
executeQueryDiagnostics
public RepositoryQueryDiagResponse executeQueryDiagnostics(RepositoryQueryDiagRequest request, OperationResult parentResult)
Description copied from interface:RepositoryService
A bit of hack - execute arbitrary query, e.g. hibernate query in case of SQL repository. Use with all the care!- Specified by:
executeQueryDiagnostics
in interfaceRepositoryService
- Parameters:
request
- Diagnostics requestparentResult
- Operation result- Returns:
- diagnostics response
-
selectorMatches
public <O extends ObjectType> boolean selectorMatches(ObjectSelectorType objectSelector, PrismObject<O> object, boolean fullInformationAvailable, ObjectFilterExpressionEvaluator filterEvaluator, Trace logger, String logMessagePrefix) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException
-
applyFullTextSearchConfiguration
public void applyFullTextSearchConfiguration(FullTextSearchConfigurationType fullTextSearch)
- Specified by:
applyFullTextSearchConfiguration
in interfaceRepositoryService
-
getFullTextSearchConfiguration
public FullTextSearchConfigurationType getFullTextSearchConfiguration()
- Specified by:
getFullTextSearchConfiguration
in interfaceRepositoryService
-
postInit
public void postInit(OperationResult parentResult) throws SchemaException
- Specified by:
postInit
in interfaceRepositoryService
- Throws:
SchemaException
-
createAndRegisterConflictWatcher
public ConflictWatcher createAndRegisterConflictWatcher(@NotNull @NotNull String oid)
- Specified by:
createAndRegisterConflictWatcher
in interfaceRepositoryService
-
unregisterConflictWatcher
public void unregisterConflictWatcher(ConflictWatcher watcher)
- Specified by:
unregisterConflictWatcher
in interfaceRepositoryService
-
hasConflict
public boolean hasConflict(ConflictWatcher watcher, OperationResult parentResult)
- Specified by:
hasConflict
in interfaceRepositoryService
-
addDiagnosticInformation
public <T extends ObjectType> void addDiagnosticInformation(Class<T> type, String oid, DiagnosticInformationType information, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
Description copied from interface:RepositoryService
Adds a diagnostic information, honoring cleanup rules (deleting obsolete records).- Specified by:
addDiagnosticInformation
in interfaceRepositoryService
- Throws:
ObjectNotFoundException
SchemaException
ObjectAlreadyExistsException
-
supports
public boolean supports(@NotNull @NotNull Class<? extends ObjectType> type)
Description copied from interface:RepositoryService
Returns `true` if the given object type is supported.- Specified by:
supports
in interfaceRepositoryService
-
-