Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Feb 24, 2022
2 parents 14e4d6b + 1e51bc2 commit ce9a772
Show file tree
Hide file tree
Showing 97 changed files with 2,502 additions and 1,545 deletions.
19 changes: 19 additions & 0 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ CREATE INDEX m_message_template_createTimestamp_idx ON m_message_template (creat
CREATE INDEX m_message_template_modifyTimestamp_idx ON m_message_template (modifyTimestamp);
$aa$);

-- MID-7487 Identity matching
call apply_change(4, $aa$
CREATE TYPE CorrelationSituationType AS ENUM ('UNCERTAIN', 'EXISTING_OWNER', 'NO_OWNER', 'ERROR');
$aa$);

call apply_change(5, $aa$
ALTER TABLE m_shadow
ADD COLUMN correlationStartTimestamp TIMESTAMPTZ,
ADD COLUMN correlationEndTimestamp TIMESTAMPTZ,
ADD COLUMN correlationCaseOpenTimestamp TIMESTAMPTZ,
ADD COLUMN correlationCaseCloseTimestamp TIMESTAMPTZ,
ADD COLUMN correlationSituation CorrelationSituationType;

CREATE INDEX m_shadow_correlationStartTimestamp_idx ON m_shadow (correlationStartTimestamp);
CREATE INDEX m_shadow_correlationEndTimestamp_idx ON m_shadow (correlationEndTimestamp);
CREATE INDEX m_shadow_correlationCaseOpenTimestamp_idx ON m_shadow (correlationCaseOpenTimestamp);
CREATE INDEX m_shadow_correlationCaseCloseTimestamp_idx ON m_shadow (correlationCaseCloseTimestamp);
$aa$);

-- WRITE CHANGES ABOVE ^^
-- IMPORTANT: update apply_change number at the end of postgres-new.sql
-- to match the number used in the last change here!
16 changes: 14 additions & 2 deletions config/sql/native-new/postgres-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ CREATE TYPE ActivationStatusType AS ENUM ('ENABLED', 'DISABLED', 'ARCHIVED');

CREATE TYPE AvailabilityStatusType AS ENUM ('DOWN', 'UP', 'BROKEN');

CREATE TYPE CorrelationSituationType AS ENUM ('UNCERTAIN', 'EXISTING_OWNER', 'NO_OWNER', 'ERROR');

CREATE TYPE LockoutStatusType AS ENUM ('NORMAL', 'LOCKED');

CREATE TYPE NodeOperationalStateType AS ENUM ('UP', 'DOWN', 'STARTING');
Expand Down Expand Up @@ -875,7 +877,13 @@ CREATE TABLE m_shadow (
primaryIdentifierValue TEXT,
synchronizationSituation SynchronizationSituationType,
synchronizationTimestamp TIMESTAMPTZ,
attributes JSONB
attributes JSONB,
-- correlation
correlationStartTimestamp TIMESTAMPTZ,
correlationEndTimestamp TIMESTAMPTZ,
correlationCaseOpenTimestamp TIMESTAMPTZ,
correlationCaseCloseTimestamp TIMESTAMPTZ,
correlationSituation CorrelationSituationType
)
INHERITS (m_object);

