Search in sources :

Example 26 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class BackendEventsResourceTest method getEntity.

protected org.ovirt.engine.core.common.businessentities.AuditLog getEntity(int index) {
    AuditLog auditLogMock = mock(org.ovirt.engine.core.common.businessentities.AuditLog.class);
    when(auditLogMock.getAuditLogId()).thenReturn(LOG_IDS[index]);
    when(auditLogMock.getSeverity()).thenReturn(AuditLogSeverity.ALERT);
    when(auditLogMock.getMessage()).thenReturn(MESSAGES[index]);
    when(auditLogMock.getOrigin()).thenReturn(ORIGIN_NAMES[index]);
    when(auditLogMock.getCustomEventId()).thenReturn(CUSTOMER_EVENT_IDS[index]);
    when(auditLogMock.getLogType()).thenReturn(AuditLogType.EXTERNAL_ALERT);
    when(auditLogMock.getLogTime()).thenReturn(new Date());
    return auditLogMock;
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Date(java.util.Date)

Example 27 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class RemoveAuditLogByIdCommandTest method getEventWithOvirtOrigin.

private AuditLog getEventWithOvirtOrigin() {
    AuditLog auditLog = new AuditLog();
    auditLog.setAuditLogId(EVENT_ID_2);
    auditLog.setOrigin(AuditLog.OVIRT_ORIGIN);
    return auditLog;
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 28 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class AddExternalEventCommand method executeCommand.

@Override
protected void executeCommand() {
    AuditLogableBase event = Injector.injectMembers(new AuditLogableBase(getParameters().getEvent()));
    event.setExternal(true);
    String message = StringUtils.abbreviate(getEvent().getMessage(), Config.getValue(ConfigValues.MaxAuditLogMessageLength));
    switch(getEvent().getSeverity()) {
        case NORMAL:
            auditLogDirector.log(event, AuditLogType.EXTERNAL_EVENT_NORMAL, message);
            break;
        case WARNING:
            auditLogDirector.log(event, AuditLogType.EXTERNAL_EVENT_WARNING, message);
            break;
        case ERROR:
            auditLogDirector.log(event, AuditLogType.EXTERNAL_EVENT_ERROR, message);
            break;
        case ALERT:
            auditLogDirector.log(event, AuditLogType.EXTERNAL_ALERT, message);
            break;
    }
    AuditLog auditLog = auditLogDao.getByOriginAndCustomEventId(getEvent().getOrigin(), getEvent().getCustomEventId());
    if (auditLog != null) {
        setActionReturnValue(auditLog.getAuditLogId());
        setSucceeded(true);
    }
    // Update host external status if set
    if (hasHostExternalStatus()) {
        vdsDynamicDao.updateExternalStatus(getEvent().getVdsId(), getParameters().getExternalStatus());
    }
    // update storage domain external status if set
    if (hasStorageDomainExternalStatus()) {
        storageDomainDynamicDao.updateExternalStatus(getEvent().getStorageDomainId(), getParameters().getExternalStatus());
    }
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 29 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class AdvancedViewColumns method initTable.

void initTable() {
    getTable().enableColumnResizing();
    AuditLogSeverityColumn severityColumn = new AuditLogSeverityColumn();
    severityColumn.setContextMenuTitle(constants.severityEvent());
    // $NON-NLS-1$
    getTable().addColumn(severityColumn, constants.empty(), "30px");
    AbstractTextColumn<AuditLog> logTimeColumn = new AbstractFullDateTimeColumn<AuditLog>() {

        @Override
        protected Date getRawValue(AuditLog object) {
            return object.getLogTime();
        }
    };
    logTimeColumn.makeSortable(AuditLogConditionFieldAutoCompleter.TIME);
    // $NON-NLS-1$
    getTable().addColumn(logTimeColumn, constants.timeEvent(), "175px");
    messageColumn = new AbstractTextColumn<AuditLog>() {

        @Override
        public String getValue(AuditLog object) {
            return object.getMessage();
        }
    };
    messageColumn.makeSortable(AuditLogConditionFieldAutoCompleter.MESSAGE);
    getTable().addColumn(messageColumn, constants.messageEvent(), BASIC_VIEW_MSG_COLUMN_WIDTH);
}
Also used : AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) AuditLogSeverityColumn(org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 30 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class NotificationListWidget method setInternalRowData.

private void setInternalRowData(int start, List<? extends AuditLog> values) {
    // Compare the new values with the ones currently displayed, if no changes, don't refresh.
    if (values != null && !valuesEquals(values)) {
        rowCount = values.size();
        boolean collapsed = checkIfCollapsed();
        currentValues = values;
        content.clear();
        eventPanelHeading = new PanelHeader();
        Heading titleHeading = new Heading(HeadingSize.H4);
        titleHeading.addStyleName(PatternflyConstants.PF_PANEL_TITLE);
        titleAnchor = new Anchor(hashString(thisWidgetId));
        titleAnchor.setDataParent(hashString(parentWidgetId));
        titleAnchor.setDataTarget(hashString(thisWidgetId));
        titleAnchor.setDataToggle(this.toggle);
        titleAnchor.setText(this.title);
        titleAnchor.addClickHandler(e -> e.preventDefault());
        if (collapsed) {
            titleAnchor.addStyleName(PatternflyConstants.COLLAPSED);
        }
        titleHeading.add(titleAnchor);
        eventPanelHeading.add(titleHeading);
        content.add(eventPanelHeading);
        PanelCollapse eventCollapse = new PanelCollapse();
        eventCollapse.setId(thisWidgetId);
        eventPanelBody = new PanelBody();
        if (this.containerHeight > 0) {
            eventPanelBody.getElement().getStyle().setProperty(MAX_HEIGHT, containerHeight + Unit.PX.getType());
            eventPanelBody.getElement().getStyle().setOverflowY(Overflow.AUTO);
        }
        eventCollapse.add(eventPanelBody);
        if (collapsed) {
            eventCollapse.getElement().setAttribute(ARIA_EXPANDED, String.valueOf(false));
            eventCollapse.getElement().getStyle().setHeight(0, Unit.PX);
        } else {
            eventCollapse.getElement().setAttribute(ARIA_EXPANDED, String.valueOf(true));
            eventCollapse.addStyleName(Styles.IN);
        }
        content.add(eventCollapse);
        for (final AuditLog auditLog : values) {
            DrawerNotification notification = new DrawerNotification(auditLog);
            for (int i = 0; i < actionLabels.size(); i++) {
                final int index = i;
                ActionAnchorListItem listItem = new ActionAnchorListItem(actionLabels.get(index));
                listItem.addClickHandler(e -> auditLogActions.get(index).executeCommand(actionCommand.get(index), auditLog));
                notification.addActionButton(listItem);
            }
            eventPanelBody.add(notification);
        }
        if (clearAllActionLabel != null) {
            actionPanel = new FlowPanel();
            actionPanel.addStyleName(PatternflyConstants.PF_DRAWER_ACTION);
            eventCollapse.add(actionPanel);
            Button clearAllbutton = new Button(clearAllActionLabel);
            clearAllbutton.addStyleName(BTN_LINK);
            clearAllbutton.addStyleName(Styles.BTN_BLOCK);
            clearAllbutton.removeStyleName(BTN_DEFAULT);
            clearAllbutton.addClickHandler(event -> clearAllActionCallback.executeCommand(clearAllActionCommand, null));
            actionPanel.add(clearAllbutton);
            Button restoreAllbutton = new Button(restoreAllActionLabel);
            restoreAllbutton.addStyleName(BTN_LINK);
            restoreAllbutton.addStyleName(Styles.BTN_BLOCK);
            restoreAllbutton.removeStyleName(BTN_DEFAULT);
            restoreAllbutton.addClickHandler(event -> restoreAllActionCallback.executeCommand(restoreAllActionCommand, null));
            actionPanel.add(restoreAllbutton);
        }
    }
}
Also used : ActionAnchorListItem(org.ovirt.engine.ui.common.widget.action.ActionAnchorListItem) Heading(org.gwtbootstrap3.client.ui.Heading) Anchor(org.gwtbootstrap3.client.ui.Anchor) PanelHeader(org.gwtbootstrap3.client.ui.PanelHeader) Button(org.gwtbootstrap3.client.ui.Button) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) PanelBody(org.gwtbootstrap3.client.ui.PanelBody) PanelCollapse(org.gwtbootstrap3.client.ui.PanelCollapse) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Aggregations

AuditLog (org.ovirt.engine.core.common.businessentities.AuditLog)31 Test (org.junit.Test)13 Date (java.util.Date)6 Guid (org.ovirt.engine.core.compat.Guid)4 AuditLogSeverity (org.ovirt.engine.core.common.AuditLogSeverity)2 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)2 AuditLogSeverityColumn (org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn)2 HasClickHandlers (com.google.gwt.event.dom.client.HasClickHandlers)1 EventBus (com.google.gwt.event.shared.EventBus)1 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HasData (com.google.gwt.view.client.HasData)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Named (com.google.inject.name.Named)1 PresenterWidget (com.gwtplatform.mvp.client.PresenterWidget)1 View (com.gwtplatform.mvp.client.View)1 RevealRootPopupContentEvent (com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent)1 Date (java.sql.Date)1 Collection (java.util.Collection)1