@Test public void testListLimitRegion() throws Exception { final AttributedList<Path> list = new SwiftContainerListService(session, new SwiftLocationFeature.SwiftRegion("IAD") ).list(new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()); final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory)); container.attributes().setRegion("IAD"); assertTrue(list.contains(container)); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List containers for %s", session)); } try { final AttributedList<Path> containers = new AttributedList<Path>(); final int limit = preferences.getInteger("openstack.list.container.limit"); final Client client = session.getClient(); for(final Region r : client.getRegions()) { if(region.getIdentifier() != null) { if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) { log.warn(String.format("Skip region %s", r)); continue; } } List<Container> chunk; String marker = null; do { chunk = client.listContainers(r, limit, marker); for(final Container f : chunk) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(f.getRegion().getRegionId()); containers.add(new Path(String.format("/%s", f.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); marker = f.getName(); } listener.chunk(directory, containers); } while(!chunk.isEmpty()); } return containers; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
SwiftContainerListService implements RootListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List containers for %s", session)); } try { final AttributedList<Path> containers = new AttributedList<Path>(); final int limit = preferences.getInteger("openstack.list.container.limit"); final Client client = session.getClient(); for(final Region r : client.getRegions()) { if(region.getIdentifier() != null) { if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) { log.warn(String.format("Skip region %s", r)); continue; } } List<Container> chunk; String marker = null; do { chunk = client.listContainers(r, limit, marker); for(final Container f : chunk) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(f.getRegion().getRegionId()); containers.add(new Path(String.format("/%s", f.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); marker = f.getName(); } listener.chunk(directory, containers); } while(!chunk.isEmpty()); } return containers; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
SwiftContainerListService implements RootListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List containers for %s", session)); } try { final AttributedList<Path> containers = new AttributedList<Path>(); final int limit = preferences.getInteger("openstack.list.container.limit"); final Client client = session.getClient(); for(final Region r : client.getRegions()) { if(region.getIdentifier() != null) { if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) { log.warn(String.format("Skip region %s", r)); continue; } } List<Container> chunk; String marker = null; do { chunk = client.listContainers(r, limit, marker); for(final Container f : chunk) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(f.getRegion().getRegionId()); containers.add(new Path(String.format("/%s", f.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); marker = f.getName(); } listener.chunk(directory, containers); } while(!chunk.isEmpty()); } return containers; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftContainerListService(final SwiftSession session, final SwiftLocationFeature.SwiftRegion region); }
SwiftContainerListService implements RootListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List containers for %s", session)); } try { final AttributedList<Path> containers = new AttributedList<Path>(); final int limit = preferences.getInteger("openstack.list.container.limit"); final Client client = session.getClient(); for(final Region r : client.getRegions()) { if(region.getIdentifier() != null) { if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) { log.warn(String.format("Skip region %s", r)); continue; } } List<Container> chunk; String marker = null; do { chunk = client.listContainers(r, limit, marker); for(final Container f : chunk) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(f.getRegion().getRegionId()); containers.add(new Path(String.format("/%s", f.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); marker = f.getName(); } listener.chunk(directory, containers); } while(!chunk.isEmpty()); } return containers; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftContainerListService(final SwiftSession session, final SwiftLocationFeature.SwiftRegion region); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
SwiftContainerListService implements RootListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List containers for %s", session)); } try { final AttributedList<Path> containers = new AttributedList<Path>(); final int limit = preferences.getInteger("openstack.list.container.limit"); final Client client = session.getClient(); for(final Region r : client.getRegions()) { if(region.getIdentifier() != null) { if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) { log.warn(String.format("Skip region %s", r)); continue; } } List<Container> chunk; String marker = null; do { chunk = client.listContainers(r, limit, marker); for(final Container f : chunk) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(f.getRegion().getRegionId()); containers.add(new Path(String.format("/%s", f.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); marker = f.getName(); } listener.chunk(directory, containers); } while(!chunk.isEmpty()); } return containers; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftContainerListService(final SwiftSession session, final SwiftLocationFeature.SwiftRegion region); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }