private boolean matchAndwriteOneAuditLog(BufferedWriter writer,AuditLog auditlog,String keyword) throws MarshallingExcetion {
  try {
    AuditLogUtils.resetDesc(auditlog,resb);
    if (AuditLogUtils.isKeywordContained(auditlog,keyword)) {
      if (_count.getAndIncrement() > 0) {
        while (!_firstWritten.get()) {
          try {
            Thread.sleep(1);
          }
 catch (          InterruptedException e) {
            _logger.warn("Sleep interrupted");
          }
        }
        writer.write("," + _mapper.writeValueAsString(auditlog));
      }
 else {
        writer.write(_mapper.writeValueAsString(auditlog));
        _firstWritten.set(true);
      }
      return true;
    }
    _logger.debug("{} filter out by description keyword {}",auditlog.getDescription(),keyword);
    return false;
  }
 catch (  JsonGenerationException e) {
    throw new MarshallingExcetion("JSON Generation Error",e);
  }
catch (  JsonMappingException e) {
    throw new MarshallingExcetion("JSON Mapping Error",e);
  }
catch (  IOException e) {
    throw new MarshallingExcetion("JSON streaming failed: ",e);
  }
}

private boolean matchAndwriteOneAuditLog ( BufferedWriter writer , AuditLog auditlog , String keyword ) throws MarshallingExcetion { try { AuditLogUtils . resetDesc ( auditlog , resb ) ; if ( AuditLogUtils . isKeywordContained ( auditlog , keyword ) ) { if ( _count . getAndIncrement ( ) > 0 ) { while ( ! _firstWritten . get ( ) ) { try { Thread . sleep ( 1 ) ; } catch ( InterruptedException e ) { _logger . warn ( "Sleep interrupted" ) ; } } writer . write ( "," + _mapper . writeValueAsString ( auditlog ) ) ; } else { writer . write ( _mapper . writeValueAsString ( auditlog ) ) ; _firstWritten . set ( true ) ; } return true ; } _logger . debug ( "{} filter out by description keyword {}" , auditlog . getDescription ( ) , keyword ) ; return false ; } catch ( JsonGenerationException e ) { throw new MarshallingExcetion ( "JSON Generation Error" , e ) ; } catch ( JsonMappingException e ) { throw new MarshallingExcetion ( "JSON Mapping Error" , e ) ; } catch ( IOException e ) { throw new MarshallingExcetion ( "JSON streaming failed: " , e ) ; } }
match if auditlog description contains expected keyword , stream out the auditlog if matched , otherwise ignore this one piece of auditlog . since the streaming format for the first auditlog is slightly different from all the rest of auditlogs , this method uses a boolean to block auditlog being streamed until the first auditlog is streamed by a thread .
