Skip to content

Commit

Permalink
Merge branch 'support-3.9' of https://github.com/Evolveum/midpoint in…
Browse files Browse the repository at this point in the history
…to support-3.9
  • Loading branch information
KaterynaHonchar committed Feb 15, 2019
2 parents 65dd0fc + 547f29a commit e3d7c1f
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build-system/pom.xml
Expand Up @@ -83,7 +83,7 @@
<activiti-spring.version>5.22.0</activiti-spring.version>
<commons-email.version>1.3</commons-email.version>
<xmlsec.version>2.0.6</xmlsec.version>
<connid.version>1.5.0.0</connid.version>
<connid.version>1.5.0.8</connid.version>
<jasper.version>6.5.0</jasper.version>
<derby.version>10.11.1.1</derby.version>
<wro4j.version>1.8.0</wro4j.version>
Expand Down
Expand Up @@ -61,7 +61,7 @@
<body wicket:id="body" class="">
<div wicket:id="mainPopup"/>
<div class="wrapper">
<header wicket:id="mainHeader" class="main-header">
<header wicket:id="mainHeader" class="main-header" style="max-height:150px;">
<!-- Logo -->
<a class="custom-logo" wicket:id="customLogo">
<i wicket:id="customLogoImgCss"/>
Expand All @@ -77,7 +77,7 @@
<span class="sr-only"><wicket:message key="PageTemplate.toggleNavigation"/></span>
</a>

