@Test(expected = NotfoundException.class) public void testDeleteNotFound() throws Exception { final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { final List<Path> deleted = new ArrayList<Path>(); for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { boolean skip = false; for(Path d : deleted) { if(file.getKey().isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file.getKey()); callback.delete(file.getKey()); try { if(session.getFeature(Lock.class) != null && file.getValue().getLockId() != null) { session.getClient().delete(new DAVPathEncoder().encode(file.getKey()), Collections.singletonMap(HttpHeaders.IF, String.format("(<%s>)", file.getValue().getLockId()))); } else { session.getClient().delete(new DAVPathEncoder().encode(file.getKey())); } } catch(SardineException e) { throw new DAVExceptionMappingService().map("Cannot delete {0}", e, file.getKey()); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file.getKey()); } } }
DAVDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { final List<Path> deleted = new ArrayList<Path>(); for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { boolean skip = false; for(Path d : deleted) { if(file.getKey().isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file.getKey()); callback.delete(file.getKey()); try { if(session.getFeature(Lock.class) != null && file.getValue().getLockId() != null) { session.getClient().delete(new DAVPathEncoder().encode(file.getKey()), Collections.singletonMap(HttpHeaders.IF, String.format("(<%s>)", file.getValue().getLockId()))); } else { session.getClient().delete(new DAVPathEncoder().encode(file.getKey())); } } catch(SardineException e) { throw new DAVExceptionMappingService().map("Cannot delete {0}", e, file.getKey()); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file.getKey()); } } } }
DAVDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { final List<Path> deleted = new ArrayList<Path>(); for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { boolean skip = false; for(Path d : deleted) { if(file.getKey().isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file.getKey()); callback.delete(file.getKey()); try { if(session.getFeature(Lock.class) != null && file.getValue().getLockId() != null) { session.getClient().delete(new DAVPathEncoder().encode(file.getKey()), Collections.singletonMap(HttpHeaders.IF, String.format("(<%s>)", file.getValue().getLockId()))); } else { session.getClient().delete(new DAVPathEncoder().encode(file.getKey())); } } catch(SardineException e) { throw new DAVExceptionMappingService().map("Cannot delete {0}", e, file.getKey()); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file.getKey()); } } } DAVDeleteFeature(final DAVSession session); }
DAVDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { final List<Path> deleted = new ArrayList<Path>(); for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { boolean skip = false; for(Path d : deleted) { if(file.getKey().isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file.getKey()); callback.delete(file.getKey()); try { if(session.getFeature(Lock.class) != null && file.getValue().getLockId() != null) { session.getClient().delete(new DAVPathEncoder().encode(file.getKey()), Collections.singletonMap(HttpHeaders.IF, String.format("(<%s>)", file.getValue().getLockId()))); } else { session.getClient().delete(new DAVPathEncoder().encode(file.getKey())); } } catch(SardineException e) { throw new DAVExceptionMappingService().map("Cannot delete {0}", e, file.getKey()); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file.getKey()); } } } DAVDeleteFeature(final DAVSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive(); }
DAVDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { final List<Path> deleted = new ArrayList<Path>(); for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { boolean skip = false; for(Path d : deleted) { if(file.getKey().isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file.getKey()); callback.delete(file.getKey()); try { if(session.getFeature(Lock.class) != null && file.getValue().getLockId() != null) { session.getClient().delete(new DAVPathEncoder().encode(file.getKey()), Collections.singletonMap(HttpHeaders.IF, String.format("(<%s>)", file.getValue().getLockId()))); } else { session.getClient().delete(new DAVPathEncoder().encode(file.getKey())); } } catch(SardineException e) { throw new DAVExceptionMappingService().map("Cannot delete {0}", e, file.getKey()); } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file.getKey()); } } } DAVDeleteFeature(final DAVSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive();  }