Interface CommentAdminSession

All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
All Known Subinterfaces:
CommentBatchAdminSession

public interface CommentAdminSession extends OsidSession

This session creates, updates, and deletes Comments . The data for create and update is provided by the consumer via the form object. OsidForms are requested for each create or update and may not be reused.

Create and update operations differ in their usage. To create a Comment , a CommentForm is requested using getCommentFormForCreate() specifying the desired relationship peers and record Types or none if no record Types are needed. The returned CommentForm will indicate that it is to be used with a create operation and can be used to examine metdata or validate data prior to creation. Once the CommentForm is submiited to a create operation, it cannot be reused with another create operation unless the first operation was unsuccessful. Each CommentForm corresponds to an attempted transaction.

For updates, CommentForms are requested to the Comment Id that is to be updated using getCommentFormForUpdate() . Similarly, the CommentForm has metadata about the data that can be updated and it can perform validation before submitting the update. The CommentForm can only be used once for a successful update and cannot be reused.

The delete operations delete Comments . To unmap a Comment from the current Book , the CommentBookAssignmentSession should be used. These delete operations attempt to remove the Comment itself thus removing it from all known Book catalogs.

This session includes an Id aliasing mechanism to assign an external Id to an internally assigned Id.

  • Method Details

    • getBookId

      Id getBookId()
      Gets the Book Id associated with this session.
      Returns:
      the Book Id associated with this session
      Compliance:
      mandatory - This method must be implemented.
    • getBook

      Gets the Book associated with this session.
      Returns:
      the book
      Throws:
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.
    • canCreateComments

      boolean canCreateComments()
      Tests if this user can create comments. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating a Comment will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.
      Returns:
      false if Comment creation is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • canCreateCommentWithRecordTypes

      boolean canCreateCommentWithRecordTypes(Type[] commentRecordTypes)
      Tests if this user can create a single Comment using the desired record types. While CommentingManager.getCommentRecordTypes() can be used to examine which records are supported, this method tests which record(s) are required for creating a specific Comment . Providing an empty array tests if a Comment can be created with no records.
      Parameters:
      commentRecordTypes - array of comment record types
      Returns:
      true if Comment creation using the specified record Types is supported, false otherwise
      Throws:
      NullArgumentException - commentRecordTypes is null
      Compliance:
      mandatory - This method must be implemented.
    • getCommentFormForCreate

      CommentForm getCommentFormForCreate(Id referenceId, Type[] commentRecordTypes) throws OperationFailedException, PermissionDeniedException
      Gets the comment form for creating new comments. A new form should be requested for each create transaction.
      Parameters:
      referenceId - the Id for the reference object
      commentRecordTypes - array of comment record types
      Returns:
      the comment form
      Throws:
      NullArgumentException - referenceId or commentRecordTypes is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - unable to get form for requested record types
      Compliance:
      mandatory - This method must be implemented.
    • createComment

      Creates a new Comment .
      Parameters:
      commentForm - the form for this Comment
      Returns:
      the new Comment
      Throws:
      IllegalStateException - commentForm already used in a create transaction
      InvalidArgumentException - one or more of the form elements is invalid
      NullArgumentException - commentForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - commentForm did not originate from getCommentFormForCreate()
      Compliance:
      mandatory - This method must be implemented.
    • canUpdateComments

      boolean canUpdateComments()
      Tests if this user can update comments. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating a Comment will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.
      Returns:
      false if Comment modification is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • getCommentFormForUpdate

      Gets the comment form for updating an existing comment. A new comment form should be requested for each update transaction.
      Parameters:
      commentId - the Id of the Comment
      Returns:
      the comment form
      Throws:
      NotFoundException - commentId is not found
      NullArgumentException - commentId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.
    • updateComment

      void updateComment(CommentForm commentForm) throws OperationFailedException, PermissionDeniedException
      Updates an existing comment.
      Parameters:
      commentForm - the form containing the elements to be updated
      Throws:
      IllegalStateException - commentForm already used in an update transaction
      InvalidArgumentException - the form contains an invalid value
      NullArgumentException - commentForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - commentForm did not originate from getCommentFormForUpdate()
      Compliance:
      mandatory - This method must be implemented.
    • canDeleteComments

      boolean canDeleteComments()
      Tests if this user can delete comments. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting an Comment will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.
      Returns:
      false if Comment deletion is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • deleteComment

      Deletes a Comment .
      Parameters:
      commentId - the Id of the Comment to remove
      Throws:
      NotFoundException - commentId not found
      NullArgumentException - commentId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.
    • canManageCommentAliases

      boolean canManageCommentAliases()
      Tests if this user can manage Id aliases for Comnents . A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in a PERMISSION_DENIED . This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.
      Returns:
      false if Comment aliasing is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • aliasComment

      Adds an Id to a Comment for the purpose of creating compatibility. The primary Id of the Comment is determined by the provider. The new Id performs as an alias to the primary Id . If the alias is a pointer to another comment, it is reassigned to the given comment Id .
      Parameters:
      commentId - the Id of a Comment
      aliasId - the alias Id
      Throws:
      AlreadyExistsException - aliasId is already assigned
      NotFoundException - commentId not found
      NullArgumentException - commentId or aliasId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.