public interface CandidateAdminSession extends OsidSession
This session creates, updates, and deletes Candidates.
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
Candidate,
a CandidateForm
is requested using
getCandidateFormForCreate()
specifying the Race
and desired record Types
or none if no record
Types
are needed. The returned CandidateForm
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
CandidateForm
is submiited to a create operation, it cannot
be reused with another create operation unless the first operation was
unsuccessful. Each CandidateForm
corresponds to an
attempted transaction.
For updates, CandidateForms
are requested to the
Candidate
Id
that is to be updated using
getCandidateFormForUpdate().
Similarly, the CandidateForm
has metadata about the data that can be updated and it can perform
validation before submitting the update. The CandidateForm
can only be used once for a successful update and cannot be reused.
The delete operations delete Candidates.
To unmap a
Candidate
from the current Polls,
the
CandidatePollsAssignmentSession
should be used. These delete
operations attempt to remove the Candidate
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.
Modifier and Type | Method and Description |
---|---|
void |
aliasCandidate(Id candidateId,
Id aliasId)
Adds an
Id to a Candidate for the
purpose of creating compatibility. |
boolean |
canCreateCandidates()
Tests if this user can create
Candidates. |
boolean |
canCreateCandidateWithRecordTypes(Type[] candidateRecordTypes)
Tests if this user can create a single
Candidate using
the desired record types. |
boolean |
canDeleteCandidates()
Tests if this user can delete
Candidates. |
boolean |
canManageCandidateAliases()
Tests if this user can manage
Id aliases for
Candidates. |
boolean |
canUpdateCandidates()
Tests if this user can update
Candidates. |
Candidate |
createCandidate(CandidateForm candidateForm)
Creates a new
Candidate. |
void |
deleteCandidate(Id candidateId)
Deletes a
Candidate. |
CandidateForm |
getCandidateFormForCreate(Id resourceId,
Id raceId,
Type[] candidateRecordTypes)
Gets the candidate form for creating new candidates.
|
CandidateForm |
getCandidateFormForUpdate(Id candidateId)
Gets the candidate form for updating an existing candidate.
|
Polls |
getPolls()
Gets the
Polls associated with this session. |
Id |
getPollsId()
Gets the
Polls Id associated with this
session. |
void |
updateCandidate(CandidateForm candidateForm)
Updates an existing candidate.
|
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactions
close
Id getPollsId()
Polls
Id
associated with this
session. Polls Id
associated with this sessionmandatory
- This method must be implemented. Polls getPolls() throws OperationFailedException, PermissionDeniedException
Polls
associated with this session. Polls
associated with this sessionOperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canCreateCandidates()
Candidates.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known creating a Candidate
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. false
if Candidate
creation is
not authorized, true
otherwisemandatory
- This method must be implemented. boolean canCreateCandidateWithRecordTypes(Type[] candidateRecordTypes)
Candidate
using
the desired record types. While
VotingManager.getCandidateRecordTypes()
can be used to examine
which records are supported, this method tests which record(s) are
required for creating a specific Candidate.
Providing
an empty array tests if a Candidate
can be created with
no records.candidateRecordTypes
- array of candidate record types true
if Candidate
creation using
the specified Types
is supported, false
otherwiseNullArgumentException
- candidateRecordTypes
is null
mandatory
- This method must be implemented. CandidateForm getCandidateFormForCreate(Id resourceId, Id raceId, Type[] candidateRecordTypes) throws NotFoundException, OperationFailedException, PermissionDeniedException
resourceId
- the resource IdraceId
- the race IdcandidateRecordTypes
- array of candidate record typesNotFoundException
- resourceId
or
raceId
is not foundNullArgumentException
- resourceId, raceId
or candidateRecordTypes
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- unable to get form with
requested record typesmandatory
- This method must be implemented. Candidate createCandidate(CandidateForm candidateForm) throws OperationFailedException, PermissionDeniedException
Candidate.
candidateForm
- the form for this Candidate
Candidate
IllegalStateException
- candidateForm
already used in a create transactionInvalidArgumentException
- one or more of the form
elements is invalidNullArgumentException
- candidateForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- candidateForm
did
not originate from getCandidateFormForCreate()
mandatory
- This method must be implemented. boolean canUpdateCandidates()
Candidates.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known updating a Candidate
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. false
if Candidate
modification
is not authorized, true
otherwisemandatory
- This method must be implemented. CandidateForm getCandidateFormForUpdate(Id candidateId) throws NotFoundException, OperationFailedException, PermissionDeniedException
candidateId
- the Id
of the Candidate
NotFoundException
- candidateId
is not
foundNullArgumentException
- candidateId
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. void updateCandidate(CandidateForm candidateForm) throws OperationFailedException, PermissionDeniedException
candidateForm
- the form containing the elements to be updatedIllegalStateException
- candidateForm
already used in an update transactionInvalidArgumentException
- the form contains an invalid
valueNullArgumentException
- candidateForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- candidateForm
did
not originate from getCandidateFormForUpdate()
mandatory
- This method must be implemented. boolean canDeleteCandidates()
Candidates.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known deleting a Candidate
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. false
if Candidate
deletion is
not authorized, true
otherwisemandatory
- This method must be implemented. void deleteCandidate(Id candidateId) throws NotFoundException, OperationFailedException, PermissionDeniedException
Candidate.
candidateId
- the Id
of the Candidate
to removeNotFoundException
- candidateId
not
foundNullArgumentException
- candidateId
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canManageCandidateAliases()
Id
aliases for
Candidates.
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. false
if Candidate
aliasing is
not authorized, true
otherwisemandatory
- This method must be implemented. void aliasCandidate(Id candidateId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException
Id
to a Candidate
for the
purpose of creating compatibility. The primary Id
of
the Candidate
is determined by the provider. The new
Id
performs as an alias to the primary Id.
If the alias is a pointer to another candidate it is
reassigned to the given candidate Id.
candidateId
- the Id
of a Candidate
aliasId
- the alias Id
AlreadyExistsException
- aliasId
is
already assignedNotFoundException
- candidateId
not
foundNullArgumentException
- aliasId
or
candidateId
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented.