public interface ResourceAdminSession extends OsidSession
This session creates, updates, and deletes Resources.
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
Resource,
a ResourceForm
is requested using
getResourceFormForCreate()
specifying desired record Types
or none if no record Types
are needed. The returned
ResourceForm
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 ResourceForm
is submiited to a create
operation, it cannot be reused with another create operation unless the
first operation was unsuccessful. Each ResourceForm
corresponds to an attempted transaction.
For updates, ResourceForms
are requested to the
Resource
Id
that is to be updated using
getResourceFormForUpdate().
Similarly, the ResourceForm
has metadata about the data that can be updated and it can perform
validation before submitting the update. The ResourceForm
can only be used once for a successful update and cannot be reused.
The delete operations delete Resources.
To unmap a
Resource
from the current Bin,
the
ResourceBinAssignmentSession
should be used. These delete
operations attempt to remove the Resource
itself thus
removing it from all known Bin
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 |
aliasResource(Id resourceId,
Id aliasId)
Adds an
Id to a Resource for the purpose
of creating compatibility. |
boolean |
canCreateResources()
Tests if this user can create
Resources. |
boolean |
canCreateResourceWithRecordTypes(Type[] resourceRecordTypes)
Tests if this user can create a single
Resource using
the desired record types. |
boolean |
canDeleteResources()
Tests if this user can delete
Resources. |
boolean |
canManageResourceAliases()
Tests if this user can manage
Id aliases for
Resources. |
boolean |
canUpdateResources()
Tests if this user can update
Resources. |
Resource |
createResource(ResourceForm resourceForm)
Creates a new
Resource. |
void |
deleteResource(Id resourceId)
Deletes a
Resource. |
Bin |
getBin()
Gets the
Bin associated with this session. |
Id |
getBinId()
Gets the
Bin Id associated with this
session. |
ResourceForm |
getResourceFormForCreate(Type[] resourceRecordTypes)
Gets the resource form for creating new resources.
|
ResourceForm |
getResourceFormForUpdate(Id resourceId)
Gets the resource form for updating an existing resource.
|
void |
updateResource(ResourceForm resourceForm)
Updates an existing resource.
|
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactions
close
Id getBinId()
Bin
Id
associated with this
session. Bin Id
associated with this sessionmandatory
- This method must be implemented. Bin getBin() throws OperationFailedException, PermissionDeniedException
Bin
associated with this session. Bin
associated with this sessionOperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canCreateResources()
Resources.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known creating a Resource
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 Resource
creation is
not authorized, true
otherwisemandatory
- This method must be implemented. boolean canCreateResourceWithRecordTypes(Type[] resourceRecordTypes)
Resource
using
the desired record types. While
ResourceManager.getResourceRecordTypes()
can be used to
examine which records are supported, this method tests which record(s)
are required for creating a specific Resource.
Providing an empty array tests if a Resource
can be
created with no records.resourceRecordTypes
- array of resource record types true
if Resource
creation using
the specified Types
is supported, false
otherwiseNullArgumentException
- resourceRecordTypes
is null
mandatory
- This method must be implemented. ResourceForm getResourceFormForCreate(Type[] resourceRecordTypes) throws OperationFailedException, PermissionDeniedException
resourceRecordTypes
- array of resource record typesNullArgumentException
- resourceRecordTypes
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- unable to get form with
requested record typesmandatory
- This method must be implemented. Resource createResource(ResourceForm resourceForm) throws OperationFailedException, PermissionDeniedException
Resource.
resourceForm
- the form for this Resource
Resource
IllegalStateException
- resourceForm
already used in a create transactionInvalidArgumentException
- one or more of the form
elements is invalidNullArgumentException
- resourceForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- resourceForm
did
not originate from getResourceFormForCreate()
mandatory
- This method must be implemented. boolean canUpdateResources()
Resources.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known updating a Resource
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 Resource
modification
is not authorized, true
otherwisemandatory
- This method must be implemented. ResourceForm getResourceFormForUpdate(Id resourceId) throws NotFoundException, OperationFailedException, PermissionDeniedException
resourceId
- the Id
of the Resource
NotFoundException
- resourceId
is not
foundNullArgumentException
- resourceId
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. void updateResource(ResourceForm resourceForm) throws OperationFailedException, PermissionDeniedException
resourceForm
- the form containing the elements to be updatedIllegalStateException
- resourceForm
already used in an update transactionInvalidArgumentException
- the form contains an invalid
valueNullArgumentException
- resourceForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- resourceForm
did
not originate from getResourceFormForUpdate()
mandatory
- This method must be implemented. boolean canDeleteResources()
Resources.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known deleting a Resource
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 Resource
deletion is
not authorized, true
otherwisemandatory
- This method must be implemented. void deleteResource(Id resourceId) throws NotFoundException, OperationFailedException, PermissionDeniedException
Resource.
resourceId
- the Id
of the Resource
to removeNotFoundException
- resourceId
not foundNullArgumentException
- resourceId
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canManageResourceAliases()
Id
aliases for
Resources.
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 Resource
aliasing is
not authorized, true
otherwisemandatory
- This method must be implemented. void aliasResource(Id resourceId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException
Id
to a Resource
for the purpose
of creating compatibility. The primary Id
of the
Resource
is determined by the provider. The new Id
performs as an alias to the primary Id.
If the
alias is a pointer to another resource it is reassigned to the given
resource Id.
resourceId
- the Id
of a Resource
aliasId
- the alias Id
AlreadyExistsException
- aliasId
is
already assignedNotFoundException
- resourceId
not foundNullArgumentException
- aliasId
or
resourceId
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented.