Search in sources :

Example 1 with AuditEventRecordType

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType in project midpoint by Evolveum.

the class ObjectHistoryTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusWrapperModel, final PageAdminObjectDetails<F> page) {
    AuditSearchDto searchDto = new AuditSearchDto();
    ObjectReferenceType ort = new ObjectReferenceType();
    ort.setOid(focusWrapperModel.getObject().getOid());
    searchDto.setTargetNames(asList(ort));
    searchDto.setEventStage(AuditEventStageType.EXECUTION);
    Map<String, Boolean> visibilityMap = new HashMap<>();
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_COLUMN_VISIBILITY, false);
    AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL, page, searchDto, visibilityMap) {

        @Override
        protected List<IColumn<AuditEventRecordType, String>> initColumns() {
            List<IColumn<AuditEventRecordType, String>> columns = super.initColumns();
            IColumn<AuditEventRecordType, String> column = new MultiButtonColumn<AuditEventRecordType>(new Model(), 2) {

                private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS };

                @Override
                public String getCaption(int id) {
                    return "";
                }

                @Override
                public String getButtonTitle(int id) {
                    switch(id) {
                        case 0:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle").getString();
                        case 1:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle").getString();
                    }
                    return "";
                }

                @Override
                public String getButtonColorCssClass(int id) {
                    return colors[id].toString();
                }

                @Override
                protected String getButtonCssClass(int id) {
                    StringBuilder sb = new StringBuilder();
                    sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
                    sb.append(getButtonColorCssClass(id)).append(" ");
                    switch(id) {
                        case 0:
                            sb.append("fa fa-circle-o");
                            break;
                        case 1:
                            sb.append("fa fa-file-text-o");
                            break;
                    }
                    return sb.toString();
                }

                @Override
                public void clickPerformed(int id, AjaxRequestTarget target, IModel<AuditEventRecordType> model) {
                    switch(id) {
                        case 0:
                            currentStateButtonClicked(target, focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE), page.getCompileTimeClass());
                            break;
                        case 1:
                            viewObjectXmlButtonClicked(focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), page.getCompileTimeClass(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE));
                            break;
                    }
                }
            };
            columns.add(column);
            return columns;
        }
    };
    panel.setOutputMarkupId(true);
    add(panel);
}
Also used : IModel(org.apache.wicket.model.IModel) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuditLogViewerPanel(com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DoubleButtonColumn(com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn) MultiButtonColumn(com.evolveum.midpoint.web.component.data.column.MultiButtonColumn)

Example 2 with AuditEventRecordType

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType in project midpoint by Evolveum.

the class PageAuditLogDetails method initEventPanel.

private void initEventPanel(WebMarkupContainer eventPanel) {
    WebMarkupContainer eventDetailsPanel = new WebMarkupContainer(ID_EVENT_DETAILS_PANEL);
    eventDetailsPanel.setOutputMarkupId(true);
    eventPanel.addOrReplace(eventDetailsPanel);
    final Label identifier = new Label(ID_PARAMETERS_EVENT_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_IDENTIFIER));
    identifier.setOutputMarkupId(true);
    eventDetailsPanel.add(identifier);
    final Label timestamp = new Label(ID_PARAMETERS_TIMESTAMP, new PropertyModel(recordModel, ID_PARAMETERS_TIMESTAMP));
    timestamp.setOutputMarkupId(true);
    eventDetailsPanel.add(timestamp);
    final Label sessionIdentifier = new Label(ID_PARAMETERS_SESSION_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_SESSION_IDENTIFIER));
    sessionIdentifier.setOutputMarkupId(true);
    eventDetailsPanel.add(sessionIdentifier);
    final Label taskIdentifier = new Label(ID_PARAMETERS_TASK_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_TASK_IDENTIFIER));
    taskIdentifier.setOutputMarkupId(true);
    eventDetailsPanel.add(taskIdentifier);
    final Label taskOID = new Label(ID_PARAMETERS_TASK_OID, new PropertyModel(recordModel, ID_PARAMETERS_TASK_OID));
    taskOID.setOutputMarkupId(true);
    eventDetailsPanel.add(taskOID);
    final Label hostIdentifier = new Label(ID_PARAMETERS_HOST_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_HOST_IDENTIFIER));
    hostIdentifier.setOutputMarkupId(true);
    eventDetailsPanel.add(hostIdentifier);
    final Label nodeIdentifier = new Label(ID_PARAMETERS_NODE_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_NODE_IDENTIFIER));
    nodeIdentifier.setOutputMarkupId(true);
    eventDetailsPanel.add(nodeIdentifier);
    final Label remoteHostAddress = new Label(ID_PARAMETERS_REMOTE_HOST_ADDRESS, new PropertyModel(recordModel, ID_PARAMETERS_REMOTE_HOST_ADDRESS));
    remoteHostAddress.setOutputMarkupId(true);
    eventDetailsPanel.add(remoteHostAddress);
    final Label initiatorRef = new Label(ID_PARAMETERS_EVENT_INITIATOR, new Model<>(WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getInitiatorRef(), this, createSimpleTask(ID_PARAMETERS_EVENT_INITIATOR), new OperationResult(ID_PARAMETERS_EVENT_INITIATOR))));
    initiatorRef.setOutputMarkupId(true);
    eventDetailsPanel.add(initiatorRef);
    final Label targetRef = new Label(ID_PARAMETERS_EVENT_TARGET, new Model<>(WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getTargetRef(), this, createSimpleTask(ID_PARAMETERS_EVENT_TARGET), new OperationResult(ID_PARAMETERS_EVENT_TARGET))));
    targetRef.setOutputMarkupId(true);
    eventDetailsPanel.add(targetRef);
    IModel<String> targetOwnerRefModel = new IModel<String>() {

        @Override
        public String getObject() {
            return WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getTargetOwnerRef(), PageAuditLogDetails.this, createSimpleTask(OPERATION_RESOLVE_REFERENCE_NAME), new OperationResult(OPERATION_RESOLVE_REFERENCE_NAME));
        }

        @Override
        public void setObject(String s) {
        }

        @Override
        public void detach() {
        }
    };
    final Label targetOwnerRef = new Label(ID_PARAMETERS_EVENT_TARGET_OWNER, targetOwnerRefModel);
    targetOwnerRef.setOutputMarkupId(true);
    eventDetailsPanel.add(targetOwnerRef);
    final Label eventType = new Label(ID_PARAMETERS_EVENT_TYPE, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_TYPE));
    eventType.setOutputMarkupId(true);
    eventDetailsPanel.add(eventType);
    final Label eventStage = new Label(ID_PARAMETERS_EVENT_STAGE, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_STAGE));
    eventStage.setOutputMarkupId(true);
    eventDetailsPanel.add(eventStage);
    final Label channel = new Label(ID_PARAMETERS_CHANNEL, new PropertyModel(recordModel, ID_PARAMETERS_CHANNEL));
    channel.setOutputMarkupId(true);
    eventDetailsPanel.add(channel);
    final Label eventOutcome = new Label(ID_PARAMETERS_EVENT_OUTCOME, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_OUTCOME));
    eventOutcome.setOutputMarkupId(true);
    eventDetailsPanel.add(eventOutcome);
    final Label eventResult = new Label(ID_PARAMETERS_EVENT_RESULT, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_RESULT));
    eventResult.setOutputMarkupId(true);
    eventDetailsPanel.add(eventResult);
    final Label parameter = new Label(ID_PARAMETERS_PARAMETER, new PropertyModel(recordModel, ID_PARAMETERS_PARAMETER));
    parameter.setOutputMarkupId(true);
    eventDetailsPanel.add(parameter);
    final Label message = new Label(ID_PARAMETERS_MESSAGE, new PropertyModel(recordModel, ID_PARAMETERS_MESSAGE));
    message.setOutputMarkupId(true);
    eventDetailsPanel.add(message);
    ListView<AuditEventRecordItemValueDto> additionalItemsList = new ListView<AuditEventRecordItemValueDto>(ID_ADDITIONAL_ITEM_LINE, new AbstractReadOnlyModel<List<AuditEventRecordItemValueDto>>() {

        @Override
        public List<AuditEventRecordItemValueDto> getObject() {
            List<AuditEventRecordItemValueDto> rv = new ArrayList<>();
            for (AuditEventRecordItemType item : getSortedItems()) {
                String currentName = getDisplayName(item.getName());
                if (item instanceof AuditEventRecordPropertyType) {
                    for (String value : ((AuditEventRecordPropertyType) item).getValue()) {
                        rv.add(new AuditEventRecordItemValueDto(currentName, value));
                        currentName = null;
                    }
                } else if (item instanceof AuditEventRecordReferenceType) {
                    for (AuditEventRecordReferenceValueType value : ((AuditEventRecordReferenceType) item).getValue()) {
                        rv.add(new AuditEventRecordItemValueDto(currentName, value.getTargetName() != null ? value.getTargetName().getOrig() : value.getOid()));
                        currentName = null;
                    }
                } else {
                // should not occur
                }
            }
            return rv;
        }

        // TODO take locale into account when sorting
        private List<AuditEventRecordItemType> getSortedItems() {
            AuditEventRecordType record = recordModel.getObject();
            List<AuditEventRecordItemType> rv = new ArrayList<>();
            rv.addAll(record.getProperty());
            rv.addAll(record.getReference());
            rv.sort((a, b) -> {
                // explicitly enumerated are shown first; others are sorted by display name
                int index_a = EXTENSION_ITEMS_ORDER.indexOf(a.getName());
                int index_b = EXTENSION_ITEMS_ORDER.indexOf(b.getName());
                if (index_a != -1 && index_b != -1) {
                    return Integer.compare(index_a, index_b);
                } else if (index_a != -1) {
                    return -1;
                } else if (index_b != -1) {
                    return 1;
                }
                String name_a = getDisplayName(a.getName());
                String name_b = getDisplayName(b.getName());
                return String.CASE_INSENSITIVE_ORDER.compare(name_a, name_b);
            });
            return rv;
        }

        private String getDisplayName(String nameKey) {
            // null should not occur so we don't try to be nice when displaying it
            return nameKey != null ? createStringResource(nameKey).getString() : "(null)";
        }
    }) {

        @Override
        protected void populateItem(ListItem<AuditEventRecordItemValueDto> item) {
            item.add(new Label(ID_ITEM_NAME, new PropertyModel<String>(item.getModel(), AuditEventRecordItemValueDto.F_NAME)));
            item.add(new Label(ID_ITEM_VALUE, new PropertyModel<String>(item.getModel(), AuditEventRecordItemValueDto.F_VALUE)));
        }
    };
    WebMarkupContainer additionalItemsContainer = new WebMarkupContainer(ID_ADDITIONAL_ITEMS);
    additionalItemsContainer.add(additionalItemsList);
    additionalItemsContainer.add(new VisibleBehaviour(() -> !additionalItemsList.getModelObject().isEmpty()));
    eventDetailsPanel.add(additionalItemsContainer);
}
Also used : AuditEventRecordItemValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordItemValueDto) java.util(java.util) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PageAdminConfiguration(com.evolveum.midpoint.web.page.admin.configuration.PageAdminConfiguration) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) Trace(com.evolveum.midpoint.util.logging.Trace) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) com.evolveum.midpoint.xml.ns._public.common.audit_3(com.evolveum.midpoint.xml.ns._public.common.audit_3) Label(org.apache.wicket.markup.html.basic.Label) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListItem(org.apache.wicket.markup.html.list.ListItem) Model(org.apache.wicket.model.Model) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AuditEventRecordItemValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordItemValueDto) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) WorkflowConstants(com.evolveum.midpoint.wf.api.WorkflowConstants) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PropertyModel(org.apache.wicket.model.PropertyModel) ObjectDeltaOperationPanel(com.evolveum.midpoint.gui.api.component.delta.ObjectDeltaOperationPanel) Item(org.apache.wicket.markup.repeater.Item) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) AuditLogStorage(com.evolveum.midpoint.web.session.AuditLogStorage) PageDescriptor(com.evolveum.midpoint.web.application.PageDescriptor) AuthorizationAction(com.evolveum.midpoint.web.application.AuthorizationAction) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 3 with AuditEventRecordType

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType in project midpoint by Evolveum.

