Interface BookAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
BookBatchAdminSession
This session creates, updates, and deletes Books . 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
Book , a BookForm is requested using
getBookFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned BookForm
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
BookForm is submiited to a create operation, it cannot be reused
with another create operation unless the first operation was unsuccessful.
Each BookForm corresponds to an attempted transaction.
For updates, BookForms are requested to the Book
Id that is to be updated using getBookFormForUpdate() .
Similarly, the BookForm has metadata about the data that can be
updated and it can perform validation before submitting the update. The
BookForm can only be used once for a successful update and cannot
be reused.
The delete operations delete Books .
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anIdto aBookfor the purpose of creating compatibility.booleanTests if this user can createBooks.booleancanCreateBookWithRecordTypes(Type[] bookRecordTypes) Tests if this user can create a singleBookusing the desired record types.booleanTests if this user can deleteBooksA return of true does not guarantee successful authorization.booleanTests if this user can manageIdaliases forBooks.booleanTests if this user can updateBooks.createBook(BookForm bookForm) Creates a newBook.voiddeleteBook(Id bookId) Deletes aBook.getBookFormForCreate(Type[] bookRecordTypes) Gets the book form for creating new books.getBookFormForUpdate(Id bookId) Gets the book form for updating an existing book.voidupdateBook(BookForm bookForm) Updates an existing book.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
-
canCreateBooks
boolean canCreateBooks()Tests if this user can createBooks. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aBookwill 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:
falseifBookcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateBookWithRecordTypes
Tests if this user can create a singleBookusing the desired record types. WhileCommentingManager.getBookRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificBook. Providing an empty array tests if aBookcan be created with no records.- Parameters:
bookRecordTypes- array of book record types- Returns:
trueifBookcreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-bookRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getBookFormForCreate
BookForm getBookFormForCreate(Type[] bookRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the book form for creating new books. A new form should be requested for each create transaction.- Parameters:
bookRecordTypes- array of book record types- Returns:
- the book form
- Throws:
NullArgumentException-bookRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createBook
Creates a newBook.- Parameters:
bookForm- the form for thisBook- Returns:
- the new
Book - Throws:
IllegalStateException-bookFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-bookFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-bookFormdid not originte fromgetBookFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateBooks
boolean canUpdateBooks()Tests if this user can updateBooks. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aBookwill 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:
falseifBookmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getBookFormForUpdate
BookForm getBookFormForUpdate(Id bookId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the book form for updating an existing book. A new book form should be requested for each update transaction.- Parameters:
bookId- theIdof theBook- Returns:
- the book form
- Throws:
NotFoundException-bookIdis not foundNullArgumentException-bookIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateBook
Updates an existing book.- Parameters:
bookForm- the form containing the elements to be updated- Throws:
IllegalStateException-bookFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-bookFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-bookFormdid not originte fromgetBookFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteBooks
boolean canDeleteBooks()Tests if this user can deleteBooksA return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aBookwill 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:
falseifBookdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteBook
void deleteBook(Id bookId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aBook.- Parameters:
bookId- theIdof theBookto remove- Throws:
NotFoundException-bookIdnot foundNullArgumentException-bookIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageBookAliases
boolean canManageBookAliases()Tests if this user can manageIdaliases forBooks. 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:
falseifBookaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasBook
void aliasBook(Id bookId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aBookfor the purpose of creating compatibility. The primaryIdof theBookis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another book, it is reassigned to the given bookId.- Parameters:
bookId- theIdof aBookaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-bookIdnot foundNullArgumentException-bookIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-