Skip to content

Commit

Permalink
Add preliminary support of identity search
Browse files Browse the repository at this point in the history
The TestInternalCorrelationMedium is now migrated to the new style.
(Will fail on generic repo!)
  • Loading branch information
mederly committed Aug 4, 2022
1 parent 293f8ab commit c80373a
Show file tree
Hide file tree
Showing 39 changed files with 701 additions and 597 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ public static GetOperationOptions createRetrieve() {
return createRetrieve(RetrieveOption.INCLUDE);
}

/** As {@link #createRetrieve()} but returns the whole collection. */
public static Collection<SelectorOptions<GetOperationOptions>> createRetrieveCollection() {
return SelectorOptions.createCollection(createRetrieve());
}

/**
* Specifies whether to return specific items. It is used for optimizations.
* Some requests only needs a subset of items therefore fetching them all is a waste
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class SchemaConstants {
// NAMESPACES

public static final String NS_ORG = "http://midpoint.evolveum.com/xml/ns/public/common/org-3";
public static final String NS_IDENTITY = "http://midpoint.evolveum.com/xml/ns/public/common/identity-3";
public static final String PREFIX_NS_ORG = "org";
public static final String NS_QUERY = PrismConstants.NS_QUERY;
public static final String NS_TYPES = PrismConstants.NS_TYPES;
Expand Down Expand Up @@ -644,6 +645,12 @@ public abstract class SchemaConstants {

public static final @NotNull ItemPath PATH_IDENTITY =
ItemPath.create(FocusType.F_IDENTITIES, FocusIdentitiesType.F_IDENTITY);
public static final @NotNull ItemPath PATH_IDENTITY_SEARCH_ITEMS =
ItemPath.create(
FocusType.F_IDENTITIES,
FocusIdentitiesType.F_IDENTITY,
FocusIdentityType.F_ITEMS,
FocusIdentityItemsType.F_NORMALIZED);
public static final @NotNull ItemPath PATH_DEFAULT_AUTHORITATIVE_SOURCE =
ItemPath.create(FocusType.F_IDENTITIES, FocusIdentitiesType.F_DEFAULT_AUTHORITATIVE_SOURCE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,13 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="correlators" type="tns:CompositeCorrelatorType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Correlators for this kind of focus objects.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="defaultAuthoritativeSource" type="tns:ObjectTemplateMappingType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public CorrelationContext(
@NotNull FocusType preFocus,
@NotNull ResourceType resource,
@NotNull ResourceObjectDefinition objectDefinition,
@Nullable ObjectTemplateType currentObjectTemplate, // TODO remove?
@Nullable SystemConfigurationType systemConfiguration,
@NotNull Task task) {
this.resourceObject = resourceObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Collection<CorrelationProperty> getCorrelationProperties(
*/
@NotNull CorrelatorContext<?> createRootCorrelatorContext(
@NotNull SynchronizationPolicy synchronizationPolicy,
@Nullable ObjectTemplateType objectTemplate,
@Nullable SystemConfigurationType systemConfiguration) throws ConfigurationException, SchemaException;

