private void verify ( final Task < Diff > task , final Diff decodedDiff , final Diff originalDiff ) throws SQLConsumerException { String orig = originalDiff . toString ( ) ; String deco = decodedDiff . toString ( ) ; boolean notEqual = ! orig . equals ( deco ) ; if ( notEqual && MODE_SURROGATES == SurrogateModes . REPLACE ) { char [ ] origDiff = orig . toCharArray ( ) ; // TODO: test if ( Surrogates . scan ( origDiff ) ) { String repDiff = new String ( Surrogates . replace ( origDiff ) ) ; notEqual = ! repDiff . equals ( deco ) ; } } if ( notEqual ) { if ( MODE_DEBUG_OUTPUT_ACTIVATED ) { try { // System.out.println("DEBUG\t" + task.toString()); WikipediaXMLWriter writer = new WikipediaXMLWriter ( LOGGING_PATH_DIFFTOOL + LOGGING_PATH_DEBUG + task . getHeader ( ) . getArticleName ( ) + ".dbg" ) ; switch ( task . getTaskType ( ) ) { case TASK_FULL : case TASK_PARTIAL_FIRST : writer . writeDiff ( task ) ; break ; case TASK_PARTIAL : case TASK_PARTIAL_LAST : { int revCount = originalDiff . getRevisionCounter ( ) ; Diff d ; boolean fullRev = false ; for ( int diffCount = 0 ; ! fullRev && diffCount < originalDiff . size ( ) ; diffCount ++ ) { d = task . get ( diffCount ) ; if ( d . getRevisionCounter ( ) <= revCount && d . isFullRevision ( ) ) { fullRev = true ; writer . writeDiff ( task , diffCount ) ; } } if ( ! fullRev ) { writer . writeDiffFile ( task ) ; } } break ; default : throw new IOException ( "Unknown TaskType" ) ; // TODO: Debug output } writer . close ( ) ; } catch ( IOException e ) { ConsumerLogMessages . logException ( logger , e ) ; } } throw ErrorFactory . createSQLConsumerException ( ErrorKeys . DIFFTOOL_SQLCONSUMER_ENCODING_VERIFICATION_FAILED , "Redecoding of " + task . getHeader ( ) . getArticleName ( ) + " failed at revision " + originalDiff . getRevisionCounter ( ) + "." ) ; } }
Verifies that the decoded diff is identical to the original diff .