Skip to content

Commit

Permalink
Remove ShadowingHelper
Browse files Browse the repository at this point in the history
It was split into ShadowAcquisitionHelper and
ShadowedObjectConstructionHelper. These are more aligned
with the other components names.
  • Loading branch information
mederly committed Feb 15, 2021
1 parent fec1194 commit cc63488
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 90 deletions.
Expand Up @@ -125,10 +125,11 @@ private PrismObject<ShadowType> shadowResourceObject(ProvisioningContext estimat
OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException,
CommunicationException, ExpressionEvaluationException, EncryptionException, SecurityViolationException {

ShadowingHelper shadowingHelper = getAdoptionHelper();
ShadowManager shadowManager = getShadowManager();
ShadowAcquisitionHelper shadowAcquisitionHelper = ictx.localBeans.shadowAcquisitionHelper;
ShadowedObjectConstructionHelper shadowedObjectConstructionHelper = ictx.localBeans.shadowedObjectConstructionHelper;
ShadowManager shadowManager = ictx.localBeans.shadowManager;

PrismObject<ShadowType> repoShadow = shadowingHelper.acquireRepoShadow(estimatedShadowCtx, resourceObject, result);
PrismObject<ShadowType> repoShadow = shadowAcquisitionHelper.acquireRepoShadow(estimatedShadowCtx, resourceObject, result);

// This determines the definitions exactly. Now the repo shadow should have proper kind/intent
ProvisioningContext shadowCtx = ictx.localBeans.shadowCaretaker.applyAttributesDefinition(ictx.ctx, repoShadow);
Expand All @@ -137,15 +138,7 @@ private PrismObject<ShadowType> shadowResourceObject(ProvisioningContext estimat

// TODO do we want also to futurize the shadow like in getObject?

return shadowingHelper.constructShadowedObject(shadowCtx, updatedRepoShadow, resourceObject, result);
}

private ShadowManager getShadowManager() {
return ictx.localBeans.shadowManager;
}

private ShadowingHelper getAdoptionHelper() {
return ictx.localBeans.shadowingHelper;
return shadowedObjectConstructionHelper.constructShadowedObject(shadowCtx, updatedRepoShadow, resourceObject, result);
}

@Override
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -15,7 +15,8 @@
class LocalBeans {

@Autowired AccessChecker accessChecker;
@Autowired ShadowingHelper shadowingHelper;
@Autowired ShadowedObjectConstructionHelper shadowedObjectConstructionHelper;
@Autowired ShadowAcquisitionHelper shadowAcquisitionHelper;
@Autowired CommonHelper commonHelper;
@Autowired ClassificationHelper classificationHelper;
@Autowired
Expand Down
Expand Up @@ -29,7 +29,7 @@
*/
@Experimental
@Component
class ShadowingHelper {
class ShadowAcquisitionHelper {

@Autowired private CommonBeans commonBeans;

Expand Down Expand Up @@ -68,22 +68,4 @@ class ShadowingHelper {
return new ShadowAcquisition(ctx, primaryIdentifier, objectClass, resourceObjectSupplier, commonBeans)
.execute(result);
}

/**
* TODO improve the description
* TODO devise better name ... like constructAdoptedObject? dunno...
*
* Make sure that the repo shadow is complete, e.g. that all the mandatory fields
* are filled (e.g name, resourceRef, ...) Also transforms the shadow with
* respect to simulated capabilities. Also shadowRefs are added to associations.
*/
@NotNull PrismObject<ShadowType> constructShadowedObject(@NotNull ProvisioningContext ctx,
@NotNull PrismObject<ShadowType> repoShadow, @NotNull PrismObject<ShadowType> resourceObject,
@NotNull OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException,
SecurityViolationException, GenericConnectorException, ExpressionEvaluationException, EncryptionException {

return ShadowedObjectConstruction.create(ctx, repoShadow, resourceObject, commonBeans)
.construct(result);
}
}
Expand Up @@ -162,7 +162,7 @@ public void initializeInternal(Task task, OperationResult result)
markRepoShadowTombstone(result);
adoptedObject = constructAdoptedObjectForDeletion(result);
} else {
adoptedObject = constructAdoptedObject(result);
adoptedObject = constructShadowedObject(result);
}

shadowChangeDescription = createResourceShadowChangeDescription();
Expand Down Expand Up @@ -283,7 +283,7 @@ private void acquireShadow(OperationResult result) throws SchemaException, Commu
PrismProperty<?> primaryIdentifier = resourceObjectChange.getPrimaryIdentifierRequired();
QName objectClass = getObjectClassDefinition().getTypeName();

repoShadow = localBeans.shadowingHelper.acquireRepoShadow(context, primaryIdentifier, objectClass,
repoShadow = localBeans.shadowAcquisitionHelper.acquireRepoShadow(context, primaryIdentifier, objectClass,
this::createResourceObjectFromChange, result);
}

Expand Down Expand Up @@ -388,12 +388,13 @@ private void markRepoShadowTombstone(OperationResult result) throws SchemaExcept
}
}

private PrismObject<ShadowType> constructAdoptedObject(OperationResult result)
private PrismObject<ShadowType> constructShadowedObject(OperationResult result)
throws CommunicationException, EncryptionException, ObjectNotFoundException, SchemaException,
SecurityViolationException, ConfigurationException, ExpressionEvaluationException {

assert !isDelete() && currentResourceObject != null;
return getAdoptionHelper().constructShadowedObject(context, repoShadow, currentResourceObject, result);
return localBeans.shadowedObjectConstructionHelper
.constructShadowedObject(context, repoShadow, currentResourceObject, result);
}

/**
Expand Down Expand Up @@ -473,8 +474,4 @@ public String debugDump(int indent) {
public String getShadowOid() {
return repoShadow != null ? repoShadow.getOid() : null;
}

private ShadowingHelper getAdoptionHelper() {
return beans.shadowsFacade.getLocalBeans().shadowingHelper;
}
}
Expand Up @@ -35,7 +35,7 @@
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

/**
* Construction of an object that is being returned from the shadow cache to a client.
* Construction of an object that is being returned from the shadows facade to a client.
*
* Data in the resulting object come from two sources:
*
Expand All @@ -49,7 +49,7 @@
* 3. Adds shadowRefs to associations. TODO
* 4. TODO
*
* Instantiated separately for each shadow that is being completed.
* Instantiated separately for each shadowing operation.
*/
public class ShadowedObjectConstruction {

Expand Down Expand Up @@ -375,7 +375,7 @@ private PrismObject<ShadowType> acquireEntitlementRepoShadow(PrismContainerValue
Collection<ResourceAttribute<?>> entitlementIdentifiers = getEntitlementIdentifiers(associationValue, identifierContainer);
PrismObject<ShadowType> providedResourceObject = identifierContainer.getUserData(ResourceObjectConverter.FULL_SHADOW_KEY);
if (providedResourceObject != null) {
return localBeans.shadowingHelper.acquireRepoShadow(ctxEntitlement, providedResourceObject, result);
return localBeans.shadowAcquisitionHelper.acquireRepoShadow(ctxEntitlement, providedResourceObject, result);
}

try {
Expand All @@ -391,7 +391,7 @@ private PrismObject<ShadowType> acquireEntitlementRepoShadow(PrismContainerValue
// Try to look up repo shadow again, this time with full resource shadow. When we
// have searched before we might have only some identifiers. The shadow
// might still be there, but it may be renamed
return localBeans.shadowingHelper.acquireRepoShadow(ctxEntitlement, fetchedResourceObject, result);
return localBeans.shadowAcquisitionHelper.acquireRepoShadow(ctxEntitlement, fetchedResourceObject, result);

} catch (ObjectNotFoundException e) {
// The entitlement to which we point is not there. Simply ignore this association value.
Expand Down
@@ -0,0 +1,45 @@
package com.evolveum.midpoint.provisioning.impl.shadows;

import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.provisioning.api.GenericConnectorException;
import com.evolveum.midpoint.provisioning.impl.CommonBeans;
import com.evolveum.midpoint.provisioning.impl.ProvisioningContext;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

/**
* Helps with the fetched resource object shadowing process (acquiring repo shadows, shadowed object construction).
*
* Currently it delegates these activities to dedicated classes: {@link ShadowAcquisition}, {@link ShadowedObjectConstruction}.
*/
@Experimental
@Component
class ShadowedObjectConstructionHelper {

@Autowired private CommonBeans commonBeans;

/**
* TODO improve the description
* TODO devise better name ... like constructAdoptedObject? dunno...
*
* Make sure that the repo shadow is complete, e.g. that all the mandatory fields
* are filled (e.g name, resourceRef, ...) Also transforms the shadow with
* respect to simulated capabilities. Also shadowRefs are added to associations.
*/
@NotNull PrismObject<ShadowType> constructShadowedObject(@NotNull ProvisioningContext ctx,
@NotNull PrismObject<ShadowType> repoShadow, @NotNull PrismObject<ShadowType> resourceObject,
@NotNull OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException,
SecurityViolationException, GenericConnectorException, ExpressionEvaluationException, EncryptionException {

return ShadowedObjectConstruction.create(ctx, repoShadow, resourceObject, commonBeans)
.construct(result);
}
}
Expand Up @@ -24,5 +24,6 @@
*
* 1. `sync` - takes care of live sync and async update
* 2. `errors` - takes care of the error handling
* 3. `task` - various task handlers related to shadows processing (currently the operation propagation/multi-propagation)
*/
package com.evolveum.midpoint.provisioning.impl.shadows;

0 comments on commit cc63488

Please sign in to comment.