@ Override public boolean clearDocuments ( ) throws DocumentException { File internalFolder = new File ( this . getDocumentsInternalPath ( ) ) ; File [ ] files = internalFolder . listFiles ( ) ; for ( File file : files ) { if ( file . isDirectory ( ) ) { try { FileUtils . deleteDirectory ( file ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw new DocumentException ( "Unable to delete " + file . getAbsolutePath ( ) ) ; } log . info ( "Folder deleted: {}" , file . getAbsolutePath ( ) ) ; } else { boolean deleted = file . delete ( ) ; if ( deleted ) { log . info ( "File deleted: {}" , file . getAbsolutePath ( ) ) ; } else { log . warn ( "Unable to delete file: {}" , file . getAbsolutePath ( ) ) ; } } } // Clear media types index File mapFile = new File ( URI . create ( new StringBuilder ( documentsInternalPath . toString ( ) ) . append ( "/" + MEDIA_TYPE_INDEX ) . toString ( ) ) ) ; if ( mapFile . exists ( ) ) { mapFile . delete ( ) ; } fileMediatypeMap . clear ( ) ; // Generate Event this . getEventBus ( ) . post ( new DocumentsClearedEvent ( new Date ( ) ) ) ; return true ; }
Deletes all the documents in iServe