@Test(expected = NotfoundException.class) public void testReadNotFound() 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.file)); assertFalse(session.getFeature(Find.class).find(test)); new IRODSReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFileFactory factory = fs.getIRODSFileFactory(); final IRODSFile f = factory.instanceIRODSFile(file.getAbsolute()); if(f.exists()) { final InputStream in = new PackingIrodsInputStream(factory.instanceIRODSFileInputStream(f)); if(status.isAppend()) { return StreamCopier.skip(in, status.getOffset()); } return in; } else { throw new NotfoundException(file.getAbsolute()); } } catch(JargonRuntimeException e) { if(e.getCause() instanceof JargonException) { throw (JargonException) e.getCause(); } throw new DefaultExceptionMappingService().map(e); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } }
IRODSReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFileFactory factory = fs.getIRODSFileFactory(); final IRODSFile f = factory.instanceIRODSFile(file.getAbsolute()); if(f.exists()) { final InputStream in = new PackingIrodsInputStream(factory.instanceIRODSFileInputStream(f)); if(status.isAppend()) { return StreamCopier.skip(in, status.getOffset()); } return in; } else { throw new NotfoundException(file.getAbsolute()); } } catch(JargonRuntimeException e) { if(e.getCause() instanceof JargonException) { throw (JargonException) e.getCause(); } throw new DefaultExceptionMappingService().map(e); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } } }
IRODSReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFileFactory factory = fs.getIRODSFileFactory(); final IRODSFile f = factory.instanceIRODSFile(file.getAbsolute()); if(f.exists()) { final InputStream in = new PackingIrodsInputStream(factory.instanceIRODSFileInputStream(f)); if(status.isAppend()) { return StreamCopier.skip(in, status.getOffset()); } return in; } else { throw new NotfoundException(file.getAbsolute()); } } catch(JargonRuntimeException e) { if(e.getCause() instanceof JargonException) { throw (JargonException) e.getCause(); } throw new DefaultExceptionMappingService().map(e); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } } IRODSReadFeature(IRODSSession session); }
IRODSReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFileFactory factory = fs.getIRODSFileFactory(); final IRODSFile f = factory.instanceIRODSFile(file.getAbsolute()); if(f.exists()) { final InputStream in = new PackingIrodsInputStream(factory.instanceIRODSFileInputStream(f)); if(status.isAppend()) { return StreamCopier.skip(in, status.getOffset()); } return in; } else { throw new NotfoundException(file.getAbsolute()); } } catch(JargonRuntimeException e) { if(e.getCause() instanceof JargonException) { throw (JargonException) e.getCause(); } throw new DefaultExceptionMappingService().map(e); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } } IRODSReadFeature(IRODSSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file); }
IRODSReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFileFactory factory = fs.getIRODSFileFactory(); final IRODSFile f = factory.instanceIRODSFile(file.getAbsolute()); if(f.exists()) { final InputStream in = new PackingIrodsInputStream(factory.instanceIRODSFileInputStream(f)); if(status.isAppend()) { return StreamCopier.skip(in, status.getOffset()); } return in; } else { throw new NotfoundException(file.getAbsolute()); } } catch(JargonRuntimeException e) { if(e.getCause() instanceof JargonException) { throw (JargonException) e.getCause(); } throw new DefaultExceptionMappingService().map(e); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } } IRODSReadFeature(IRODSSession session); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file);  }