Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 29, 2021
2 parents 06925fc + df62a91 commit df4ad15
Show file tree
Hide file tree
Showing 16 changed files with 191 additions and 48 deletions.
Expand Up @@ -722,11 +722,15 @@ public static boolean isRefreshOnRead(ResourceType resource) {
if (consistency == null) {
return false;
}
Boolean reshreshOnRead = consistency.isReshreshOnRead();
if (reshreshOnRead == null) {
Boolean refreshOnRead = consistency.isRefreshOnRead();
if (refreshOnRead == null) {
Boolean reshreshOnRead = consistency.isReshreshOnRead();
if (reshreshOnRead == null) {
return false;
}
return false;
}
return reshreshOnRead;
return refreshOnRead;
}

public static ErrorSelectorType getConnectorErrorCriticality(ResourceType resourceType) {
Expand Down
Expand Up @@ -7617,10 +7617,22 @@
</xsd:annotation>
</xsd:element>
<xsd:element name="reshreshOnRead" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
WARNING: There is a this property. Use the correct form "refreshOnRead" instead.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.9</a:since>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.3</a:deprecatedSince>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="refreshOnRead" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then midPoint will always refresh shadow when it is retrieved.
Refreshing a shadow means that the status of asynchronous (e.g. manual) opearions
Refreshing a shadow means that the status of asynchronous (e.g. manual) operations
is checked, unfinished operations may be retried and so on. In this case shadow
will always be as fresh as it can be. But read may be slower and there may be
strange errors (e.g. reading a shadow may cause "already exists" error because
Expand All @@ -7630,7 +7642,7 @@
(e.g. during reconciliation).
</xsd:documentation>
<xsd:appinfo>
<a:since>3.9</a:since>
<a:since>4.3</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -55,6 +55,10 @@ public class ShadowRefreshTaskHandler

public ShadowRefreshTaskHandler() {
super(LOGGER, "Shadow refresh", OperationConstants.SHADOW_REFRESH);

// A temporary solution for MID-6934.
// We should decide whether we want to have aggregate statistics for this kind of tasks.
globalReportingOptions.setPreserveStatistics(false);
}

@PostConstruct
Expand Down
Expand Up @@ -39,6 +39,7 @@ public class FocusValidityScannerTaskHandler

public FocusValidityScannerTaskHandler() {
super(LOGGER, "Focus validity scan", OperationConstants.FOCUS_VALIDITY_SCAN);
globalReportingOptions.setCountObjectsOnStart(false); // To avoid problems like in MID-6934.
}

@PostConstruct
Expand Down
Expand Up @@ -54,6 +54,7 @@ public class TriggerScannerTaskHandler

public TriggerScannerTaskHandler() {
super(LOGGER, "Trigger scan", OperationConstants.TRIGGER_SCAN);
globalReportingOptions.setCountObjectsOnStart(false); // To avoid problems like in MID-6934.
}

@PostConstruct
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -893,7 +893,7 @@
<dependency>
<groupId>com.evolveum.polygon</groupId>
<artifactId>connector-databasetable</artifactId>
<version>1.4.4.0</version>
<version>1.4.6.0</version>
</dependency>
<dependency>
<groupId>com.evolveum.polygon</groupId>
Expand Down
Expand Up @@ -1313,9 +1313,10 @@ public SearchResultMetadata searchResourceObjects(ProvisioningContext ctx,
FetchErrorReportingMethodType errorReportingMethod, OperationResult parentResult) throws SchemaException,
CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {

LOGGER.trace("Searching resource objects, query: {}", query);

RefinedObjectClassDefinition objectClassDef = ctx.getObjectClassDefinition();

LOGGER.trace("Searching resource objects, query: {}, OC: {}", query, objectClassDef);

AttributesToReturn attributesToReturn = ProvisioningUtil.createAttributesToReturn(ctx);
SearchHierarchyConstraints searchHierarchyConstraints = entitlementConverter.determineSearchHierarchyConstraints(ctx, parentResult);

Expand Down
Expand Up @@ -134,6 +134,9 @@ public class TestOpenDj extends AbstractOpenDjTest {
private static final QName QNAME_DN = new QName(RESOURCE_NS, "dn");
private static final ItemPath PATH_DN = ItemPath.create(ShadowType.F_ATTRIBUTES, QNAME_DN);

private static final QName QNAME_CN = new QName(RESOURCE_NS, "cn");
private static final ItemPath PATH_CN = ItemPath.create(ShadowType.F_ATTRIBUTES, QNAME_CN);

private String groupSailorOid;

@Autowired
Expand Down Expand Up @@ -1750,6 +1753,34 @@ public void test206SearchObjectsComplexFilterStartsWith() throws Exception {
assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0);
}

/**
* Searches for given CN with kind=entitlement, intent=unlimitedGroup (leading to OC of groupOfUniqueNames).
* The problem is that this CN exists for a user. The connector should sort this out.
*
* MID-6898
*/
@Test(enabled = false)
public void test210SearchObjectsFromAnotherObjectClass() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();

ObjectQuery query = queryFor(ShadowType.class)
.item(ShadowType.F_RESOURCE_REF).ref(RESOURCE_OPENDJ_OID)
.and().item(ShadowType.F_KIND).eq(ShadowKindType.ENTITLEMENT)
.and().item(ShadowType.F_INTENT).eq("unlimitedGroup")
.and().item(PATH_CN, getAccountAttributeDefinition(QNAME_CN)).eq("Will Turner")
.build();

when();
List<PrismObject<ShadowType>> shadows =
provisioningService.searchObjects(ShadowType.class, query, null, task, result);

then();
assertSuccess(result);

assertEquals("Unexpected number of objects found", 0, shadows.size());
}

@Test
public void test230SearchObjectsPagedNoOffset() throws Exception {
Task task = getTestTask();
Expand Down
Expand Up @@ -31,12 +31,12 @@
<icfcldap:bindPassword><t:clearValue>secret</t:clearValue></icfcldap:bindPassword>
<icfcldap:pagingStrategy>auto</icfcldap:pagingStrategy>
<icfcldap:vlvSortAttribute>entryUUID</icfcldap:vlvSortAttribute>
<icfcldap:operationalAttributes>ds-pwp-account-disabled</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>isMemberOf</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>createTimestamp</icfcldap:operationalAttributes>
<icfcldap:languageTagAttributes>description</icfcldap:languageTagAttributes> <!-- MID-5210 -->
<icfcldap:operationalAttributes>ds-pwp-account-disabled</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>isMemberOf</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>createTimestamp</icfcldap:operationalAttributes>
<icfcldap:languageTagAttributes>description</icfcldap:languageTagAttributes> <!-- MID-5210 -->
<icfcldap:useTreeDelete>auto</icfcldap:useTreeDelete>
<icfcldap:enableExtraTests>false</icfcldap:enableExtraTests> <!-- MID-3477 -->
<icfcldap:enableExtraTests>false</icfcldap:enableExtraTests> <!-- MID-3477 -->
</icfc:configurationProperties>

<icfc:connectorPoolConfiguration>
Expand Down Expand Up @@ -201,6 +201,26 @@
</attribute>
</objectType>

<objectType>
<!-- Yet another entitlement. Same objectclass, but no baseContext. Testing MID-6898. -->
<kind>entitlement</kind>
<intent>unlimitedGroup</intent>
<objectClass>ri:groupOfUniqueNames</objectClass>
<attribute>
<ref>ri:entryUUID</ref>
<matchingRule>mr:stringIgnoreCase</matchingRule>
</attribute>
<attribute>
<ref>ri:dn</ref>
<matchingRule>mr:distinguishedName</matchingRule>
</attribute>
<attribute>
<ref>ri:uniqueMember</ref>
<matchingRule>mr:distinguishedName</matchingRule>
<fetchStrategy>minimal</fetchStrategy>
</attribute>
</objectType>

<objectType>
<!-- OrganizationUnit with base context pointing to organizationUnit.
Make sure this won't end up in an endless loop. -->
Expand Down
3 changes: 1 addition & 2 deletions repo/repo-sqale/sql/pgnew-repo.sql
Expand Up @@ -1198,8 +1198,7 @@ ALTER TABLE m_form ADD CONSTRAINT m_form_name_norm_key UNIQUE (name_norm);
--0 48756229
-- abstract common structure for m_assignment and m_inducement
CREATE TABLE m_assignment_type (
owner_oid UUID NOT NULL, -- see sub-tables for PK definition
containerType ContainerType NOT NULL,
-- owner_oid + containerType from m_container, final specification in sub-tables
-- new column may avoid join to object for some queries
owner_type ObjectType NOT NULL,
lifecycleState TEXT/*VARCHAR(255)*/,
Expand Down
Expand Up @@ -50,11 +50,13 @@ public S toSchemaObject(Tuple row, Q entityPath,
PrismObject<S> prismObject;
String serializedForm = new String(row.get(entityPath.fullObject), StandardCharsets.UTF_8);
try {
SqlTransformerSupport.ParseResult<S> result = transformerSupport.parsePrismObject(serializedForm);
SqlTransformerSupport.ParseResult<S> result =
transformerSupport.parsePrismObject(serializedForm);
prismObject = result.prismObject;
if (result.parsingContext.hasWarnings()) {
logger.warn("Object {} parsed with {} warnings",
ObjectTypeUtil.toShortString(prismObject), result.parsingContext.getWarnings().size());
ObjectTypeUtil.toShortString(prismObject),
result.parsingContext.getWarnings().size());
}
} catch (SchemaException | RuntimeException | Error e) {
// This is a serious thing. We have corrupted XML in the repo. This may happen even
Expand Down Expand Up @@ -205,7 +207,7 @@ public byte[] createFullObject(S schemaObject) throws SchemaException {
"Serialized object must have assigned OID and version: " + schemaObject);
}

return transformerSupport.serializer()
return transformerSupport.createStringSerializer()
.itemsToSkip(fullObjectItemsToSkip())
.options(SerializationOptions
.createSerializeReferenceNamesForNullOids()
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void test100AddNamedUserWithoutOidWorksOk()
repositoryService.addObject(userType.asPrismObject(), null, result);

then("operation is successful and user row for it is created");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand Down Expand Up @@ -110,7 +110,7 @@ public void test102AddWithoutOidIgnoresOverwriteOption()
repositoryService.addObject(userType.asPrismObject(), createOverwrite(), result);

then("operation is successful and user row for it is created, overwrite is meaningless");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand All @@ -134,7 +134,7 @@ public void test110AddUserWithProvidedOidWorksOk()
repositoryService.addObject(userType.asPrismObject(), null, result);

then("operation is successful and user row with provided OID is created");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand Down Expand Up @@ -191,7 +191,7 @@ public void test200AddObjectWithMultivalueContainers()
repositoryService.addObject(user.asPrismObject(), null, result);

then("object and its container rows are created and container IDs are assigned");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand Down Expand Up @@ -231,7 +231,7 @@ public void test201AddObjectWithOidAndMultivalueContainers()
repositoryService.addObject(user.asPrismObject(), null, result);

then("object and its container rows are created and container IDs are assigned");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand Down Expand Up @@ -267,7 +267,7 @@ public void test205AddObjectWithMultivalueRefs()
repositoryService.addObject(user.asPrismObject(), null, result);

then("object and its container rows are created and container IDs are assigned");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
Expand Down Expand Up @@ -354,7 +354,7 @@ public void test900SystemConfigurationBasicObjectAttributes() throws Exception {
repositoryService.addObject(systemConfiguration.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MObject row = selectObjectByOid(QSystemConfiguration.class, systemConfiguration.getOid());
display("FULL OBJECT: " + new String(row.fullObject, StandardCharsets.UTF_8));
Expand Down Expand Up @@ -402,7 +402,7 @@ public void test901ContainerTrigger() throws Exception {
repositoryService.addObject(object.asPrismObject(), null, result);

then("it is stored with its persisted trigger containers");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QTrigger t = aliasFor(QTrigger.class);
List<MTrigger> containers = select(t, t.ownerOid.eq(UUID.fromString(object.getOid())));
Expand Down Expand Up @@ -450,7 +450,7 @@ public void test902ContainerOperationExecution() throws Exception {
repositoryService.addObject(object.asPrismObject(), null, result);

then("it is stored with its persisted trigger containers");
assertResult(result);
assertThatOperationResult(result).isSuccess();

QOperationExecution oe = aliasFor(QOperationExecution.class);
List<MOperationExecution> containers =
Expand Down Expand Up @@ -509,7 +509,7 @@ public void test910ResourceAndItsBusinessApproverReferences() throws Exception {
repositoryService.addObject(resource.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MResource row = selectObjectByOid(QResource.class, resource.getOid());
assertThat(row.businessAdministrativeState)
Expand Down Expand Up @@ -556,7 +556,7 @@ public void test911Connector() throws Exception {
repositoryService.addObject(connector.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MConnector row = selectObjectByOid(QConnector.class, connector.getOid());
assertThat(row.connectorBundle).isEqualTo("com.connector.package");
Expand Down Expand Up @@ -599,7 +599,7 @@ public void test918Shadow() throws Exception {
repositoryService.addObject(shadow.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MShadow row = selectObjectByOid(QShadow.class, shadow.getOid());
assertCachedUri(row.objectClassId, objectClass);
Expand Down Expand Up @@ -658,7 +658,7 @@ public void test920GenericObject() throws Exception {
repositoryService.addObject(genericObject.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MGenericObject row = selectObjectByOid(
QGenericObject.class, UUID.fromString(genericObject.getOid()));
Expand Down Expand Up @@ -728,7 +728,7 @@ public void test930Task() throws Exception {
repositoryService.addObject(task.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MTask row = selectObjectByOid(QTask.class, task.getOid());
assertThat(row.taskIdentifier).isEqualTo("task-id");
Expand Down Expand Up @@ -776,7 +776,7 @@ public void test940AccessCertificationDefinition() throws Exception {
repositoryService.addObject(accessCertificationDefinition.asPrismObject(), null, result);

then("it is stored and relevant attributes are in columns");
assertResult(result);
assertThatOperationResult(result).isSuccess();

MAccessCertificationDefinition row = selectObjectByOid(
QAccessCertificationDefinition.class, accessCertificationDefinition.getOid());
Expand Down
Expand Up @@ -25,14 +25,11 @@
import com.evolveum.midpoint.repo.sqale.qmodel.common.QUri;
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObject;
import com.evolveum.midpoint.repo.sqale.qmodel.object.QObject;
import com.evolveum.midpoint.repo.sqale.qmodel.object.QObjectMapping;
import com.evolveum.midpoint.repo.sqlbase.JdbcSession;
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase;
import com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.test.util.AbstractSpringTest;
import com.evolveum.midpoint.test.util.InfraTestMixin;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.QNameUtil;

@ContextConfiguration(locations = { "../../../../../ctx-test.xml" })
Expand Down Expand Up @@ -68,15 +65,6 @@ public void cleanDatabase() {
}
}

protected void assertResult(OperationResult opResult) {
if (opResult.isEmpty()) {
// this is OK. Nothing added to result.
return;
}
opResult.computeStatus();
TestUtil.assertSuccess(opResult);
}

/**
* Returns default query instance (alias) for the specified query type.
* Don't use this for multi-table types like references, use something like this instead:
Expand Down

0 comments on commit df4ad15

Please sign in to comment.