Interface BallotAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
BallotBatchAdminSession
This session creates, updates, and deletes Ballots . 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
Ballot , a BallotForm is requested using
getBallotFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned
BallotForm 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 BallotForm is submiited to a create operation, it cannot
be reused with another create operation unless the first operation was
unsuccessful. Each BallotForm corresponds to an attempted
transaction.
For updates, BallotForms are requested to the Ballot
Id that is to be updated using getBallotFormForUpdate() .
Similarly, the BallotForm has metadata about the data that can be
updated and it can perform validation before submitting the update. The
BallotForm can only be used once for a successful update and
cannot be reused.
The delete operations delete Ballots . To unmap a
Ballot from the current Polls , the
BallotPollsAssignmentSession should be used. These delete operations
attempt to remove the Ballot itself thus removing it from all
known Polls catalogs.
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaliasBallot(Id ballotId, Id aliasId) Adds anIdto aBallotfor the purpose of creating compatibility.booleanTests if this user can createBallots.booleancanCreateBallotWithRecordTypes(Type[] ballotRecordTypes) Tests if this user can create a singleBallotusing the desired record types.booleanTests if this user can deleteBallots.booleanTests if this user can manageIdaliases forBallots.booleanTests if this user can updateBallots.createBallot(BallotForm ballotForm) Creates a newBallot.voiddeleteBallot(Id ballotId) Deletes aBallot.getBallotFormForCreate(Type[] ballotRecordTypes) Gets the ballot form for creating new ballots.getBallotFormForUpdate(Id ballotId) Gets the ballot form for updating an existing ballot.getPolls()Gets thePollsassociated with this session.Gets thePollsIdassociated with this session.voidupdateBallot(BallotForm ballotForm) Updates an existing ballot.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
-
getPollsId
Id getPollsId()Gets thePollsIdassociated with this session.- Returns:
- the
Polls Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getPolls
Gets thePollsassociated with this session.- Returns:
- the
Pollsassociated with this session - Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreateBallots
boolean canCreateBallots()Tests if this user can createBallots. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aBallotwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer create operations to an unauthorized user.- Returns:
falseifBallotcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateBallotWithRecordTypes
Tests if this user can create a singleBallotusing the desired record types. WhileVotingManager.getBallotRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificBallot. Providing an empty array tests if aBallotcan be created with no records.- Parameters:
ballotRecordTypes- array of ballot record types- Returns:
trueifBallotcreation using the specifiedTypesis supported,falseotherwise- Throws:
NullArgumentException-ballotRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getBallotFormForCreate
BallotForm getBallotFormForCreate(Type[] ballotRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the ballot form for creating new ballots. A new form should be requested for each create transaction.- Parameters:
ballotRecordTypes- array of ballot record types- Returns:
- the ballot form
- Throws:
NullArgumentException-ballotRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form with requested record types- Compliance:
mandatory- This method must be implemented.
-
createBallot
Ballot createBallot(BallotForm ballotForm) throws OperationFailedException, PermissionDeniedException Creates a newBallot.- Parameters:
ballotForm- the form for thisBallot- Returns:
- the new
Ballot - Throws:
IllegalStateException-ballotFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-ballotFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-ballotFormdid not originate fromgetBallotFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateBallots
boolean canUpdateBallots()Tests if this user can updateBallots. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aBallotwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer update operations to an unauthorized user.- Returns:
falseifBallotmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getBallotFormForUpdate
BallotForm getBallotFormForUpdate(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the ballot form for updating an existing ballot. A new ballot form should be requested for each update transaction.- Parameters:
ballotId- theIdof theBallot- Returns:
- the ballot form
- Throws:
NotFoundException-ballotIdis not foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateBallot
Updates an existing ballot.- Parameters:
ballotForm- the form containing the elements to be updated- Throws:
IllegalStateException-ballotFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-ballotFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-ballotFormdid not originate fromgetBallotFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteBallots
boolean canDeleteBallots()Tests if this user can deleteBallots. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aBallotwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer delete operations to an unauthorized user.- Returns:
falseifBallotdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteBallot
void deleteBallot(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aBallot.- Parameters:
ballotId- theIdof theBallotto remove- Throws:
NotFoundException-ballotIdnot foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageBallotAliases
boolean canManageBallotAliases()Tests if this user can manageIdaliases forBallots. 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:
falseifBallotaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasBallot
void aliasBallot(Id ballotId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aBallotfor the purpose of creating compatibility. The primaryIdof theBallotis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another ballot it is reassigned to the given ballotId.- Parameters:
ballotId- theIdof aBallotaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-ballotIdnot foundNullArgumentException-aliasIdorballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-