org.licas

## Class ContractManager

- java.lang.Object
- - org.licas.ContractManager

-     public class ContractManager
      extends java.lang.Object

  This class can be used to store and process service level agreements, or contracts between a client and a service. This implementation is a basic default version that simply tries to find the appropriate service level agreement object and asks it to evaluate the contract proposal that is passed in. You can derive your own contract handler from this class and implement the methods in any way you want your contracts to be processed. The contract manager essentially has to agree to release or send the correct password, after which the service's related methods are open to be invoked.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.HashMap<java.lang.String,ServiceLevel>` | `serviceLevelAgreements` Stores the service level agreements.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContractManager(org.licas_xml.abs.Element document)` Create a new instance of ContractManager.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contractIsOK(Contract theContract)` Parse the negotiation contract to determine if it is OK.
    `void` | `parseServiceContracts(org.licas_xml.abs.Element document)` Parse the admin or service level agreements document to store the contract details for each service level.
    `Contract` | `processClientContract(java.lang.String clientID, Contract theContract)` Process the specified contract to determine if it meets the requirements for the service level.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### serviceLevelAgreements

          protected java.util.HashMap<java.lang.String,ServiceLevel> serviceLevelAgreements

      Stores the service level agreements. Key is the service level and value if of type `ServiceLevel`.

  - ### Constructor Detail

    - #### ContractManager

          public ContractManager(org.licas_xml.abs.Element document)
                          throws java.lang.Exception

      Create a new instance of ContractManager.
      Parameters:
        `document` - the service level agreements document to parse to create the service level agreements.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### parseServiceContracts

          public void parseServiceContracts(org.licas_xml.abs.Element document)
                                     throws java.lang.Exception

      Parse the admin or service level agreements document to store the contract details for each service level. This default implementation does nothing. You need to implement your own functionality in any derived class.
      Parameters:
        `document` - an XML-based document that stores the relevant details.
      Throws:
        `java.lang.Exception` - any error.

    - #### contractIsOK

          public boolean contractIsOK(Contract theContract)
                               throws java.lang.Exception

      Parse the negotiation contract to determine if it is OK. If this service does not have any contracts installed, then a default value of true is returned, no matter what the contract parameter contains. This service however can have a default 'yes' or 'no' contract installed, that will again override any negotiation contract that is passed in.
      Parameters:
        `theContract` - a wrapper for an XML-based document that stores the contract proposal as an arbitrary description. It must however contain certain standard elements, such as the service level, relating to the service level agreement licas contract that it wants to satisfy. This parameter can also be set to null, to check if the service has a default 'yes' or 'no' agreement contract installed.
      Returns:
        true if the reply is OK, false otherwise.
      Throws:
        `java.lang.Exception` - any error.

    - #### processClientContract

          public Contract processClientContract(java.lang.String clientID,
                                                Contract theContract)
                                         throws java.lang.Exception

      Process the specified contract to determine if it meets the requirements for the service level. This is the contract proposed by the client.
      Parameters:
        `clientID` - the id of the client making the request.
        `theContract` - the client contract.
      Returns:
        the reply from the service, indicating if the contract is acceptable or not.
      Throws:
        `java.lang.Exception` - any error.