Interface CommentAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
CommentBatchAdminSession
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 Summary
Modifier and TypeMethodDescriptionvoidaliasComment(Id commentId, Id aliasId) Adds anIdto aCommentfor the purpose of creating compatibility.booleanTests if this user can create comments.booleancanCreateCommentWithRecordTypes(Type[] commentRecordTypes) Tests if this user can create a singleCommentusing the desired record types.booleanTests if this user can delete comments.booleanTests if this user can manageIdaliases forComnents.booleanTests if this user can update comments.createComment(CommentForm commentForm) Creates a newComment.voiddeleteComment(Id commentId) Deletes aComment.getBook()Gets theBookassociated with this session.Gets theBookIdassociated with this session.getCommentFormForCreate(Id referenceId, Type[] commentRecordTypes) Gets the comment form for creating new comments.getCommentFormForUpdate(Id commentId) Gets the comment form for updating an existing comment.voidupdateComment(CommentForm commentForm) Updates an existing comment.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
getBookId
Id getBookId()Gets theBookIdassociated with this session.- Returns:
- the
Book Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getBook
Gets theBookassociated with this session.- Returns:
- the book
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- 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 aCommentwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.- Returns:
falseifCommentcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateCommentWithRecordTypes
Tests if this user can create a singleCommentusing the desired record types. WhileCommentingManager.getCommentRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificComment. Providing an empty array tests if aCommentcan be created with no records.- Parameters:
commentRecordTypes- array of comment record types- Returns:
trueifCommentcreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-commentRecordTypesisnull- 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- theIdfor the reference objectcommentRecordTypes- array of comment record types- Returns:
- the comment form
- Throws:
NullArgumentException-referenceId or commentRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createComment
Comment createComment(CommentForm commentForm) throws OperationFailedException, PermissionDeniedException Creates a newComment.- Parameters:
commentForm- the form for thisComment- Returns:
- the new
Comment - Throws:
IllegalStateException-commentFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-commentFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-commentFormdid not originate fromgetCommentFormForCreate()- 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 aCommentwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.- Returns:
falseifCommentmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getCommentFormForUpdate
CommentForm getCommentFormForUpdate(Id commentId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the comment form for updating an existing comment. A new comment form should be requested for each update transaction.- Parameters:
commentId- theIdof theComment- Returns:
- the comment form
- Throws:
NotFoundException-commentIdis not foundNullArgumentException-commentIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- 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-commentFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-commentFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-commentFormdid not originate fromgetCommentFormForUpdate()- 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 anCommentwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.- Returns:
falseifCommentdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteComment
void deleteComment(Id commentId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aComment.- Parameters:
commentId- theIdof theCommentto remove- Throws:
NotFoundException-commentIdnot foundNullArgumentException-commentIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageCommentAliases
boolean canManageCommentAliases()Tests if this user can manageIdaliases forComnents. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.- Returns:
falseifCommentaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasComment
void aliasComment(Id commentId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aCommentfor the purpose of creating compatibility. The primaryIdof theCommentis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another comment, it is reassigned to the given commentId.- Parameters:
commentId- theIdof aCommentaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-commentIdnot foundNullArgumentException-commentIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-