Expand All @@ -899,6 +907,10 @@ CREATE INDEX m_shadow_fullTextInfo_idx ON m_shadow USING gin (fullTextInfo gin_t
CREATE INDEX m_shadow_resourceRefTargetOid_idx ON m_shadow (resourceRefTargetOid);
CREATE INDEX m_shadow_createTimestamp_idx ON m_shadow (createTimestamp);
CREATE INDEX m_shadow_modifyTimestamp_idx ON m_shadow (modifyTimestamp);
CREATE INDEX m_shadow_correlationStartTimestamp_idx ON m_shadow (correlationStartTimestamp);
CREATE INDEX m_shadow_correlationEndTimestamp_idx ON m_shadow (correlationEndTimestamp);
CREATE INDEX m_shadow_correlationCaseOpenTimestamp_idx ON m_shadow (correlationCaseOpenTimestamp);
CREATE INDEX m_shadow_correlationCaseCloseTimestamp_idx ON m_shadow (correlationCaseCloseTimestamp);

/*
TODO: reconsider, especially boolean things like dead (perhaps WHERE in other indexes?)
Expand Down Expand Up @@ -1889,4 +1901,4 @@ END $$;
-- endregion

-- Initializing the last change number used in postgres-new-upgrade.sql.
call apply_change(3, $$ SELECT 1 $$, true);
call apply_change(5, $$ SELECT 1 $$, true);
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.schema.util.cases.CorrelationCaseUtil;

import com.evolveum.midpoint.schema.util.cases.OwnerOptionIdentifier;

import com.evolveum.midpoint.util.exception.SchemaException;

import org.jetbrains.annotations.Nullable;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.model.api.correlator.FullCorrelationContext;
import com.evolveum.midpoint.prism.PrismObject;
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.util.exception.CommonException;
Expand Down Expand Up @@ -65,14 +70,17 @@ public class CorrelationContextDto implements Serializable {
}

private void load(CaseType aCase, PageBase pageBase, Task task, OperationResult result) throws CommonException {
resolveObjectsInCorrelationContext(aCase.getCorrelationContext(), pageBase, task, result);
createCorrelationOptions(aCase.getCorrelationContext());
ResourceObjectOwnerOptionsType ownerOptions = CorrelationCaseUtil.getOwnerOptions(aCase);
if (ownerOptions != null) {
resolvePotentialOwners(ownerOptions, pageBase, task, result);
}
createCorrelationOptions(aCase);
createCorrelationPropertiesDefinitions(aCase, pageBase, task, result);
}

private void resolveObjectsInCorrelationContext(CorrelationContextType correlationContext, PageBase pageBase, Task task, OperationResult result) {
for (PotentialOwnerType potentialOwner : correlationContext.getPotentialOwners().getPotentialOwner()) {
resolve(potentialOwner.getCandidateOwnerRef(), "candidate " + potentialOwner.getUri(), pageBase, task, result);
private void resolvePotentialOwners(ResourceObjectOwnerOptionsType potentialOwners, PageBase pageBase, Task task, OperationResult result) {
for (ResourceObjectOwnerOptionType potentialOwner : potentialOwners.getOption()) {
resolve(potentialOwner.getCandidateOwnerRef(), "candidate " + potentialOwner.getIdentifier(), pageBase, task, result);
}
}

Expand Down Expand Up @@ -101,13 +109,15 @@ private PrismObject<?> loadObject(String oid, PageBase pageBase, Task task, Oper
}
}

private void createCorrelationOptions(CorrelationContextType context) {
private void createCorrelationOptions(CaseType aCase) throws SchemaException {
CaseCorrelationContextType context = aCase.getCorrelationContext();
int suggestionNumber = 1;
for (PotentialOwnerType potentialOwner : context.getPotentialOwners().getPotentialOwner()) {
if (SchemaConstants.CORRELATION_NONE_URI.equals(potentialOwner.getUri())) {
for (ResourceObjectOwnerOptionType potentialOwner : CorrelationCaseUtil.getOwnerOptionsList(aCase)) {
OwnerOptionIdentifier identifier = OwnerOptionIdentifier.of(potentialOwner);
if (identifier.isNewOwner()) {
optionHeaders.add(0, TEXT_BEING_CORRELATED);
correlationOptions.add(0,
new CorrelationOptionDto(context.getPreFocusRef()));
new CorrelationOptionDto(potentialOwner, context.getPreFocusRef()));
} else {
optionHeaders.add(String.format(TEXT_CANDIDATE, suggestionNumber));
correlationOptions.add(
Expand All @@ -121,7 +131,8 @@ private void createCorrelationPropertiesDefinitions(CaseType aCase, PageBase pag
throws CommonException {
FullCorrelationContext instantiationContext =
pageBase.getCorrelationService().getFullCorrelationContext(aCase.asPrismObject(), task, result);
CorrelationPropertiesDefinitionType propertiesBean = instantiationContext.synchronizationBean.getCorrelationProperties();
CorrelationPropertiesDefinitionType propertiesBean = // TODO what if there's no definition?
instantiationContext.synchronizationBean.getCorrelationDefinition().getCorrelationProperties();
CorrelationOptionDto newOwnerOption = getNewOwnerOption();
if (propertiesBean != null) {
PrismObject<?> preFocus = newOwnerOption != null ? newOwnerOption.getObject() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.WorkItemId;
import com.evolveum.midpoint.schema.util.cases.CorrelationCaseUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void onClick(AjaxRequestTarget target) {
CaseType correlationCase = getObjectDetailsModels().getObjectType();
WorkItemId workItemId = WorkItemId.of(correlationCase.getWorkItem().get(0));
AbstractWorkItemOutputType output = new AbstractWorkItemOutputType()
.outcome(item.getModelObject().getUri());
.outcome(item.getModelObject().getIdentifier());

Task task = getPageBase().createSimpleTask("DecideCorrelation");
OperationResult result = task.getResult();
Expand Down Expand Up @@ -161,8 +162,8 @@ protected void populateItem(ListItem<CorrelationPropertyDefinition> item) {
private IModel<CorrelationContextDto> createCorrelationContextModel() {
return new ReadOnlyModel<>(() -> {
CaseType aCase = getObjectDetailsModels().getObjectType();
CorrelationContextType correlationContext = aCase.getCorrelationContext();
if (correlationContext == null || correlationContext.getPotentialOwners() == null) {
CaseCorrelationContextType correlationContext = aCase.getCorrelationContext();
if (correlationContext == null || CorrelationCaseUtil.getOwnerOptions(aCase) == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
import java.io.Serializable;
import java.util.Set;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectOwnerOptionType;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.util.MatchingUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PotentialOwnerType;

/**
* Represents a correlation option: a candidate owner or a "new owner".
Expand All @@ -39,30 +39,30 @@ public class CorrelationOptionDto implements Serializable {
private final boolean newOwner;

/**
* URI corresponding to this choice. It should be sent to the case management engine when completing this request.
* Identifier corresponding to this choice. It should be sent to the case management engine when completing this request.
*/
@NotNull private final String uri;
@NotNull private final String identifier;

/**
* Creates a DTO in the case of existing owner.
*/
CorrelationOptionDto(@NotNull PotentialOwnerType potentialOwner) {
CorrelationOptionDto(@NotNull ResourceObjectOwnerOptionType potentialOwner) {
this.object = MiscUtil.requireNonNull(
ObjectTypeUtil.getPrismObjectFromReference(potentialOwner.getCandidateOwnerRef()),
() -> new IllegalStateException("No focus object"));
this.newOwner = false;
this.uri = potentialOwner.getUri();
this.identifier = potentialOwner.getIdentifier();
}

/**
* Creates a DTO in the case of new owner.
* Creates a DTO in the case of new owner (pre-focus).
*/
CorrelationOptionDto(@NotNull ObjectReferenceType reference) {
CorrelationOptionDto(@NotNull ResourceObjectOwnerOptionType potentialOwner, @NotNull ObjectReferenceType preFocus) {
this.object = MiscUtil.requireNonNull(
ObjectTypeUtil.getPrismObjectFromReference(reference),
ObjectTypeUtil.getPrismObjectFromReference(preFocus),
() -> new IllegalStateException("No focus object"));
this.newOwner = true;
this.uri = SchemaConstants.CORRELATION_NONE_URI;
this.identifier = potentialOwner.getIdentifier();
}

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ public String getReferenceId() {
return object.getOid();
}

public @NotNull String getUri() {
return uri;
public @NotNull String getIdentifier() {
return identifier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class TestIntegrationObjectWrapperFactory extends AbstractInitializedGuiI
ShadowType.F_ACTIVATION,
ShadowType.F_CREDENTIALS,
ShadowType.F_POLICY_EXCEPTION,
ShadowType.F_CORRELATION_STATE);
ShadowType.F_CORRELATION);
private static final List<ItemPath> BASIC_ORG_CONTAINERS_PATHS = Arrays.asList(
OrgType.F_EXTENSION,
OrgType.F_ASSIGNMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ public class ExpressionConstants {

public static final String VAR_SYNCHRONIZATION_CONTEXT = "synchronizationContext";
public static final String VAR_CORRELATION_CONTEXT = "correlationContext";
public static final String VAR_CORRELATION_STATE = "correlationState";
public static final String VAR_CORRELATOR_STATE = "correlatorState";
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,6 @@ public abstract class SchemaConstants {
public static final ActivityPath PATH_CLOSED_CERTIFICATION_CAMPAIGNS_CLEANUP =
ActivityPath.fromId(ID_CLOSED_CERTIFICATION_CAMPAIGNS_CLEANUP);

public static final String CORRELATION_NS = NS_C; // at least for now
public static final String CORRELATION_NONE = "none";
public static final QName CORRELATION_NONE_QNAME = new QName(CORRELATION_NS, CORRELATION_NONE);
public static final String CORRELATION_NONE_URI = qNameToUri(CORRELATION_NONE_QNAME);
public static final String CORRELATION_OPTION_PREFIX = "existing-";
public static final String CORRELATION_EXISTING_PREFIX = "existing-";
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ default boolean matchesKind(@Nullable ShadowKindType kind) {
boolean isDefaultForObjectClass();

ResourceObjectTypeDefinition forLayer(@NotNull LayerType layerType);

/**
* Returns the "raw" configuration bean for this object type.
*/
@NotNull ResourceObjectTypeDefinitionType getDefinitionBean();
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ public SearchHierarchyScope getSearchHierarchyScope() {
@Override
public @Nullable DefaultInboundMappingEvaluationPhasesType getDefaultInboundMappingEvaluationPhases() {
// In the future we may define the value also on resource or even global system level
return definitionBean.getInboundMappingsEvaluation() != null ?
definitionBean.getInboundMappingsEvaluation().getDefaultEvaluationPhases() : null;
if (definitionBean.getMappingsEvaluation() == null) {
return null;
}
if (definitionBean.getMappingsEvaluation().getInbound() == null) {
return null;
}
return definitionBean.getMappingsEvaluation().getInbound().getDefaultEvaluationPhases();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public interface ResourceSchema extends PrismSchema, Cloneable, LayeredDefinitio
/**
* Returns object definition (type or class) matching given kind and intent, and object class.
*
* The object class is used to:
* The object class parameter is used to:
*
* 1. verify that object type that matches given kind and intent is compatible with (currently: equal to) the object class;
* 2. provide a complementary means to select a type when intent is not specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static ResourceSchema getExistingRefinedSchema(PrismObject<ResourceType>
/**
* Obtains refined schema for the resource.
*
* Returns null if the resource does not contain any (raw) schema.
*
* If the resource does NOT contain the schema, it must be mutable.
*
* TODO rework this -- management of refined resource schemas will be the responsibility of ResourceManager
Expand Down Expand Up @@ -162,7 +164,6 @@ public static boolean hasParsedSchema(ResourceType resourceType) {
*
* Normally internal to this class, but may be called externally from the test code.
*/
@VisibleForTesting
public static ResourceSchema parseCompleteSchema(ResourceType resource) throws SchemaException {
return new RefinedResourceSchemaParser(resource)
.parse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2193,16 +2193,7 @@ private void dumpIndent(StringBuilder sb, int indent, boolean printStackTrace) {
}

if (cause != null) {
DebugUtil.indentDebugDump(sb, indent + 2);
sb.append("[cause]");
sb.append(cause.getClass().getSimpleName());
sb.append(":");
sb.append(cause.getMessage());
sb.append("\n");
if (printStackTrace) {
dumpStackTrace(sb, cause.getStackTrace(), indent + 4);
dumpInnerCauses(sb, cause.getCause(), indent + 3);
}
DebugUtil.dumpThrowable(sb, "[cause]", cause, indent + 2, printStackTrace);
}

for (OperationResult sub : getSubresults()) {
Expand All @@ -2223,28 +2214,6 @@ private String dumpEntry(Collection<String> values) {
return values.toString();
}

private void dumpInnerCauses(StringBuilder sb, Throwable innerCause, int indent) {
if (innerCause == null) {
return;
}
DebugUtil.indentDebugDump(sb, indent);
sb.append("Caused by ");
sb.append(innerCause.getClass().getName());
sb.append(": ");
sb.append(innerCause.getMessage());
sb.append("\n");
dumpStackTrace(sb, innerCause.getStackTrace(), indent + 1);
dumpInnerCauses(sb, innerCause.getCause(), indent);
}

private static void dumpStackTrace(StringBuilder sb, StackTraceElement[] stackTrace, int indent) {
for (StackTraceElement stackTraceElement : stackTrace) {
DebugUtil.indentDebugDump(sb, indent);
sb.append(stackTraceElement.toString());
sb.append("\n");
}
}

@Override
public void shortDump(StringBuilder sb) {
sb.append(operation).append(" ").append(status).append(" ").append(message);
Expand Down

0 comments on commit ce9a772

Please sign in to comment.