Class ContentRestrictionResource


  • public class ContentRestrictionResource
    extends Object
    • Method Detail

      • byOperation

        @PublicApi
        public Map<OperationKey,​ContentRestriction> byOperation​(ContentId id,
                                                                      String expand)

        Returns info about all restrictions by operation

        Parameters:
        id - the id of the content
        expand - a comma separated list of properties to expand on the content properties. Default value: group.
        Returns:
        a JSON representation of the restrictions group by operations
      • forOperation

        @PublicApi
        public ContentRestriction forOperation​(ContentId id,
                                               OperationKey opKey,
                                               String expand,
                                               int start,
                                               int limit)

        Returns info about all restrictions of given operation

        Parameters:
        id - the id of the content
        opKey - key of the operation
        expand - a comma separated list of properties to expand on the content properties. Default value: group.
        start - pagination start
        limit - pagination limit
        Returns:
        a JSON representation of the restrictions group by operations
      • updateRestrictions

        @PublicApi
        public PageResponse<ContentRestriction> updateRestrictions​(ContentId contentId,
                                                                   String expand,
                                                                   List<ContentRestriction> contentRestrictions)
        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.

        Example request URI:

        • http://example.com/confluence/rest/content/1234567/restriction?expand=

        The payload uses the same schema as returned by the GET requests from /rest/api/content/{id}/restriction/byOperation* which can be used as a template but is not necessary.

        Note that the required keys are operation and restrictions.

        E.g.

        Example request for a single content restriction:

        
         [
           {
             "operation": "update",
             "restrictions":
             {
               "user": [
                 {
                   "type": "known",
                   "username": "admin"
                 }
               ]
             }
           }
         ]
         

        Example request for updating two ContentRestrictions:

        
         [
             {
                 "operation": "update",
                 "restrictions": {
                     "user": [
                         {
                             "type": "known",
                             "username": "admin"
                         }
                     ]
                 }
             },
             {
                 "operation": "read",
                 "restrictions": {
                     "user": [
                         {
                             "type": "known",
                             "username": "fred"
                         }
                     ]
                 }
        
             }
         ]
         

        Rules for using this method:

        - The provided ContentRestrictions will overwrite any existing restrictions on the Content for the corresponding operations.

        - If the provided ContentRestriction lacks any supported operations, the restrictions for the operations will not be altered.

        - Setting "users" and/or "groups" map entries as empty arrays will remove the corresponding content restrictions.

        - Missing "users" and/or "groups" map entries means the corresponding operation's user/group content restrictions won't be changed.

        - Modifying restrictions to revoke the requesting user's access is prohibited.

        Parameters:
        contentId - content to set restrictions for
        expand - A comma separated list of properties to expand in the response. Default is restrictions.user, restrictions.group
        Returns:
        the new state of the resource. PageResponse with all the restrictions which are specified directly on a Content. Result is the same as the response of GET to the same resource would return.