Search in sources :

Example 36 with ObjectDeltaOperationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.

the class AuditInsertion method convertDelta.

/**
 * Returns prepared audit delta row without PK columns which will be added later.
 * For normal repo this code would be in mapper, but here we know exactly what type we work with.
 */
@Nullable
private MAuditDelta convertDelta(ObjectDeltaOperationType deltaOperation) {
    try {
        MAuditDelta deltaRow = new MAuditDelta();
        ObjectDeltaType delta = deltaOperation.getObjectDelta();
        if (delta != null) {
            DeltaConversionOptions options = DeltaConversionOptions.createSerializeReferenceNames();
            options.setEscapeInvalidCharacters(escapeIllegalCharacters);
            String serializedDelta = DeltaConvertor.serializeDelta(delta, options, repoContext.getJdbcRepositoryConfiguration().getFullObjectFormat());
            // serializedDelta is transient, needed for changed items later
            deltaRow.serializedDelta = serializedDelta;
            deltaRow.delta = serializedDelta.getBytes(StandardCharsets.UTF_8);
            deltaRow.deltaOid = SqaleUtils.oidToUUid(delta.getOid());
            deltaRow.deltaType = delta.getChangeType();
        }
        OperationResultType executionResult = deltaOperation.getExecutionResult();
        byte[] fullResult = null;
        if (executionResult != null) {
            fullResult = repoContext.createFullResult(executionResult);
            deltaRow.status = executionResult.getStatus();
            deltaRow.fullResult = fullResult;
        }
        deltaRow.resourceOid = SqaleUtils.oidToUUid(deltaOperation.getResourceOid());
        if (deltaOperation.getObjectName() != null) {
            deltaRow.objectNameOrig = deltaOperation.getObjectName().getOrig();
            deltaRow.objectNameNorm = deltaOperation.getObjectName().getNorm();
        }
        if (deltaOperation.getResourceName() != null) {
            deltaRow.resourceNameOrig = deltaOperation.getResourceName().getOrig();
            deltaRow.resourceNameNorm = deltaOperation.getResourceName().getNorm();
        }
        deltaRow.checksum = computeChecksum(deltaRow.delta, fullResult);
        return deltaRow;
    } catch (Exception ex) {
        logger.warn("Unexpected problem during audit delta conversion", ex);
        return null;
    }
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeltaConversionOptions(com.evolveum.midpoint.schema.DeltaConversionOptions) IOException(java.io.IOException) SystemException(com.evolveum.midpoint.util.exception.SystemException) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with ObjectDeltaOperationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.

the class QAuditDeltaMapping method toSchemaObject.

public ObjectDeltaOperationType toSchemaObject(MAuditDelta row) {
    ObjectDeltaOperationType odo = new ObjectDeltaOperationType();
    String deltaId = row.recordId + "-" + row.checksum;
    odo.setObjectDelta(parseBytes(row.delta, "delta-" + deltaId, ObjectDeltaType.class));
    odo.setExecutionResult(parseBytes(row.fullResult, "result-" + deltaId, OperationResultType.class));
    if (row.objectNameOrig != null || row.objectNameNorm != null) {
        odo.setObjectName(new PolyStringType(new PolyString(row.objectNameOrig, row.objectNameNorm)));
    }
    odo.setResourceOid(row.resourceOid != null ? row.resourceOid.toString() : null);
    if (row.resourceNameOrig != null || row.resourceNameNorm != null) {
        odo.setResourceName(new PolyStringType(new PolyString(row.resourceNameOrig, row.resourceNameNorm)));
    }
    return odo;
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)28 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)23 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)12 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)12 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)11 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)6 QName (javax.xml.namespace.QName)5 Test (org.testng.annotations.Test)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)3 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 CanonicalItemPath (com.evolveum.midpoint.prism.path.CanonicalItemPath)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 MAuditDelta (com.evolveum.midpoint.repo.sql.audit.beans.MAuditDelta)2 DeltaConversionOptions (com.evolveum.midpoint.schema.DeltaConversionOptions)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2