@Audit(action = Audit.Action.UPDATE, logStatement = "Updated value (for id: {0}): {1}", logExpressions = {"${auditEntity.id}", "${auditEntity.value}"}) public String getValue() { return value; }
/** * Construct a log message from an Audit annotation and the record that was updated in some way. * @param audit - The annotation containing the type of operation (UPDATE, DELETE, CREATE) * @param record - The modified record * @param changeSpec - Change spec of modified elements (if logging object change). empty otherwise * @throws InvalidSyntaxException if the Audit annotation has invalid syntax. */ public LogMessage(Audit audit, PersistentResource record, Optional<ChangeSpec> changeSpec) throws InvalidSyntaxException { this(audit.logStatement(), record, audit.logExpressions(), audit.operation(), changeSpec); }
/** * Audit an action on field. * * @param changeSpec Change spec for audit */ protected void auditField(final ChangeSpec changeSpec) { final String fieldName = changeSpec.getFieldName(); Audit[] annotations = dictionary.getAttributeOrRelationAnnotations(getResourceClass(), Audit.class, fieldName ); if (annotations == null || annotations.length == 0) { // Default to class-level annotation for action auditClass(Audit.Action.UPDATE, changeSpec); return; } for (Audit annotation : annotations) { if (annotation.action().length == 1 && annotation.action()[0] == Audit.Action.UPDATE) { LogMessage message = new LogMessage(annotation, this, Optional.of(changeSpec)); getRequestScope().getAuditLogger().log(message); } else { throw new InvalidSyntaxException("Only Audit.Action.UPDATE is allowed on fields."); } } }
/** * Audit an action on an entity. * * @param action the action * @param changeSpec the change that occurred */ protected void auditClass(Audit.Action action, ChangeSpec changeSpec) { Audit[] annotations = getResourceClass().getAnnotationsByType(Audit.class); if (annotations == null) { return; } for (Audit annotation : annotations) { for (Audit.Action auditAction : annotation.action()) { if (auditAction == action) { // compare object reference LogMessage message = new LogMessage(annotation, this, Optional.ofNullable(changeSpec)); getRequestScope().getAuditLogger().log(message); } } } }
/** * Construct a log message from an Audit annotation and the record that was updated in some way. * @param audit - The annotation containing the type of operation (UPDATE, DELETE, CREATE) * @param record - The modified record * @param changeSpec - Change spec of modified elements (if logging object change). empty otherwise * @throws InvalidSyntaxException if the Audit annotation has invalid syntax. */ public LogMessage(Audit audit, PersistentResource record, Optional<ChangeSpec> changeSpec) throws InvalidSyntaxException { this(audit.logStatement(), record, audit.logExpressions(), audit.operation(), changeSpec); }
@OneToOne @Audit(action = Audit.Action.UPDATE, logStatement = "Updated relationship (for id: {0}): {1}", logExpressions = {"${auditEntity.id}", "${auditEntity.otherEntity.id}"}) public AuditEntity getOtherEntity() { return otherEntity; }
/** * Audit an action on field. * * @param changeSpec Change spec for audit */ protected void auditField(final ChangeSpec changeSpec) { final String fieldName = changeSpec.getFieldName(); Audit[] annotations = dictionary.getAttributeOrRelationAnnotations(getResourceClass(), Audit.class, fieldName ); if (annotations == null || annotations.length == 0) { // Default to class-level annotation for action auditClass(Audit.Action.UPDATE, changeSpec); return; } for (Audit annotation : annotations) { if (annotation.action().length == 1 && annotation.action()[0] == Audit.Action.UPDATE) { LogMessage message = new LogMessage(annotation, this, Optional.of(changeSpec)); getRequestScope().getAuditLogger().log(message); } else { throw new InvalidSyntaxException("Only Audit.Action.UPDATE is allowed on fields."); } } }
@Audit(action = Audit.Action.UPDATE, operation = 1, logStatement = "UPDATE Child {0} Parent {1}", logExpressions = {"${child.id}", "${parent.id}"} ) @Column(unique = true) public String getName() { return this.name; }
/** * Audit an action on an entity. * * @param action the action * @param changeSpec the change that occurred */ protected void auditClass(Audit.Action action, ChangeSpec changeSpec) { Audit[] annotations = getResourceClass().getAnnotationsByType(Audit.class); if (annotations == null) { return; } for (Audit annotation : annotations) { for (Audit.Action auditAction : annotation.action()) { if (auditAction == action) { // compare object reference LogMessage message = new LogMessage(annotation, this, Optional.ofNullable(changeSpec)); getRequestScope().getAuditLogger().log(message); } } } }
@ManyToMany(mappedBy = "entities") @Audit(action = Audit.Action.UPDATE, logStatement = "Entity with id {0} now has inverse list {1}", logExpressions = {"${auditEntity.id}", "${auditEntity.inverses}"}) public List<AuditEntityInverse> getInverses() { return inverses; }
@ManyToMany @Audit(action = Audit.Action.UPDATE, logStatement = "Inverse entities: {0}", logExpressions = "${auditEntityInverse.entities}") public List<AuditEntity> getEntities() { return entities; }
@SharePermission @Paginate @Audit(action = Audit.Action.CREATE, operation = 10, logStatement = "{0}",
@Include(rootLevel = true) @SharePermission @Audit(action = Audit.Action.CREATE, operation = 10, logStatement = "{0}",
@ReadPermission(expression = "negativeChildId AND negativeIntegerUser AND initCheckOp AND initCheckFilter") @Include(rootLevel = true, type = "child") @Audit(action = Audit.Action.DELETE, operation = 0, logStatement = "DELETE Child {0} Parent {1}", logExpressions = {"${child.id}", "${parent.id}"}) @Audit(action = Audit.Action.CREATE, operation = 0, logStatement = "CREATE Child {0} Parent {1}",
@Include(rootLevel = true) @Paginate @Audit(action = Audit.Action.CREATE, operation = 10, logStatement = "{0}",
@Entity @Audit(action = Audit.Action.CREATE, logStatement = "Created with value: {0}", logExpressions = {"${auditEntity.value}"})