@ Override public AuditEvent transformToEvent ( AnnotationAuditEvent annotationEvent ) { AuditEvent event = null ; if ( annotationEvent . getClazz ( ) . isAnnotationPresent ( Audit . class ) && ! annotationEvent . getMethod ( ) . isAnnotationPresent ( IgnoreAudit . class ) ) { event = new AuditEvent ( ) ; Audit audit = annotationEvent . getClazz ( ) . getAnnotation ( Audit . class ) ; // Extract fields event . setFields ( getFields ( annotationEvent . getMethod ( ) , annotationEvent . getArgs ( ) ) ) ; // Extract Actor String annotationAction = audit . action ( ) ; if ( ACTION . equals ( annotationAction ) ) { event . setAction ( annotationEvent . getMethod ( ) . getName ( ) ) ; } else { event . setAction ( annotationAction ) ; } // Extract repository event . setRepository ( audit . repository ( ) ) ; event . setActor ( annotationEvent . getActor ( ) ) ; event . setOrigin ( annotationEvent . getOrigin ( ) ) ; } else if ( ! annotationEvent . getClazz ( ) . isAnnotationPresent ( Audit . class ) && annotationEvent . getMethod ( ) . isAnnotationPresent ( Audit . class ) ) { event = new AuditEvent ( ) ; Audit audit = annotationEvent . getMethod ( ) . getAnnotation ( Audit . class ) ; // Extract fields event . setFields ( getFields ( annotationEvent . getMethod ( ) , annotationEvent . getArgs ( ) ) ) ; // Extract Actor String annotationAction = audit . action ( ) ; if ( ACTION . equals ( annotationAction ) ) { event . setAction ( annotationEvent . getMethod ( ) . getName ( ) ) ; } else { event . setAction ( annotationAction ) ; } // Extract repository event . setRepository ( audit . repository ( ) ) ; event . setActor ( annotationEvent . getActor ( ) ) ; event . setOrigin ( annotationEvent . getOrigin ( ) ) ; } return event ; }
Transform annotation informations to Audit Event object .