Skip to content

Commit

Permalink
getting default object template for the specified object type
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 14, 2023
1 parent 71778be commit eaed27c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,19 @@ private ArchetypePolicyType computePolicyForArchetype(ArchetypeType archetype, O
}
}

/** Determines default object policy configuration for the specified object type */
public <O extends ObjectType> ObjectPolicyConfigurationType determineObjectPolicyConfiguration(
@NotNull Class<O> objectClass, OperationResult result) throws SchemaException, ConfigurationException {
SystemConfigurationType systemConfiguration = systemObjectCache.getSystemConfigurationBean(result);
if (systemConfiguration == null) {
return null;
}
return determineObjectPolicyConfiguration(
objectClass,
null,
systemConfiguration);
}

/** Determines legacy object policy configuration (from subtypes) */
public ObjectPolicyConfigurationType determineObjectPolicyConfiguration(
ObjectType object, OperationResult result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public boolean checkCandidateOwner(
synchronizationPolicy.getObjectTypeDefinition(),
synchronizationPolicy,
preFocus,
determineObjectTemplate(synchronizationPolicy.getArchetypeOid(), preFocus, task, result),
determineObjectTemplate(synchronizationPolicy.getArchetypeOid(), preFocus, null, task, result),
asObjectable(systemObjectCache.getSystemConfiguration(result)),
new CorrelatorDiscriminator(null, CorrelationUseType.SYNCHRONIZATION),
task);
Expand Down Expand Up @@ -359,7 +359,7 @@ void resolve(
policy.getObjectTypeDefinition(),
policy,
preFocus,
determineObjectTemplate(policy.getArchetypeOid(), preFocus, task, result),
determineObjectTemplate(policy.getArchetypeOid(), preFocus, null, task, result),
asObjectable(systemObjectCache.getSystemConfiguration(result)),
new CorrelatorDiscriminator(null, CorrelationUseType.SYNCHRONIZATION),
task);
Expand All @@ -382,7 +382,7 @@ void resolve(
preFocus,
archetypeOid,
candidateOids,
determineObjectTemplate(archetypeOid, preFocus, task, result),
determineObjectTemplate(archetypeOid, preFocus, null, task, result),
systemObjectCache.getSystemConfigurationBean(result),
discriminator,
task);
Expand Down Expand Up @@ -436,17 +436,20 @@ public void clearCorrelationState(@NotNull String shadowOid, @NotNull OperationR
* @param explicitArchetypeOid If present, it overrides the archetype OID from the pre-focus (that may or may not be there).
* Used for shadow correlation when specified by the synchronization policy.
*/
public ObjectTemplateType determineObjectTemplate(
public <F extends FocusType> ObjectTemplateType determineObjectTemplate(
@Nullable String explicitArchetypeOid,
@Nullable FocusType preFocus,
@Nullable Class<F> objectType,
@NotNull Task task,
@NotNull OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException {
ArchetypePolicyType policy;
ArchetypePolicyType policy = null;
if (explicitArchetypeOid != null) {
policy = beans.archetypeManager.getPolicyForArchetype(explicitArchetypeOid, result);
} else {
} else if (preFocus != null) {
policy = beans.archetypeManager.determineArchetypePolicy(preFocus, result);
} else if (objectType != null) {
policy =beans.archetypeManager.determineObjectPolicyConfiguration(objectType, result);
}
LOGGER.trace("Determined archetype policy: {} (explicit archetype OID is: {})", policy, explicitArchetypeOid);
String oid = policy != null ? getOid(policy.getObjectTemplateRef()) : null;
Expand Down Expand Up @@ -526,7 +529,7 @@ public PathSet determineCorrelatorConfiguration(
// from the default object template. should determineObjectTemplate method cope with this situation?
// and while getting default object template do we consider UserType to be default?

ObjectTemplateType template = determineObjectTemplate(archetypeOid, null, task, result);
ObjectTemplateType template = determineObjectTemplate(archetypeOid, null, UserType.class, task, result);
//TODO //@NotNull correlation definition bean. probably shoudl be changed
CorrelatorContext<?> ctx = CorrelatorContextCreator.createRootContext(
new CorrelationDefinitionType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ private <F extends FocusType> void setObjectTemplateForCorrelation(
beans.correlationServiceImpl.determineObjectTemplate(
syncCtx.getArchetypeOid(),
syncCtx.getPreFocus(),
null,
task,
result));
}
Expand Down

0 comments on commit eaed27c

Please sign in to comment.