Interface BallotAdminSession

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

public interface BallotAdminSession extends OsidSession

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 Details

    • getPollsId

      Id getPollsId()
      Gets the Polls Id associated with this session.
      Returns:
      the Polls Id associated with this session
      Compliance:
      mandatory - This method must be implemented.
    • getPolls

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

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

      boolean canCreateBallotWithRecordTypes(Type[] ballotRecordTypes)
      Tests if this user can create a single Ballot using the desired record types. While VotingManager.getBallotRecordTypes() can be used to examine which records are supported, this method tests which record(s) are required for creating a specific Ballot . Providing an empty array tests if a Ballot can be created with no records.
      Parameters:
      ballotRecordTypes - array of ballot record types
      Returns:
      true if Ballot creation using the specified Types is supported, false otherwise
      Throws:
      NullArgumentException - ballotRecordTypes is null
      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 - ballotRecordTypes is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - unable to get form with requested record types
      Compliance:
      mandatory - This method must be implemented.
    • createBallot

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

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

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

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

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

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

      boolean canManageBallotAliases()
      Tests if this user can manage Id aliases for Ballots . 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 Ballot aliasing is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • aliasBallot

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