private void crawl ( File path ) { File [ ] contents = path . listFiles ( FileUtil . getFileFilter ( ) ) ; if ( contents != null ) { Arrays . sort ( contents ) ; for ( File sourceFile : contents ) { if ( sourceFile . isFile ( ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Processing [" ) . append ( sourceFile . getPath ( ) ) . append ( "]... " ) ; String sha1 = buildHash ( sourceFile ) ; String uri = buildURI ( sourceFile ) ; boolean process = true ; DocumentStatus status = DocumentStatus . NEW ; for ( String docType : DocumentTypes . getDocumentTypes ( ) ) { status = findDocumentStatus ( docType , uri , sha1 ) ; if ( status == DocumentStatus . UPDATED ) { sb . append ( " : modified " ) ; db . deleteContent ( docType , uri ) ; } else if ( status == DocumentStatus . IDENTICAL ) { sb . append ( " : same " ) ; process = false ; } if ( ! process ) { break ; } } if ( DocumentStatus . NEW == status ) { sb . append ( " : new " ) ; } if ( process ) { // new or updated crawlSourceFile ( sourceFile , sha1 , uri ) ; } LOGGER . info ( "{}" , sb ) ; } if ( sourceFile . isDirectory ( ) ) { crawl ( sourceFile ) ; } } } }
Crawl all files and folders looking for content .