Search in sources :

Example 16 with ObjectDeltaOperationType

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

the class AuditEventRecord method createAuditEventRecordType.

// TODO: currently unused (2021), but if audit(AERType) will be reused as part of audit(AER) it can still be useful
public AuditEventRecordType createAuditEventRecordType(boolean tolerateInconsistencies) {
    AuditEventRecordType auditRecord = new AuditEventRecordType();
    auditRecord.setRepoId(repoId);
    auditRecord.setChannel(channel);
    auditRecord.setEventIdentifier(eventIdentifier);
    auditRecord.setEventStage(AuditEventStage.toSchemaValue(eventStage));
    auditRecord.setEventType(AuditEventType.toSchemaValue(eventType));
    auditRecord.setHostIdentifier(hostIdentifier);
    auditRecord.setRemoteHostAddress(remoteHostAddress);
    auditRecord.setNodeIdentifier(nodeIdentifier);
    auditRecord.setInitiatorRef(ObjectTypeUtil.createObjectRef(initiatorRef, true));
    auditRecord.setAttorneyRef(ObjectTypeUtil.createObjectRef(attorneyRef, true));
    auditRecord.setMessage(message);
    auditRecord.setOutcome(OperationResultStatus.createStatusType(outcome));
    auditRecord.setParameter(parameter);
    auditRecord.setResult(result);
    auditRecord.setSessionIdentifier(sessionIdentifier);
    auditRecord.setTargetOwnerRef(ObjectTypeUtil.createObjectRef(targetOwnerRef, true));
    auditRecord.setTargetRef(ObjectTypeUtil.createObjectRef(targetRef, true));
    auditRecord.setRequestIdentifier(requestIdentifier);
    auditRecord.setTaskIdentifier(taskIdentifier);
    auditRecord.setTaskOID(taskOid);
    auditRecord.getResourceOid().addAll(resourceOids);
    auditRecord.setTimestamp(MiscUtil.asXMLGregorianCalendar(timestamp));
    for (ObjectDeltaOperation<?> delta : deltas) {
        ObjectDeltaOperationType odo = new ObjectDeltaOperationType();
        try {
            DeltaConversionOptions options = DeltaConversionOptions.createSerializeReferenceNames();
            // This can be tricky because it can create human-readable but machine-unprocessable
            // data, see MID-6262. But in current context the results of this method are to be
            // used only in GUI and reports, so we are safe here.
            options.setEscapeInvalidCharacters(true);
            DeltaConvertor.toObjectDeltaOperationType(delta, odo, options);
            auditRecord.getDelta().add(odo);
        } catch (Exception e) {
            if (tolerateInconsistencies) {
                if (delta.getExecutionResult() != null) {
                    // TODO does this even work? [med]
                    delta.getExecutionResult().setMessage("Could not show audit record, bad data in delta: " + delta.getObjectDelta());
                } else {
                    OperationResult result = new OperationResult("Create audit event record type");
                    result.setMessage("Could not show audit record, bad data in delta: " + delta.getObjectDelta());
                    odo.setExecutionResult(result.createOperationResultType());
                }
            } else {
                throw new SystemException(e.getMessage(), e);
            }
        }
    }
    for (Map.Entry<String, Set<String>> propertyEntry : properties.entrySet()) {
        AuditEventRecordPropertyType propertyType = new AuditEventRecordPropertyType();
        propertyType.setName(propertyEntry.getKey());
        propertyType.getValue().addAll(propertyEntry.getValue());
        auditRecord.getProperty().add(propertyType);
    }
    for (Map.Entry<String, Set<AuditReferenceValue>> referenceEntry : references.entrySet()) {
        AuditEventRecordReferenceType referenceType = new AuditEventRecordReferenceType();
        referenceType.setName(referenceEntry.getKey());
        referenceEntry.getValue().forEach(v -> referenceType.getValue().add(v.toXml()));
        auditRecord.getReference().add(referenceType);
    }
    for (Map.Entry<String, String> customColumnEntry : customColumnProperty.entrySet()) {
        AuditEventRecordCustomColumnPropertyType customColumn = new AuditEventRecordCustomColumnPropertyType();
        customColumn.setName(customColumnEntry.getKey());
        customColumn.setValue(customColumnEntry.getValue());
        auditRecord.getCustomColumnProperty().add(customColumn);
    }
    // TODO MID-5531 convert custom properties too? What about other than string types?
    return auditRecord;
}
Also used : AuditEventRecordReferenceType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) AuditEventRecordCustomColumnPropertyType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordCustomColumnPropertyType) SystemException(com.evolveum.midpoint.util.exception.SystemException) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) DeltaConversionOptions(com.evolveum.midpoint.schema.DeltaConversionOptions) AuditEventRecordPropertyType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordPropertyType)

