@Test(expected = AccessDeniedException.class) public void testParseNotFound() throws Exception { new CloudMounterBookmarkCollection().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 { final NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } final List<NSDictionary> array = new PlistDeserializer(serialized).listForKey("CustomPluginSettings"); if(null == array) { log.warn("Missing key CustomPluginSettings"); return; } for(NSDictionary dict : array) { final PlistDeserializer bookmark = new PlistDeserializer(dict); final String identifier = bookmark.stringForKey("MountFSClassName"); if(StringUtils.isBlank(identifier)) { log.warn("Missing key MountFSClassName"); continue; } final Protocol protocol; switch(identifier) { case "FtpConnection": protocol = protocols.forType(Protocol.Type.ftp); break; case "WebDAVConnection": protocol = protocols.forType(Protocol.Type.dav); break; case "OpenStackConnection": protocol = protocols.forType(Protocol.Type.swift); break; case "BBConnection": protocol = protocols.forType(Protocol.Type.b2); break; case "S3Connection": protocol = protocols.forType(Protocol.Type.s3); break; case "DropboxConnection": protocol = protocols.forType(Protocol.Type.dropbox); break; case "GDriveConnection": protocol = protocols.forType(Protocol.Type.googledrive); break; default: protocol = null; break; } if(null == protocol) { log.warn(String.format("Unable to determine protocol for %s", identifier)); continue; } final NSDictionary details = bookmark.objectForKey("MountFSOptions"); if(null == details) { continue; } final PlistDeserializer options = new PlistDeserializer(details); final String hostname = options.stringForKey("host"); if(StringUtils.isBlank(hostname)) { continue; } final Host host = new Host(protocol, hostname, new Credentials(options.stringForKey("login"))); host.setNickname(bookmark.stringForKey("MountFSLabel")); host.setDefaultPath(options.stringForKey("remotePath")); this.add(host); } }
CloudMounterBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { final NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } final List<NSDictionary> array = new PlistDeserializer(serialized).listForKey("CustomPluginSettings"); if(null == array) { log.warn("Missing key CustomPluginSettings"); return; } for(NSDictionary dict : array) { final PlistDeserializer bookmark = new PlistDeserializer(dict); final String identifier = bookmark.stringForKey("MountFSClassName"); if(StringUtils.isBlank(identifier)) { log.warn("Missing key MountFSClassName"); continue; } final Protocol protocol; switch(identifier) { case "FtpConnection": protocol = protocols.forType(Protocol.Type.ftp); break; case "WebDAVConnection": protocol = protocols.forType(Protocol.Type.dav); break; case "OpenStackConnection": protocol = protocols.forType(Protocol.Type.swift); break; case "BBConnection": protocol = protocols.forType(Protocol.Type.b2); break; case "S3Connection": protocol = protocols.forType(Protocol.Type.s3); break; case "DropboxConnection": protocol = protocols.forType(Protocol.Type.dropbox); break; case "GDriveConnection": protocol = protocols.forType(Protocol.Type.googledrive); break; default: protocol = null; break; } if(null == protocol) { log.warn(String.format("Unable to determine protocol for %s", identifier)); continue; } final NSDictionary details = bookmark.objectForKey("MountFSOptions"); if(null == details) { continue; } final PlistDeserializer options = new PlistDeserializer(details); final String hostname = options.stringForKey("host"); if(StringUtils.isBlank(hostname)) { continue; } final Host host = new Host(protocol, hostname, new Credentials(options.stringForKey("login"))); host.setNickname(bookmark.stringForKey("MountFSLabel")); host.setDefaultPath(options.stringForKey("remotePath")); this.add(host); } } }
CloudMounterBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { final NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } final List<NSDictionary> array = new PlistDeserializer(serialized).listForKey("CustomPluginSettings"); if(null == array) { log.warn("Missing key CustomPluginSettings"); return; } for(NSDictionary dict : array) { final PlistDeserializer bookmark = new PlistDeserializer(dict); final String identifier = bookmark.stringForKey("MountFSClassName"); if(StringUtils.isBlank(identifier)) { log.warn("Missing key MountFSClassName"); continue; } final Protocol protocol; switch(identifier) { case "FtpConnection": protocol = protocols.forType(Protocol.Type.ftp); break; case "WebDAVConnection": protocol = protocols.forType(Protocol.Type.dav); break; case "OpenStackConnection": protocol = protocols.forType(Protocol.Type.swift); break; case "BBConnection": protocol = protocols.forType(Protocol.Type.b2); break; case "S3Connection": protocol = protocols.forType(Protocol.Type.s3); break; case "DropboxConnection": protocol = protocols.forType(Protocol.Type.dropbox); break; case "GDriveConnection": protocol = protocols.forType(Protocol.Type.googledrive); break; default: protocol = null; break; } if(null == protocol) { log.warn(String.format("Unable to determine protocol for %s", identifier)); continue; } final NSDictionary details = bookmark.objectForKey("MountFSOptions"); if(null == details) { continue; } final PlistDeserializer options = new PlistDeserializer(details); final String hostname = options.stringForKey("host"); if(StringUtils.isBlank(hostname)) { continue; } final Host host = new Host(protocol, hostname, new Credentials(options.stringForKey("login"))); host.setNickname(bookmark.stringForKey("MountFSLabel")); host.setDefaultPath(options.stringForKey("remotePath")); this.add(host); } }  }
CloudMounterBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { final NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } final List<NSDictionary> array = new PlistDeserializer(serialized).listForKey("CustomPluginSettings"); if(null == array) { log.warn("Missing key CustomPluginSettings"); return; } for(NSDictionary dict : array) { final PlistDeserializer bookmark = new PlistDeserializer(dict); final String identifier = bookmark.stringForKey("MountFSClassName"); if(StringUtils.isBlank(identifier)) { log.warn("Missing key MountFSClassName"); continue; } final Protocol protocol; switch(identifier) { case "FtpConnection": protocol = protocols.forType(Protocol.Type.ftp); break; case "WebDAVConnection": protocol = protocols.forType(Protocol.Type.dav); break; case "OpenStackConnection": protocol = protocols.forType(Protocol.Type.swift); break; case "BBConnection": protocol = protocols.forType(Protocol.Type.b2); break; case "S3Connection": protocol = protocols.forType(Protocol.Type.s3); break; case "DropboxConnection": protocol = protocols.forType(Protocol.Type.dropbox); break; case "GDriveConnection": protocol = protocols.forType(Protocol.Type.googledrive); break; default: protocol = null; break; } if(null == protocol) { log.warn(String.format("Unable to determine protocol for %s", identifier)); continue; } final NSDictionary details = bookmark.objectForKey("MountFSOptions"); if(null == details) { continue; } final PlistDeserializer options = new PlistDeserializer(details); final String hostname = options.stringForKey("host"); if(StringUtils.isBlank(hostname)) { continue; } final Host host = new Host(protocol, hostname, new Credentials(options.stringForKey("login"))); host.setNickname(bookmark.stringForKey("MountFSLabel")); host.setDefaultPath(options.stringForKey("remotePath")); this.add(host); } }  @Override String getName(); @Override Local getFile(); @Override String getBundleIdentifier(); }
CloudMounterBookmarkCollection extends ThirdpartyBookmarkCollection { @Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { final NSDictionary serialized = NSDictionary.dictionaryWithContentsOfFile(file.getAbsolute()); if(null == serialized) { throw new LocalAccessDeniedException(String.format("Invalid bookmark file %s", file)); } final List<NSDictionary> array = new PlistDeserializer(serialized).listForKey("CustomPluginSettings"); if(null == array) { log.warn("Missing key CustomPluginSettings"); return; } for(NSDictionary dict : array) { final PlistDeserializer bookmark = new PlistDeserializer(dict); final String identifier = bookmark.stringForKey("MountFSClassName"); if(StringUtils.isBlank(identifier)) { log.warn("Missing key MountFSClassName"); continue; } final Protocol protocol; switch(identifier) { case "FtpConnection": protocol = protocols.forType(Protocol.Type.ftp); break; case "WebDAVConnection": protocol = protocols.forType(Protocol.Type.dav); break; case "OpenStackConnection": protocol = protocols.forType(Protocol.Type.swift); break; case "BBConnection": protocol = protocols.forType(Protocol.Type.b2); break; case "S3Connection": protocol = protocols.forType(Protocol.Type.s3); break; case "DropboxConnection": protocol = protocols.forType(Protocol.Type.dropbox); break; case "GDriveConnection": protocol = protocols.forType(Protocol.Type.googledrive); break; default: protocol = null; break; } if(null == protocol) { log.warn(String.format("Unable to determine protocol for %s", identifier)); continue; } final NSDictionary details = bookmark.objectForKey("MountFSOptions"); if(null == details) { continue; } final PlistDeserializer options = new PlistDeserializer(details); final String hostname = options.stringForKey("host"); if(StringUtils.isBlank(hostname)) { continue; } final Host host = new Host(protocol, hostname, new Credentials(options.stringForKey("login"))); host.setNickname(bookmark.stringForKey("MountFSLabel")); host.setDefaultPath(options.stringForKey("remotePath")); this.add(host); } }  @Override String getName(); @Override Local getFile(); @Override String getBundleIdentifier();  }