class DefaultRightResolver extends AbstractRightResolver {

    @Override
    public AccessLevel resolve(DocumentReference user,
                               EntityReference entity,
                               RightCacheKey entityKey,
                               Collection<DocumentReference> groups,
                               List<Collection<RightsObject>> rightsObjects)
    {
        AccessLevel accessLevel = new AccessLevel();

        /*
         * Allow everything for superadmin.
         */
        if (isSuperAdmin(user)) {
            for (Right right : Right.values()) {
                accessLevel.allow(right);
            }
            return accessLevel.getExistingInstance();
        }

        /*
         * Creator is granted delete-rights.
         */
        if (isCreator(user, entity)) {
            accessLevel.allow(DELETE);
        }

        /*
         * Wiki owner is granted admin rights.
         */
        if (isWikiOwner(user, entity)) {
            accessLevel.allow(ADMIN);
        }

        ListIterator<Collection<RightsObject>> iterator
            = rightsObjects.listIterator(rightsObjects.size());
        EntityReference ref = entityKey.getEntityReference();
        while (iterator.hasPrevious() && ref != null) {
            resolve(user, groups, iterator.previous(), ref, accessLevel);
            ref = ref.getParent();
        }

        assert (!iterator.hasPrevious() && ref == null);

        postProcess(user, entity, accessLevel);

        return accessLevel.getExistingInstance();
    }

}