Example 17 with ObjectDeltaOperationType

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

the class PageAuditLogDetails method initDeltasPanel.

private void initDeltasPanel(WebMarkupContainer eventPanel) {
    ListView<ObjectDeltaOperationType> deltaScene = new ListView<>(ID_DELTA_LIST_PANEL, createObjectDeltasModel()) {

        @Override
        protected void populateItem(ListItem<ObjectDeltaOperationType> item) {
            ObjectDeltaOperationPanel deltaPanel = new ObjectDeltaOperationPanel(ID_DELTA_PANEL, item.getModel(), PageAuditLogDetails.this) {

                @Override
                public boolean getIncludeOriginalObject() {
                    return false;
                }
            };
            deltaPanel.setOutputMarkupId(true);
            item.add(deltaPanel);
        }
    };
    eventPanel.add(deltaScene);
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ListView(org.apache.wicket.markup.html.list.ListView) ObjectDeltaOperationPanel(com.evolveum.midpoint.gui.api.component.delta.ObjectDeltaOperationPanel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 18 with ObjectDeltaOperationType

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

the class PageAuditLogDetails method connectDeltas.

private List<ObjectDeltaOperationType> connectDeltas(List<ObjectDeltaOperationType> deltas) {
    Map<PolyStringType, ObjectDeltaOperationType> focusDeltas = new HashMap<>();
    List<ObjectDeltaOperationType> otherDeltas = new ArrayList<>();
    for (ObjectDeltaOperationType delta : deltas) {
        if (delta != null && delta.getObjectDelta() != null && FocusType.class.isAssignableFrom(WebComponentUtil.qnameToClass(getPrismContext(), delta.getObjectDelta().getObjectType()))) {
            if (focusDeltas.containsKey(delta.getObjectName())) {
                focusDeltas.get(delta.getObjectName()).setResourceName(null);
                focusDeltas.get(delta.getObjectName()).setResourceOid(null);
                if (delta.getObjectDelta() != null) {
                    if (focusDeltas.get(delta.getObjectName()).getObjectDelta() == null) {
                        focusDeltas.get(delta.getObjectName()).setObjectDelta(delta.getObjectDelta());
                    } else {
                        focusDeltas.get(delta.getObjectName()).getObjectDelta().getItemDelta().addAll(delta.getObjectDelta().getItemDelta());
                    }
                    for (ItemDeltaType itemDelta : delta.getObjectDelta().getItemDelta()) {
                        if (itemDelta == null) {
                            // TODO why?
                            continue;
                        }
                    }
                }
            } else {
                focusDeltas.put(delta.getObjectName(), delta);
            }
        } else {
            otherDeltas.add(delta);
        }
    }
    List<ObjectDeltaOperationType> retDeltas = new ArrayList<>();
    retDeltas.addAll(focusDeltas.values());
    retDeltas.addAll(otherDeltas);
    return retDeltas;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 19 with ObjectDeltaOperationType

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

the class SchemaDebugUtil method shortDump.

public static void shortDump(StringBuilder sb, ObjectDeltaOperationType deltaOpType) {
    if (deltaOpType == null) {
        sb.append("null");
        return;
    }
    shortDump(sb, deltaOpType.getObjectDelta());
    sb.append(": ");
    OperationResultType result = deltaOpType.getExecutionResult();
    if (result == null) {
        sb.append("null result");
    } else {
        sb.append(result.getStatus());
    }
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)

Example 20 with ObjectDeltaOperationType

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

the class Main method modifyRoleModifyInducement.

private static void modifyRoleModifyInducement(ModelPortType modelPort, String roleOid) throws IOException, SAXException, FaultMessage {
    ItemDeltaType inducementDelta = new ItemDeltaType();
    inducementDelta.setModificationType(ModificationTypeType.ADD);
    inducementDelta.setPath(ModelClientUtil.createItemPathType("inducement[3]/construction/attribute"));
    inducementDelta.getValue().add(ModelClientUtil.parseElement("<value>\n" + "        <ref xmlns:ri=\"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3\">ri:pager</ref>\n" + "        <outbound>\n" + "            <expression>\n" + "                <value>00-000-001</value>\n" + "                <value>00-000-003</value>\n" + "            </expression>\n" + "        </outbound>\n" + "    </value>"));
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
    deltaType.setChangeType(ChangeTypeType.MODIFY);
    deltaType.setOid(roleOid);
    deltaType.getItemDelta().add(inducementDelta);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, null);
    for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
        if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
            System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
        }
    }
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

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