Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 16, 2019
2 parents 6feb890 + 383c097 commit bb42c7b
Show file tree
Hide file tree
Showing 35 changed files with 407 additions and 230 deletions.
Expand Up @@ -27,7 +27,7 @@ public class ParameterizedEquivalenceStrategy implements EquivalenceStrategy {

/**
* The (almost) highest level of recognition. Useful e.g. for comparing values for the purpose of XML editing.
* Still, ignores e.g. definitions, parent objects, immutability flag, etc.
* Still, ignores e.g. definitions, parent objects, origin, immutability flag, etc.
*
* Corresponds to pre-4.0 flags ignoreMetadata = false, literal = true.
*/
Expand All @@ -39,7 +39,7 @@ public class ParameterizedEquivalenceStrategy implements EquivalenceStrategy {
*
* Currently this is the default for equals/hashCode.
*
* Corresponds to pre-4.0 flags ignoreMetadata = false, literal = false.
* Roughly corresponds to pre-4.0 flags ignoreMetadata = false, literal = false.
*/
public static final ParameterizedEquivalenceStrategy NOT_LITERAL;

Expand Down Expand Up @@ -101,7 +101,7 @@ public class ParameterizedEquivalenceStrategy implements EquivalenceStrategy {
LITERAL.consideringOperationalData = true;
LITERAL.consideringContainerIds = true;
LITERAL.consideringDifferentContainerIds = true;
LITERAL.consideringValueOrigin = true;
LITERAL.consideringValueOrigin = false;
LITERAL.consideringReferenceFilters = true;
LITERAL.compareElementNames = true;
putIntoNiceNames(LITERAL, "LITERAL");
Expand All @@ -111,7 +111,7 @@ public class ParameterizedEquivalenceStrategy implements EquivalenceStrategy {
NOT_LITERAL.consideringOperationalData = true;
NOT_LITERAL.consideringContainerIds = true;
NOT_LITERAL.consideringDifferentContainerIds = true;
NOT_LITERAL.consideringValueOrigin = true;
NOT_LITERAL.consideringValueOrigin = false;
NOT_LITERAL.consideringReferenceFilters = true;
NOT_LITERAL.compareElementNames = true;
putIntoNiceNames(NOT_LITERAL, "NOT_LITERAL");
Expand Down
Expand Up @@ -29,7 +29,7 @@
"plus",
"minus"
})
public class DeltaSetTripleType implements Serializable, JaxbVisitable {
public class DeltaSetTripleType implements Serializable, JaxbVisitable, Cloneable {

@XmlElement
@Raw
Expand Down
Expand Up @@ -116,7 +116,7 @@ public boolean equals(Object o) {

// TODO consider the strategy
@Override
public int hashCode(ParameterizedEquivalenceStrategy strategy) {
public int hashCode(@NotNull ParameterizedEquivalenceStrategy strategy) {
return Objects.hash(super.hashCode(strategy), oid);
}

Expand Down
Expand Up @@ -153,6 +153,12 @@ public class OperationResult implements Serializable, DebugDumpable, ShortDumpab
private boolean collectingLogEntries; // NOT SERIALIZED
private boolean startedLoggingOverride; // NOT SERIALIZED

/**
* After a trace rooted at this operation result is stored, the dictionary that was extracted is stored here.
* It is necessary to correctly interpret traces in this result and its subresults.
*/
private TraceDictionaryType extractedDictionary; // NOT SERIALIZED

private final List<TraceType> traces = new ArrayList<>();

// Caller can specify the reason of the operation invocation.
Expand Down Expand Up @@ -2414,4 +2420,12 @@ public void setCallerReason(String callerReason) {
public List<LogSegmentType> getLogSegments() {
return logSegments;
}

public TraceDictionaryType getExtractedDictionary() {
return extractedDictionary;
}

public void setExtractedDictionary(TraceDictionaryType extractedDictionary) {
this.extractedDictionary = extractedDictionary;
}
}
Expand Up @@ -2186,6 +2186,16 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="identifier" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Identifier of the dictionary. Used when multiple dictionaries are to be merged.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="entry" type="tns:TraceDictionaryEntryType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -2210,13 +2220,20 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="identifier" type="xsd:long" minOccurs="0">
<xsd:element name="identifier" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Entry identifier.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="originDictionaryId" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Identifier of the dictionary in which this entry was originally created.
</xsd:documentation>
<xsd:appinfo>
<a:composite>true</a:composite>
<a:since>4.0.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -236,7 +236,7 @@ public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task
} finally {
recordTraceAtEnd(context, trace, result);
if (tracingRequested) {
tracer.storeTrace(task, result);
tracer.storeTrace(task, result, parentResult);
TracingAppender.terminateCollecting(); // todo reconsider
LevelOverrideTurboFilter.cancelLoggingOverride(); // todo reconsider
}
Expand Down
Expand Up @@ -659,9 +659,9 @@ private <F extends FocusType> void loadLinkRefsFromFocus(LensContext<F> context,
}
LensProjectionContext existingAccountContext = findAccountContext(oid, context);

if (!canBeLoaded(context, existingAccountContext)) {
continue;
}
// if (!canBeLoaded(context, existingAccountContext)) {
// continue;
// }

if (existingAccountContext != null) {
// TODO: do we need to reload the account inside here? yes we need
Expand Down Expand Up @@ -993,15 +993,15 @@ private <F extends ObjectType> void loadProjectionContextsSync(LensContext<F> co
}
}

private <F extends ObjectType> boolean canBeLoaded(LensContext<F> context, LensProjectionContext projCtx){
if (QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_DISCOVERY).equals(context.getChannel()) && projCtx == null && ModelExecuteOptions.isLimitPropagation(context.getOptions())) {
// avoid to create projection context if the channel which
// triggered this operation is discovery..we need only
// projection context of discovered shadow
return false;
}
return true;
}
// private <F extends ObjectType> boolean canBeLoaded(LensContext<F> context, LensProjectionContext projCtx){
// if (QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_DISCOVERY).equals(context.getChannel()) && projCtx == null && ModelExecuteOptions.isLimitPropagation(context.getOptions())) {
// // avoid to create projection context if the channel which
// // triggered this operation is discovery..we need only
// // projection context of discovered shadow
// return false;
// }
// return true;
// }

private <F extends FocusType> LensProjectionContext getOrCreateAccountContext(LensContext<F> context,
PrismObject<ShadowType> projection, Task task, OperationResult result) throws ObjectNotFoundException,
Expand Down Expand Up @@ -1046,7 +1046,7 @@ private <F extends FocusType> LensProjectionContext getOrCreateAccountContext(Le
LOGGER.trace("Projection {} already exists in context\nExisting:\n{}\nNew:\n{}", rsd,
existingShadow.debugDump(1), newShadow.debugDump(1));
}
if (!ShadowUtil.isDead(existingShadow.asObjectable())) {
if (!ShadowUtil.isDead(newShadow.asObjectable())) {
throw new PolicyViolationException("Projection "+rsd+" already exists in context (existing "+existingShadow+", new "+projection);
}
// Dead shadow. This is somehow expected, fix it and we can go on
Expand Down
Expand Up @@ -56,7 +56,7 @@ public class SynchronizationContext<F extends FocusType> implements DebugDumpabl
private PrismObject<ShadowType> currentShadow;
private PrismObject<ResourceType> resource;
private PrismObject<SystemConfigurationType> systemConfiguration;
private String chanel;
private String channel;
private ExpressionProfile expressionProfile;

private Task task;
Expand All @@ -81,11 +81,11 @@ public class SynchronizationContext<F extends FocusType> implements DebugDumpabl

private PrismContext prismContext;

public SynchronizationContext(PrismObject<ShadowType> applicableShadow, PrismObject<ShadowType> currentShadow, PrismObject<ResourceType> resource, String chanel, PrismContext prismContext, Task task, OperationResult result) {
public SynchronizationContext(PrismObject<ShadowType> applicableShadow, PrismObject<ShadowType> currentShadow, PrismObject<ResourceType> resource, String channel, PrismContext prismContext, Task task, OperationResult result) {
this.applicableShadow = applicableShadow;
this.currentShadow = currentShadow;
this.resource = resource;
this.chanel = chanel;
this.channel = channel;
this.task = task;
this.result = result;
this.prismContext = prismContext;
Expand Down Expand Up @@ -125,7 +125,7 @@ public boolean isSatisfyTaskConstraints() throws SchemaException {
return isApplicable;
}

//TODO multi-threded tasks?
//TODO multi-threaded tasks?
private <T> T getTaskPropertyValue(QName propertyName) {
PrismProperty<T> prop = task.getExtensionPropertyOrClone(ItemName.fromQName(propertyName));
if (prop == null || prop.isEmpty()) {
Expand Down Expand Up @@ -197,19 +197,18 @@ public SynchronizationReactionType getReaction() throws ConfigurationException {
throw new ConfigurationException("No situation defined for a reaction in " + resource);
}
if (reactionSituation.equals(situation)) {
if (syncReaction.getChannel() != null && !syncReaction.getChannel().isEmpty()) {
if (syncReaction.getChannel().isEmpty()) {
defaultReaction = syncReaction;
} else {
if (syncReaction.getChannel().contains("") || syncReaction.getChannel().contains(null)) {
defaultReaction = syncReaction;
}
if (syncReaction.getChannel().contains(chanel)) {
if (syncReaction.getChannel().contains(channel)) {
reaction = syncReaction;
return reaction;
} else {
LOGGER.trace("Skipping reaction {} because the channel does not match {}", reaction, chanel);
continue;
LOGGER.trace("Skipping reaction {} because the channel does not match {}", reaction, channel);
}
} else {
defaultReaction = syncReaction;
}
}
}
Expand Down Expand Up @@ -243,8 +242,8 @@ public Boolean isDoReconciliation() {
}

public Boolean isLimitPropagation() {
if (StringUtils.isNotBlank(chanel)) {
QName channelQName = QNameUtil.uriToQName(chanel);
if (StringUtils.isNotBlank(channel)) {
QName channelQName = QNameUtil.uriToQName(channel);
// Discovery channel is used when compensating some inconsistent
// state. Therefore we do not want to propagate changes to other
// resources. We only want to resolve the problem and continue in
Expand Down Expand Up @@ -344,8 +343,8 @@ public void setSituation(SynchronizationSituationType situation) {
public PrismObject<SystemConfigurationType> getSystemConfiguration() {
return systemConfiguration;
}
public String getChanel() {
return chanel;
public String getChannel() {
return channel;
}
public void setApplicableShadow(PrismObject<ShadowType> applicableShadow) {
this.applicableShadow = applicableShadow;
Expand All @@ -359,8 +358,8 @@ public void setResource(PrismObject<ResourceType> resource) {
public void setSystemConfiguration(PrismObject<SystemConfigurationType> systemConfiguration) {
this.systemConfiguration = systemConfiguration;
}
public void setChanel(String chanel) {
this.chanel = chanel;
public void setChannel(String channel) {
this.channel = channel;
}

// public SynchronizationReactionType getReaction() {
Expand Down Expand Up @@ -448,7 +447,7 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelLn(sb, "currentShadow", currentShadow, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "resource", resource, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "systemConfiguration", systemConfiguration, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "chanel", chanel, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "channel", channel, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "expressionProfile", expressionProfile, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "objectSynchronization", objectSynchronization, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "focusClass", focusClass, indent + 1);
Expand Down
Expand Up @@ -322,7 +322,7 @@ private <F extends FocusType> ObjectSynchronizationDiscriminatorType evaluateSyn
String desc = "synchronization divider type ";
ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(null, syncCtx.getApplicableShadow(), null,
syncCtx.getResource(), syncCtx.getSystemConfiguration(), null, syncCtx.getPrismContext());
variables.put(ExpressionConstants.VAR_CHANNEL, syncCtx.getChanel(), String.class);
variables.put(ExpressionConstants.VAR_CHANNEL, syncCtx.getChannel(), String.class);
try {
ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(task, result));
//noinspection unchecked
Expand Down Expand Up @@ -380,7 +380,7 @@ private <F extends FocusType> boolean checkSynchronizationPolicy(Synchronization
if (!syncCtx.hasApplicablePolicy()) {
String message = "SYNCHRONIZATION no matching policy for " + syncCtx.getApplicableShadow() + " ("
+ syncCtx.getApplicableShadow().asObjectable().getObjectClass() + ") " + " on " + syncCtx.getResource()
+ ", ignoring change from channel " + syncCtx.getChanel();
+ ", ignoring change from channel " + syncCtx.getChannel();
LOGGER.debug(message);
List<PropertyDelta<?>> modifications = createShadowIntentAndSynchronizationTimestampDelta(syncCtx, false);
executeShadowModifications(syncCtx.getApplicableShadow(), modifications, task, subResult);
Expand All @@ -392,7 +392,7 @@ private <F extends FocusType> boolean checkSynchronizationPolicy(Synchronization

if (!syncCtx.isSynchronizationEnabled()) {
String message = "SYNCHRONIZATION is not enabled for " + syncCtx.getResource()
+ " ignoring change from channel " + syncCtx.getChanel();
+ " ignoring change from channel " + syncCtx.getChannel();
LOGGER.debug(message);
List<PropertyDelta<?>> modifications = createShadowIntentAndSynchronizationTimestampDelta(syncCtx, true);
executeShadowModifications(syncCtx.getApplicableShadow(), modifications, task, subResult);
Expand Down
Expand Up @@ -91,13 +91,14 @@ public void completeWorkItem(WorkItemId workItemId, @NotNull AbstractWorkItemOut
throw e;
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result);
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}

private void storeTraceIfRequested(boolean tracingRequested, Task task, OperationResult result) {
private void storeTraceIfRequested(boolean tracingRequested, Task task, OperationResult result,
OperationResult parentResult) {
if (tracingRequested) {
tracer.storeTrace(task, result);
tracer.storeTrace(task, result, parentResult);
TracingAppender.terminateCollecting(); // todo reconsider
LevelOverrideTurboFilter.cancelLoggingOverride(); // todo reconsider
}
Expand Down Expand Up @@ -131,7 +132,7 @@ public void completeWorkItems(CompleteWorkItemsRequest request, Task task, Opera
throw e;
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result);
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}

Expand All @@ -153,7 +154,7 @@ public void claimWorkItem(WorkItemId workItemId, Task task, OperationResult pare
throw e;
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result);
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}

Expand All @@ -175,7 +176,7 @@ public void releaseWorkItem(WorkItemId workItemId, Task task, OperationResult pa
throw e;
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result);
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}

Expand Down Expand Up @@ -215,7 +216,7 @@ public void delegateWorkItem(@NotNull WorkItemId workItemId, @NotNull WorkItemDe
throw new IllegalStateException(e);
} finally {
result.computeStatusIfUnknown();
storeTraceIfRequested(tracingRequested, task, result);
storeTraceIfRequested(tracingRequested, task, result, parentResult);
}
}

Expand Down
Expand Up @@ -1212,7 +1212,7 @@ private void previewAssignRolesToJack(String TEST_NAME, boolean immediate, boole
result.computeStatus();
//noinspection ConstantConditions
if (TRACE) {
tracer.storeTrace(task, result);
tracer.storeTrace(task, result, null);
}

// we do not assert success here, because there are (intentional) exceptions in some of the expressions
Expand Down

0 comments on commit bb42c7b

Please sign in to comment.