@Test(expected = NotfoundException.class) public void testDeleteNotFound() throws Exception { final Path test = new Path(DriveHomeFinderService.MYDRIVE_FOLDER, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); test.attributes().setVersionId("n"); new DriveDeleteFeature(session, new DriveFileidProvider(session).withCache(cache)).delete(Collections.singletonList(test), 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(file.getType().contains(Path.Type.placeholder)) { continue; } callback.delete(file); try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(file.getParent())) { session.getClient().teamdrives().delete(fileid.getFileid(file, new DisabledListProgressListener())).execute(); } else { if(PreferencesFactory.get().getBoolean("googledrive.delete.trash")) { final File properties = new File(); properties.setTrashed(true); session.getClient().files().update(fileid.getFileid(file, new DisabledListProgressListener()), properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } else { session.getClient().files().delete(fileid.getFileid(file, new DisabledListProgressListener())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot delete {0}", e, file); } } }
DriveDeleteFeature 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(file.getType().contains(Path.Type.placeholder)) { continue; } callback.delete(file); try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(file.getParent())) { session.getClient().teamdrives().delete(fileid.getFileid(file, new DisabledListProgressListener())).execute(); } else { if(PreferencesFactory.get().getBoolean("googledrive.delete.trash")) { final File properties = new File(); properties.setTrashed(true); session.getClient().files().update(fileid.getFileid(file, new DisabledListProgressListener()), properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } else { session.getClient().files().delete(fileid.getFileid(file, new DisabledListProgressListener())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot delete {0}", e, file); } } } }
DriveDeleteFeature 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(file.getType().contains(Path.Type.placeholder)) { continue; } callback.delete(file); try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(file.getParent())) { session.getClient().teamdrives().delete(fileid.getFileid(file, new DisabledListProgressListener())).execute(); } else { if(PreferencesFactory.get().getBoolean("googledrive.delete.trash")) { final File properties = new File(); properties.setTrashed(true); session.getClient().files().update(fileid.getFileid(file, new DisabledListProgressListener()), properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } else { session.getClient().files().delete(fileid.getFileid(file, new DisabledListProgressListener())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot delete {0}", e, file); } } } DriveDeleteFeature(final DriveSession session, final DriveFileidProvider fileid); }
DriveDeleteFeature 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(file.getType().contains(Path.Type.placeholder)) { continue; } callback.delete(file); try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(file.getParent())) { session.getClient().teamdrives().delete(fileid.getFileid(file, new DisabledListProgressListener())).execute(); } else { if(PreferencesFactory.get().getBoolean("googledrive.delete.trash")) { final File properties = new File(); properties.setTrashed(true); session.getClient().files().update(fileid.getFileid(file, new DisabledListProgressListener()), properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } else { session.getClient().files().delete(fileid.getFileid(file, new DisabledListProgressListener())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot delete {0}", e, file); } } } DriveDeleteFeature(final DriveSession session, final DriveFileidProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isSupported(final Path file); @Override boolean isRecursive(); }
DriveDeleteFeature 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(file.getType().contains(Path.Type.placeholder)) { continue; } callback.delete(file); try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(file.getParent())) { session.getClient().teamdrives().delete(fileid.getFileid(file, new DisabledListProgressListener())).execute(); } else { if(PreferencesFactory.get().getBoolean("googledrive.delete.trash")) { final File properties = new File(); properties.setTrashed(true); session.getClient().files().update(fileid.getFileid(file, new DisabledListProgressListener()), properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } else { session.getClient().files().delete(fileid.getFileid(file, new DisabledListProgressListener())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot delete {0}", e, file); } } } DriveDeleteFeature(final DriveSession session, final DriveFileidProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isSupported(final Path file); @Override boolean isRecursive();  }