@Override
    public void preflight(final Path source, final Path target) throws BackgroundException {
        // defaults to Acl.EMPTY (disabling role checking) if target does not exist
        assumeRole(target, WRITEPERMISSION);
        // no createfilespermission required for now
        if(source.isDirectory()) {
            assumeRole(target.getParent(), target.getName(), CREATEDIRECTORIESPERMISSION);
        }
    }
@Test
    public void testPreflightFileAccessDeniedTargetExistsNotWritableCustomProps() throws Exception {
        final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        source.setAttributes(source.attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.READPERMISSION)));
        final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        target.setAttributes(target.attributes().withAcl(new Acl(new Acl.CanonicalUser())));
        // no createfilespermission required for now
        target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser())));
        final CteraAttributesFinderFeature mock = mock(CteraAttributesFinderFeature.class);
        // target exists and not writable
        when(mock.find(eq(target))).thenReturn(new PathAttributes().withAcl(new Acl(new Acl.CanonicalUser())));
        final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session, mock).preflight(source, target));
        assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), target.getName())));
    }