@Override
    public HttpResponseOutputStream<Void> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
        try {
            return this.write(file, this.toHeaders(file, status, expect), status);
        }
        catch(ConflictException e) {
            if(expect) {
                if(null != status.getLockId()) {
                    // Handle 412 Precondition Failed with expired token
                    log.warn(String.format("Retry failure %s with lock id %s removed", e, status.getLockId()));
                    return this.write(file, this.toHeaders(file, status.withLockId(null), expect), status);
                }
            }
            throw e;
        }
        catch(InteroperabilityException e) {
            if(expect) {
                // Handle 417 Expectation Failed
                log.warn(String.format("Retry failure %s with Expect: Continue removed", e));
                return this.write(file, this.toHeaders(file, status.withLockId(null), false), status);
            }
            throw e;
        }
    }
@Test(expected = AccessDeniedException.class)
    @Ignore
    public void testWriteAccessDenied() throws Exception {
        final Path test = new Path(new DefaultHomeFinderService(session).find().getAbsolute() + "/nosuchdirectory/" + new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        // With Expect: Continue header
        final HttpResponseOutputStream<Void> out = new DAVWriteFeature(session).write(test, new TransferStatus().withLength(0L), new DisabledConnectionCallback());
        out.close();
    }