Interface UtilityAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
UtilityBatchAdminSession
This session creates, updates, and deletes Utilities . 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
UtilityForm , a UtilityForm is requested using
getUtilityFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned
UtilityForm 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 UtilityForm is submiited to a create operation, it cannot
be reused with another create operation unless the first operation was
unsuccessful. Each UtilityForm corresponds to an attempted
transaction.
For updates, UtilityForms are requested to the Utility
Id that is to be updated using getUtilityFormForUpdate() .
Similarly, the UtilityForm has metadata about the data that can be
updated and it can perform validation before submitting the update. The
UtilityForm can only be used once for a successful update and
cannot be reused.
The delete operations delete Utilities .
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaliasUtility(Id utilityId, Id aliasId) Adds anIdto aUtilityfor the purpose of creating compatibility.booleanTests if this user can createUtilities.booleancanCreateUtilityWithRecordTypes(Type[] utilityRecordTypes) Tests if this user can create a singleUtilityusing the desired record interface types.booleanTests if this user can deleteUtilities.booleanTests if this user can manageIdaliases for utilities.booleanTests if this user can updateUtilities.createUtility(UtilityForm utilityForm) Creates a newUtility.voiddeleteUtility(Id utilityId) Deletes aUtility.getUtilityFormForCreate(Type[] utilityRecordTypes) Gets the utility form for creating new utilities.getUtilityFormForUpdate(Id utilityId) Gets the utility form for updating an existing utility.voidupdateUtility(UtilityForm utilityForm) Updates an existing utility.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
-
canCreateUtilities
boolean canCreateUtilities()Tests if this user can createUtilities. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aUtilitywill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.- Returns:
falseifUtilitycreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateUtilityWithRecordTypes
Tests if this user can create a singleUtilityusing the desired record interface types. WhileMeteringManager.getUtilityRecordTypes()can be used to examine which record interfaces are supported, this method tests which record(s) are required for creating a specificUtility. Providing an empty array tests if aUtilitycan be created with no records.- Parameters:
utilityRecordTypes- array of utility record types- Returns:
trueifUtilitycreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-utilityRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getUtilityFormForCreate
UtilityForm getUtilityFormForCreate(Type[] utilityRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the utility form for creating new utilities. A new form should be requested for each create transaction.- Parameters:
utilityRecordTypes- array of utility record types- Returns:
- the utility form
- Throws:
NullArgumentException-utilityRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createUtility
Utility createUtility(UtilityForm utilityForm) throws OperationFailedException, PermissionDeniedException Creates a newUtility.- Parameters:
utilityForm- the form for thisUtility- Returns:
- the new
Utility - Throws:
IllegalStateException-utilityFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-utilityFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-utilityFormdid not originate fromgetUtilityFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateUtilities
boolean canUpdateUtilities()Tests if this user can updateUtilities. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aUtilitywill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.- Returns:
falseifUtilitymodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getUtilityFormForUpdate
UtilityForm getUtilityFormForUpdate(Id utilityId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the utility form for updating an existing utility. A new utility form should be requested for each update transaction.- Parameters:
utilityId- theIdof theUtility- Returns:
- the utility form
- Throws:
NotFoundException-utilityIdis not foundNullArgumentException-utilityIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateUtility
void updateUtility(UtilityForm utilityForm) throws OperationFailedException, PermissionDeniedException Updates an existing utility.- Parameters:
utilityForm- the form containing the elements to be updated- Throws:
IllegalStateException-utilityFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-utilityFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-utilityFormdid not originate fromgetUtilityFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteUtilities
boolean canDeleteUtilities()Tests if this user can deleteUtilities. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aUtilitywill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.- Returns:
falseifUtilitydeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteUtility
void deleteUtility(Id utilityId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aUtility.- Parameters:
utilityId- theIdof theUtilityto remove- Throws:
NotFoundException-utilityIdnot foundNullArgumentException-utilityIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageUtilityAliases
boolean canManageUtilityAliases()Tests if this user can manageIdaliases for utilities. 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:
falseifUtilityaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasUtility
void aliasUtility(Id utilityId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aUtilityfor the purpose of creating compatibility. The primaryIdof theUtilityis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another event, it is reassigned to the given eventId.- Parameters:
utilityId- theIdof aUtilityaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-utilityIdnot foundNullArgumentException-utilityIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-