the class AuditEventRecord method createAuditEventRecordType.

public AuditEventRecordType createAuditEventRecordType(boolean tolerateInconsistencies) {
    AuditEventRecordType auditRecordType = new AuditEventRecordType();
    auditRecordType.setChannel(channel);
    auditRecordType.setEventIdentifier(eventIdentifier);
    auditRecordType.setEventStage(AuditEventStage.fromAuditEventStage(eventStage));
    auditRecordType.setEventType(AuditEventType.fromAuditEventType(eventType));
    auditRecordType.setHostIdentifier(hostIdentifier);
    auditRecordType.setRemoteHostAddress(remoteHostAddress);
    auditRecordType.setNodeIdentifier(nodeIdentifier);
    auditRecordType.setInitiatorRef(ObjectTypeUtil.createObjectRef(initiator, true));
    auditRecordType.setMessage(message);
    auditRecordType.setOutcome(OperationResultStatus.createStatusType(outcome));
    auditRecordType.setParameter(parameter);
    auditRecordType.setResult(result);
    auditRecordType.setSessionIdentifier(sessionIdentifier);
    auditRecordType.setTargetOwnerRef(ObjectTypeUtil.createObjectRef(targetOwner, true));
    auditRecordType.setTargetRef(ObjectTypeUtil.createObjectRef(target, true));
    auditRecordType.setTaskIdentifier(taskIdentifier);
    auditRecordType.setTaskOID(taskOID);
    auditRecordType.setTimestamp(MiscUtil.asXMLGregorianCalendar(timestamp));
    for (ObjectDeltaOperation delta : deltas) {
        ObjectDeltaOperationType odo = new ObjectDeltaOperationType();
        try {
            DeltaConvertor.toObjectDeltaOperationType(delta, odo, DeltaConversionOptions.createSerializeReferenceNames());
            auditRecordType.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());
                }
                continue;
            } 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());
        auditRecordType.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()));
        auditRecordType.getReference().add(referenceType);
    }
    return auditRecordType;
}
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) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) SystemException(com.evolveum.midpoint.util.exception.SystemException) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) AuditEventRecordPropertyType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordPropertyType)

