@Test public void testOverride() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final AtomicBoolean list = new AtomicBoolean(); final AtomicBoolean find = new AtomicBoolean(); final SwiftRegionService regionService = new SwiftRegionService(session); final Write.Append append = new SwiftWriteFeature(session, regionService, new SwiftObjectListService(session, regionService) { @Override public AttributedList<Path> list(Path directory, ListProgressListener listener) { list.set(true); return new AttributedList<Path>(Collections.singletonList(file)); } }, new SwiftSegmentService(session), new Find() { @Override public boolean find(final Path file) { find.set(true); return true; } }, new AttributesFinder() { @Override public PathAttributes find(final Path file) { return new PathAttributes(); } } ).append(new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), 1024L, PathCache.empty()); assertFalse(append.append); assertTrue(append.override); assertFalse(list.get()); assertTrue(find.get()); }
@Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { final List<Path> segments; long size = 0L; try { segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } } catch(NotfoundException e) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
SwiftWriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { final List<Path> segments; long size = 0L; try { segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } } catch(NotfoundException e) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } }
SwiftWriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { final List<Path> segments; long size = 0L; try { segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } } catch(NotfoundException e) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService, final Find finder);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService,
                             final Find finder, final AttributesFinder attributes); }
SwiftWriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { final List<Path> segments; long size = 0L; try { segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } } catch(NotfoundException e) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService, final Find finder);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService,
                             final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Append append(final Path file, final Long length, final Cache<Path> cache); @Override boolean temporary(); @Override boolean random(); @Override ChecksumCompute checksum(final Path file, final TransferStatus status); }
SwiftWriteFeature extends AbstractHttpWriteFeature<StorageObject> implements Write<StorageObject> { @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("openstack.upload.largeobject.threshold")) { if(preferences.getBoolean("openstack.upload.largeobject")) { final List<Path> segments; long size = 0L; try { segments = listService.list(segmentService.getSegmentsDirectory(file, length), new DisabledListProgressListener()).toList(); if(segments.isEmpty()) { return Write.notfound; } } catch(NotfoundException e) { return Write.notfound; } for(Path segment : segments) { size += segment.attributes().getSize(); } return new Append(size); } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; } SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService, final Find finder);  SwiftWriteFeature(final SwiftSession session, final SwiftRegionService regionService,
                             final SwiftObjectListService listService,
                             final SwiftSegmentService segmentService,
                             final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override Append append(final Path file, final Long length, final Cache<Path> cache); @Override boolean temporary(); @Override boolean random(); @Override ChecksumCompute checksum(final Path file, final TransferStatus status);  }