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 May 11, 2016
2 parents f048c59 + 76daa0e commit a965457
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 102 deletions.
Expand Up @@ -21,12 +21,6 @@
import javax.annotation.PostConstruct;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.repo.cache.RepositoryCache;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.util.logging.LoggingUtils;

import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
Expand All @@ -42,30 +36,35 @@
import com.evolveum.midpoint.model.impl.util.Utils;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.AndFilter;
import com.evolveum.midpoint.prism.query.EqualFilter;
import com.evolveum.midpoint.prism.query.LessFilter;
import com.evolveum.midpoint.prism.query.NotFilter;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.OrFilter;
import com.evolveum.midpoint.prism.query.RefFilter;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.provisioning.api.ChangeNotificationDispatcher;
import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions;
import com.evolveum.midpoint.provisioning.api.ProvisioningService;
import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.cache.RepositoryCache;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.result.OperationConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskCategory;
Expand All @@ -81,12 +80,15 @@
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

/**
* The task hander for reconciliation.
Expand Down Expand Up @@ -534,8 +536,12 @@ private boolean performShadowReconciliation(final PrismObject<ResourceType> reso

LessFilter timestampFilter = LessFilter.createLess(ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP, ShadowType.class, prismContext,
XmlTypeConverter.createXMLGregorianCalendar(startTimestamp) , true);
ObjectFilter filter = AndFilter.createAnd(timestampFilter,
RefFilter.createReferenceEqual(ShadowType.F_RESOURCE_REF, ShadowType.class, prismContext, resource.getOid()),
PrismObjectDefinition<ShadowType> shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
EqualFilter nullTimestamptFilter = EqualFilter.createNullEqual(new ItemPath(ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP), shadowDef.findPropertyDefinition(ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP), null);
OrFilter fullTimestampFilter = OrFilter.createOr(timestampFilter, nullTimestamptFilter);
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(resource);
ObjectFilter filter = AndFilter.createAnd(fullTimestampFilter,
RefFilter.createReferenceEqual(new ItemPath(ShadowType.F_RESOURCE_REF), ShadowType.class, prismContext, ref.asReferenceValue()),
EqualFilter.createEqual(ShadowType.F_OBJECT_CLASS, ShadowType.class, prismContext, objectclassDef.getTypeName()));

ObjectQuery query = ObjectQuery.createObjectQuery(filter);
Expand Down
Expand Up @@ -193,20 +193,6 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
eventInfo.setOriginalSituation(situation.getSituation());
eventInfo.setNewSituation(situation.getSituation()); // overwritten later (TODO fix this!)

// if (isProtected((PrismObject<ShadowType>) currentShadow)){
// LOGGER.trace("SYNCHRONIZATION skipping {} because it is protected", currentShadow);
// // Just make sure there is no misleading synchronization situation in the shadow
// if (currentShadow.asObjectable().getSynchronizationSituation() != null) {
// ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, currentShadow.getOid(),
// ShadowType.F_SYNCHRONIZATION_SITUATION, prismContext);
// provisioningService.modifyObject(ShadowType.class, currentShadow.getOid(),
// shadowDelta.getModifications(), null, null, task, subResult);
// }
// subResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it is protected");
// eventInfo.setProtected();
// eventInfo.record(task);
// return;
// }
if (change.isUnrelatedChange() || Utils.isDryRun(task) || isProtected((PrismObject<ShadowType>) currentShadow)){
PrismObject object = null;
if (change.getCurrentShadow() != null){
Expand Down Expand Up @@ -345,26 +331,24 @@ private boolean isPolicyApplicable(PrismObject<? extends ShadowType> currentShad

String policyIntent = synchronizationPolicy.getIntent();
ShadowKindType policyKind = synchronizationPolicy.getKind();
ObjectClassComplexTypeDefinition policyObjectClass = null;
RefinedResourceSchema schema = RefinedResourceSchema.getRefinedSchema(resource);
if (policyKind == null && policyIntent == null) {
LOGGER.warn("Neither objectClass nor kind/intent defined for sycnrhonization policy. Could not reliably apply synchronization definition. Skipping...");
return false;
policyObjectClass = schema.findDefaultObjectClassDefinition(policyKind);
}

ObjectClassComplexTypeDefinition policyObjectClass;

if (policyKind != null){
RefinedResourceSchema schema = RefinedResourceSchema.getRefinedSchema(resource);
if (StringUtils.isEmpty(policyIntent)) {
policyObjectClass = schema.findDefaultObjectClassDefinition(policyKind);
} else {
policyObjectClass = schema.findObjectClassDefinition(policyKind, policyIntent);
}

if (policyObjectClass != null && policyObjectClass.getTypeName().equals(shadowObjectClass)){
return true;
}

return false;
}
if (policyObjectClass != null && policyObjectClass.getTypeName().equals(shadowObjectClass)){
return true;
}
}

if (policyObjectClasses != null && !policyObjectClasses.isEmpty()) {
Expand Down
@@ -1,13 +1,26 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.model.impl.lens;

import java.io.File;

import static com.evolveum.midpoint.test.IntegrationTestTools.display;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -18,28 +31,24 @@
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestReconScript extends AbstractInternalModelIntegrationTest{
public class TestReconScript extends AbstractInternalModelIntegrationTest {

private static final String TASK_RECON_DUMMY_FILENAME = "src/test/resources/common/task-reconcile-dummy.xml";
private static final String TASK_RECON_DUMMY_OID = "10000000-0000-0000-5656-565600000004";
Expand All @@ -48,8 +57,7 @@ public class TestReconScript extends AbstractInternalModelIntegrationTest{
private static final String ACCOUNT_BEFORE_SCRIPT_OID = "acc00000-0000-0000-0000-000000001234";

@Test
public void text001testReconcileScriptsWhenProvisioning() throws Exception{

public void text001testReconcileScriptsWhenProvisioning() throws Exception{
final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning";
TestUtil.displayTestTile(this, TEST_NAME);

Expand Down Expand Up @@ -93,7 +101,6 @@ public void text001testReconcileScriptsWhenProvisioning() throws Exception{

@Test
public void test002testReconcileScriptsWhenReconciling() throws Exception{

final String TEST_NAME = "test002testReconcileScriptsWhenReconciling";
TestUtil.displayTestTile(this, TEST_NAME);

Expand All @@ -110,8 +117,6 @@ public void test002testReconcileScriptsWhenReconciling() throws Exception{

waitForTaskFinish(TASK_RECON_DUMMY_OID, false);



for (ScriptHistoryEntry script : dummyResource.getScriptHistory()){

String userName = (String) script.getParams().get("midpoint_usercn");
Expand All @@ -131,7 +136,6 @@ public void test002testReconcileScriptsWhenReconciling() throws Exception{

@Test
public void test003testReconcileScriptsAddUserAction() throws Exception{

final String TEST_NAME = "test003testReconcileScriptsAddUserAction";
TestUtil.displayTestTile(this, TEST_NAME);

Expand All @@ -142,7 +146,7 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{

provisioningService.addObject(shadow.asPrismObject(), null, null, task, parentResult);

dummyResource.getScriptHistory().clear();
dummyResource.getScriptHistory().clear();

// importObjectFromFile(new File(TASK_RECON_DUMMY_FILENAME));
//
Expand Down Expand Up @@ -187,7 +191,6 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{

@Test
public void test005TestDryRunDelete() throws Exception{

final String TEST_NAME = "test005TestDryRunDelete";
TestUtil.displayTestTile(this, TEST_NAME);

Expand Down Expand Up @@ -220,11 +223,9 @@ public void test005TestDryRunDelete() throws Exception{
}

@Test
public void test005TestReconDelete() throws Exception{

final String TEST_NAME = "test005TestDryRunDelete";
public void test006TestReconDelete() throws Exception{
final String TEST_NAME = "test006TestReconDelete";
TestUtil.displayTestTile(this, TEST_NAME);


PrismObject<TaskType> task = getTask(TASK_RECON_DUMMY_OID);
OperationResult parentResult = new OperationResult(TEST_NAME);
Expand Down
19 changes: 2 additions & 17 deletions model/model-impl/src/test/resources/common/user-elaine.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2013 Evolveum
~ Copyright (c) 2010-2016 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,27 +28,12 @@
<resourceRef oid="10000000-0000-0000-0000-000000000004"/>
</construction>
</assignment>

<assignment>
<construction>
<resourceRef oid="10000000-0000-0000-0000-000000000104"/>
</construction>
</assignment>

<assignment>
<construction>
<resourceRef oid="10000000-0000-0000-0000-000000000204"/>
</construction>
</assignment>


<linkRef oid="c0c010c0-d34d-b33f-f00d-22220004000e" type="c:ShadowType"/>
<linkRef oid="c0c010c0-d34d-b33f-f00d-22220104000e" type="c:ShadowType"/>
<linkRef oid="c0c010c0-d34d-b33f-f00d-22220204000e" type="c:ShadowType"/>

<fullName>Elaine Marley</fullName>
<givenName>Elaine</givenName>
<familyName>Marley</familyName>
<locality>Melee Island</locality>


</user>
8 changes: 4 additions & 4 deletions model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -43,7 +43,7 @@
if any of the following is set to "TRACE" then it was changed by mistake and should be changed back -->
<logger name="com.evolveum.midpoint.model.impl.lens.Clockwork" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.Projector" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.Projector" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ContextLoader" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.FocusProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.InboundProcessor" level="DEBUG" />
Expand All @@ -61,7 +61,7 @@
<logger name="com.evolveum.midpoint.model.impl.util" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.sync" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="TRACE" />
<logger name="com.evolveum.midpoint.provisioning" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ResourceManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.expression" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.common.expression" level="DEBUG" />
Expand All @@ -76,8 +76,8 @@
<logger name="com.evolveum.midpoint.security" level="DEBUG" />
<logger name="com.evolveum.midpoint.security.impl.SecurityEnforcerImpl" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.util.AbstractSearchIterativeTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.SynchronizationServiceImpl" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.sync.SynchronizationServiceImpl" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.FocusValidityScannerTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.controller.ModelController" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.controller.ModelInteractionServiceImpl" level="DEBUG" />
Expand Down
Expand Up @@ -2002,7 +2002,11 @@ public void timeout() {
try {
Task freshTask = taskManager.getTask(taskOid, waitResult);
OperationResult result = freshTask.getResult();
LOGGER.debug("Result of timed-out task:\n{}", result.debugDump());
LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump());
display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp)
+ ", origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp)
+ ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp())
+ ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp()));
assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result;
} catch (ObjectNotFoundException e) {
LOGGER.error("Exception during task refresh: {}", e,e);
Expand All @@ -2012,6 +2016,14 @@ public void timeout() {
}
};
IntegrationTestTools.waitFor("Waiting for task " + taskOid + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME);

Task freshTask = taskManager.getTask(taskOid, waitResult);
LOGGER.debug("Final task:\n{}", freshTask.debugDump());
display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp)
+ ", origLastRunStartTimestamp=" + longTimeToString(origLastRunStartTimestamp)
+ ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp())
+ ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp()));

return taskResultHolder.getValue();
}

Expand Down

0 comments on commit a965457

Please sign in to comment.