org.licas.server.esb

## Class ServiceRepository

- java.lang.Object
- - org.licas.server.esb.ServiceRepository

-     public class ServiceRepository
      extends java.lang.Object

  This acts as a repository to store metadata describing services running on the server. The information stored might only be a subset of all metadata information and it is always a static copy, created and added when the service is registered. If other metadata is required, then the service itself can be invoked, probably through an `AutoServer getServiceMeta...` method. With appropriate passwords however, the repository metadata can be retrieved and updated. The retrieval process would also typically be password protected at the server level, with this class stored on a server privately.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.HashMap<java.lang.String,ServiceRepositoryInfo>` | `serviceMeta` ArrayList of service details.
    `protected java.util.HashMap<java.lang.String,ServiceRepositoryInfo>` | `serviceTypes` ArrayList of service types.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceRepository()` Create a new instance of ServiceRepository.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addServiceMeta(java.lang.String adminKey, ServiceMeta theServiceMeta)` Add new service details.
    `void` | `clearServiceMetadata()` Clear all service metadata apart from the server itself.
    `void` | `clearServiceMetadata(java.util.ArrayList<java.lang.String> serviceIDs)` Clear all service metadata for the specified services apart from the server itself.
    `java.util.ArrayList<java.lang.String>` | `getServiceIDs()` Get a list of all of the service ids for the related metadata, of type String.
    `org.licas_xml.abs.Element` | `getServiceMeta(java.lang.String serviceID)` Get the service details for the specified service.
    `org.licas_xml.abs.Element` | `getServiceMeta(java.lang.String serviceID, java.util.ArrayList<java.lang.String> toInclude, ServiceMeta serviceObjMeta)` Retrieve just one part of the metadata, not the whole object.
    `ServiceMeta` | `getServiceMeta(java.lang.String serviceID, java.lang.String adminKey)` Get the service details for the specified service.
    `org.licas_xml.abs.Element` | `getServiceMetaPart(java.lang.String serviceID, java.lang.String toInclude, ServiceMeta serviceObjMeta)` Retrieve just one part of the metadata, not the whole object.
    `java.util.ArrayList<java.lang.String>` | `getServiceTypes()` Get an ordered list of all registered service types.
    `java.util.ArrayList<java.lang.String>` | `getServiceTypes(java.lang.String category)` Get a list of all of the service types in the network for a particular category.
    `boolean` | `isStoredService(java.lang.String theServiceID)` Return true if the service id is stored for a loaded service.
    `boolean` | `removeServiceMeta(java.lang.String serviceID, java.lang.String adminKey)` Remove details about the specified service from the repository.

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

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

- - ### Field Detail

    - #### serviceMeta

          protected java.util.HashMap<java.lang.String,ServiceRepositoryInfo> serviceMeta

      ArrayList of service details. Keys are the unique service ids of type String and values are the `ServiceRepositoryInfo` objects describing the service. The key can also be a service type, e.g. `Message` or `File`, if the metadata description is a general one.

    - #### serviceTypes

          protected java.util.HashMap<java.lang.String,ServiceRepositoryInfo> serviceTypes

      ArrayList of service types. Keys are the service class names of type String and values are the `ServiceRepositoryInfo` objects describing the service. If the key is a service type instead, e.g. `Message` or `File`, the type will be removed if the corresponding metadata object is removed.

  - ### Constructor Detail

    - #### ServiceRepository

          public ServiceRepository()

      Create a new instance of ServiceRepository.

  - ### Method Detail

    - #### isStoredService

          public boolean isStoredService(java.lang.String theServiceID)

      Return true if the service id is stored for a loaded service.
      Parameters:
        `theServiceID` - the unique service id.
      Returns:
        true if registered for a loaded service of false otherwise.

    - #### clearServiceMetadata

          public void clearServiceMetadata()

      Clear all service metadata apart from the server itself.

    - #### clearServiceMetadata

          public void clearServiceMetadata(java.util.ArrayList<java.lang.String> serviceIDs)

      Clear all service metadata for the specified services apart from the server itself.
      Parameters:
        `serviceIDs` - list of service IDs to remove metadata for.

    - #### getServiceIDs

          public java.util.ArrayList<java.lang.String> getServiceIDs()

      Get a list of all of the service ids for the related metadata, of type String.
      Returns:
        the list of ids for all stored services.

    - #### getServiceTypes

          public java.util.ArrayList<java.lang.String> getServiceTypes()

      Get an ordered list of all registered service types.
      Returns:
        an ordered list of all service types, of type String.

    - #### getServiceTypes

          public java.util.ArrayList<java.lang.String> getServiceTypes(java.lang.String category)

      Get a list of all of the service types in the network for a particular category.
      Parameters:
        `category` - the category to return service types for.
      Returns:
        a list of all of the service types, of type String.

    - #### getServiceMeta

          public org.licas_xml.abs.Element getServiceMeta(java.lang.String serviceID)
                                                   throws java.lang.Exception

      Get the service details for the specified service.
      Parameters:
        `serviceID` - the unique id of the service.
      Returns:
        the service meta details in XML format if the service exists.
      Throws:
        `java.lang.Exception` - any error.

    - #### getServiceMeta

          public org.licas_xml.abs.Element getServiceMeta(java.lang.String serviceID,
                                                          java.util.ArrayList<java.lang.String> toInclude,
                                                          ServiceMeta serviceObjMeta)
                                                   throws java.lang.Exception

      Retrieve just one part of the metadata, not the whole object. If this is not available for the server repository, the service can be invoked and asked, but the password is then required.
      Parameters:
        `serviceID` - the unique id of the service to retrieve.
        `toInclude` - meta part to return.
        `serviceObjMeta` - full description of the service's metadata to retrieve from.
      Returns:
        the metadata in XML format if it exists, or null if it does not.
      Throws:
        `java.lang.Exception` - any error.

    - #### getServiceMetaPart

          public org.licas_xml.abs.Element getServiceMetaPart(java.lang.String serviceID,
                                                              java.lang.String toInclude,
                                                              ServiceMeta serviceObjMeta)
                                                       throws java.lang.Exception

      Retrieve just one part of the metadata, not the whole object. If this is not available for the server repository, the service can be invoked and asked, but the password is then required.
      Parameters:
        `serviceID` - the unique id of the service to retrieve.
        `toInclude` - meta part to return.
        `serviceObjMeta` - full description of the service's metadata to retrieve from.
      Returns:
        the metadata in XML format if it exists, or null if it does not.
      Throws:
        `java.lang.Exception` - any error.

    - #### getServiceMeta

          public ServiceMeta getServiceMeta(java.lang.String serviceID,
                                            java.lang.String adminKey)

      Get the service details for the specified service.
      Parameters:
        `serviceID` - the unique id of the service to retrieve.
        `adminKey` - the unique admin key for the service.
      Returns:
        a direct reference to the service meta details so that they can be changed.

    - #### addServiceMeta

          public boolean addServiceMeta(java.lang.String adminKey,
                                        ServiceMeta theServiceMeta)

      Add new service details.
      Parameters:
        `adminKey` - the service key.
        `theServiceMeta` - the service metadata.
      Returns:
        true if the details are added or false otherwise.

    - #### removeServiceMeta

          public boolean removeServiceMeta(java.lang.String serviceID,
                                           java.lang.String adminKey)

      Remove details about the specified service from the repository. If this is also stored as a service type, remove it from the service type list.
      Parameters:
        `serviceID` - the unique id of the service to remove.
        `adminKey` - the unique admin key for the service.
      Returns:
        true if the info is removed or false otherwise.