@Test public void testListEmptyFolder() throws Exception { final Path folder = new MantaDirectoryFeature(session).mkdir(new Path( testPathPrefix, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertTrue(new MantaListService(session).list(folder, new DisabledListProgressListener()).isEmpty()); new MantaDeleteFeature(session).delete(Arrays.asList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(directory.isRoot()) { return new AttributedList<Path>(Collections.singletonList( new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath())); } final AttributedList<Path> children = new AttributedList<>(); final Iterator<MantaObject> objectsIter; try { objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator(); } catch(MantaObjectException e) { throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e); } final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session); while(objectsIter.hasNext()) { MantaObject o = objectsIter.next(); final Path file = new Path(directory, PathNormalizer.name(o.getPath()), EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o) ); children.add(file); listener.chunk(directory, children); } return children; }
MantaListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(directory.isRoot()) { return new AttributedList<Path>(Collections.singletonList( new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath())); } final AttributedList<Path> children = new AttributedList<>(); final Iterator<MantaObject> objectsIter; try { objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator(); } catch(MantaObjectException e) { throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e); } final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session); while(objectsIter.hasNext()) { MantaObject o = objectsIter.next(); final Path file = new Path(directory, PathNormalizer.name(o.getPath()), EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o) ); children.add(file); listener.chunk(directory, children); } return children; } }
MantaListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(directory.isRoot()) { return new AttributedList<Path>(Collections.singletonList( new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath())); } final AttributedList<Path> children = new AttributedList<>(); final Iterator<MantaObject> objectsIter; try { objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator(); } catch(MantaObjectException e) { throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e); } final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session); while(objectsIter.hasNext()) { MantaObject o = objectsIter.next(); final Path file = new Path(directory, PathNormalizer.name(o.getPath()), EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o) ); children.add(file); listener.chunk(directory, children); } return children; } MantaListService(final MantaSession session); }
MantaListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(directory.isRoot()) { return new AttributedList<Path>(Collections.singletonList( new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath())); } final AttributedList<Path> children = new AttributedList<>(); final Iterator<MantaObject> objectsIter; try { objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator(); } catch(MantaObjectException e) { throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e); } final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session); while(objectsIter.hasNext()) { MantaObject o = objectsIter.next(); final Path file = new Path(directory, PathNormalizer.name(o.getPath()), EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o) ); children.add(file); listener.chunk(directory, children); } return children; } MantaListService(final MantaSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
MantaListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(directory.isRoot()) { return new AttributedList<Path>(Collections.singletonList( new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath())); } final AttributedList<Path> children = new AttributedList<>(); final Iterator<MantaObject> objectsIter; try { objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator(); } catch(MantaObjectException e) { throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e); } final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session); while(objectsIter.hasNext()) { MantaObject o = objectsIter.next(); final Path file = new Path(directory, PathNormalizer.name(o.getPath()), EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o) ); children.add(file); listener.chunk(directory, children); } return children; } MantaListService(final MantaSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }