use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.
the class AuditHelperImpl method addCreateAuditEvent.
@Override
public AuditEvent addCreateAuditEvent(Auditable auditable, String note, User user) {
this.addAuditTrailIfNeeded(auditable);
assert auditable.getAuditTrail() != null;
assert auditable.getAuditTrail().getEvents().size() == 0;
AuditEvent auditEvent = AuditEvent.Factory.newInstance(new Date(), AuditAction.CREATE, note, null, user, null);
return this.tryUpdate(auditable, auditEvent);
}
use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.
the class AuditTrailServiceImpl method addUpdateEvent.
/**
* This method creates a new event in the audit trail of the passed Auditable object. If this object also implements
* the {@link Curatable} interface, and the passed auditEventType is one of the extensions of
* {@link CurationDetailsEvent} AuditEventType, this method will pass its result to
* {@link CurationDetailsService#update(Curatable, AuditEvent)}, to update the curatable objects curation details,
* before returning it.
*
* @param auditable the auditable object to whose audit trail should a new event be added.
* @param auditEventType the type of the event that should be created.
* @param note string displayed as a note for the event
* @param detail detailed description of the event.
* @return the new AuditEvent that was created in the audit trail of the given auditable object.
* @see AuditTrailService#addUpdateEvent(Auditable, AuditEventType, String, String)
*/
@Override
@Transactional
public AuditEvent addUpdateEvent(final Auditable auditable, final AuditEventType auditEventType, final String note, final String detail) {
// Create new audit event
AuditEvent auditEvent = AuditEvent.Factory.newInstance(new Date(), AuditAction.UPDATE, note, detail, null, auditEventType);
auditEvent = this.auditTrailDao.addEvent(auditable, auditEvent);
// If object is curatable, update curation details
if (auditable instanceof Curatable && auditEvent != null && auditEvent.getEventType() != null) {
curationDetailsService.update((Curatable) auditable, auditEvent);
}
// return the newly created event
return auditEvent;
}
use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.
the class AuditController method addAuditEvent.
@SuppressWarnings("unchecked")
public void addAuditEvent(EntityDelegator e, String auditEventType, String comment, String detail) {
AbstractAuditable entity = this.getAuditable(e);
if (entity == null) {
AuditController.log.warn("Couldn't find Auditable represented by " + e);
return;
}
Class<?> clazz;
try {
clazz = Class.forName("ubic.gemma.model.common.auditAndSecurity.eventType." + auditEventType);
} catch (ClassNotFoundException e1) {
throw new RuntimeException("Unknown event type: " + auditEventType);
}
AuditEvent auditEvent = auditTrailService.addUpdateEvent(entity, (Class<? extends AuditEventType>) clazz, comment, detail);
if (auditEvent == null) {
AuditController.log.error("Persisting the audit event failed! On auditable id " + entity.getId());
} else {
AuditController.log.info("created new event: " + auditEvent);
}
}
use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.
the class AuditController method getEvents.
public Collection<AuditEventValueObject> getEvents(EntityDelegator e) {
Collection<AuditEventValueObject> result = new HashSet<>();
Auditable entity = this.getAuditable(e);
if (entity == null) {
return result;
}
assert entity.getAuditTrail().getId() != null;
Collection<AuditEvent> events = auditEventService.getEvents(entity);
for (AuditEvent ev : events) {
if (ev == null)
continue;
/*
* Hide generic update events.
*/
if (ev.getAction().equals(AuditAction.UPDATE) && ev.getEventType() == null)
continue;
result.add(new AuditEventValueObject(ev));
}
return result;
}
Aggregations