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