@Test(expected = AccessDeniedException.class) public void testParseNotFound() throws Exception { new WsFtpBookmarkCollection().read(new ProtocolFactory(), new Local(System.getProperty("java.io.tmpdir"), "f")); }
protected void read(final ProtocolFactory protocols, Local file) throws AccessDeniedException { try (final BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { Host current = null; String line; while((line = in.readLine()) != null) { log.trace(line); if(line.startsWith("[")) { this.add(current); current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if(matcher.matches()) { current.setNickname(matcher.group(1)); } } else if(StringUtils.isBlank(line)) { this.add(current); } else { if(null == current) { log.warn("Failed to detect start of bookmark"); continue; } this.parse(protocols, current, line); } } } catch(IOException e) { log.error(e.getMessage()); } }
WsFtpBookmarkCollection extends ThirdpartyBookmarkCollection { protected void read(final ProtocolFactory protocols, Local file) throws AccessDeniedException { try (final BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { Host current = null; String line; while((line = in.readLine()) != null) { log.trace(line); if(line.startsWith("[")) { this.add(current); current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if(matcher.matches()) { current.setNickname(matcher.group(1)); } } else if(StringUtils.isBlank(line)) { this.add(current); } else { if(null == current) { log.warn("Failed to detect start of bookmark"); continue; } this.parse(protocols, current, line); } } } catch(IOException e) { log.error(e.getMessage()); } } }
WsFtpBookmarkCollection extends ThirdpartyBookmarkCollection { protected void read(final ProtocolFactory protocols, Local file) throws AccessDeniedException { try (final BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { Host current = null; String line; while((line = in.readLine()) != null) { log.trace(line); if(line.startsWith("[")) { this.add(current); current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if(matcher.matches()) { current.setNickname(matcher.group(1)); } } else if(StringUtils.isBlank(line)) { this.add(current); } else { if(null == current) { log.warn("Failed to detect start of bookmark"); continue; } this.parse(protocols, current, line); } } } catch(IOException e) { log.error(e.getMessage()); } }  }
WsFtpBookmarkCollection extends ThirdpartyBookmarkCollection { protected void read(final ProtocolFactory protocols, Local file) throws AccessDeniedException { try (final BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { Host current = null; String line; while((line = in.readLine()) != null) { log.trace(line); if(line.startsWith("[")) { this.add(current); current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if(matcher.matches()) { current.setNickname(matcher.group(1)); } } else if(StringUtils.isBlank(line)) { this.add(current); } else { if(null == current) { log.warn("Failed to detect start of bookmark"); continue; } this.parse(protocols, current, line); } } } catch(IOException e) { log.error(e.getMessage()); } }  @Override String getBundleIdentifier(); @Override String getName(); @Override Local getFile(); @Override boolean add(Host bookmark); }
WsFtpBookmarkCollection extends ThirdpartyBookmarkCollection { protected void read(final ProtocolFactory protocols, Local file) throws AccessDeniedException { try (final BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { Host current = null; String line; while((line = in.readLine()) != null) { log.trace(line); if(line.startsWith("[")) { this.add(current); current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if(matcher.matches()) { current.setNickname(matcher.group(1)); } } else if(StringUtils.isBlank(line)) { this.add(current); } else { if(null == current) { log.warn("Failed to detect start of bookmark"); continue; } this.parse(protocols, current, line); } } } catch(IOException e) { log.error(e.getMessage()); } }  @Override String getBundleIdentifier(); @Override String getName(); @Override Local getFile(); @Override boolean add(Host bookmark);  }