public interface AssetAdminSession extends OsidSession
This session creates, updates, and deletes Assets.
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 an
Asset,
an AssetForm
is requested using
getAssetFormForCreate()
specifying the desired record
Types
or none if no record Types
are needed.
The returned AssetyForm
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 AssetForm
is submiited to
a create operation, it cannot be reused with another create operation
unless the first operation was unsuccessful. Each AssetForm
corresponds to an attempted transaction.
For updates, AssetForms
are requested to the
Asset
Id
that is to be updated using
getAssetFormForUpdate().
Similarly, the AssetForm
has metadata about the data that can be updated and it can perform
validation before submitting the update. The AssetForm
can
only be used once for a successful update and cannot be reused.
The delete operations delete Assets.
To unmap an
Asset
from the current Repository,
the
AssetRepositoryAssignmentSession
should be used. These delete
operations attempt to remove the Bid
itself thus removing
it from all known Repository
catalogs.
This session includes an Id
aliasing mechanism to
assign an external Id
to an internally assigned Id.
The view of the administrative methods defined in this session is
determined by the provider. For an instance of this session where no
repository has been specified, it may not be parallel to the
AssetLookupSession.
For example, a default
AssetLookupSession
may view the entire repository hierarchy while
the default AssetAdminSession
uses an isolated
Repository
to create new Assets
or
a
specific repository to operate on a predetermined set of Assets.
Another scenario is a federated provider who does not wish to
permit administrative operations for the federation unaware.
Example create:
if (!session.canCreateAssets()) { return "asset creation not permitted"; } Type types[1]; types[0] = assetPhotographType; if (!session.canCreateAssetWithRecordTypes(types)) { return "creating an asset with a photograph type is not supported"; } AssetForm form = session.getAssetFormForCreate(); Metadata metadata = form.getDisplayNameMetadata(); if (metadata.isReadOnly()) { return "cannot set display name"; } form.setDisplayName("my photo"); PhotographRecordForm photoForm = (PhotographRecordForn) form.getRecordForm(assetPhotogaphType); Metadata metadata = form.getApertureMetadata(); if (metadata.isReadOnly()) { return ("cannot set aperture"); } photoForm.setAperture("5.6"); if (!form.isValid()) { return form.getValidationMessage(); } Asset newAsset = session.createAsset(form);
Modifier and Type | Method and Description |
---|---|
void |
aliasAsset(Id assetId,
Id aliasId)
Adds an
Id to an Asset for the purpose
of creating compatibility. |
boolean |
canCreateAssetContent()
Tests if this user can create content for
Assets. |
boolean |
canCreateAssetContentWithRecordTypes(Type[] assetContentRecordTypes)
Tests if this user can create an
AssetContent using the
desired record types. |
boolean |
canCreateAssets()
Tests if this user can create
Assets. |
boolean |
canCreateAssetWithRecordTypes(Type[] assetRecordTypes)
Tests if this user can create a single
Asset using the
desired record types. |
boolean |
canDeleteAssetContents()
Tests if this user can delete
AssetsContents. |
boolean |
canDeleteAssets()
Tests if this user can delete
Assets. |
boolean |
canManageAssetAliases()
Tests if this user can manage
Id aliases for
Assets. |
boolean |
canUpdateAssetContents()
Tests if this user can update
AssetContent. |
boolean |
canUpdateAssets()
Tests if this user can update
Assets. |
Asset |
createAsset(AssetForm assetForm)
Creates a new
Asset. |
AssetContent |
createAssetContent(AssetContentForm assetContentForm)
Creates new
AssetContent for a given asset. |
void |
deleteAsset(Id assetId)
Deletes an
Asset. |
void |
deleteAssetContent(Id assetContentId)
Deletes content from an
Asset. |
AssetContentForm |
getAssetContentFormForCreate(Id assetId,
Type[] assetContentRecordTypes)
Gets an asset content form for creating new assets.
|
AssetContentForm |
getAssetContentFormForUpdate(Id assetContentId)
Gets the asset content form for updating an existing asset content.
|
AssetForm |
getAssetFormForCreate(Type[] assetRecordTypes)
Gets the asset form for creating new assets.
|
AssetForm |
getAssetFormForUpdate(Id assetId)
Gets the asset form for updating an existing asset.
|
Repository |
getRepository()
Gets the
Repository associated with this session. |
Id |
getRepositoryId()
Gets the
Repository Id associated with
this session. |
void |
updateAsset(AssetForm assetForm)
Updates an existing asset.
|
void |
updateAssetContent(AssetContentForm assetContentForm)
Updates an existing asset content.
|
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactions
close
Id getRepositoryId()
Repository
Id
associated with
this session. Repository Id
associated with this sessionmandatory
- This method must be implemented. Repository getRepository() throws OperationFailedException, PermissionDeniedException
Repository
associated with this session. Repository
associated with this sessionOperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canCreateAssets()
Assets.
A return of true
does not guarantee successful authorization. A return of false
indicates that it is known creating an Asset
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 Asset
creation is not
authorized, true
otherwisemandatory
- This method must be implemented. boolean canCreateAssetWithRecordTypes(Type[] assetRecordTypes)
Asset
using the
desired record types. While
RepositoryManager.getAssetRecordTypes()
can be used to examine
which records are supported, this method tests which record(s) are
required for creating a specific Asset.
Providing an
empty array tests if an Asset
can be created with no
records.assetRecordTypes
- array of asset record types true
if Asset
creation using the
specified record Types
is supported,
false
otherwiseNullArgumentException
- assetRecordTypes
is null
mandatory
- This method must be implemented. AssetForm getAssetFormForCreate(Type[] assetRecordTypes) throws OperationFailedException, PermissionDeniedException
assetRecordTypes
- array of asset record typesNullArgumentException
- assetRecordTypes
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- unable to get form for requested
record typesmandatory
- This method must be implemented. Asset createAsset(AssetForm assetForm) throws OperationFailedException, PermissionDeniedException
Asset.
assetForm
- the form for this Asset
Asset
IllegalStateException
- assetForm
already used in a create transactionInvalidArgumentException
- one or more of the form
elements is invalidNullArgumentException
- assetForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- assetForm
did not
originate from getAssetFormForCreate()
mandatory
- This method must be implemented. boolean canUpdateAssets()
Assets.
A return of true
does not guarantee successful authorization. A return of false
indicates that it is known updating an Asset
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 Asset
modification is
not authorized, true
otherwisemandatory
- This method must be implemented. AssetForm getAssetFormForUpdate(Id assetId) throws NotFoundException, OperationFailedException, PermissionDeniedException
assetId
- the Id
of the Asset
NotFoundException
- assetId
is not foundNullArgumentException
- assetId
is nullOperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. void updateAsset(AssetForm assetForm) throws OperationFailedException, PermissionDeniedException
assetForm
- the form containing the elements to be updatedIllegalStateException
- assetForm
already used in anupdate transactionInvalidArgumentException
- the form contains an invalid
valueNullArgumentException
- assetForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- assetForm
did not
originate from getAssetFormForUpdate()
mandatory
- This method must be implemented. boolean canDeleteAssets()
Assets.
A return of true
does not guarantee successful authorization. A return of false
indicates that it is known deleting an Asset
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 Asset
deletion is not
authorized, true
otherwisemandatory
- This method must be implemented. void deleteAsset(Id assetId) throws NotFoundException, OperationFailedException, PermissionDeniedException
Asset.
assetId
- the Id
of the Asset
to
removeNotFoundException
- assetId
not foundNullArgumentException
- assetId
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canManageAssetAliases()
Id
aliases for
Assets.
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 Asset
aliasing is not
authorized, true
otherwisemandatory
- This method must be implemented. void aliasAsset(Id assetId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException
Id
to an Asset
for the purpose
of creating compatibility. The primary Id
of the
Asset
is determined by the provider. The new Id
performs as an alias to the primary Id.
If the alias is
a pointer to another asset, it is reassigned to the given asset
Id.
assetId
- the Id
of an Asset
aliasId
- the alias Id
AlreadyExistsException
- aliasId
is
already assignedNotFoundException
- assetId
not foundNullArgumentException
- assetId
or
aliasId
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented. boolean canCreateAssetContent()
Assets.
A
return of true does not guarantee successful authorization. A return
of false indicates that it is known creating an AssetContent
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 Asset
content creation
is not authorized, true
otherwisemandatory
- This method must be implemented. boolean canCreateAssetContentWithRecordTypes(Type[] assetContentRecordTypes)
AssetContent
using the
desired record types. While
RepositoryManager.getAssetContentRecordTypes()
can be used to
test which records are supported, this method tests which records are
required for creating a specific AssetContent.
Providing an empty array tests if an AssetContent
can
be created with no records.assetContentRecordTypes
- array of asset content record types true
if AssetContent
creation
using the specified Types
is supported,
false
otherwiseNullArgumentException
- assetContentRecordTypes
is null
mandatory
- This method must be implemented. AssetContentForm getAssetContentFormForCreate(Id assetId, Type[] assetContentRecordTypes) throws NotFoundException, OperationFailedException, PermissionDeniedException
assetId
- the Id
of an Asset
assetContentRecordTypes
- array of asset content record typesNotFoundException
- assetId
is not foundNullArgumentException
- assetId
or
assetContentRecordTypes
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- unable to get form for requested
record typesmandatory
- This method must be implemented. AssetContent createAssetContent(AssetContentForm assetContentForm) throws OperationFailedException, PermissionDeniedException
AssetContent
for a given asset.assetContentForm
- the form for this AssetContent
AssetContent
IllegalStateException
- assetContentForm
already used in a create transactionInvalidArgumentException
- one or more of the form
elements is invalidNullArgumentException
- assetContentForm
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- assetContentForm
did not originate from getAssetContentFormForCreate()
mandatory
- This method must be implemented. boolean canUpdateAssetContents()
AssetContent.
A return of
true does not guarantee successful authorization. A return of false
indicates that it is known updating an AssetContent
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 AssetContent
modification is not authorized, true
otherwisemandatory
- This method must be implemented. AssetContentForm getAssetContentFormForUpdate(Id assetContentId) throws NotFoundException, OperationFailedException
assetContentId
- the Id
of the
AssetContent
NotFoundException
- assetContentId
is
not foundNullArgumentException
- assetContentId
is null
OperationFailedException
- unable to complete requestmandatory
- This method must be implemented. void updateAssetContent(AssetContentForm assetContentForm) throws OperationFailedException, PermissionDeniedException
assetContentForm
- the form containing the elements to be
updatedIllegalStateException
- assetContentForm
already used in an update transactionInvalidArgumentException
- the form contains an invalid
valueNullArgumentException
- assetForm
is
null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failureUnsupportedException
- assetContentForm
did not originate from getAssetContentFormForUpdate()
mandatory
- This method must be implemented. boolean canDeleteAssetContents()
AssetsContents.
A return
of true does not guarantee successful authorization. A return of false
indicates that it is known deleting an AssetContent
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 AssetContent
deletion
is not authorized, true
otherwisemandatory
- This method must be implemented. void deleteAssetContent(Id assetContentId) throws NotFoundException, OperationFailedException, PermissionDeniedException
Asset.
assetContentId
- the Id
of the
AssetContent
NotFoundException
- assetContentId
is
not foundNullArgumentException
- assetContentId
is null
OperationFailedException
- unable to complete requestPermissionDeniedException
- authorization failuremandatory
- This method must be implemented.