@Test public void testFind() throws Exception { final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final B2FileidProvider fileid = new B2FileidProvider(session).withCache(cache); new B2TouchFeature(session, fileid).touch(file, new TransferStatus()); assertTrue(new B2FindFeature(session, fileid).find(file)); assertFalse(new B2FindFeature(session, fileid).find(new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)))); new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public boolean find(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<B2BucketResponse> buckets = session.getClient().listBuckets(); for(B2BucketResponse bucket : buckets) { if(StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) { return true; } } } else { try { return null != fileid.withCache(cache).getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { return false; } } return false; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
B2FindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<B2BucketResponse> buckets = session.getClient().listBuckets(); for(B2BucketResponse bucket : buckets) { if(StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) { return true; } } } else { try { return null != fileid.withCache(cache).getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { return false; } } return false; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
B2FindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<B2BucketResponse> buckets = session.getClient().listBuckets(); for(B2BucketResponse bucket : buckets) { if(StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) { return true; } } } else { try { return null != fileid.withCache(cache).getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { return false; } } return false; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2FindFeature(final B2Session session, final B2FileidProvider fileid); }
B2FindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<B2BucketResponse> buckets = session.getClient().listBuckets(); for(B2BucketResponse bucket : buckets) { if(StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) { return true; } } } else { try { return null != fileid.withCache(cache).getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { return false; } } return false; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2FindFeature(final B2Session session, final B2FileidProvider fileid); @Override boolean find(final Path file); @Override Find withCache(final Cache<Path> cache); }
B2FindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<B2BucketResponse> buckets = session.getClient().listBuckets(); for(B2BucketResponse bucket : buckets) { if(StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) { return true; } } } else { try { return null != fileid.withCache(cache).getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { return false; } } return false; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2FindFeature(final B2Session session, final B2FileidProvider fileid); @Override boolean find(final Path file); @Override Find withCache(final Cache<Path> cache);  }