Skip to content

Commit

Permalink
fixing delete operation for dependent accounts..
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Oct 15, 2014
1 parent bf6692e commit c0fa5f2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
Expand Up @@ -122,7 +122,7 @@ public static <F extends ObjectType> void traceContext(Trace logger, String acti
new Object[]{activity, phase, context.dump(showTriples)});
}
}

public static <F extends ObjectType> ResourceType getResource(LensContext<F> context,
String resourceOid, ProvisioningService provisioningService, OperationResult result) throws ObjectNotFoundException,
CommunicationException, SchemaException, ConfigurationException, SecurityViolationException {
Expand Down Expand Up @@ -607,7 +607,7 @@ public static <F extends ObjectType> void loadFullAccount(LensContext<F> context
return;
}
}
LOGGER.trace("Loading full account {} from provisioning", accCtx);
LOGGER.trace("Loading full resource object {} from provisioning", accCtx);

try{
GetOperationOptions getOptions = GetOperationOptions.createDoNotDiscovery();
Expand All @@ -622,7 +622,7 @@ public static <F extends ObjectType> void loadFullAccount(LensContext<F> context
accCtx.determineFullShadowFlag(oldShadow.getFetchResult());

} catch (ObjectNotFoundException ex){
if (accCtx.isDelete() || context.getFocusContext().isDelete()){
if (accCtx.isDelete()){
//this is OK, shadow was deleted, but we will continue in processing with old shadow..and set it as full so prevent from other full loading
accCtx.setFullShadow(true);
} else
Expand All @@ -633,7 +633,7 @@ public static <F extends ObjectType> void loadFullAccount(LensContext<F> context


if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded full account:\n{}", accCtx.debugDump());
LOGGER.trace("Loaded full resource object:\n{}", accCtx.debugDump());
}
}

Expand Down
Expand Up @@ -207,6 +207,9 @@ private <F extends ObjectType> LensProjectionContext determineProjectionWaveDepr
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("DEP(rev): {}", outDependency);
}
LOGGER.trace("projection context: {}", projectionContext );
LOGGER.trace("dependency source context: {}", dependencySourceContext);
LOGGER.trace("in dependency {} \nout dependency {}", inDependency, outDependency);
if (inDependency != null && isHigerOrder(outDependency, inDependency)) {
// There is incomming dependency. Deal only with dependencies of this order and lower
// otherwise we can end up in endless loop even for legal dependencies.
Expand All @@ -233,7 +236,9 @@ private <F extends ObjectType> LensProjectionContext determineProjectionWaveDepr
// Wave for this context was set during the run of this method (it was not set when we
// started, we checked at the beginning). Therefore this context must have been visited again.
// therefore there is a circular dependency. Therefore we need to create another context to split it.
resultAccountContext = createAnotherContext(context, projectionContext, determinedOrder);
if (!projectionContext.isDelete()){
resultAccountContext = createAnotherContext(context, projectionContext, determinedOrder);
}
}
// LOGGER.trace("Wave for {}: {}", resultAccountContext.getResourceAccountType(), wave);
resultAccountContext.setWave(determinedWave);
Expand Down Expand Up @@ -287,6 +292,19 @@ private boolean isHigerOrder(ResourceObjectTypeDependencyType a,
}
return ao > bo;
}

private boolean isLowerOrder(ResourceObjectTypeDependencyType a,
ResourceObjectTypeDependencyType b) {
Integer ao = a.getOrder();
Integer bo = b.getOrder();
if (ao == null) {
ao = 0;
}
if (bo == null) {
bo = 0;
}
return ao < bo;
}

/**
* Find context that has the closest order to the dependency.
Expand Down
Expand Up @@ -29,10 +29,13 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

import com.evolveum.icf.dummy.resource.DummyAccount;
import com.evolveum.icf.dummy.resource.DummyObjectClass;
import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
Expand Down Expand Up @@ -88,6 +91,10 @@ public class TestScience extends AbstractStoryTest {

private static final String DUMMY_ACCOUNT_ATTRIBUTE_STATS_DESC_NAME = "Desc";

private static final String NS_RESOURCE_INSTANCE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance-3";

private static final QName UNIX_INTERNAL_ID = new QName(NS_RESOURCE_INSTANCE, DummyAccount.ATTR_INTERNAL_ID);


protected static DummyResource dummyResourceUnix;
protected static DummyResourceContoller dummyResourceCtlUnix;
Expand Down Expand Up @@ -203,9 +210,15 @@ public void test100jackAssignRoleStatistics() throws Exception {
PrismObject<ShadowType> shadowOpenDj = provisioningService.getObject(ShadowType.class, accountOpenDjOid, null, task, result);
IntegrationTestTools.display("AD account: ", shadowOpenDj);

PrismProperty<Integer> generatedValue = userJack.findExtensionItem(SCIENCE_EXTENSION_UID_QNAME);
assertNotNull("Generated id value must not be null", generatedValue);
assertFalse("Generated value must not be empty", generatedValue.isEmpty());

//internalId on unix dummy resource and title on openDJ simulation must be the same
PrismProperty unixId = shadowUnix.findProperty(new ItemPath(ShadowType.F_ATTRIBUTES, UNIX_INTERNAL_ID));
PrismProperty openDjSyncedId = shadowOpenDj.findProperty(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(NS_RESOURCE_INSTANCE, "title")));
PrismAsserts.assertEquals("Unix id was not synced to the opendj properly.", String.valueOf(unixId.getAnyRealValue()), openDjSyncedId.getAnyRealValue());

// PrismProperty<Integer> generatedValue = userJack.findExtensionItem(SCIENCE_EXTENSION_UID_QNAME);
// assertNotNull("Generated id value must not be null", generatedValue);
// assertFalse("Generated value must not be empty", generatedValue.isEmpty());

}

Expand Down
Expand Up @@ -147,10 +147,10 @@
</inbound>
</attribute>
<dependency>
<resourceRef oid="10000000-0000-0000-0000-0000000100ad"/>
<resourceRef oid="10000000-0000-0000-0000-0000000001ad"/>
<strictness>relaxed</strictness>
</dependency>

<activation>
<administrativeStatus>
<outbound/>
Expand Down

0 comments on commit c0fa5f2

Please sign in to comment.