Interface PostAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
PostBatchAdminSession
This session creates, updates, and deletes Posts . 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
Post , a PostForm is requested using
getPostFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned PostForm
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
PostForm is submiited to a create operation, it cannot be reused
with another create operation unless the first operation was unsuccessful.
Each PostForm corresponds to an attempted transaction.
For updates, PostForms are requested to the Post
Id that is to be updated using getPostFormForUpdate() .
Similarly, the PostForm has metadata about the data that can be
updated and it can perform validation before submitting the update. The
PostForm can only be used once for a successful update and cannot
be reused.
The delete operations delete Posts . To unmap a Post
from the current Forum , the PostForumAssignmentSession
should be used. These delete operations attempt to remove the Post
itself thus removing it from all known Forum catalogs.
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anIdto aPostfor the purpose of creating compatibility.booleanTests if this user can createPosts.booleancanCreatePostWithRecordTypes(Type[] postRecordTypes) Tests if this user can create a singlePostusing the desired record types.booleanTests if this user can deletePostsA return of true does not guarantee successful authorization.booleanTests if this user can manageIdaliases forPosts.booleanTests if this user can updatePosts.createPost(PostForm postForm) Creates a newPost.voiddeletePost(Id postId) Deletes aPost.getForum()Gets theForumassociated with this session.Gets theForumIdassociated with this session.getPostFormForCreate(Type[] postRecordTypes) Gets the post form for creating new posts.getPostFormForUpdate(Id postId) Gets the post form for updating an existing post.voidupdatePost(PostForm postForm) Updates an existing post.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
-
getForumId
Id getForumId()Gets theForumIdassociated with this session.- Returns:
- the
Forum Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getForum
Gets theForumassociated with this session.- Returns:
- the forum
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreatePosts
boolean canCreatePosts()Tests if this user can createPosts. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aPostwill 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:
falseifPostcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreatePostWithRecordTypes
Tests if this user can create a singlePostusing the desired record types. WhileForumManager.getPostRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificPost. Providing an empty array tests if aPostcan be created with no records.- Parameters:
postRecordTypes- array of post record types- Returns:
trueifPostcreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-postRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getPostFormForCreate
PostForm getPostFormForCreate(Type[] postRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the post form for creating new posts. A new form should be requested for each create transaction.- Parameters:
postRecordTypes- array of post record types- Returns:
- the post form
- Throws:
NullArgumentException-postRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createPost
Creates a newPost.- Parameters:
postForm- the form for thisPost- Returns:
- the new
Post - Throws:
IllegalStateException-postFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-postFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-postFormdid not originate fromgetPostFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdatePosts
boolean canUpdatePosts()Tests if this user can updatePosts. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aPostwill 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:
falseifPostmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getPostFormForUpdate
PostForm getPostFormForUpdate(Id postId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the post form for updating an existing post. A new post form should be requested for each update transaction.- Parameters:
postId- theIdof thePost- Returns:
- the post form
- Throws:
NotFoundException-postIdis not foundNullArgumentException-postIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updatePost
Updates an existing post.- Parameters:
postForm- the form containing the elements to be updated- Throws:
IllegalStateException-postFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-postFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-postFormdid not originate fromgetPostFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeletePosts
boolean canDeletePosts()Tests if this user can deletePostsA return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aPostwill 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:
falseifPostdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deletePost
void deletePost(Id postId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aPost.- Parameters:
postId- theIdof thePostto remove- Throws:
NotFoundException-postIdnot foundNullArgumentException-postIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManagePostAliases
boolean canManagePostAliases()Tests if this user can manageIdaliases forPosts. 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:
falseifPostaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasPost
void aliasPost(Id postId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aPostfor the purpose of creating compatibility. The primaryIdof thePostis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another post, it is reassigned to the given postId.- Parameters:
postId- theIdof aPostaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-postIdnot foundNullArgumentException-postIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-