Interface UtilityAdminSession

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

public interface UtilityAdminSession extends OsidSession

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 Details

    • canCreateUtilities

      boolean canCreateUtilities()
      Tests if this user can create Utilities . A return of true does not guarantee successful authorization. A return of false indicates that it is known creating a Utility will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.
      Returns:
      false if Utility creation is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • canCreateUtilityWithRecordTypes

      boolean canCreateUtilityWithRecordTypes(Type[] utilityRecordTypes)
      Tests if this user can create a single Utility using the desired record interface types. While MeteringManager.getUtilityRecordTypes() can be used to examine which record interfaces are supported, this method tests which record(s) are required for creating a specific Utility . Providing an empty array tests if a Utility can be created with no records.
      Parameters:
      utilityRecordTypes - array of utility record types
      Returns:
      true if Utility creation using the specified record Types is supported, false otherwise
      Throws:
      NullArgumentException - utilityRecordTypes is null
      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 - utilityRecordTypes 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.
    • createUtility

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

      boolean canUpdateUtilities()
      Tests if this user can update Utilities . A return of true does not guarantee successful authorization. A return of false indicates that it is known updating a Utility will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.
      Returns:
      false if Utility modification is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • getUtilityFormForUpdate

      Gets the utility form for updating an existing utility. A new utility form should be requested for each update transaction.
      Parameters:
      utilityId - the Id of the Utility
      Returns:
      the utility form
      Throws:
      NotFoundException - utilityId is not found
      NullArgumentException - utilityId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - 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 - utilityForm already used in an update transaction
      InvalidArgumentException - the form contains an invalid value
      NullArgumentException - utilityForm is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - utilityForm did not originate from getUtilityFormForUpdate()
      Compliance:
      mandatory - This method must be implemented.
    • canDeleteUtilities

      boolean canDeleteUtilities()
      Tests if this user can delete Utilities . A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting a Utility will result in a PERMISSION_DENIED . This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.
      Returns:
      false if Utility deletion is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • deleteUtility

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

      boolean canManageUtilityAliases()
      Tests if this user can manage Id aliases 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 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 Utility aliasing is not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • aliasUtility

      Adds an Id to a Utility for the purpose of creating compatibility. The primary Id of the Utility is determined by the provider. The new Id performs as an alias to the primary Id . If the alias is a pointer to another event, it is reassigned to the given event Id .
      Parameters:
      utilityId - the Id of a Utility
      aliasId - the alias Id
      Throws:
      AlreadyExistsException - aliasId is already assigned
      NotFoundException - utilityId not found
      NullArgumentException - utilityId or aliasId is null
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      Compliance:
      mandatory - This method must be implemented.