@Test public void testCreatePlaceholder() throws Exception { final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials( System.getProperties().getProperty("azure.account"), System.getProperties().getProperty("azure.key") )); final AzureSession session = new AzureSession(host); new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener()).connect(session, PathCache.empty(), new DisabledCancelCallback()); final Path container = new Path("/cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory)); final Path placeholder = new AzureDirectoryFeature(session, null).mkdir(new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertTrue(placeholder.getType().contains(Path.Type.placeholder)); assertTrue(new AzureFindFeature(session, null).find(placeholder)); assertEquals(placeholder.attributes(), new AzureAttributesFinderFeature(session, null).find(placeholder)); new AzureDeleteFeature(session, null).delete(Collections.<Path>singletonList(placeholder), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new AzureFindFeature(session, null).find(placeholder)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final BlobRequestOptions options = new BlobRequestOptions(); if(containerService.isContainer(folder)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder)); } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback())); return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder)); } } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } }
AzureDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final BlobRequestOptions options = new BlobRequestOptions(); if(containerService.isContainer(folder)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder)); } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback())); return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder)); } } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } } }
AzureDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final BlobRequestOptions options = new BlobRequestOptions(); if(containerService.isContainer(folder)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder)); } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback())); return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder)); } } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } } AzureDirectoryFeature(final AzureSession session, final OperationContext context); }
AzureDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final BlobRequestOptions options = new BlobRequestOptions(); if(containerService.isContainer(folder)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder)); } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback())); return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder)); } } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } } AzureDirectoryFeature(final AzureSession session, final OperationContext context); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override Directory<Void> withWriter(final Write<Void> writer); }
AzureDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final BlobRequestOptions options = new BlobRequestOptions(); if(containerService.isContainer(folder)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); return new Path(folder.getParent(), folder.getName(), folder.getType(), new AzureAttributesFinderFeature(session, context).find(folder)); } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback())); return new Path(placeholder.getParent(), placeholder.getName(), placeholder.getType(), new AzureAttributesFinderFeature(session, context).find(placeholder)); } } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } } AzureDirectoryFeature(final AzureSession session, final OperationContext context); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override Directory<Void> withWriter(final Write<Void> writer);  }