@Test(expected = InteroperabilityException.class) public void testWriteRoot() throws Exception { final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session).withCache(cache); final Path test = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final TransferStatus status = new TransferStatus(); final SDSMultipartWriteFeature writer = new SDSMultipartWriteFeature(session, nodeid); final HttpResponseOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback()); }
@Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final String uploadToken = upload.start(file, status); final MultipartUploadTokenOutputStream proxy = new MultipartUploadTokenOutputStream(session, file, status, uploadToken); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, PreferencesFactory.get().getInteger("sds.upload.multipart.chunksize"))) { private final AtomicBoolean close = new AtomicBoolean(); @Override public VersionId getStatus() { return proxy.getVersionId(); } @Override public void close() throws IOException { try { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } super.close(); try { status.setVersion(upload.complete(file, uploadToken, status)); } catch(ConflictException e) { status.setVersion(upload.complete(file, uploadToken, new TransferStatus(status).exists(true))); } } catch(BackgroundException e) { throw new IOException(e); } finally { close.set(true); } } @Override protected void handleIOException(final IOException e) throws IOException { try { upload.cancel(file, uploadToken); } catch(BackgroundException f) { log.warn(String.format("Failure %s cancelling upload for file %s with upload token %s after failure %s", f, file, uploadToken, e)); } throw e; } }; }
SDSMultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final String uploadToken = upload.start(file, status); final MultipartUploadTokenOutputStream proxy = new MultipartUploadTokenOutputStream(session, file, status, uploadToken); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, PreferencesFactory.get().getInteger("sds.upload.multipart.chunksize"))) { private final AtomicBoolean close = new AtomicBoolean(); @Override public VersionId getStatus() { return proxy.getVersionId(); } @Override public void close() throws IOException { try { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } super.close(); try { status.setVersion(upload.complete(file, uploadToken, status)); } catch(ConflictException e) { status.setVersion(upload.complete(file, uploadToken, new TransferStatus(status).exists(true))); } } catch(BackgroundException e) { throw new IOException(e); } finally { close.set(true); } } @Override protected void handleIOException(final IOException e) throws IOException { try { upload.cancel(file, uploadToken); } catch(BackgroundException f) { log.warn(String.format("Failure %s cancelling upload for file %s with upload token %s after failure %s", f, file, uploadToken, e)); } throw e; } }; } }
SDSMultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final String uploadToken = upload.start(file, status); final MultipartUploadTokenOutputStream proxy = new MultipartUploadTokenOutputStream(session, file, status, uploadToken); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, PreferencesFactory.get().getInteger("sds.upload.multipart.chunksize"))) { private final AtomicBoolean close = new AtomicBoolean(); @Override public VersionId getStatus() { return proxy.getVersionId(); } @Override public void close() throws IOException { try { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } super.close(); try { status.setVersion(upload.complete(file, uploadToken, status)); } catch(ConflictException e) { status.setVersion(upload.complete(file, uploadToken, new TransferStatus(status).exists(true))); } } catch(BackgroundException e) { throw new IOException(e); } finally { close.set(true); } } @Override protected void handleIOException(final IOException e) throws IOException { try { upload.cancel(file, uploadToken); } catch(BackgroundException f) { log.warn(String.format("Failure %s cancelling upload for file %s with upload token %s after failure %s", f, file, uploadToken, e)); } throw e; } }; } SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid);  SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final Find finder, final AttributesFinder attributes); }
SDSMultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final String uploadToken = upload.start(file, status); final MultipartUploadTokenOutputStream proxy = new MultipartUploadTokenOutputStream(session, file, status, uploadToken); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, PreferencesFactory.get().getInteger("sds.upload.multipart.chunksize"))) { private final AtomicBoolean close = new AtomicBoolean(); @Override public VersionId getStatus() { return proxy.getVersionId(); } @Override public void close() throws IOException { try { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } super.close(); try { status.setVersion(upload.complete(file, uploadToken, status)); } catch(ConflictException e) { status.setVersion(upload.complete(file, uploadToken, new TransferStatus(status).exists(true))); } } catch(BackgroundException e) { throw new IOException(e); } finally { close.set(true); } } @Override protected void handleIOException(final IOException e) throws IOException { try { upload.cancel(file, uploadToken); } catch(BackgroundException f) { log.warn(String.format("Failure %s cancelling upload for file %s with upload token %s after failure %s", f, file, uploadToken, e)); } throw e; } }; } SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid);  SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<VersionId> 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(); }
SDSMultipartWriteFeature implements MultipartWrite<VersionId> { @Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final String uploadToken = upload.start(file, status); final MultipartUploadTokenOutputStream proxy = new MultipartUploadTokenOutputStream(session, file, status, uploadToken); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, PreferencesFactory.get().getInteger("sds.upload.multipart.chunksize"))) { private final AtomicBoolean close = new AtomicBoolean(); @Override public VersionId getStatus() { return proxy.getVersionId(); } @Override public void close() throws IOException { try { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } super.close(); try { status.setVersion(upload.complete(file, uploadToken, status)); } catch(ConflictException e) { status.setVersion(upload.complete(file, uploadToken, new TransferStatus(status).exists(true))); } } catch(BackgroundException e) { throw new IOException(e); } finally { close.set(true); } } @Override protected void handleIOException(final IOException e) throws IOException { try { upload.cancel(file, uploadToken); } catch(BackgroundException f) { log.warn(String.format("Failure %s cancelling upload for file %s with upload token %s after failure %s", f, file, uploadToken, e)); } throw e; } }; } SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid);  SDSMultipartWriteFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final Find finder, final AttributesFinder attributes); @Override HttpResponseOutputStream<VersionId> 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();  }