/**
Expand Down Expand Up @@ -124,6 +125,13 @@ boolean checkCandidateOwner(
throws SchemaException, ExpressionEvaluationException, SecurityViolationException, CommunicationException,
ConfigurationException, ObjectNotFoundException;

/** TEMPORARY!!! */
ObjectTemplateType determineObjectTemplate(
@NotNull SynchronizationPolicy synchronizationPolicy,
@NotNull FocusType preFocus,
@NotNull OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException;

@FunctionalInterface
interface CaseCloser {
/** Closes the case in repository. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.evolveum.midpoint.model.api.correlator;

import com.evolveum.axiom.concepts.Lazy;
import com.evolveum.midpoint.model.api.identities.IdentityManagementConfiguration;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.schema.route.ItemRoute;
import com.evolveum.midpoint.schema.util.CorrelationItemDefinitionUtil;
Expand Down Expand Up @@ -49,6 +50,9 @@ public class CorrelatorContext<C extends AbstractCorrelatorType> implements Debu
/** Complete correlation definition. Used to access things outside of specific correlator configuration. */
@Nullable private final CorrelationDefinitionType correlationDefinitionBean;

/** TODO */
@NotNull private final IdentityManagementConfiguration identityManagementConfiguration;

/** System configuration, used to look for correlator configurations. */
@Nullable private final SystemConfigurationType systemConfiguration;

Expand All @@ -63,12 +67,14 @@ public CorrelatorContext(
@NotNull CorrelatorConfiguration configuration,
@NotNull AbstractCorrelatorType originalConfigurationBean,
@Nullable CorrelationDefinitionType correlationDefinitionBean,
@NotNull IdentityManagementConfiguration identityManagementConfiguration,
@Nullable SystemConfigurationType systemConfiguration) {
//noinspection unchecked
this.configurationBean = (C) configuration.getConfigurationBean();
this.configuration = configuration;
this.originalConfigurationBean = originalConfigurationBean;
this.correlationDefinitionBean = correlationDefinitionBean;
this.identityManagementConfiguration = identityManagementConfiguration;
this.systemConfiguration = systemConfiguration;
}

Expand Down Expand Up @@ -173,6 +179,10 @@ private List<CorrelationItemDefinitionType> getLocalItemsDefinitionCollection()
return systemConfiguration;
}

public @NotNull IdentityManagementConfiguration getIdentityManagementConfiguration() {
return identityManagementConfiguration;
}

@Override
public String debugDump(int indent) {
// Temporary: this config bean is the core of the context; other things need not be so urgently dumped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.impl.lens.identities;
package com.evolveum.midpoint.model.api.identities;

import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;

import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IdentityItemDefinitionType;
Expand All @@ -21,7 +23,10 @@

public class IdentityItemConfiguration implements Serializable {

/** Beware, the name may be unqualified! */
@NotNull private final QName name;

/** Beware, the path segments may be unqualified! */
@NotNull private final ItemPath path;

private IdentityItemConfiguration(@NotNull QName name, @NotNull ItemPath path) {
Expand Down Expand Up @@ -52,6 +57,15 @@ private IdentityItemConfiguration(@NotNull QName name, @NotNull ItemPath path) {
return name;
}

@SuppressWarnings("WeakerAccess")
public @NotNull String getLocalName() {
return name.getLocalPart();
}

public @NotNull ItemName getDefaultSearchItemName() {
return new ItemName(SchemaConstants.NS_IDENTITY, getLocalName());
}

public @NotNull ItemPath getPath() {
return path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.impl.lens.identities;
package com.evolveum.midpoint.model.api.identities;

import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.exception.ConfigurationException;
Expand Down Expand Up @@ -36,7 +36,7 @@ private IdentityManagementConfiguration(@NotNull ObjectTemplateType objectTempla
this.objectTemplate = objectTemplate;
}

public static IdentityManagementConfiguration of(@Nullable ObjectTemplateType objectTemplate) {
public static @NotNull IdentityManagementConfiguration of(@Nullable ObjectTemplateType objectTemplate) {
return new IdentityManagementConfiguration(
Objects.requireNonNullElseGet(
objectTemplate,
Expand Down Expand Up @@ -72,4 +72,11 @@ public static IdentityManagementConfiguration of(@Nullable ObjectTemplateType ob
public boolean hasNoItems() throws ConfigurationException {
return getItems().isEmpty();
}

@Override
public String toString() {
return "IdentityManagementConfiguration{" +
"objectTemplate=" + objectTemplate +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ public class FullCorrelationContext {
@NotNull public final ResourceType resource;
@NotNull public final ResourceObjectDefinition resourceObjectDefinition;
@NotNull public final SynchronizationPolicy synchronizationPolicy;
@Nullable public final ObjectTemplateType objectTemplate;
@Nullable public final SystemConfigurationType systemConfiguration;

public FullCorrelationContext(
@NotNull ShadowType shadow,
@NotNull ResourceType resource,
@NotNull ResourceObjectDefinition resourceObjectDefinition,
@NotNull SynchronizationPolicy synchronizationPolicy,
@Nullable ObjectTemplateType objectTemplate,
@Nullable SystemConfigurationType systemConfiguration) {
this.shadow = shadow;
this.resource = resource;
this.resourceObjectDefinition = resourceObjectDefinition;
this.synchronizationPolicy = synchronizationPolicy;
this.objectTemplate = objectTemplate;
this.systemConfiguration = systemConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.annotation.PreDestroy;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.common.SystemObjectCache;

import com.evolveum.midpoint.schema.result.OperationResultStatus;
Expand All @@ -22,6 +23,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.CacheInvalidationContext;
Expand All @@ -47,6 +49,8 @@
* It is backed by caches, therefore this is supposed to be a low-overhead service that can be
* used in many places.
*
* As a secondary responsibility, this class handles the resolution of object templates.
*
* [NOTE]
* ====
* When resolving archetype references (i.e. obtaining archetype objects from references in object assignments and
Expand Down Expand Up @@ -77,6 +81,7 @@ public class ArchetypeManager implements Cache {
@Autowired private CacheRegistry cacheRegistry;
@Autowired private ArchetypeDeterminer archetypeDeterminer;
@Autowired private ArchetypePolicyMerger archetypePolicyMerger;
@Autowired @Qualifier("cacheRepositoryService") private RepositoryService cacheRepositoryService;

private final Map<String, ArchetypePolicyType> archetypePolicyCache = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -236,6 +241,14 @@ private ArchetypePolicyType determineArchetypePolicyFromArchetypes(
return mergedPolicy;
}

/** A convenience variant of {@link #getPolicyForArchetype(ArchetypeType, OperationResult)}. */
public @Nullable ArchetypePolicyType getPolicyForArchetype(@NotNull String archetypeOid, OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException {
return getPolicyForArchetype(
getArchetype(archetypeOid, result),
result);
}

/**
* Returns policy collected from this archetype and its super-archetypes. Uses the policy cache.
*/
Expand Down Expand Up @@ -397,4 +410,20 @@ public void dumpContent() {
archetypePolicyCache.forEach((k, v) -> LOGGER_CONTENT.info("Cached archetype policy: {}: {}", k, v));
}
}

/**
* Returns the "expanded" object template, i.e. the one with "include" instructions resolved.
*
* Note that the handling of dangling references is graceful just like in the case of archetypes,
* see the note in the class-level javadoc. However, if the `oid` parameter cannot be resolved,
* the respective exception is thrown.
*
* FIXME implement the expansion function
*/
public @NotNull ObjectTemplateType getExpandedObjectTemplate(@NotNull String oid, @NotNull OperationResult result)
throws SchemaException, ObjectNotFoundException {
return cacheRepositoryService
.getObject(ObjectTemplateType.class, oid, null, result)
.asObjectable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.evolveum.midpoint.model.api.correlator.CorrelatorFactoryRegistry;
import com.evolveum.midpoint.model.common.ModelCommonBeans;

import com.evolveum.midpoint.model.common.archetypes.ArchetypeManager;
import com.evolveum.midpoint.model.impl.lens.identities.IdentitiesManager;
import com.evolveum.midpoint.provisioning.api.SynchronizationSorterEvaluator;
import com.evolveum.midpoint.repo.common.SystemObjectCache;
Expand Down Expand Up @@ -137,4 +138,5 @@ public static ModelBeans get() {
@Autowired public SynchronizationSorterEvaluator synchronizationSorterEvaluator;
@Autowired public SynchronizationActionFactory synchronizationActionFactory;
@Autowired public ProjectionContextKeyFactory projectionContextKeyFactory;
@Autowired public ArchetypeManager archetypeManager;
}

0 comments on commit c80373a

Please sign in to comment.