22
33import com .ithit .webdav .server .HierarchyItem ;
44import com .ithit .webdav .server .Logger ;
5- import com .ithit .webdav .server .exceptions .ServerException ;
65import com .ithit .webdav .server .search .SearchOptions ;
76import org .apache .commons .lang .StringEscapeUtils ;
87import org .apache .lucene .analysis .TokenStream ;
@@ -95,14 +94,14 @@ private class IndexTask extends TimerTask {
9594 */
9695 @ Override
9796 public void run () {
98- List <HierarchyItem > filesToIndex = new ArrayList <>();
99- File data = new File (dataFolder );
100- StandardAnalyzer standardAnalyzer = new StandardAnalyzer ();
101- searcher = new Searcher (indexFolder , standardAnalyzer , logger );
102- getFilesToIndex (data .listFiles (), filesToIndex , dataFolder );
10397 ForkJoinPool forkJoinPool = new ForkJoinPool (4 );
10498 Directory fsDir ;
10599 try {
100+ List <HierarchyItem > filesToIndex = new ArrayList <>();
101+ File data = new File (dataFolder );
102+ StandardAnalyzer standardAnalyzer = new StandardAnalyzer ();
103+ searcher = new Searcher (indexFolder , standardAnalyzer , logger );
104+ getFilesToIndex (data .listFiles (), filesToIndex , dataFolder );
106105 fsDir = FSDirectory .open (Paths .get (indexFolder ));
107106 IndexWriterConfig conf = new IndexWriterConfig (standardAnalyzer );
108107 conf .setOpenMode (IndexWriterConfig .OpenMode .CREATE_OR_APPEND );
@@ -164,7 +163,7 @@ private void addFileToTheList(List<HierarchyItem> result, String dataFolder, Fil
164163 context += "/" ;
165164 }
166165 result .add (engine .getHierarchyItem (context ));
167- } catch (Exception e ) {
166+ } catch (Throwable e ) {
168167 logger .logDebug ("Cannot add file to the list: " + f .getAbsolutePath ());
169168 }
170169 }
@@ -217,7 +216,7 @@ protected void compute() {
217216 for (HierarchyItem f : files ) {
218217 try {
219218 indexFile (f .getName (), f .getPath (), null , f );
220- } catch (ServerException e ) {
219+ } catch (Throwable e ) {
221220 logger .logDebug ("Cannot find path for this file." );
222221 }
223222 }
@@ -280,7 +279,7 @@ void indexFile(String fileName, String currentPath, String oldPath, HierarchyIte
280279 void stop () {
281280 try {
282281 indexWriter .close ();
283- } catch (IOException e ) {
282+ } catch (Throwable e ) {
284283 logger .logError ("Cannot release index resources" , e );
285284 }
286285 }
@@ -293,7 +292,7 @@ void stop() {
293292 void deleteIndex (HierarchyItem file ) {
294293 try {
295294 indexWriter .deleteDocuments (new Term (PATH , file .getPath ()));
296- } catch (Exception e ) {
295+ } catch (Throwable e ) {
297296 logger .logError ("Cannot delete index for the file." , e );
298297 }
299298 }
@@ -324,7 +323,7 @@ static class CommitTask extends TimerTask {
324323 public void run () {
325324 try {
326325 indexWriter .commit ();
327- } catch (IOException e ) {
326+ } catch (Throwable e ) {
328327 logger .logError ("Cannot commit." , e );
329328 }
330329 }
@@ -403,7 +402,7 @@ Map<String, String> search(String searchLine, SearchOptions options, String pare
403402 if (options .isSearchName ()) {
404403 paths .putAll (searchName (searchLine , parent ));
405404 }
406- } catch (Exception e ) {
405+ } catch (Throwable e ) {
407406 logger .logError ("Error while doing index search." , e );
408407 }
409408 return paths ;
@@ -435,7 +434,7 @@ private Map<String, String> searchWithSnippet(IndexReader indexReader, Query que
435434 Highlighter highlighter = new Highlighter (htmlFormatter , queryScorer );
436435 highlighter .setTextFragmenter (fragmenter );
437436
438- ScoreDoc scoreDocs [] = indexSearcher .search (query , 100 ).scoreDocs ;
437+ ScoreDoc [] scoreDocs = indexSearcher .search (query , 100 ).scoreDocs ;
439438 Map <String , String > result = new LinkedHashMap <>();
440439 for (ScoreDoc scoreDoc : scoreDocs ) {
441440 Document document = indexSearcher .doc (scoreDoc .doc );
0 commit comments