@Test(expected = NotfoundException.class) public void testListNotfound() throws Exception { final Host host = new Host(new DAVSSLProtocol(), "svn.cyberduck.ch", new Credentials( PreferencesFactory.get().getProperty("connection.login.anon.name"), null )); final DAVSession session = new DAVSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); assertNotNull(session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback())); assertTrue(session.isConnected()); assertNotNull(session.getClient()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); new DAVListService(session).list(new Path("/notfound", EnumSet.of(Path.Type.directory, Path.Type.volume)), new DisabledListProgressListener()); session.close(); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); for(final DavResource resource : this.list(directory)) { final String href = PathNormalizer.normalize(resource.getHref().getPath(), true); if(href.equals(directory.getAbsolute())) { log.warn(String.format("Ignore resource %s", href)); if(resource.isDirectory()) { continue; } throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); final Path file = new Path(directory, PathNormalizer.name(href), resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); children.add(file); listener.chunk(directory, children); } return children; } catch(SardineException e) { throw new DAVExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, directory); } }
DAVListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); for(final DavResource resource : this.list(directory)) { final String href = PathNormalizer.normalize(resource.getHref().getPath(), true); if(href.equals(directory.getAbsolute())) { log.warn(String.format("Ignore resource %s", href)); if(resource.isDirectory()) { continue; } throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); final Path file = new Path(directory, PathNormalizer.name(href), resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); children.add(file); listener.chunk(directory, children); } return children; } catch(SardineException e) { throw new DAVExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, directory); } } }
DAVListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); for(final DavResource resource : this.list(directory)) { final String href = PathNormalizer.normalize(resource.getHref().getPath(), true); if(href.equals(directory.getAbsolute())) { log.warn(String.format("Ignore resource %s", href)); if(resource.isDirectory()) { continue; } throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); final Path file = new Path(directory, PathNormalizer.name(href), resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); children.add(file); listener.chunk(directory, children); } return children; } catch(SardineException e) { throw new DAVExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, directory); } } DAVListService(final DAVSession session);  DAVListService(final DAVSession session, final DAVAttributesFinderFeature attributes); }
DAVListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); for(final DavResource resource : this.list(directory)) { final String href = PathNormalizer.normalize(resource.getHref().getPath(), true); if(href.equals(directory.getAbsolute())) { log.warn(String.format("Ignore resource %s", href)); if(resource.isDirectory()) { continue; } throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); final Path file = new Path(directory, PathNormalizer.name(href), resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); children.add(file); listener.chunk(directory, children); } return children; } catch(SardineException e) { throw new DAVExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, directory); } } DAVListService(final DAVSession session);  DAVListService(final DAVSession session, final DAVAttributesFinderFeature attributes); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
DAVListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); for(final DavResource resource : this.list(directory)) { final String href = PathNormalizer.normalize(resource.getHref().getPath(), true); if(href.equals(directory.getAbsolute())) { log.warn(String.format("Ignore resource %s", href)); if(resource.isDirectory()) { continue; } throw new NotfoundException(directory.getAbsolute()); } final PathAttributes attr = attributes.toAttributes(resource); final Path file = new Path(directory, PathNormalizer.name(href), resource.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attr); children.add(file); listener.chunk(directory, children); } return children; } catch(SardineException e) { throw new DAVExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, directory); } } DAVListService(final DAVSession session);  DAVListService(final DAVSession session, final DAVAttributesFinderFeature attributes); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }