private void setAccountId ( CloudTrailEventData eventData ) { if ( eventData . getRecipientAccountId ( ) != null ) { eventData . add ( "accountId" , eventData . getRecipientAccountId ( ) ) ; return ; } if ( eventData . getUserIdentity ( ) != null && eventData . getUserIdentity ( ) . getAccountId ( ) != null ) { eventData . add ( "accountId" , eventData . getUserIdentity ( ) . getAccountId ( ) ) ; return ; } if ( eventData . getUserIdentity ( ) != null && eventData . getUserIdentity ( ) . getAccountId ( ) == null && eventData . getUserIdentity ( ) . getSessionContext ( ) != null && eventData . getUserIdentity ( ) . getSessionContext ( ) . getSessionIssuer ( ) != null && eventData . getUserIdentity ( ) . getSessionContext ( ) . getSessionIssuer ( ) . getAccountId ( ) != null ) { eventData . add ( "accountId" , eventData . getUserIdentity ( ) . getSessionContext ( ) . getSessionIssuer ( ) . getAccountId ( ) ) ; } }
Set AccountId in CloudTrailEventData top level from either recipientAccountID or from UserIdentity . If recipientAccountID exists then recipientAccountID is set to accountID ; otherwise accountID is retrieved from UserIdentity .