@Test public void testDeletePlaceholder() throws Exception { final B2FileidProvider fileid = new B2FileidProvider(session).withCache(cache); final Path bucket = new B2DirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus()); final Path directory = new B2DirectoryFeature(session, fileid).mkdir(new Path(bucket, String.format("%s %s", UUID.randomUUID().toString(), "1"), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); new B2DeleteFeature(session, fileid).delete(Arrays.asList(bucket, directory), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(containerService.isContainer(file)) { continue; } callback.delete(file); if(file.getType().contains(Path.Type.upload)) { new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId()); } else { if(file.isDirectory()) { final String fileid; try { fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file)); continue; } try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid); } catch(B2ApiException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } else if(file.isFile()) { try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid.getFileid(file, new DisabledListProgressListener())); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } } for(Path file : files.keySet()) { try { if(containerService.isContainer(file)) { callback.delete(file); session.getClient().deleteBucket(fileid.getFileid(file, new DisabledListProgressListener())); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
B2DeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(containerService.isContainer(file)) { continue; } callback.delete(file); if(file.getType().contains(Path.Type.upload)) { new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId()); } else { if(file.isDirectory()) { final String fileid; try { fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file)); continue; } try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid); } catch(B2ApiException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } else if(file.isFile()) { try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid.getFileid(file, new DisabledListProgressListener())); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } } for(Path file : files.keySet()) { try { if(containerService.isContainer(file)) { callback.delete(file); session.getClient().deleteBucket(fileid.getFileid(file, new DisabledListProgressListener())); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } }
B2DeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(containerService.isContainer(file)) { continue; } callback.delete(file); if(file.getType().contains(Path.Type.upload)) { new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId()); } else { if(file.isDirectory()) { final String fileid; try { fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file)); continue; } try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid); } catch(B2ApiException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } else if(file.isFile()) { try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid.getFileid(file, new DisabledListProgressListener())); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } } for(Path file : files.keySet()) { try { if(containerService.isContainer(file)) { callback.delete(file); session.getClient().deleteBucket(fileid.getFileid(file, new DisabledListProgressListener())); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } B2DeleteFeature(final B2Session session, final B2FileidProvider fileid); }
B2DeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(containerService.isContainer(file)) { continue; } callback.delete(file); if(file.getType().contains(Path.Type.upload)) { new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId()); } else { if(file.isDirectory()) { final String fileid; try { fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file)); continue; } try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid); } catch(B2ApiException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } else if(file.isFile()) { try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid.getFileid(file, new DisabledListProgressListener())); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } } for(Path file : files.keySet()) { try { if(containerService.isContainer(file)) { callback.delete(file); session.getClient().deleteBucket(fileid.getFileid(file, new DisabledListProgressListener())); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } B2DeleteFeature(final B2Session session, final B2FileidProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); }
B2DeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(containerService.isContainer(file)) { continue; } callback.delete(file); if(file.getType().contains(Path.Type.upload)) { new B2LargeUploadPartService(session, fileid).delete(file.attributes().getVersionId()); } else { if(file.isDirectory()) { final String fileid; try { fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); } catch(NotfoundException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file)); continue; } try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid); } catch(B2ApiException e) { log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } else if(file.isFile()) { try { session.getClient().deleteFileVersion(containerService.getKey(file), fileid.getFileid(file, new DisabledListProgressListener())); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } } for(Path file : files.keySet()) { try { if(containerService.isContainer(file)) { callback.delete(file); session.getClient().deleteBucket(fileid.getFileid(file, new DisabledListProgressListener())); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot delete {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } B2DeleteFeature(final B2Session session, final B2FileidProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback);  }