@Test public void testFind() throws Exception { final Host host = new Host(new TestProtocol()); assertNull(host.getDownloadFolder()); final DownloadDirectoryFinder finder = new DownloadDirectoryFinder(); assertEquals(System.getProperty("user.dir"), finder.find(host).getAbsolute()); host.setDownloadFolder(new Local(String.format("/%s", UUID.randomUUID()))); assertEquals(System.getProperty("user.dir"), finder.find(host).getAbsolute()); final Local folder = new Local("~/Documents"); new DefaultLocalDirectoryFeature().mkdir(folder); host.setDownloadFolder(folder); assertEquals(String.format("~%sDocuments", PreferencesFactory.get().getProperty("local.delimiter")), finder.find(host).getAbbreviatedPath()); }
@Override public Local find(final Host bookmark) { if(null != bookmark.getDownloadFolder()) { if(bookmark.getDownloadFolder().exists()) { return bookmark.getDownloadFolder(); } } final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark( preferences.getProperty("queue.download.folder.bookmark")); if(log.isInfoEnabled()) { log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark)); } return directory; }
DownloadDirectoryFinder implements DirectoryFinder { @Override public Local find(final Host bookmark) { if(null != bookmark.getDownloadFolder()) { if(bookmark.getDownloadFolder().exists()) { return bookmark.getDownloadFolder(); } } final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark( preferences.getProperty("queue.download.folder.bookmark")); if(log.isInfoEnabled()) { log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark)); } return directory; } }
DownloadDirectoryFinder implements DirectoryFinder { @Override public Local find(final Host bookmark) { if(null != bookmark.getDownloadFolder()) { if(bookmark.getDownloadFolder().exists()) { return bookmark.getDownloadFolder(); } } final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark( preferences.getProperty("queue.download.folder.bookmark")); if(log.isInfoEnabled()) { log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark)); } return directory; }  }
DownloadDirectoryFinder implements DirectoryFinder { @Override public Local find(final Host bookmark) { if(null != bookmark.getDownloadFolder()) { if(bookmark.getDownloadFolder().exists()) { return bookmark.getDownloadFolder(); } } final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark( preferences.getProperty("queue.download.folder.bookmark")); if(log.isInfoEnabled()) { log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark)); } return directory; }  @Override Local find(final Host bookmark); @Override void save(final Host bookmark, final Local directory); }
DownloadDirectoryFinder implements DirectoryFinder { @Override public Local find(final Host bookmark) { if(null != bookmark.getDownloadFolder()) { if(bookmark.getDownloadFolder().exists()) { return bookmark.getDownloadFolder(); } } final Local directory = LocalFactory.get(preferences.getProperty("queue.download.folder")).withBookmark( preferences.getProperty("queue.download.folder.bookmark")); if(log.isInfoEnabled()) { log.info(String.format("Suggest default download folder %s for bookmark %s", directory, bookmark)); } return directory; }  @Override Local find(final Host bookmark); @Override void save(final Host bookmark, final Local directory);  }