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;
}
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);
}
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;
}
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());
}
}
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());
}
}
}
Aggregations