@Test public void testCreatePlaceholderEqualSign() throws Exception { final String name = String.format("%s=", new AlphanumericRandomStringService().random()); final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(container, name, EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertTrue(new S3FindFeature(session).find(test)); assertTrue(new DefaultFindFeature(session).find(test)); assertTrue(new S3ObjectListService(session).list(test, new DisabledListProgressListener()).isEmpty()); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { if(containerService.isContainer(folder)) { final S3BucketCreateService service = new S3BucketCreateService(session); service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region); return folder; } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); status.setMime(MIMETYPE); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), type, new S3AttributesFinderFeature(session).toAttributes(metadata)); } }
S3DirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { if(containerService.isContainer(folder)) { final S3BucketCreateService service = new S3BucketCreateService(session); service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region); return folder; } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); status.setMime(MIMETYPE); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), type, new S3AttributesFinderFeature(session).toAttributes(metadata)); } } }
S3DirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { if(containerService.isContainer(folder)) { final S3BucketCreateService service = new S3BucketCreateService(session); service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region); return folder; } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); status.setMime(MIMETYPE); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), type, new S3AttributesFinderFeature(session).toAttributes(metadata)); } } S3DirectoryFeature(final S3Session session, final Write<StorageObject> writer); }
S3DirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { if(containerService.isContainer(folder)) { final S3BucketCreateService service = new S3BucketCreateService(session); service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region); return folder; } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); status.setMime(MIMETYPE); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), type, new S3AttributesFinderFeature(session).toAttributes(metadata)); } } S3DirectoryFeature(final S3Session session, final Write<StorageObject> writer); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override S3DirectoryFeature withWriter(final Write<StorageObject> writer); }
S3DirectoryFeature implements Directory<StorageObject> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { if(containerService.isContainer(folder)) { final S3BucketCreateService service = new S3BucketCreateService(session); service.create(folder, StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region); return folder; } else { status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)); status.setMime(MIMETYPE); final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), type, new S3AttributesFinderFeature(session).toAttributes(metadata)); } } S3DirectoryFeature(final S3Session session, final Write<StorageObject> writer); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override S3DirectoryFeature withWriter(final Write<StorageObject> writer);  }