@Test public void testFind() throws Exception { assertTrue(new DAVFindFeature(session).find(new DefaultHomeFinderService(session).find())); assertFalse(new DAVFindFeature(session).find( new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)) )); assertFalse(new DAVFindFeature(session).find( new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)) )); }
@Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { try { try { final HttpHead request = new HttpHead(new DAVPathEncoder().encode(file)); for(Header header : this.headers()) { request.addHeader(header); } return session.getClient().execute(request, new ExistsResponseHandler()); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } catch(AccessDeniedException | InteroperabilityException e) { return new DefaultFindFeature(session).withCache(cache).find(file); } } catch(AccessDeniedException e) { return true; } catch(LoginFailureException | NotfoundException e) { return false; } }
DAVFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { try { try { final HttpHead request = new HttpHead(new DAVPathEncoder().encode(file)); for(Header header : this.headers()) { request.addHeader(header); } return session.getClient().execute(request, new ExistsResponseHandler()); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } catch(AccessDeniedException | InteroperabilityException e) { return new DefaultFindFeature(session).withCache(cache).find(file); } } catch(AccessDeniedException e) { return true; } catch(LoginFailureException | NotfoundException e) { return false; } } }
DAVFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { try { try { final HttpHead request = new HttpHead(new DAVPathEncoder().encode(file)); for(Header header : this.headers()) { request.addHeader(header); } return session.getClient().execute(request, new ExistsResponseHandler()); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } catch(AccessDeniedException | InteroperabilityException e) { return new DefaultFindFeature(session).withCache(cache).find(file); } } catch(AccessDeniedException e) { return true; } catch(LoginFailureException | NotfoundException e) { return false; } } DAVFindFeature(final DAVSession session); }
DAVFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { try { try { final HttpHead request = new HttpHead(new DAVPathEncoder().encode(file)); for(Header header : this.headers()) { request.addHeader(header); } return session.getClient().execute(request, new ExistsResponseHandler()); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } catch(AccessDeniedException | InteroperabilityException e) { return new DefaultFindFeature(session).withCache(cache).find(file); } } catch(AccessDeniedException e) { return true; } catch(LoginFailureException | NotfoundException e) { return false; } } DAVFindFeature(final DAVSession session); @Override boolean find(final Path file); Set<Header> headers(); @Override Find withCache(final Cache<Path> cache); }
DAVFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { try { try { final HttpHead request = new HttpHead(new DAVPathEncoder().encode(file)); for(Header header : this.headers()) { request.addHeader(header); } return session.getClient().execute(request, new ExistsResponseHandler()); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } catch(AccessDeniedException | InteroperabilityException e) { return new DefaultFindFeature(session).withCache(cache).find(file); } } catch(AccessDeniedException e) { return true; } catch(LoginFailureException | NotfoundException e) { return false; } } DAVFindFeature(final DAVSession session); @Override boolean find(final Path file); Set<Header> headers(); @Override Find withCache(final Cache<Path> cache);  }