CrawlLogIndexer extends IndexerBase { @Override public void indexFiles(Long harvestResultOid) throws ServiceException { log.info("Generating " + sortedLogFileName + " file for " + getResult().getTargetInstanceOid()); String logPath = directory.getAbsolutePath().substring(0, directory.getAbsolutePath().length()-1); logPath = logPath + logsSubFolder + directory.separator; try { BufferedReader inputStream = new BufferedReader(new FileReader(logPath + crawlLogFileName)); PrintWriter outputStream = new PrintWriter(new FileWriter(logPath + strippedLogFileName)); String inLine = null; while ((inLine = inputStream.readLine()) != null) { outputStream.println(inLine.replaceAll(" +", " ")); } outputStream.close(); inputStream.close(); } catch (IOException e) { log.error("Could not create " + strippedLogFileName + " file in directory: " + logPath ); return; } ExternalSort sort = new ExternalSort(); try { sort.setInFile(logPath + strippedLogFileName); } catch (FileNotFoundException e1) { log.error("Could not find " + strippedLogFileName + " file in directory: " + logPath ); return; } try { sort.setOutFile(logPath + sortedLogFileName); } catch (FileNotFoundException e1) { log.error("Could not find directory: " + logPath ); return; } int[] cols = {3,0}; sort.setColumns(cols); sort.setSeparator(' '); try { sort.run(); } catch (IOException e1) { log.error("Could not sort " + crawlLogFileName + " file in directory: " + logPath ); return; } log.info("Completed sort of crawl.log for job " + getResult().getTargetInstanceOid()); } CrawlLogIndexer(); protected  CrawlLogIndexer(CrawlLogIndexer original); @Override RunnableIndex getCopy(); @Override Long begin(); @Override String getName(); @Override void indexFiles(Long harvestResultOid); @Override void removeIndex(Long harvestResultOid); @Override void initialise(ArcHarvestResultDTO result, File directory); void setCrawlLogFileName(String crawlLogFileName); String getCrawlLogFileName(); void setStrippedLogFileName(String strippedLogFileName); String getStrippedLogFileName(); void setSortedLogFileName(String sortedLogFileName); String getSortedLogFileName(); void setLogsSubFolder(String logsSubFolder); String getLogsSubFolder(); void setEnabled(boolean enabled); @Override boolean isEnabled();  }
@Test public final void testIndexFiles() { try { Long hrOid = testInstance.begin(); testInstance.indexFiles(hrOid); File[] files = logsFolder.listFiles(); assertEquals(3, files.length); } catch(Exception e) { fail(e.getMessage()); } }