Search in sources :

Example 6 with AuditLog

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

the class EventListModel method refreshModel.

protected void refreshModel() {
    AsyncQuery<QueryReturnValue> query = new AsyncQuery<>(returnValue -> {
        List<AuditLog> newEvents = returnValue.getReturnValue();
        List<AuditLog> currentEvents = (List<AuditLog>) getItems();
        if (isDisplayEventsOnly()) {
            newEvents = newEvents.stream().filter(e -> e.getSeverity() != AuditLogSeverity.ALERT).collect(Collectors.toList());
        }
        if (!newEvents.isEmpty() && currentEvents != null && (currentEvents.isEmpty() || !currentEvents.get(0).equals(newEvents.get(0)))) {
            // We received some new events, tell the active models to update.
            RefreshActiveModelEvent.fire(EventListModel.this, false);
        }
        EventListModel.this.setItems(newEvents);
        EventListModel.this.setLastEvent(Linq.firstOrNull(newEvents));
    });
    SearchParameters params = new SearchParameters(applySortOptions(getSearchString()), SearchType.AuditLog, isCaseSensitiveSearch());
    params.setMaxCount(getSearchPageSize());
    params.setRefresh(false);
    Frontend.getInstance().runQuery(QueryType.Search, params, query);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) List(java.util.List) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 7 with AuditLog

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

the class RemoveAuditLogByIdCommand method executeCommand.

@Override
protected void executeCommand() {
    AuditLog auditLog = getAuditLog();
    auditLogDao.remove(getParameters().getAuditLogId());
    setAuditLogDetails(auditLog);
    // clear the id so the auditLog will be considered as a system-level auditLog
    auditLog.setUserId(Guid.Empty);
    AuditLogable logableToClear = createAuditLogableImpl(auditLog);
    // clean cache manager entry (if exists)
    EventFloodRegulator eventFloodRegulator = new EventFloodRegulator(logableToClear, auditLog.getLogType());
    eventFloodRegulator.evict();
    setSucceeded(true);
}
Also used : EventFloodRegulator(org.ovirt.engine.core.dal.dbbroker.auditloghandling.EventFloodRegulator) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 8 with AuditLog

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

the class EventMapper method map.

@Mapping(from = Event.class, to = AuditLog.class)
public static AuditLog map(Event event, AuditLog entity) {
    AuditLog auditLog = (entity != null) ? entity : new AuditLog();
    AuditLogSeverity severity = map(event.getSeverity(), null);
    if (severity != null) {
        auditLog.setSeverity(severity);
    }
    auditLog.setLogTime(event.isSetTime() ? event.getTime().toGregorianCalendar().getTime() : new Date(Calendar.getInstance().getTimeInMillis()));
    auditLog.setMessage(event.getDescription());
    if (event.isSetUser() && event.getUser().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getUser().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setUserId(guid);
        }
    }
    if (event.isSetVm() && event.getVm().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getVm().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVmId(guid);
        }
    }
    if (event.isSetStorageDomain() && event.getStorageDomain().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getStorageDomain().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setStorageDomainId(guid);
        }
    }
    if (event.isSetHost() && event.getHost().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getHost().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVdsId(guid);
        }
    }
    if (event.isSetTemplate() && event.getTemplate().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getTemplate().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVmTemplateId(guid);
        }
    }
    if (event.isSetCluster() && event.getCluster().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getCluster().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setClusterId(guid);
        }
    }
    if (event.isSetDataCenter() && event.getDataCenter().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getDataCenter().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setStoragePoolId(guid);
        }
    }
    if (event.isSetCorrelationId()) {
        auditLog.setCorrelationId(event.getCorrelationId());
    }
    if (event.isSetOrigin()) {
        auditLog.setOrigin(event.getOrigin());
    }
    if (event.isSetCustomId()) {
        auditLog.setCustomEventId(event.getCustomId());
    }
    if (event.isSetFloodRate()) {
        auditLog.setEventFloodInSec(event.getFloodRate());
    }
    if (event.isSetCustomData()) {
        auditLog.setCustomData(event.getCustomData());
    }
    return auditLog;
}
Also used : AuditLogSeverity(org.ovirt.engine.core.common.AuditLogSeverity) Guid(org.ovirt.engine.core.compat.Guid) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Date(java.sql.Date)

Example 9 with AuditLog

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

the class AuditLogDirector method saveToDb.

private AuditLog saveToDb(AuditLogable auditLogable, AuditLogType logType, String loggerString) {
    AuditLog auditLog = create(auditLogable, logType, loggerString);
    if (auditLog == null) {
        return null;
    }
    auditLogable.setPropertiesForAuditLog(auditLog);
    // truncate user name
    auditLog.setUserName(StringUtils.abbreviate(auditLog.getUserName(), USERNAME_LENGTH));
    TransactionSupport.executeInNewTransaction(() -> {
        auditLogDao.save(auditLog);
        return null;
    });
    return auditLog;
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 10 with AuditLog

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

the class AuditLogDaoTest method testSave.

/**
 * Ensures that saving a AuditLog works as expected.
 */
@Test
public void testSave() {
    dao.save(newAuditLog);
    AuditLog result = dao.get(newAuditLog.getAuditLogId());
    assertNotNull(result);
    assertEquals(newAuditLog, result);
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Test(org.junit.Test)

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