<div class="navbar-title" wicket:id="pageTitleContainer">
<div class="navbar-title" wicket:id="pageTitleContainer" style="max-width:94%;">
<span class="page-title" wicket:id="pageTitle">
<span wicket:id="deploymentName"/>
<span wicket:id="pageTitleReal"/>
Expand Down
Expand Up @@ -329,7 +329,7 @@ private void closeCaseWorkItemPerformed(AjaxRequestTarget target) {
CaseManagementService cms = getCaseManagementService();
AbstractWorkItemOutputType output = new AbstractWorkItemOutputType()
.comment(dto.getComment())
.outcome("SUCCESS");
.outcome(OperationResultStatusType.SUCCESS.value());
FileUploadField evidenceUploadField = (FileUploadField) get(ID_MAIN_FORM).get(ID_CASE_WORK_ITEM_FORM).get(ID_CASE_WORK_ITEM_FORM_EVIDENCE);
if (evidenceUploadField != null) {
FileUpload evidence = evidenceUploadField.getFileUpload();
Expand Down
Expand Up @@ -18,13 +18,13 @@
<wicket:panel xmlns:wicket="http://wicket.apache.org">

<div class="box box-solid object-org-box" style="height: 100%; display: flex; flex-direction: column; flex-wrap: wrap;">
<div class="box-header with-border" wicket:id="treeHeader" style="flex: 1 1 26px;">
<div class="box-header with-border" wicket:id="treeHeader" style="flex: 1 1 26px; max-height: 41px;">
<h3 class="box-title"><div wicket:id="treeTitle"/></h3>
<div class="box-tools pull-right">
<div class="cog" wicket:id="treeMenu" about="treeMenu"/>
</div>
</div>
<div wicket:id="treeContainer" class="box-body org-tree-container" style="flex: 100 1 auto; max-height: 717px;">
<div wicket:id="treeContainer" class="box-body org-tree-container" style="flex: 100 1 auto; max-height: 92%;">
<div wicket:id="tree"/>
</div>
</div>
Expand Down
Expand Up @@ -21,7 +21,7 @@
<!-- <div class="col-md-12 clearfix">
</div>-->
<div class="col-md-4">
<div style="max-height:800px; padding-bottom:20px;" wicket:id="treePanel"/>
<div style="height: 100%; max-height:800px; padding-bottom:20px;" wicket:id="treePanel"/>
</div>
<div class="col-md-8">
<div class="box box-solid object-user-box org-managers-box" wicket:id="managerContainer">
Expand Down
Expand Up @@ -72,6 +72,7 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.LoggingUtils;
Expand Down Expand Up @@ -2270,7 +2271,11 @@ public void completeWorkItem(@NotNull String caseOid, long workItemId, AbstractW
}
XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis());
ObjectDelta<CaseType> delta = DeltaBuilder.deltaFor(CaseType.class, prismContext)
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT).replace(output)
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_OUTCOME).replace(output.getOutcome())
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_COMMENT).replace(output.getComment())
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_EVIDENCE).replace(output.getEvidence())
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_EVIDENCE_CONTENT_TYPE).replace(output.getEvidenceContentType())
.item(CaseType.F_WORK_ITEM, workItemId, WorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_EVIDENCE_FILENAME).replace(output.getEvidenceFilename())
.item(CaseType.F_STATE).replace(SchemaConstants.CASE_STATE_CLOSED)
.item(CaseType.F_OUTCOME).replace(output != null ? output.getOutcome() : null)
.item(CaseType.F_CLOSE_TIMESTAMP).replace(now)
Expand Down
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.xml.namespace.QName;
Expand Down Expand Up @@ -244,9 +245,11 @@ private void transformConnectorTimeoutsConfiguration(APIConfiguration apiConfig,

if (SchemaConstants.NS_ICF_CONFIGURATION.equals(propertQName.getNamespaceURI())) {
String opName = propertQName.getLocalPart();
Class<? extends APIOperation> apiOpClass = ConnectorFactoryConnIdImpl.resolveApiOpClass(opName);
if (apiOpClass != null) {
apiConfig.setTimeout(apiOpClass, parseInt(prismProperty));
Collection<Class<? extends APIOperation>> apiOpClasses = ConnectorFactoryConnIdImpl.resolveApiOpClass(opName);
if (apiOpClasses != null) {
for (Class<? extends APIOperation> apiOpClass : apiOpClasses) {
apiConfig.setTimeout(apiOpClass, parseInt(prismProperty));
}
} else {
throw new SchemaException("Unknown operation name " + opName + " in "
+ ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME);
Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.net.URL;
import java.security.Key;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -68,6 +69,7 @@
import org.identityconnectors.framework.api.operations.SyncApiOp;
import org.identityconnectors.framework.api.operations.TestApiOp;
import org.identityconnectors.framework.api.operations.UpdateApiOp;
import org.identityconnectors.framework.api.operations.UpdateDeltaApiOp;
import org.identityconnectors.framework.api.operations.ValidateApiOp;
import org.identityconnectors.framework.common.FrameworkUtil;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -157,7 +159,7 @@ public class ConnectorFactoryConnIdImpl implements ConnectorFactory {
public static final String CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_CASE_INSENSITIVE_HANDLER = "enableCaseInsensitiveFilter";
public static final String CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_ATTRIBUTES_TO_GET_SEARCH_RESULTS_HANDLER = "enableAttributesToGetSearchResultsHandler";

static final Map<String, Class<? extends APIOperation>> apiOpMap = new HashMap<>();
static final Map<String, Collection<Class<? extends APIOperation>>> apiOpMap = new HashMap<>();

private static final String ICF_CONFIGURATION_NAMESPACE_PREFIX = SchemaConstants.ICF_FRAMEWORK_URI + "/bundle/";
private static final String CONNECTOR_IDENTIFIER_SEPARATOR = "/";
Expand Down Expand Up @@ -896,23 +898,23 @@ public void access(char[] decryptedChars) {
result.computeStatus();
}

static Class<? extends APIOperation> resolveApiOpClass(String opName) {
static Collection<Class<? extends APIOperation>> resolveApiOpClass(String opName) {
return apiOpMap.get(opName);
}

static {
apiOpMap.put("create", CreateApiOp.class);
apiOpMap.put("get", GetApiOp.class);
apiOpMap.put("update", UpdateApiOp.class);
apiOpMap.put("delete", DeleteApiOp.class);
apiOpMap.put("test", TestApiOp.class);
apiOpMap.put("scriptOnConnector", ScriptOnConnectorApiOp.class);
apiOpMap.put("scriptOnResource", ScriptOnResourceApiOp.class);
apiOpMap.put("authentication", AuthenticationApiOp.class);
apiOpMap.put("search", SearchApiOp.class);
apiOpMap.put("validate", ValidateApiOp.class);
apiOpMap.put("sync", SyncApiOp.class);
apiOpMap.put("schema", SchemaApiOp.class);
apiOpMap.put("create", Arrays.asList(CreateApiOp.class));
apiOpMap.put("get", Arrays.asList(GetApiOp.class));
apiOpMap.put("update", Arrays.asList(UpdateApiOp.class, UpdateDeltaApiOp.class));
apiOpMap.put("delete", Arrays.asList(DeleteApiOp.class));
apiOpMap.put("test", Arrays.asList(TestApiOp.class));
apiOpMap.put("scriptOnConnector", Arrays.asList(ScriptOnConnectorApiOp.class));
apiOpMap.put("scriptOnResource", Arrays.asList(ScriptOnResourceApiOp.class));
apiOpMap.put("authentication", Arrays.asList(AuthenticationApiOp.class));
apiOpMap.put("search", Arrays.asList(SearchApiOp.class));
apiOpMap.put("validate", Arrays.asList(ValidateApiOp.class));
apiOpMap.put("sync", Arrays.asList(SyncApiOp.class));
apiOpMap.put("schema", Arrays.asList(SchemaApiOp.class));
}

@Override
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,11 +26,19 @@
import com.evolveum.midpoint.repo.api.RepoModifyOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import javax.xml.namespace.QName;

import static java.util.Collections.emptySet;
import static org.testng.AssertJUnit.assertEquals;

Expand Down Expand Up @@ -79,4 +87,67 @@ public void testReindex() throws Exception {
assertEquals("Wrong # of objects found", 1, count);
}

/**
* MID-5128
*/
@Test
public void testReindexShadow() throws Exception {
final String TEST_NAME = "testReindexShadow";
TestUtil.displayTestTitle(TEST_NAME);
OperationResult result = new OperationResult(TEST_NAME);

String APPROVER_OID = "9123090439201432";
PrismObject<ShadowType> shadow = prismContext.createObjectable(ShadowType.class)
.name("unstable")
.beginMetadata()
.modifyApproverRef(APPROVER_OID, UserType.COMPLEX_TYPE)
.<ShadowType>end()
.asPrismObject();
PrismPropertyDefinition<String> def = new PrismPropertyDefinitionImpl<>(new QName("http://temp/", "attr1"), DOMUtil.XSD_STRING, prismContext);
((PrismPropertyDefinitionImpl<String>) def).setIndexed(true);
PrismProperty<String> attribute = def.instantiate();
attribute.addRealValue("value");
shadow.findOrCreateContainer(ShadowType.F_ATTRIBUTES).add(attribute);

ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext)
.item(ShadowType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF).ref(APPROVER_OID, UserType.COMPLEX_TYPE)
.build();

// add shadow and check metadata search

String oid = repositoryService.addObject(shadow, null, result);

int count = repositoryService.countObjects(ShadowType.class, query, null, result);
assertEquals("Wrong # of objects found (after creation)", 1, count);

// break metadata in repo

Session session = factory.openSession();

System.out.println("definitions: " + session.createQuery("from RExtItem").list());
System.out.println("ext values: " + session.createQuery("from ROExtString").list());

Transaction transaction = session.beginTransaction();
Query updateQuery = session.createQuery(
"update com.evolveum.midpoint.repo.sql.data.common.RObjectReference set type = null where ownerOid = '" + oid
+ "'");
System.out.println("records modified = " + updateQuery.executeUpdate());
transaction.commit();
session.close();

// verify search is broken

count = repositoryService.countObjects(ShadowType.class, query, null, result);
assertEquals("Wrong # of objects found (after zeroing the type)", 0, count);

// reindex

repositoryService.modifyObject(ShadowType.class, oid, emptySet(), getModifyOptions(), result);

// verify search is OK

count = repositoryService.countObjects(ShadowType.class, query, null, result);
assertEquals("Wrong # of objects found (after reindexing)", 1, count);
}

}
Expand Up @@ -387,12 +387,15 @@ public <T extends ObjectType> void modifyObjectAttempt(Class<T> type, String oid
//
// So the first step is to retrieve the current value of photo - we obviously do this only if the modifications
// deal with the jpegPhoto property.
Collection<SelectorOptions<GetOperationOptions>> options;
Collection<SelectorOptions<GetOperationOptions>> options = new ArrayList<>();
boolean containsFocusPhotoModification = FocusType.class.isAssignableFrom(type) && containsPhotoModification(modifications);
if (containsFocusPhotoModification) {
options = Collections.singletonList(SelectorOptions.create(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
} else {
options = null;
options.add(SelectorOptions.create(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
}

if (reindex) {
LOGGER.trace("Setting 'raw' option for object fetching because reindex is being applied");
options.addAll(GetOperationOptions.createRawCollection());
}

// get object
Expand Down
Expand Up @@ -94,6 +94,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

/**
* Test for various resource-side errors, strange situations, timeouts
Expand All @@ -109,6 +110,8 @@ public class TestMisbehavingResources extends AbstractStoryTest {

protected static final File RESOURCE_DUMMY_FILE = new File(TEST_DIR, "resource-dummy.xml");
protected static final String RESOURCE_DUMMY_OID = "5f9615a2-d05b-11e8-9dab-37186a8ab7ef";

private static final String USER_JACK_FULL_NAME_CAPTAIN = "Captain Jack Sparrow";

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
Expand Down Expand Up @@ -159,7 +162,7 @@ public void test019SanityUnassignJackDummyAccount() throws Exception {
}

/**
* MID-4773
* MID-4773, MID-5099
*/
@Test
public void test100AssignJackDummyAccountTimeout() throws Exception {
Expand All @@ -180,11 +183,7 @@ public void test100AssignJackDummyAccountTimeout() throws Exception {
displayThen(TEST_NAME);
assertInProgress(result);

// ConnId timeout is obviously not enforced. Therefore if the operation
// does not fail by itself it is not forcibly stopped. The account is
// created anyway.
assertDummyAccountByUsername(null, USER_JACK_USERNAME)
.assertFullName(USER_JACK_FULL_NAME);
assertNoDummyAccount(USER_JACK_USERNAME);
}

@Test
Expand All @@ -201,7 +200,7 @@ public void test102AssignJackDummyAccounRetry() throws Exception {
// WHEN
displayWhen(TEST_NAME);

recomputeUser(USER_JACK_OID, task, result);
reconcileUser(USER_JACK_OID, task, result);

// THEN
displayThen(TEST_NAME);
Expand All @@ -210,4 +209,55 @@ public void test102AssignJackDummyAccounRetry() throws Exception {
assertDummyAccountByUsername(null, USER_JACK_USERNAME)
.assertFullName(USER_JACK_FULL_NAME);
}

/**
* MID-5126
*/
@Test
public void test110ModifyJackDummyAccountTimeout() throws Exception {
final String TEST_NAME = "test110ModifyJackDummyAccountTimeout";
displayTestTitle(TEST_NAME);

getDummyResource().setOperationDelayOffset(3000);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);

modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN));

// THEN
displayThen(TEST_NAME);
assertInProgress(result);

assertDummyAccountByUsername(null, USER_JACK_USERNAME)
// operation timed out, data not updated
.assertFullName(USER_JACK_FULL_NAME);
}

@Test
public void test112ModifyJackDummyAccounRetry() throws Exception {
final String TEST_NAME = "test112ModifyJackDummyAccounRetry";
displayTestTitle(TEST_NAME);

getDummyResource().setOperationDelayOffset(0);
clockForward("P1D");

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);

reconcileUser(USER_JACK_OID, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

assertDummyAccountByUsername(null, USER_JACK_USERNAME)
.assertFullName(USER_JACK_FULL_NAME_CAPTAIN);
}
}
1 change: 1 addition & 0 deletions testing/story/src/test/resources/logback-test.xml
Expand Up @@ -79,6 +79,7 @@

<logger name="org.identityconnectors.framework" level="TRACE" />
<logger name="com.evolveum.polygon.connector.ldap" level="TRACE" />
<logger name="com.evolveum.icf" level="DEBUG" />

<logger name="com.evolveum.midpoint.repo" level="INFO" />
<logger name="com.evolveum.midpoint.wf" level="TRACE" />
Expand Down

0 comments on commit e3d7c1f

Please sign in to comment.