Skip to content

Commit

Permalink
Fix/workaround for MID-3598: After incorrect system configuration rep…
Browse files Browse the repository at this point in the history
…ository objects fail to load
  • Loading branch information
mederly committed Dec 12, 2016
1 parent 321c090 commit a2833ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Expand Up @@ -23,6 +23,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.schema.internals.InternalsConfig;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang.Validate;

Expand Down Expand Up @@ -349,7 +350,9 @@ public static Collection<ItemDeltaType> toItemDeltaTypes(ItemDelta delta) throws
}

public static Collection<ItemDeltaType> toItemDeltaTypes(ItemDelta delta, DeltaConversionOptions options) throws SchemaException {
delta.checkConsistence();
if (InternalsConfig.consistencyChecks) {
delta.checkConsistence();
}
if (!delta.isEmpty() && delta.getPrismContext() == null) {
throw new IllegalStateException("Non-empty ItemDelta with no prismContext cannot be converted to ItemDeltaType.");
}
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.evolveum.midpoint.repo.cache.RepositoryCache;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.internals.InternalsConfig;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultRunner;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
Expand Down Expand Up @@ -409,15 +410,14 @@ public Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(fin
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("MODEL.executeChanges(\n deltas:\n{}\n options:{}", DebugUtil.debugDump(deltas, 2), options);
}

OperationResultRunner.run(result, new Runnable() {
@Override
public void run() {
for(ObjectDelta<? extends ObjectType> delta: deltas) {

if (InternalsConfig.consistencyChecks) {
OperationResultRunner.run(result, () -> {
for (ObjectDelta<? extends ObjectType> delta : deltas) {
delta.checkConsistence();
}
}
});
});
}

RepositoryCache.enter();

Expand Down
Expand Up @@ -569,7 +569,9 @@ private <T extends ObjectType> void validateObject(PrismObject<T> object, GetOpe
// Tolerate some raw meat in that case.
tolerateRaw = true;
}
object.checkConsistence(true, !tolerateRaw, ConsistencyCheckScope.THOROUGH);
if (InternalsConfig.consistencyChecks) {
object.checkConsistence(true, !tolerateRaw, ConsistencyCheckScope.THOROUGH);
}
} catch (RuntimeException e) {
result.recordFatalError(e);
throw e;
Expand Down

0 comments on commit a2833ff

Please sign in to comment.