Skip to content

Commit de67d71

Browse files
committed
Address few issues in the code.
**What** - Add JavaDoc to one of the classes to make it more clear what it does. - Fix potential NPE. - Use item factory to create prism reference value instead of direct constructor. **Why** The item factory is used to not rely on implementation details of the prism objects (in a broad sense not the `PrismObject` directly). **Task**: 11112
1 parent 7076ef0 commit de67d71

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/correlation/ResourceCorrelationDefinitionProvider.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,31 @@
77

88
package com.evolveum.midpoint.model.impl.correlation;
99

10+
import java.util.Objects;
1011
import java.util.Optional;
1112

1213
import com.evolveum.midpoint.model.api.correlation.CorrelationDefinitionProvider;
1314
import com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition;
1415
import com.evolveum.midpoint.schema.processor.ResourceObjectTypeIdentification;
1516
import com.evolveum.midpoint.schema.util.CorrelatorsDefinitionUtil;
1617
import com.evolveum.midpoint.schema.util.Resource;
18+
import com.evolveum.midpoint.schema.util.ShadowUtil;
1719
import com.evolveum.midpoint.util.exception.ConfigurationException;
1820
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
1921
import com.evolveum.midpoint.util.exception.SchemaException;
2022
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
2123

24+
/**
25+
* Provides correlation definition for a specific resource object type.
26+
*
27+
* This implementation of {@link CorrelationDefinitionProvider} resolves the correlation definition
28+
* by merging information from two sources:
29+
*
30+
* . The resource object type definition from the complete schema (including short - attribute bound - form).
31+
* . The object synchronization configuration from the resource's synchronization settings
32+
*
33+
* @see CorrelationDefinitionProvider
34+
*/
2235
public class ResourceCorrelationDefinitionProvider implements CorrelationDefinitionProvider {
2336
private final ResourceType resource;
2437
private final ResourceObjectTypeIdentification objectTypeId;
@@ -46,8 +59,9 @@ public CorrelationDefinitionType get() throws SchemaException, ObjectNotFoundExc
4659
}
4760

4861
private boolean matchKindAndIntent(ObjectSynchronizationType synchronizationType) {
49-
return this.objectTypeId.getKind().equals(synchronizationType.getKind())
50-
&& this.objectTypeId.getIntent().equals(synchronizationType.getIntent());
62+
return Objects.equals(this.objectTypeId.getKind(), ShadowUtil.resolveDefault(synchronizationType.getKind()))
63+
&& Objects.equals(this.objectTypeId.getIntent(),
64+
ShadowUtil.resolveDefault(synchronizationType.getIntent()));
5165
}
5266

5367
}

model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/mappings/ShadowWithOwner.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
2-
* Copyright (c) 2025 Evolveum and contributors
3-
*
4-
* Licenced under the EUPL-1.2 or later.
2+
* Copyright (c) 2026 Evolveum and contributors
53
*
4+
* Licensed under the EUPL-1.2 or later.
65
*
76
*/
87

model/smart-impl/src/test/java/com/evolveum/midpoint/smart/impl/TestMappingsSuggestionOperation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.evolveum.midpoint.model.test.CommonInitialObjects;
55
import com.evolveum.midpoint.model.test.smart.MockServiceClientImpl;
66
import com.evolveum.midpoint.prism.PrismContext;
7-
import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl;
7+
import com.evolveum.midpoint.prism.PrismReferenceValue;
88
import com.evolveum.midpoint.prism.path.ItemPath;
99
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
1010
import com.evolveum.midpoint.schema.processor.ResourceObjectTypeIdentification;
@@ -116,10 +116,12 @@ private void correlateAccount(TestObject<UserType> user, Task task, OperationRes
116116
.withDefaultAccountType()
117117
.withNameValue(user.getNameOrig())
118118
.build().findRequired(task, result);
119+
final PrismReferenceValue userReference = PrismContext.get().itemFactory().createReferenceValue(user.oid,
120+
UserType.COMPLEX_TYPE);
119121
executeChanges(
120122
PrismContext.get().deltaFor(ShadowType.class)
121123
.item(ShadowType.F_CORRELATION, ShadowCorrelationStateType.F_RESULTING_OWNER)
122-
.add(new PrismReferenceValueImpl(user.oid, UserType.COMPLEX_TYPE))
124+
.add(userReference)
123125
.asObjectDelta(shadow.getOid()),
124126
null, task, result);
125127
}

0 commit comments

Comments
 (0)