Skip to content

Commit

Permalink
WIP: Audit Shadow Kind/Intent
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkáčik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed Aug 21, 2023
1 parent c6dada6 commit 6e58995
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public static void toObjectDeltaOperationType(ObjectDeltaOperation<?> odo, Objec
if (odo.getResourceName() != null) {
odoBean.setResourceName(new PolyStringType(odo.getResourceName()));
}
odoBean.setShadowKind(odo.getShadowKind());
odoBean.setShadowIntent(odo.getShadowIntent());
}

private static ChangeTypeType convertChangeType(ChangeType changeType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import com.evolveum.midpoint.util.MiscUtil;

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

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -41,6 +43,9 @@ public class ObjectDeltaOperation<O extends ObjectType> implements DebugDumpable
private String resourceOid;
private PolyString resourceName;

private ShadowKindType shadowKind;
private String shadowIntent;

public ObjectDeltaOperation() {
super();
}
Expand Down Expand Up @@ -359,4 +364,20 @@ public boolean wasReallyExecuted() {
public String getOid() {
return objectDelta != null ? objectDelta.getOid() : null;
}

public void setShadowKind(ShadowKindType kind) {
this.shadowKind = kind;
}

public void setShadowIntent(String intent) {
this.shadowIntent = intent;
}

public ShadowKindType getShadowKind() {
return this.shadowKind;
}

public String getShadowIntent() {
return shadowIntent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17866,6 +17866,21 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<xsd:element name="shadowKind" type="tns:ShadowKindType">
<xsd:annotation>
<xsd:documentation>
Shadow kind of the shadow, that is related to this operation.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="shadowIntent" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Shadow kind of the shadow, that is related to this operation.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private ObjectDeltaOperation<? extends ObjectType> prepareObjectDeltaOperation(O
ShadowType shadow = (ShadowType) objectToDetermineDetailsForAudit;
odoToAudit.setResourceOid(ShadowUtil.getResourceOid(shadow));
odoToAudit.setResourceName(ShadowUtil.getResourceName(shadow));
odoToAudit.setShadowKind(ShadowUtil.getKind(shadow));
odoToAudit.setShadowIntent(ShadowUtil.getIntent(shadow));
}
}
return odoToAudit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ private Collection<MAuditDelta> prepareDeltas(Collection<ObjectDeltaOperation<?>
deltaRow.resourceNameOrig = deltaOperation.getResourceName().getOrig();
deltaRow.resourceNameNorm = deltaOperation.getResourceName().getNorm();
}
deltaRow.shadowKind = deltaOperation.getShadowKind();
deltaRow.shadowIntent = deltaOperation.getShadowIntent();

deltaRow.checksum = computeChecksum(deltaRow.delta, fullResultForCheckSum);
return deltaRow;
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType;

/**
Expand All @@ -32,6 +33,10 @@ public class MAuditDelta {
public UUID resourceOid;
public String resourceNameNorm;
public String resourceNameOrig;

public ShadowKindType shadowKind;
public String shadowIntent;

public OperationResultStatusType status;

// "transient" fields not used by Querydsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import static com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType.*;

/**
* Mapping between {@link QAuditDelta} and {@link ObjectDeltaOperationType}.
*/
Expand All @@ -48,6 +50,11 @@ public static QAuditDeltaMapping get() {
private QAuditDeltaMapping(@NotNull SqaleRepoContext repositoryContext) {
super(TABLE_NAME, DEFAULT_ALIAS_NAME,
ObjectDeltaOperationType.class, QAuditDelta.class, repositoryContext);
// FIXME: Add mappers
addItemMapping(F_RESOURCE_OID);
addItemMapping(F_SHADOW_INTENT);
addItemMapping(F_SHADOW_KIND);

}

@Override
Expand All @@ -71,6 +78,8 @@ public ObjectDeltaOperationType toSchemaObject(MAuditDelta row) {
odo.setResourceName(new PolyStringType(
new PolyString(row.resourceNameOrig, row.resourceNameNorm)));
}
odo.setShadowKind(row.shadowKind);
odo.setShadowIntent(row.shadowIntent);

return odo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.util.*;
import java.util.function.Function;

import com.evolveum.midpoint.repo.sqlbase.mapping.TableRelationResolver;

import com.google.common.collect.Table;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.dsl.ArrayPath;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -114,6 +117,9 @@ private QAuditEventRecordMapping(@NotNull SqaleRepoContext repositoryContext) {
ctx -> new AuditPropertiesItemFilterProcessor(ctx, q -> q.properties)));

addItemMapping(F_CUSTOM_COLUMN_PROPERTY, AuditCustomColumnItemFilterProcessor.mapper());

addRelationResolver(F_DELTA,
TableRelationResolver.usingJoin(QAuditDeltaMapping::get, (r,d) -> r.id.eq(d.recordId)));
}

@Override
Expand Down

0 comments on commit 6e58995

Please sign in to comment.