Example 4 with AuditEventRecordType

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType in project midpoint by Evolveum.

the class AuditEventRecord method createAuditEventRecord.

public static AuditEventRecord createAuditEventRecord(AuditEventRecordType auditEventRecordType) {
    AuditEventRecord auditRecord = new AuditEventRecord();
    auditRecord.setChannel(auditEventRecordType.getChannel());
    auditRecord.setEventIdentifier(auditEventRecordType.getEventIdentifier());
    auditRecord.setEventStage(AuditEventStage.toAuditEventStage(auditEventRecordType.getEventStage()));
    auditRecord.setEventType(AuditEventType.toAuditEventType(auditEventRecordType.getEventType()));
    auditRecord.setHostIdentifier(auditEventRecordType.getHostIdentifier());
    auditRecord.setRemoteHostAddress(auditEventRecordType.getRemoteHostAddress());
    auditRecord.setNodeIdentifier(auditEventRecordType.getNodeIdentifier());
    auditRecord.setInitiator(getObjectFromObjectReferenceType(auditEventRecordType.getInitiatorRef()));
    auditRecord.setMessage(auditEventRecordType.getMessage());
    auditRecord.setOutcome(OperationResultStatus.parseStatusType(auditEventRecordType.getOutcome()));
    auditRecord.setParameter(auditEventRecordType.getParameter());
    auditRecord.setResult(auditEventRecordType.getResult());
    auditRecord.setSessionIdentifier(auditEventRecordType.getSessionIdentifier());
    auditRecord.setTarget(getReferenceValueFromObjectReferenceType(auditEventRecordType.getTargetRef()));
    auditRecord.setTargetOwner(getObjectFromObjectReferenceType(auditEventRecordType.getTargetOwnerRef()));
    auditRecord.setTaskIdentifier(auditEventRecordType.getTaskIdentifier());
    auditRecord.setTaskOID(auditEventRecordType.getTaskOID());
    auditRecord.setTimestamp(MiscUtil.asLong(auditEventRecordType.getTimestamp()));
    for (AuditEventRecordPropertyType propertyType : auditEventRecordType.getProperty()) {
        propertyType.getValue().forEach(v -> auditRecord.addPropertyValue(propertyType.getName(), v));
    }
    for (AuditEventRecordReferenceType referenceType : auditEventRecordType.getReference()) {
        referenceType.getValue().forEach(v -> auditRecord.addReferenceValue(referenceType.getName(), AuditReferenceValue.fromXml(v)));
    }
    return auditRecord;
}
Also used : AuditEventRecordReferenceType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceType) AuditEventRecordPropertyType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordPropertyType)

