@Test @Ignore public void testList() 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); assertNotNull(session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback())); assertTrue(session.isConnected()); assertNotNull(session.getClient()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final AttributedList<Path> list = new IRODSListService(session).list(new IRODSHomeFinderService(session).find(), new DisabledListProgressListener()); assertFalse(list.isEmpty()); for(Path p : list) { assertEquals(new IRODSHomeFinderService(session).find(), p.getParent()); assertNotEquals(-1L, p.attributes().getModificationDate()); assertNotEquals(-1L, p.attributes().getSize()); } session.close(); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if(!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if(StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
IRODSListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if(!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if(StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } } }
IRODSListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if(!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if(StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } } IRODSListService(IRODSSession session); }
IRODSListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if(!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if(StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } } IRODSListService(IRODSSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
IRODSListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if(!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if(StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } } IRODSListService(IRODSSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }