Class ArchetypeManager
- java.lang.Object
-
- com.evolveum.midpoint.model.common.archetypes.ArchetypeManager
-
- All Implemented Interfaces:
Cache
,CacheInvalidationListener
@Component public class ArchetypeManager extends Object implements Cache
Component that can efficiently determine archetypes for objects. It is backed by caches, therefore this is supposed to be a low-overhead service that can be used in many places. As a secondary responsibility, this class handles the resolution of object templates. [NOTE] ==== When resolving archetype references (i.e. obtaining archetype objects from references in object assignments and `archetypeRef` values, as well as when resolving super-archetypes), we currently handle dangling references (non-existing objects) by ignoring them. We just log the exception, and keep theOperationResultStatus.FATAL_ERROR
in the result tree - where the lower-level code put it. (It may or may not be available to the ultimate caller; depending on the overall operation result processing.) ====- Author:
- Radovan Semancik
-
-
Constructor Summary
Constructors Constructor Description ArchetypeManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Set<String>
determineArchetypeOids(@Nullable ObjectType object)
Determines all archetype OIDs (structural + auxiliary) for a given (static) object.<O extends ObjectType>
@NotNull Set<String>determineArchetypeOids(O before, O after)
Determines all archetype OIDs in the "dynamic" case where the object is changed during clockwork processing.ArchetypePolicyType
determineArchetypePolicy(@Nullable PrismObject<? extends ObjectType> object, OperationResult result)
A convenience variant ofdetermineArchetypePolicy(ObjectType, OperationResult)
.ArchetypePolicyType
determineArchetypePolicy(@Nullable ObjectType object, OperationResult result)
Determines the archetype policy for an object.ArchetypePolicyType
determineArchetypePolicy(Collection<ArchetypeType> allArchetypes, ObjectType object, OperationResult result)
Determines "complex" archetype policy; takes auxiliary archetypes, super archetypes, and even legacy (subtype) configuration into account.@NotNull List<ArchetypeType>
determineArchetypes(@Nullable ObjectType object, OperationResult result)
Determines all archetypes for a "static" object.<O extends ObjectType>
ExpressionProfiledetermineExpressionProfile(PrismObject<O> object, OperationResult result)
static <O extends ObjectType>
LifecycleStateModelTypedetermineLifecycleModel(PrismObject<O> object, PrismObject<SystemConfigurationType> systemConfiguration)
static <O extends ObjectType>
LifecycleStateModelTypedetermineLifecycleModel(PrismObject<O> object, SystemConfigurationType systemConfiguration)
static <O extends ObjectType>
ObjectPolicyConfigurationTypedetermineObjectPolicyConfiguration(Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfiguration)
ArchetypeType
determineStructuralArchetype(@Nullable AssignmentHolderType assignmentHolder, OperationResult result)
Determines the structural archetype for a "static" object.void
dumpContent()
@NotNull ArchetypeType
getArchetype(String oid, OperationResult result)
Gets an archetype by OID.@NotNull ObjectTemplateType
getExpandedObjectTemplate(@NotNull String oid, @NotNull TaskExecutionMode executionMode, @NotNull OperationResult result)
Returns the "expanded" object template, i.e.@Nullable ArchetypePolicyType
getPolicyForArchetype(@NotNull String archetypeOid, OperationResult result)
A convenience variant ofgetPolicyForArchetype(ArchetypeType, OperationResult)
.ArchetypePolicyType
getPolicyForArchetype(ArchetypeType archetype, OperationResult result)
Returns policy collected from this archetype and its super-archetypes.@NotNull Collection<SingleCacheStateInformationType>
getStateInformation()
void
invalidate(Class<?> type, String oid, CacheInvalidationContext context)
void
register()
List<ArchetypeType>
resolveArchetypeOids(Collection<String> oids, Object context, OperationResult result)
Resolves archetype OIDs to full objects.void
unregister()
-
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.Cache
getEventSpecifications, invalidate
-
-
-
-
Method Detail
-
register
@PostConstruct public void register()
-
unregister
@PreDestroy public void unregister()
-
getArchetype
@NotNull public @NotNull ArchetypeType getArchetype(String oid, OperationResult result) throws ObjectNotFoundException, SchemaException
Gets an archetype by OID. Assumes that caching ofArchetypeType
objects is enabled by global repository cache. (By default, it is - see `default-caching-profile.xml` in `infra/schema` resources.)
-
resolveArchetypeOids
public List<ArchetypeType> resolveArchetypeOids(Collection<String> oids, Object context, OperationResult result) throws SchemaException
Resolves archetype OIDs to full objects. See the class-level note about resolving dangling references.- Throws:
SchemaException
-
determineArchetypeOids
@NotNull public @NotNull Set<String> determineArchetypeOids(@Nullable @Nullable ObjectType object)
Determines all archetype OIDs (structural + auxiliary) for a given (static) object.
-
determineArchetypeOids
@NotNull public <O extends ObjectType> @NotNull Set<String> determineArchetypeOids(O before, O after)
Determines all archetype OIDs in the "dynamic" case where the object is changed during clockwork processing.- See Also:
determineArchetypeOids(ObjectType)
-
determineArchetypes
@NotNull public @NotNull List<ArchetypeType> determineArchetypes(@Nullable @Nullable ObjectType object, OperationResult result) throws SchemaException
Determines all archetypes for a "static" object. See the class-level note about resolving dangling references.- Throws:
SchemaException
-
determineStructuralArchetype
public ArchetypeType determineStructuralArchetype(@Nullable @Nullable AssignmentHolderType assignmentHolder, OperationResult result) throws SchemaException
Determines the structural archetype for a "static" object. (See the class-level note about resolving dangling references.)- Throws:
SchemaException
-
determineArchetypePolicy
public ArchetypePolicyType determineArchetypePolicy(@Nullable @Nullable ObjectType object, OperationResult result) throws SchemaException, ConfigurationException
Determines the archetype policy for an object. (See the class-level note about resolving dangling archetype references.)
-
determineArchetypePolicy
public ArchetypePolicyType determineArchetypePolicy(@Nullable @Nullable PrismObject<? extends ObjectType> object, OperationResult result) throws SchemaException, ConfigurationException
A convenience variant ofdetermineArchetypePolicy(ObjectType, OperationResult)
.
-
determineArchetypePolicy
public ArchetypePolicyType determineArchetypePolicy(Collection<ArchetypeType> allArchetypes, ObjectType object, OperationResult result) throws SchemaException, ConfigurationException
Determines "complex" archetype policy; takes auxiliary archetypes, super archetypes, and even legacy (subtype) configuration into account.
-
getPolicyForArchetype
@Nullable public @Nullable ArchetypePolicyType getPolicyForArchetype(@NotNull @NotNull String archetypeOid, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException
A convenience variant ofgetPolicyForArchetype(ArchetypeType, OperationResult)
.
-
getPolicyForArchetype
public ArchetypePolicyType getPolicyForArchetype(ArchetypeType archetype, OperationResult result) throws SchemaException, ConfigurationException
Returns policy collected from this archetype and its super-archetypes. Uses the policy cache.
-
determineObjectPolicyConfiguration
public static <O extends ObjectType> ObjectPolicyConfigurationType determineObjectPolicyConfiguration(Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfiguration) throws ConfigurationException
- Throws:
ConfigurationException
-
determineLifecycleModel
public static <O extends ObjectType> LifecycleStateModelType determineLifecycleModel(PrismObject<O> object, PrismObject<SystemConfigurationType> systemConfiguration) throws ConfigurationException
- Throws:
ConfigurationException
-
determineLifecycleModel
public static <O extends ObjectType> LifecycleStateModelType determineLifecycleModel(PrismObject<O> object, SystemConfigurationType systemConfiguration) throws ConfigurationException
- Throws:
ConfigurationException
-
determineExpressionProfile
public <O extends ObjectType> ExpressionProfile determineExpressionProfile(PrismObject<O> object, OperationResult result) throws SchemaException, ConfigurationException
-
invalidate
public void invalidate(Class<?> type, String oid, CacheInvalidationContext context)
- Specified by:
invalidate
in interfaceCache
-
getStateInformation
@NotNull public @NotNull Collection<SingleCacheStateInformationType> getStateInformation()
- Specified by:
getStateInformation
in interfaceCache
-
dumpContent
public void dumpContent()
- Specified by:
dumpContent
in interfaceCache
-
getExpandedObjectTemplate
@NotNull public @NotNull ObjectTemplateType getExpandedObjectTemplate(@NotNull @NotNull String oid, @NotNull @NotNull TaskExecutionMode executionMode, @NotNull @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException, ConfigurationException
Returns the "expanded" object template, i.e. the one with "include" instructions resolved. Note that the handling of dangling references is graceful just like in the case of archetypes, see the note in the class-level javadoc. However, if the `oid` parameter cannot be resolved, the respective exception is thrown.- Returns:
- Immutable expanded template
- Throws:
SchemaException
ObjectNotFoundException
ConfigurationException
-
-