Example 5 with AuditEventRecordType

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType in project midpoint by Evolveum.

the class AuditLogViewerPanel method initColumns.

protected List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
    IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
                    return WebComponentUtil.formatDate(time);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType record = rowModel.getObject();
            try {
                AuditEventRecord.adopt(record, pageBase.getPrismContext());
            } catch (SchemaException e) {
                throw new SystemException("Couldn't adopt event record: " + e, e);
            }
            pageBase.navigateToNext(new PageAuditLogDetails(record));
        }
    };
    columns.add(linkColumn);
    PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = rowModel.getObject();
            createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
        }
    };
    columns.add(initiatorRefColumn);
    if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
        IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
        columns.add(eventStageColumn);
    }
    IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
    columns.add(eventTypeColumn);
    if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
            }
        };
        columns.add(targetRefColumn);
    }
    if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
            }
        };
        columns.add(targetOwnerRefColumn);
    }
    IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
            String channel = auditEventRecordType.getChannel();
            if (channel != null) {
                QName channelQName = QNameUtil.uriToQName(channel);
                String return_ = channelQName.getLocalPart();
                item.add(new Label(componentId, return_));
            } else {
                item.add(new Label(componentId, ""));
            }
            item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
        }
    };
    columns.add(channelColumn);
    IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
    columns.add(outcomeColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) QName(javax.xml.namespace.QName) PageAuditLogDetails(com.evolveum.midpoint.web.page.admin.reports.PageAuditLogDetails) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Item(org.apache.wicket.markup.repeater.Item) SystemException(com.evolveum.midpoint.util.exception.SystemException) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Aggregations

AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ArrayList (java.util.ArrayList)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 AuditEventRecordProvider (com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider)2 AuditSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto)2 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)2 AuditEventRecordPropertyType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordPropertyType)2 AuditEventRecordReferenceType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceType)2 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 HashMap (java.util.HashMap)2