Skip to content

Commit

Permalink
Fixing possible NPE.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 1, 2017
1 parent 1e0efa8 commit 17c553a
Showing 1 changed file with 7 additions and 10 deletions.
Expand Up @@ -20,7 +20,6 @@
import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.Visitor;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.IdItemPathSegment;
Expand Down Expand Up @@ -78,7 +77,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
Expand Down Expand Up @@ -397,7 +395,7 @@ private PrismObject<ShadowType> futurizeShadow(PrismObject<ShadowType> shadow,
PrismObject<ShadowType> resultShadow = shadow;
ShadowType resultShadowType = resultShadow.asObjectable();
List<PendingOperationType> sortedOperations = sortOperations(resultShadowType.getPendingOperation());
boolean resourceReadIsCachingOnly = resourceReadIsCahingOnly(resource);
boolean resourceReadIsCachingOnly = resourceReadIsCachingOnly(resource);
for (PendingOperationType pendingOperation: sortedOperations) {
OperationResultStatusType resultStatus = pendingOperation.getResultStatus();
if (resultStatus == OperationResultStatusType.FATAL_ERROR || resultStatus == OperationResultStatusType.NOT_APPLICABLE) {
Expand All @@ -416,7 +414,7 @@ private PrismObject<ShadowType> futurizeShadow(PrismObject<ShadowType> shadow,
ObjectDeltaType pendingDeltaType = pendingOperation.getDelta();
ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext);
if (pendingDelta.isAdd()) {
if (resultShadowType.isExists() == Boolean.FALSE) {
if (Boolean.FALSE.equals(resultShadowType.isExists())) {
resultShadow = pendingDelta.getObjectToAdd().clone();
resultShadow.setOid(shadow.getOid());
resultShadowType = resultShadow.asObjectable();
Expand All @@ -443,13 +441,12 @@ private PrismObject<ShadowType> futurizeShadow(PrismObject<ShadowType> shadow,
return resultShadow;
}

private boolean resourceReadIsCahingOnly(ResourceType resource) {
private boolean resourceReadIsCachingOnly(ResourceType resource) {
ReadCapabilityType readCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, ReadCapabilityType.class);
Boolean cachingOnly = readCapabilityType.isCachingOnly();
if (cachingOnly == Boolean.TRUE) {
return true;
if (readCapabilityType == null) {
return false; // TODO reconsider this
}
return false;
return Boolean.TRUE.equals(readCapabilityType.isCachingOnly());
}

private boolean canReturnCachedAfterNotFoundOnResource(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException {
Expand All @@ -468,7 +465,7 @@ private boolean canReturnCachedAfterNotFoundOnResource(Collection<SelectorOption
}

private boolean canReturnCached(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException {
if (resourceReadIsCahingOnly(resource)) {
if (resourceReadIsCachingOnly(resource)) {
return true;
}
PointInTimeType pit = GetOperationOptions.getPointInTimeType(SelectorOptions.findRootOptions(options));
Expand Down

0 comments on commit 17c553a

Please sign in to comment.