Interface ResourceAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
ResourceBatchAdminSession
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaliasResource(Id resourceId, Id aliasId) Adds anIdto aResourcefor the purpose of creating compatibility.booleanTests if this user can createResources.booleancanCreateResourceWithRecordTypes(Type[] resourceRecordTypes) Tests if this user can create a singleResourceusing the desired record types.booleanTests if this user can deleteResources.booleanTests if this user can manageIdaliases forResources.booleanTests if this user can updateResources.createResource(ResourceForm resourceForm) Creates a newResource.voiddeleteResource(Id resourceId) Deletes aResource.getBin()Gets theBinassociated with this session.getBinId()Gets theBinIdassociated with this session.getResourceFormForCreate(Type[] resourceRecordTypes) Gets the resource form for creating new resources.getResourceFormForUpdate(Id resourceId) Gets the resource form for updating an existing resource.voidupdateResource(ResourceForm resourceForm) Updates an existing resource.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
getBinId
Id getBinId()Gets theBinIdassociated with this session.- Returns:
- the
Bin Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getBin
Gets theBinassociated with this session.- Returns:
- the
Binassociated with this session - Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreateResources
boolean canCreateResources()Tests if this user can createResources. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aResourcewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer create operations to an unauthorized user.- Returns:
falseifResourcecreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateResourceWithRecordTypes
Tests if this user can create a singleResourceusing the desired record types. WhileResourceManager.getResourceRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificResource. Providing an empty array tests if aResourcecan be created with no records.- Parameters:
resourceRecordTypes- array of resource record types- Returns:
trueifResourcecreation using the specifiedTypesis supported,falseotherwise- Throws:
NullArgumentException-resourceRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getResourceFormForCreate
ResourceForm getResourceFormForCreate(Type[] resourceRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the resource form for creating new resources. A new form should be requested for each create transaction.- Parameters:
resourceRecordTypes- array of resource record types- Returns:
- the resource form
- Throws:
NullArgumentException-resourceRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form with requested record types- Compliance:
mandatory- This method must be implemented.
-
createResource
Resource createResource(ResourceForm resourceForm) throws OperationFailedException, PermissionDeniedException Creates a newResource.- Parameters:
resourceForm- the form for thisResource- Returns:
- the new
Resource - Throws:
IllegalStateException-resourceFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-resourceFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-resourceFormdid not originate fromgetResourceFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateResources
boolean canUpdateResources()Tests if this user can updateResources. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aResourcewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer update operations to an unauthorized user.- Returns:
falseifResourcemodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getResourceFormForUpdate
ResourceForm getResourceFormForUpdate(Id resourceId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the resource form for updating an existing resource. A new resource form should be requested for each update transaction.- Parameters:
resourceId- theIdof theResource- Returns:
- the resource form
- Throws:
NotFoundException-resourceIdis not foundNullArgumentException-resourceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateResource
void updateResource(ResourceForm resourceForm) throws OperationFailedException, PermissionDeniedException Updates an existing resource.- Parameters:
resourceForm- the form containing the elements to be updated- Throws:
IllegalStateException-resourceFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-resourceFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-resourceFormdid not originate fromgetResourceFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteResources
boolean canDeleteResources()Tests if this user can deleteResources. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aResourcewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer delete operations to an unauthorized user.- Returns:
falseifResourcedeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteResource
void deleteResource(Id resourceId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aResource.- Parameters:
resourceId- theIdof theResourceto remove- Throws:
NotFoundException-resourceIdnot foundNullArgumentException-resourceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageResourceAliases
boolean canManageResourceAliases()Tests if this user can manageIdaliases forResources. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.- Returns:
falseifResourcealiasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasResource
void aliasResource(Id resourceId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aResourcefor the purpose of creating compatibility. The primaryIdof theResourceis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another resource it is reassigned to the given resourceId.- Parameters:
resourceId- theIdof aResourcealiasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-resourceIdnot foundNullArgumentException-aliasIdorresourceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-