Interface ContentRestrictionService

    • Method Detail

      • getRestrictionsForOperation

        ContentRestriction getRestrictionsForOperation​(ContentId target,
                                                       OperationKey operationKey,
                                                       PageRequest pageRequest,
                                                       Expansion... expansions)
                                                throws ServiceException
        Retrieves all restrictions for given operation key on given content.
        Parameters:
        target - the id of the content to look up permissions for
        operationKey - the operation key to look up restrictions for
        pageRequest - pagination through the subjects contained within the ContentRestriction
        expansions - the expansions to the ContentRestriction.
        Returns:
        ContentRestriction containing relevant restrictions for given operation key, or null if operation key does not have corresponding restrictions.
        Throws:
        NotFoundException - if given content id does not exist, or is not viewable by user, or if the given operation key is not recognised for the content.
        ServiceException
        Since:
        5.7
      • getRestrictions

        ContentRestrictionsPageResponse getRestrictions​(ContentId target,
                                                        PageRequest pageRequest,
                                                        Expansion... expansions)
                                                 throws NotFoundException
        Retrieves all the restrictions for all the operations on a given Content.
        Parameters:
        target - the id of the content to look up permissions for
        pageRequest - pagination through the list of all the ContentRestrictions returned
        expansions - the expansions to the ContentRestriction
        Returns:
        a paginated response, containing all the ContentRestrictions for the given content
        Throws:
        NotFoundException - if given content id does not exist, or is not viewable by user
        Since:
        5.10
      • updateRestrictions

        ContentRestrictionsPageResponse updateRestrictions​(ContentId target,
                                                           Collection<? extends ContentRestriction> contentRestrictions,
                                                           Expansion... expansions)
                                                    throws ServiceException
        Sets all the restrictions specified to a piece of content identified by contentId, replacing any existing permissions. Setting per-content restrictions is currently allowed for Pages or BlogPosts only.

        Rules of applying restrictions via this method:

        • Provided collection of ContentRestrictions is allowed to have only 1 (ONE) ContentRestriction object for each operation.
        • Provided ContentRestrictions will replace (overwrite) any pre-existing restrictions on the Content under the corresponding operations.
        • In case provided collection of ContentRestriction does not have any of the operations supported it is assumed that restrictions for such operation should not be changed at all.
        • Restrictions with the "users" and/or "groups" map entries explicitly set to be empty arrays will result in removing corresponding restrictions for the content.
        • Restrictions with the "users" and/or "groups" map entries missing will result in not changing corresponding operation's user/group restrictions for the content.
        • It is not allowed to edit the restrictions in such a way which would remove requesting user's access.
        • Only Page, BlogPost and other add-on provided Content Types that support direct content restrictions are supported.
        Parameters:
        target - the id of the content to assign restrictions to
        contentRestrictions - Collection of ContentRestrictions to apply to the Content specified
        expansions - the expansions to the ContentRestriction. To be expanded on response.
        Returns:
        ContentRestrictionsPageResponse describing the new state of the content identified by contentId (same as getRestrictions(ContentId, PageRequest, Expansion...) would return)
        Throws:
        ServiceException - or one of it subtypes.
        NotFoundException - in case there's no Content with ID provided or user does not have enough rights to view it
        PermissionException - in case user is not allowed to alter restrictions on the content specified
        BadRequestException - in case when data supplied is not enough/corrupt, etc... many reasons. Exception generally would have message which explains what's wrong.
        Since:
        5.10
      • addRestrictions

        ContentRestrictionsPageResponse addRestrictions​(ContentId target,
                                                        Collection<? extends ContentRestriction> contentRestrictions,
                                                        Expansion... expansions)
                                                 throws ServiceException
        Attempts to add all the restrictions specified to a piece of content identified by contentId. Does not replace/remove/alter any pre-existing ContentRestrictions. Provided ContentRestrictions will be added, i.e. "merged with" any pre-existing restrictions on the Content under the corresponding operations. Changing per-content restrictions is currently allowed for Pages or BlogPosts only.

        Rules of applying restrictions via this method:

        • Provided collection of ContentRestrictions is allowed to have only 1 (ONE) ContentRestriction object for each operation.
        • Provided ContentRestrictions will be added, i.e. "merged with" any pre-existing restrictions on the Content under the corresponding operations.
        • In case provided collection of ContentRestriction does not have any of the operations supported no changes will happen.
        • Restrictions with the "users" and/or "groups" map entries explicitly set to be empty arrays will result in not changing corresponding operation's user/group restrictions for the content.
        • Restrictions with the "users" and/or "groups" map entries missing will result in not changing corresponding operation's user/group restrictions for the content.
        • It is not allowed to edit the restrictions in such a way which would remove requesting user's access.
        • Only Page, BlogPost and other add-on provided Content Types that support direct content restrictions are supported.
        Parameters:
        target - the id of the content to add restrictions to
        contentRestrictions - Collection of ContentRestrictions to apply to the Content specified
        expansions - the expansions to the ContentRestriction. To be expanded on response.
        Returns:
        ContentRestrictionsPageResponse describing the new state of the content identified by contentId (same as getRestrictions(ContentId, PageRequest, Expansion...) would return)
        Throws:
        ServiceException - or one of it subtypes.
        NotFoundException - in case there's no Content with ID provided or user does not have enough rights to view it
        PermissionException - in case user is not allowed to alter restrictions on the content specified
        BadRequestException - in case when data supplied is not enough/corrupt, etc... many reasons. Exception generally would have message which explains what's wrong.
        Since:
        5.10
      • deleteAllDirectRestrictions

        ContentRestrictionsPageResponse deleteAllDirectRestrictions​(ContentId target,
                                                                    Expansion... expansions)
                                                             throws ServiceException
        Attempts to delete all the restrictions specified directly on a piece of content identified by contentId. "specified directly" means that deleting restrictions on some content won't affect any restrictions inherited from its parents. Changing per-content restrictions is currently allowed for Pages, Blog Posts and other add-on provided Content Types that support direct content restrictions.
        Parameters:
        target - the id of the content to remove all directly specified restrictions from
        expansions - the expansions to the ContentRestriction. To be expanded on response.
        Returns:
        ContentRestrictionsPageResponse describing the new state of the content identified by contentId (same as getRestrictions(ContentId, PageRequest, Expansion...) would return)
        Throws:
        ServiceException - or one of it subtypes.
        NotFoundException - in case there's no Content with ID provided or user does not have enough rights to view it
        PermissionException - in case user is not allowed to alter restrictions on the content specified
        Since:
        5.10
      • hasDirectRestrictionForSubject

        boolean hasDirectRestrictionForSubject​(ContentId contentId,
                                               OperationKey operationKey,
                                               Subject subject)
                                        throws ServiceException
        Returns true if the User or Group specified by the subject parameter has restriction(s) for the operationKey operation which are specified directly on the Content identified by contentId parameter.

        Returns false otherwise.

        Can throw BadRequestException or PermissionException and other various subtypes of ServiceException in case of bad IDs, parameters, permission problems, etc.

        Parameters:
        contentId - the id of the content which the check will be performed on
        operationKey - the operation key to check restrictions against
        subject - either User or Group who's restriction is in question
        Returns:
        true or false depending on whether user/group specified have any direct restrictions on a content specified
        Throws:
        ServiceException - or one of it subtypes.
        NotFoundException - in case there's no Content with ID provided or user does not have enough rights to view it
        Since:
        5.10
      • deleteDirectRestrictionForSubject

        void deleteDirectRestrictionForSubject​(ContentId contentId,
                                               OperationKey operationKey,
                                               Subject subject)
                                        throws ServiceException
        Deletes singular direct ContentRestriction for operationKey and subject from the content identified by contentId parameter. Throws subclasses of ServiceException in case of various problems (cannot find content, restrictions to be deleted does not exist, etc...)
        Parameters:
        contentId - the id of the content which the restriction to be removed from
        operationKey - the operation to remove restriction for
        subject - either User or Group who's restriction is to be deleted
        Throws:
        ServiceException
        Since:
        5.10
      • addDirectRestrictionForSubject

        void addDirectRestrictionForSubject​(ContentId contentId,
                                            OperationKey operationKey,
                                            Subject subject)
                                     throws ServiceException
        Adds singular direct ContentRestriction for operationKey and subject to the content identified by contentId parameter. Throws subclasses of ServiceException in case of various problems (cannot find content, wrong operationKey, restricting self, etc...)
        Parameters:
        contentId - the id of the content which the restriction to be added to
        operationKey - the operation to remove restriction for
        subject - either User or Group who's restriction is to be added
        Throws:
        ServiceException
        Since:
        5.10