Skip to content

Commit

Permalink
Separate association simulation from the rest
Browse files Browse the repository at this point in the history
Work in progress. Provisioning and model-impl tests now pass.
  • Loading branch information
mederly committed Mar 5, 2024
1 parent 3034ce4 commit 4cf3260
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public interface AssociationConfigItem extends DebugDumpable {

String getLifecycleState();

@NotNull QName getAssociationTypeName() throws ConfigurationException;

record AttributeBinding(
@NotNull QName subjectSide,
@NotNull QName objectSide) implements ShortDumpable, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static ResourceObjectAssociationConfigItem of(
.as(ResourceObjectAssociationConfigItem.class);
}

public @NotNull ItemName getAssociationTypeName() throws ConfigurationException {
public @NotNull ItemName getAssociationName() throws ConfigurationException {
return singleNameRequired(value().getRef(), "association name (ref)");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ public static ShadowAssociationTypeDefinitionConfigItem of(
ShadowAssociationTypeDefinitionType.F_OBJECT);
}

public @NotNull QName getAssociationTypeName() throws ConfigurationException {
return nonNull(value().getName(), "association type name");
}

@Override
public boolean isExclusiveStrong() {
return false; // not part of the configuration (we should deprecate it)
Expand Down Expand Up @@ -141,7 +137,7 @@ public String getLifecycleState() {

@Override
public @NotNull String localDescription() {
return "simulated association type '" + value().getName() + "' definition";
return "association type for '" + value().getAssociationClass() + "' definition";
}

public @Nullable MappingConfigItem getOutboundMapping() throws ConfigurationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ class RefinedResourceSchemaParser {
// In theory, this could be done alongside creation of empty object type definitions.
resolveAuxiliaryObjectClassNames();

// Associations refer to object types, so we have to parse them after empty type definitions are created.
parseAssociationTypesDefinitions();
parseLegacyAssociations();

// We can parse attributes only after we have all the object class info parsed (including auxiliary object classes)
parseAttributes();

// Protected objects, delineation, and so on.
// Protected objects and delineation. They refer to attributes.
parseOtherFeatures();

// Associations refer to object types, attributes, and delineation, so they must come after them.
parseAssociationTypesDefinitions();
parseLegacyAssociations();

completeSchema.freeze();

return completeSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.jetbrains.annotations.Nullable;

import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.Collection;

/**
Expand All @@ -23,7 +24,7 @@
*
* TODO later, we may move filter(s) here as well
*/
public abstract class ResourceObjectSetDelineation {
public abstract class ResourceObjectSetDelineation implements Serializable {

/**
* There is intentionally only a single class name here. The reason is that we cannot execute resource searches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.evolveum.midpoint.util.DebugDumpable;

import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
Expand All @@ -28,7 +29,7 @@
import java.util.Collection;

import static com.evolveum.midpoint.schema.config.ConfigurationItem.DESC;
import static com.evolveum.midpoint.util.MiscUtil.stateCheck;
import static com.evolveum.midpoint.util.MiscUtil.stateNonEmpty;

/**
* Specifies how to simulate the association class, e.g., what attributes to use for the association.
Expand Down Expand Up @@ -89,8 +90,8 @@ private ShadowAssociationClassSimulationDefinition(
this.referentialSubjectDefinition = referentialSubjectDefinition;
this.subjectSidePrimaryBindingAttributeDefinition = subjectSidePrimaryBindingAttributeDefinition;
this.referentialObjectDefinition = referentialObjectDefinition;
this.subjectDelineations = subjectDelineations;
this.objectDelineations = objectDelineations;
this.subjectDelineations = MiscUtil.stateNonEmpty(subjectDelineations, "no subject delineations in %s", this);
this.objectDelineations = MiscUtil.stateNonEmpty(objectDelineations, "no object delineations in %s", this);
}

static ShadowAssociationClassSimulationDefinition parseFromAssociationType(
Expand Down Expand Up @@ -208,13 +209,13 @@ public <T> ResourceAttributeDefinition<T> getObjectAttributeDefinition(QName att
}

public @NotNull Collection<SimulatedAssociationClassParticipantDelineation> getSubjectDelineations() {
stateCheck(subjectDelineations.isEmpty(), "No object delineations in %s", this);
return subjectDelineations;
return stateNonEmpty(
subjectDelineations, "No subject delineations in %s (already checked!)", this);
}

public @NotNull Collection<SimulatedAssociationClassParticipantDelineation> getObjectDelineations() {
stateCheck(objectDelineations.isEmpty(), "No object delineations in %s", this);
return objectDelineations;
return stateNonEmpty(
objectDelineations, "No object delineations in %s (already checked!)", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private ShadowAssociationTypeDefinition(
definitionCI.configNonNull(associationsCapabilityCI,
"No simulated associations for %s (native associations are not implemented yet)", DESC);
return new ShadowAssociationTypeDefinition(
definitionCI.getAssociationTypeName(),
definitionCI.getAssociationClassName(),
ShadowAssociationClassSimulationDefinition.parseFromAssociationType(
definitionCI,
schemaBeingParsed,
Expand All @@ -84,7 +84,7 @@ static ShadowAssociationTypeDefinition parseLegacy(
@NotNull ResourceObjectTypeDefinition referentialSubjectDefinition, // is currently being built!
@NotNull ResourceObjectTypeDefinition referentialObjectDefinition) throws ConfigurationException {
return new ShadowAssociationTypeDefinition(
definitionCI.getAssociationTypeName(),
definitionCI.getAssociationName(), // the "ref" serves as an association type name; not very nice but ...
ShadowAssociationClassSimulationDefinition.parseLegacy(
definitionCI, schemaBeingParsed, referentialSubjectDefinition, referentialObjectDefinition),
referentialObjectDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
Expand Down Expand Up @@ -175,43 +174,66 @@
<default>false</default>
<objectClass>ri:CustomprivilegeObjectClass</objectClass>
</objectType>
<associationTypes>
<simulated>
<name>ri:groupMembership</name>
<subject>
<associationType>
<associationClass>ri:groupMembership</associationClass>
<subject>
<type>
<kind>account</kind>
<intent>default</intent>
<primaryBindingAttributeRef>icfs:name</primaryBindingAttributeRef>
<itemName>ri:group</itemName>
</subject>
<object>
</type>
</subject>
<object>
<type>
<kind>entitlement</kind>
<intent>group</intent>
<primaryBindingAttributeRef>ri:members</primaryBindingAttributeRef>
</object>
<direction>objectToSubject</direction>
</simulated>
<simulated>
<name>ri:priv</name>
<subject>
</type>
</object>
</associationType>
<associationType>
<associationClass>ri:accountPrivilege</associationClass>
<subject>
<type>
<kind>account</kind>
<intent>default</intent>
<primaryBindingAttributeRef>ri:privileges</primaryBindingAttributeRef>
</subject>
<object>
</type>
</subject>
<object>
<type>
<kind>entitlement</kind>
<intent>privilege</intent>
<primaryBindingAttributeRef>icfs:name</primaryBindingAttributeRef>
</object>
<direction>subjectToObject</direction>
</simulated>
</associationTypes>
</type>
</object>
</associationType>
</schemaHandling>
<capabilities>
<configured>
<cap:countObjects>
<cap:simulate>pagedSearchEstimate</cap:simulate>
</cap:countObjects>
<cap:associations>
<cap:associationClass>
<cap:name>ri:groupMembership</cap:name>
<cap:subject>
<cap:primaryBindingAttributeRef>icfs:name</cap:primaryBindingAttributeRef>
<cap:localItemName>ri:group</cap:localItemName>
</cap:subject>
<cap:object>
<cap:primaryBindingAttributeRef>ri:members</cap:primaryBindingAttributeRef>
</cap:object>
<cap:direction>objectToSubject</cap:direction>
</cap:associationClass>
<cap:associationClass>
<cap:name>ri:accountPrivilege</cap:name>
<cap:subject>
<cap:primaryBindingAttributeRef>ri:privileges</cap:primaryBindingAttributeRef>
<cap:localItemName>ri:priv</cap:localItemName>
</cap:subject>
<cap:object>
<cap:primaryBindingAttributeRef>icfs:name</cap:primaryBindingAttributeRef>
</cap:object>
<cap:direction>subjectToObject</cap:direction>
</cap:associationClass>
</cap:associations>
</configured>
</capabilities>
</resource>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<delineation>
<objectClass>ri:AccountObjectClass</objectClass>
<filter>
<q:text>attributes/ri:name contains "d_"</q:text> <!-- intentionally with NS prefixe -->
<q:text>attributes/icfs:name contains "d_"</q:text> <!-- intentionally with NS prefix -->
</filter>
<classificationOrder>3</classificationOrder>
</delineation>
Expand Down

0 comments on commit 4cf3260

Please sign in to comment.