@Test public void testCheckPresentForWrongInput() throws Exception { CachedDownloads cachedDownloads = new CachedDownloads("null", extractor, appContext); cachedDownloads.buildLocalIndex(); }
public synchronized void buildLocalIndex() { for (String dir : directories) { try { if (dir != null) { try { dir = dir.trim(); if (!dir.isEmpty() && Files.exists(Paths.get(dir))) { logger.info("Scanning directory [{}] for barcode - ", dir); AtomicInteger counter = new AtomicInteger(0); Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final String filename = path.getFileName().toString(); if (filename.endsWith(".pdf")) { add(extractor.extractFromPdf(filename), path); counter.incrementAndGet(); } return CONTINUE; } }); logger.info("Total files processed from directory [{}] = {}", dir, counter.get()); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } try { commitChanges(); } catch (IOException e) { e.printStackTrace(); } cacheReady = true; notifyAll(); }
CachedDownloads { public synchronized void buildLocalIndex() { for (String dir : directories) { try { if (dir != null) { try { dir = dir.trim(); if (!dir.isEmpty() && Files.exists(Paths.get(dir))) { logger.info("Scanning directory [{}] for barcode - ", dir); AtomicInteger counter = new AtomicInteger(0); Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final String filename = path.getFileName().toString(); if (filename.endsWith(".pdf")) { add(extractor.extractFromPdf(filename), path); counter.incrementAndGet(); } return CONTINUE; } }); logger.info("Total files processed from directory [{}] = {}", dir, counter.get()); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } try { commitChanges(); } catch (IOException e) { e.printStackTrace(); } cacheReady = true; notifyAll(); } }
CachedDownloads { public synchronized void buildLocalIndex() { for (String dir : directories) { try { if (dir != null) { try { dir = dir.trim(); if (!dir.isEmpty() && Files.exists(Paths.get(dir))) { logger.info("Scanning directory [{}] for barcode - ", dir); AtomicInteger counter = new AtomicInteger(0); Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final String filename = path.getFileName().toString(); if (filename.endsWith(".pdf")) { add(extractor.extractFromPdf(filename), path); counter.incrementAndGet(); } return CONTINUE; } }); logger.info("Total files processed from directory [{}] = {}", dir, counter.get()); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } try { commitChanges(); } catch (IOException e) { e.printStackTrace(); } cacheReady = true; notifyAll(); } CachedDownloads(String directories, BarcodeExtractor extractor, AppContext appContext); }
CachedDownloads { public synchronized void buildLocalIndex() { for (String dir : directories) { try { if (dir != null) { try { dir = dir.trim(); if (!dir.isEmpty() && Files.exists(Paths.get(dir))) { logger.info("Scanning directory [{}] for barcode - ", dir); AtomicInteger counter = new AtomicInteger(0); Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final String filename = path.getFileName().toString(); if (filename.endsWith(".pdf")) { add(extractor.extractFromPdf(filename), path); counter.incrementAndGet(); } return CONTINUE; } }); logger.info("Total files processed from directory [{}] = {}", dir, counter.get()); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } try { commitChanges(); } catch (IOException e) { e.printStackTrace(); } cacheReady = true; notifyAll(); } CachedDownloads(String directories, BarcodeExtractor extractor, AppContext appContext); synchronized void awaitCache(); synchronized void buildLocalIndex(); synchronized void add(String barcode, Path path); synchronized void commitChanges(); }
CachedDownloads { public synchronized void buildLocalIndex() { for (String dir : directories) { try { if (dir != null) { try { dir = dir.trim(); if (!dir.isEmpty() && Files.exists(Paths.get(dir))) { logger.info("Scanning directory [{}] for barcode - ", dir); AtomicInteger counter = new AtomicInteger(0); Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final String filename = path.getFileName().toString(); if (filename.endsWith(".pdf")) { add(extractor.extractFromPdf(filename), path); counter.incrementAndGet(); } return CONTINUE; } }); logger.info("Total files processed from directory [{}] = {}", dir, counter.get()); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } try { commitChanges(); } catch (IOException e) { e.printStackTrace(); } cacheReady = true; notifyAll(); } CachedDownloads(String directories, BarcodeExtractor extractor, AppContext appContext); synchronized void awaitCache(); synchronized void buildLocalIndex(); synchronized void add(String barcode, Path path); synchronized void commitChanges();  }