@Test(expected = AccessDeniedException.class) public void testParseNotFound() throws Exception { new FetchBookmarkCollection().parse(new ProtocolFactory(Collections.emptySet()), new Local(System.getProperty("java.io.tmpdir"), "f")); }
@Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } NSDictionary dict = new PlistDeserializer(serialized).objectForKey("Shortcuts v2"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } dict = new PlistDeserializer(dict).objectForKey("Shortcuts"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } List<NSDictionary> shortcuts = new PlistDeserializer(dict).listForKey("Shortcuts"); for(NSDictionary shortcut : shortcuts) { PlistDeserializer reader = new PlistDeserializer(shortcut); NSDictionary remote = reader.objectForKey("Remote Item"); if(null == remote) { continue; } NSDictionary location = new PlistDeserializer(remote).objectForKey("Location"); if(null == location) { continue; } String url = new PlistDeserializer(location).stringForKey("URL"); if(null == url) { continue; } final Host host; try { host = new HostParser(protocols).get(url); } catch(HostParserException e) { log.warn(e); continue; } host.setNickname(reader.stringForKey("Name")); this.add(host); } }
FetchBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } NSDictionary dict = new PlistDeserializer(serialized).objectForKey("Shortcuts v2"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } dict = new PlistDeserializer(dict).objectForKey("Shortcuts"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } List<NSDictionary> shortcuts = new PlistDeserializer(dict).listForKey("Shortcuts"); for(NSDictionary shortcut : shortcuts) { PlistDeserializer reader = new PlistDeserializer(shortcut); NSDictionary remote = reader.objectForKey("Remote Item"); if(null == remote) { continue; } NSDictionary location = new PlistDeserializer(remote).objectForKey("Location"); if(null == location) { continue; } String url = new PlistDeserializer(location).stringForKey("URL"); if(null == url) { continue; } final Host host; try { host = new HostParser(protocols).get(url); } catch(HostParserException e) { log.warn(e); continue; } host.setNickname(reader.stringForKey("Name")); this.add(host); } } }
FetchBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } NSDictionary dict = new PlistDeserializer(serialized).objectForKey("Shortcuts v2"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } dict = new PlistDeserializer(dict).objectForKey("Shortcuts"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } List<NSDictionary> shortcuts = new PlistDeserializer(dict).listForKey("Shortcuts"); for(NSDictionary shortcut : shortcuts) { PlistDeserializer reader = new PlistDeserializer(shortcut); NSDictionary remote = reader.objectForKey("Remote Item"); if(null == remote) { continue; } NSDictionary location = new PlistDeserializer(remote).objectForKey("Location"); if(null == location) { continue; } String url = new PlistDeserializer(location).stringForKey("URL"); if(null == url) { continue; } final Host host; try { host = new HostParser(protocols).get(url); } catch(HostParserException e) { log.warn(e); continue; } host.setNickname(reader.stringForKey("Name")); this.add(host); } }  }
FetchBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } NSDictionary dict = new PlistDeserializer(serialized).objectForKey("Shortcuts v2"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } dict = new PlistDeserializer(dict).objectForKey("Shortcuts"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } List<NSDictionary> shortcuts = new PlistDeserializer(dict).listForKey("Shortcuts"); for(NSDictionary shortcut : shortcuts) { PlistDeserializer reader = new PlistDeserializer(shortcut); NSDictionary remote = reader.objectForKey("Remote Item"); if(null == remote) { continue; } NSDictionary location = new PlistDeserializer(remote).objectForKey("Location"); if(null == location) { continue; } String url = new PlistDeserializer(location).stringForKey("URL"); if(null == url) { continue; } final Host host; try { host = new HostParser(protocols).get(url); } catch(HostParserException e) { log.warn(e); continue; } host.setNickname(reader.stringForKey("Name")); this.add(host); } }  @Override String getBundleIdentifier(); @Override String getName(); @Override Local getFile(); }
FetchBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } NSDictionary dict = new PlistDeserializer(serialized).objectForKey("Shortcuts v2"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } dict = new PlistDeserializer(dict).objectForKey("Shortcuts"); if(null == dict) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } List<NSDictionary> shortcuts = new PlistDeserializer(dict).listForKey("Shortcuts"); for(NSDictionary shortcut : shortcuts) { PlistDeserializer reader = new PlistDeserializer(shortcut); NSDictionary remote = reader.objectForKey("Remote Item"); if(null == remote) { continue; } NSDictionary location = new PlistDeserializer(remote).objectForKey("Location"); if(null == location) { continue; } String url = new PlistDeserializer(location).stringForKey("URL"); if(null == url) { continue; } final Host host; try { host = new HostParser(protocols).get(url); } catch(HostParserException e) { log.warn(e); continue; } host.setNickname(reader.stringForKey("Name")); this.add(host); } }  @Override String getBundleIdentifier(); @Override String getName(); @Override Local getFile();  }