@Test(expected = NotfoundException.class) public void testListNotFoundFolder() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); new SwiftObjectListService(session).list(new Path(container, "notfound", EnumSet.of(Path.Type.directory)), new DisabledListProgressListener()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for(StorageObject object : list) { final PathAttributes attr = attributes.toAttributes(object); final EnumSet<Path.Type> types = "application/directory" .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { continue; } } attr.setOwner(container.attributes().getOwner()); attr.setRegion(container.attributes().getRegion()); children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName(); } listener.chunk(directory, children); } while(list.size() == limit); if(!containerService.isContainer(directory) && children.isEmpty()) { if(!new SwiftFindFeature(session).find(directory)) { throw new NotfoundException(directory.getAbsolute()); } } return children; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } }
SwiftObjectListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for(StorageObject object : list) { final PathAttributes attr = attributes.toAttributes(object); final EnumSet<Path.Type> types = "application/directory" .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { continue; } } attr.setOwner(container.attributes().getOwner()); attr.setRegion(container.attributes().getRegion()); children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName(); } listener.chunk(directory, children); } while(list.size() == limit); if(!containerService.isContainer(directory) && children.isEmpty()) { if(!new SwiftFindFeature(session).find(directory)) { throw new NotfoundException(directory.getAbsolute()); } } return children; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } } }
SwiftObjectListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for(StorageObject object : list) { final PathAttributes attr = attributes.toAttributes(object); final EnumSet<Path.Type> types = "application/directory" .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { continue; } } attr.setOwner(container.attributes().getOwner()); attr.setRegion(container.attributes().getRegion()); children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName(); } listener.chunk(directory, children); } while(list.size() == limit); if(!containerService.isContainer(directory) && children.isEmpty()) { if(!new SwiftFindFeature(session).find(directory)) { throw new NotfoundException(directory.getAbsolute()); } } return children; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } } SwiftObjectListService(final SwiftSession session);  SwiftObjectListService(final SwiftSession session, final SwiftRegionService regionService); }
SwiftObjectListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for(StorageObject object : list) { final PathAttributes attr = attributes.toAttributes(object); final EnumSet<Path.Type> types = "application/directory" .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { continue; } } attr.setOwner(container.attributes().getOwner()); attr.setRegion(container.attributes().getRegion()); children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName(); } listener.chunk(directory, children); } while(list.size() == limit); if(!containerService.isContainer(directory) && children.isEmpty()) { if(!new SwiftFindFeature(session).find(directory)) { throw new NotfoundException(directory.getAbsolute()); } } return children; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } } SwiftObjectListService(final SwiftSession session);  SwiftObjectListService(final SwiftSession session, final SwiftRegionService regionService); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
SwiftObjectListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for(StorageObject object : list) { final PathAttributes attr = attributes.toAttributes(object); final EnumSet<Path.Type> types = "application/directory" .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { continue; } } attr.setOwner(container.attributes().getOwner()); attr.setRegion(container.attributes().getRegion()); children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName(); } listener.chunk(directory, children); } while(list.size() == limit); if(!containerService.isContainer(directory) && children.isEmpty()) { if(!new SwiftFindFeature(session).find(directory)) { throw new NotfoundException(directory.getAbsolute()); } } return children; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } } SwiftObjectListService(final SwiftSession session);  SwiftObjectListService(final SwiftSession session, final SwiftRegionService regionService); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }