@Test(expected = NotfoundException.class) public void testDeleteNotFound() throws Exception { final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new IRODSProtocol()))); final Profile profile = new ProfilePlistReader(factory).read( new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile")); final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials( System.getProperties().getProperty("irods.key"), System.getProperties().getProperty("irods.secret") )); final IRODSSession session = new IRODSSession(host); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path test = new Path(new IRODSHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); assertFalse(new IRODSFindFeature(session).find(test)); new IRODSDeleteFeature(session).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 { final List<Path> deleted = new ArrayList<Path>(); for(Path file : files.keySet()) { boolean skip = false; for(Path d : deleted) { if(file.isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file); callback.delete(file); try { final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute())); } if(f.isFile()) { session.getClient().fileDeleteForce(f); } else if(f.isDirectory()) { session.getClient().directoryDeleteForce(f); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file); } } }
IRODSDeleteFeature 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(Path file : files.keySet()) { boolean skip = false; for(Path d : deleted) { if(file.isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file); callback.delete(file); try { final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute())); } if(f.isFile()) { session.getClient().fileDeleteForce(f); } else if(f.isDirectory()) { session.getClient().directoryDeleteForce(f); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file); } } } }
IRODSDeleteFeature 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(Path file : files.keySet()) { boolean skip = false; for(Path d : deleted) { if(file.isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file); callback.delete(file); try { final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute())); } if(f.isFile()) { session.getClient().fileDeleteForce(f); } else if(f.isDirectory()) { session.getClient().directoryDeleteForce(f); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file); } } } IRODSDeleteFeature(IRODSSession session); }
IRODSDeleteFeature 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(Path file : files.keySet()) { boolean skip = false; for(Path d : deleted) { if(file.isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file); callback.delete(file); try { final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute())); } if(f.isFile()) { session.getClient().fileDeleteForce(f); } else if(f.isDirectory()) { session.getClient().directoryDeleteForce(f); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file); } } } IRODSDeleteFeature(IRODSSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive(); }
IRODSDeleteFeature 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(Path file : files.keySet()) { boolean skip = false; for(Path d : deleted) { if(file.isChild(d)) { skip = true; break; } } if(skip) { continue; } deleted.add(file); callback.delete(file); try { final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute())); } if(f.isFile()) { session.getClient().fileDeleteForce(f); } else if(f.isDirectory()) { session.getClient().directoryDeleteForce(f); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file); } } } IRODSDeleteFeature(IRODSSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive();  }