@Test public void testCreatePlaceholder() throws Exception { final AtomicBoolean put = new AtomicBoolean(); final String name = UUID.randomUUID().toString(); session.withListener(new TranscriptListener() { @Override public void log(final Type request, final String message) { switch(request) { case request: if(("PUT /v1/MossoCloudFS_59113590-c679-46c3-bf62-9d7c3d5176ee/test.cyberduck.ch/" + name + " HTTP/1.1").equals(message)) { put.set(true); } } } }); final Path container = new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory)); container.attributes().setRegion("IAD"); final SwiftDirectoryFeature feature = new SwiftDirectoryFeature(session, new SwiftRegionService(session), new SwiftWriteFeature(session, new SwiftRegionService(session))); final Path placeholder = feature.mkdir(new Path(container, name, EnumSet.of(Path.Type.directory)), null, new TransferStatus()); Thread.sleep(1000L); assertTrue(put.get()); assertTrue(new SwiftFindFeature(session).find(placeholder)); assertTrue(new DefaultFindFeature(session).find(placeholder)); assertEquals(placeholder.attributes().getChecksum(), new SwiftAttributesFinderFeature(session).find(placeholder).getChecksum()); new SwiftDeleteFeature(session).delete(Collections.singletonList(placeholder), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new SwiftFindFeature(session).find(placeholder)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } }
SwiftDirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } } }
SwiftDirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SwiftDirectoryFeature(final SwiftSession session);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService, final Write<StorageObject> writer); }
SwiftDirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SwiftDirectoryFeature(final SwiftSession session);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService, final Write<StorageObject> writer); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override SwiftDirectoryFeature withWriter(final Write<StorageObject> writer); }
SwiftDirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SwiftDirectoryFeature(final SwiftSession session);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService);  SwiftDirectoryFeature(final SwiftSession session, final SwiftRegionService regionService, final Write<StorageObject> writer); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override SwiftDirectoryFeature withWriter(final Write<StorageObject> writer);  }