Interface AssetAdminSession

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

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 = (PhotographRecordForm) 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);            
  
  • Method Details

    • getRepositoryId

      Id getRepositoryId()
      Gets the Repository Id associated with this session.
      Returns:
      the Repository Id associated with this session
      Compliance:
      mandatory - This method must be implemented.
    • getRepository

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

      boolean canCreateAssets()
      Tests if this user can create 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.
      Returns:
      false if Asset creation is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • canCreateAssetWithRecordTypes

      boolean canCreateAssetWithRecordTypes(Type[] assetRecordTypes)
      Tests if this user can create a single 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.
      Parameters:
      assetRecordTypes - array of asset record types
      Returns:
      true if Asset creation using the specified record Types is supported, false otherwise
      Throws:
      NullArgumentException - assetRecordTypes is null
      Compliance:
      mandatory - This method must be implemented.
    • getAssetFormForCreate

      AssetForm getAssetFormForCreate(Type[] assetRecordTypes) throws OperationFailedException, PermissionDeniedException
      Gets the asset form for creating new assets. A new form should be requested for each create transaction.
      Parameters:
      assetRecordTypes - array of asset record types
      Returns:
      the asset form
      Throws:
      NullArgumentException - assetRecordTypes is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - unable to get form for requested record types
      Compliance:
      mandatory - This method must be implemented.
    • createAsset

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

      boolean canUpdateAssets()
      Tests if this user can update 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.
      Returns:
      false if Asset modification is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • getAssetFormForUpdate

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

      void updateAsset(AssetForm assetForm) throws OperationFailedException, PermissionDeniedException
      Updates an existing asset.
      Parameters:
      assetForm - the form containing the elements to be updated
      Throws:
      IllegalStateException - assetForm already used in anupdate transaction
      InvalidArgumentException - the form contains an invalid value
      NullArgumentException - assetForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - assetForm did not originate from getAssetFormForUpdate()
      Compliance:
      mandatory - This method must be implemented.
    • canDeleteAssets

      boolean canDeleteAssets()
      Tests if this user can delete 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.
      Returns:
      false if Asset deletion is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • deleteAsset

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

      boolean canManageAssetAliases()
      Tests if this user can manage 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.
      Returns:
      false if Asset aliasing is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • aliasAsset

      Adds an 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 .
      Parameters:
      assetId - the Id of an Asset
      aliasId - the alias Id
      Throws:
      AlreadyExistsException - aliasId is already assigned
      NotFoundException - assetId not found
      NullArgumentException - assetId or aliasId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.
    • canCreateAssetContent

      @Deprecated boolean canCreateAssetContent()
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Tests if this user can create content for 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.
      Returns:
      false if Asset content creation is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • canCreateAssetContentWithRecordTypes

      @Deprecated boolean canCreateAssetContentWithRecordTypes(Type[] assetContentRecordTypes)
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Tests if this user can create an 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.
      Parameters:
      assetContentRecordTypes - array of asset content record types
      Returns:
      true if AssetContent creation using the specified Types is supported, false otherwise
      Throws:
      NullArgumentException - assetContentRecordTypes is null
      Compliance:
      mandatory - This method must be implemented.
    • getAssetContentFormForCreate

      @Deprecated AssetContentForm getAssetContentFormForCreate(Id assetId, Type[] assetContentRecordTypes) throws NotFoundException, OperationFailedException, PermissionDeniedException
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Gets an asset content form for creating new assets.
      Parameters:
      assetId - the Id of an Asset
      assetContentRecordTypes - array of asset content record types
      Returns:
      the asset content form
      Throws:
      NotFoundException - assetId is not found
      NullArgumentException - assetId or assetContentRecordTypes is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - unable to get form for requested record types
      Compliance:
      mandatory - This method must be implemented.
    • createAssetContent

      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Creates new AssetContent for a given asset.
      Parameters:
      assetContentForm - the form for this AssetContent
      Returns:
      the new AssetContent
      Throws:
      IllegalStateException - assetContentForm already used in a create transaction
      InvalidArgumentException - one or more of the form elements is invalid
      NullArgumentException - assetContentForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - assetContentForm did not originate from getAssetContentFormForCreate()
      Compliance:
      mandatory - This method must be implemented.
    • canUpdateAssetContents

      @Deprecated boolean canUpdateAssetContents()
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Tests if this user can update 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.
      Returns:
      false if AssetContent modification is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • getAssetContentFormForUpdate

      @Deprecated AssetContentForm getAssetContentFormForUpdate(Id assetContentId) throws NotFoundException, OperationFailedException
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Gets the asset content form for updating an existing asset content. A new asset content form should be requested for each update transaction.
      Parameters:
      assetContentId - the Id of the AssetContent
      Returns:
      the asset content form
      Throws:
      NotFoundException - assetContentId is not found
      NullArgumentException - assetContentId is null
      OperationFailedException - unable to complete request
      Compliance:
      mandatory - This method must be implemented.
    • updateAssetContent

      @Deprecated void updateAssetContent(AssetContentForm assetContentForm) throws OperationFailedException, PermissionDeniedException
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Updates an existing asset content.
      Parameters:
      assetContentForm - the form containing the elements to be updated
      Throws:
      IllegalStateException - assetContentForm already used in an update transaction
      InvalidArgumentException - the form contains an invalid value
      NullArgumentException - assetForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - assetContentForm did not originate from getAssetContentFormForUpdate()
      Compliance:
      mandatory - This method must be implemented.
    • canDeleteAssetContents

      @Deprecated boolean canDeleteAssetContents()
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Tests if this user can delete 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.
      Returns:
      false if AssetContent deletion is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • deleteAssetContent

      @Deprecated void deleteAssetContent(Id assetContentId) throws NotFoundException, OperationFailedException, PermissionDeniedException
      Deprecated.
      as of 3.0.0rc6. Method moved to AssetContentAdminSession .
      Deletes content from an Asset .
      Parameters:
      assetContentId - the Id of the AssetContent
      Throws:
      NotFoundException - assetContentId is not found
      NullArgumentException - assetContentId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.