class DropboxRootListService implements ListService {

    @Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        try {
            if(directory.isRoot()) {
                final FullAccount account = new DbxUserUsersRequests(session.getClient()).getCurrentAccount();
                switch(account.getAccountType()) {
                    case BUSINESS:
                        return new DropboxListService(session).list(
                            directory.withAttributes(new PathAttributes().withVersionId(account.getRootInfo().getRootNamespaceId())),
                            new HomeNamespaceListProgressListener(listener, account));
                }
            }
            return new DropboxListService(session).list(directory, listener);
        }
        catch(DbxException e) {
            throw new DropboxExceptionMappingService().map("Listing directory {0} failed", e, directory);
        }
    }

    public  DropboxRootListService(final DropboxSession session);

}