@Override
    public boolean isAccessible(final Path file, final boolean container) {
        if(file.isRoot()) {
            return false;
        }
        if(file.attributes().isDuplicate()) {
            return false;
        }
        final ContainerItem containerItem = this.getContainer(file);

        // Operations using container access:
        // touch, directory
        // copy, move: Only for target check
        // Operations not using container access:
        // copy, move: For source check.

        // For touch/directory:
        // Allow inside any directory that is either /My Files or a subfolder of /Shared.

        // For copy/move
        // Allow from a non-container item to a container-item.
        // e.g.
        // * /My Files/Folder/ToBeMoved to /My Files
        // * /Shared/Shared Folder/Nested/ToBeMoved to /Shared/Shared Folder/

        // Test for Container.
        if(containerItem.isDrive()) {
            // Is /My Files.
            // Tests whether container access is used, orelse deny access to /My Files.
            return container || !containerItem.getContainerPath().map(new SimplePathPredicate(file)::test).orElse(false);
        }
        else {
            // Check for /Shared-path
            // Catches modification of items in /Shared
            Optional<Boolean> predicate = containerItem.getCollectionPath().map(new SimplePathPredicate(file)::test);
            if(!container) {
                // Append condition to /Shared-path check for
                // If file parent is /Shared then return inaccessible below
                // Cannot modify items in /Shared/*, but /Shared/**/*
                // User must not be able to rename, move or copy first level of /Shared.
                predicate = predicate.map(o -> o || containerItem.getCollectionPath().map(new SimplePathPredicate(file.getParent())::test).get());
            }
            // Fallback to deny access for invalid paths (/Invalid).
            // Logic is upside down. Predicate determines whether to block access. Flip it.
            return !predicate.orElse(true);
        }
    }
@Test
    public void testIsAccessible() {
        // Tests for valid accessibility for regular access and container access.
        // Determines whether Touch/Directory/Move/Copy can perform actions
        // Touch/Directory require valid container.
        // Move/Copy require valid container for target and valid source.

        final List<TestCase> test = new ArrayList<>();
        test.add(new TestCase("/", false, false));
        test.add(new TestCase("/Invalid", false, false));
        test.add(new TestCase("/My Files", false, true));
        test.add(new TestCase("/My Files/Test", true, true));
        test.add(new TestCase("/Shared", false, false));
        test.add(new TestCase("/Shared/Folder", false, true));
        test.add(new TestCase("/Shared/Folder/Test", true, true));

        for(TestCase testCase : test) {
            final Path path = new Path(testCase.target, EnumSet.of(Path.Type.directory));
            assertEquals(String.format("Non-Container access: for %s", path), testCase.isValid, session.isAccessible(path, false));
            assertEquals(String.format("Container access: for %s", path), testCase.isValidContainer, session.isAccessible(path, true));
        }
    }