org.licas

## Class ServiceHandler

- java.lang.Object
- - org.licas.ServiceHandler

-     public class ServiceHandler
      extends java.lang.Object

  This class manages basic creation and parsing for Service objects.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.Object` | `syncOn` To synchronize this service internally on

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceHandler()` Creates a new instance of ServiceHandler.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ServiceMeta` | `createMetaForRepos(java.lang.String theAdminKey, Service service)` Create a metadata description of this service for the server repository.
    `static ServiceMeta` | `createMetaFull(java.util.ArrayList<java.lang.String> jarFile, java.lang.String theAdminKey, Service service)` Create a full metadata description of this service.
    `static org.licas_xml.abs.Element` | `dynamicLinkQuery(LinkQueryConfig queryConfig, Service s)` Perform a query over the link paths to return matching sources.
    `static org.licas_xml.abs.Element` | `dynamicLinksToXml(Service s)` Return all linked sources in XML format.
    `static org.licas_xml.abs.Element` | `dynamicLinksToXml(java.lang.String adminKey, Service s)` Return all linked sources in XML format, including all link levels and the source weight values.
    `static org.licas_xml.abs.Element` | `linksToXml(java.lang.String adminKey, Service s)` Return all linked references in XML format.
    `static org.licas_xml.abs.Element` | `passwordsStateToXml(java.lang.String adminKey, Service toSerialize)` Serialize the stored passwords list and the service state, and return as an XML-based description.
    `static org.licas_xml.abs.Element` | `permanentLinksToXml(Service s)` Return all permanent linked-t0 services in XML format.
    `static org.licas_xml.abs.Element` | `serviceToXml(java.lang.String adminKey, java.util.ArrayList<java.lang.String> adminToRemove, java.util.ArrayList<java.lang.String> partsToKeep, Service toSerialize)` Serialize the service using the `ServiceSerialize` class.
    `static org.licas_xml.abs.Element` | `serviceToXml(java.lang.String adminKey, Service service)` Serialize the service using the `ServiceSerialize` class.
    `static boolean` | `xmlToDynamicLinks(org.licas_xml.abs.Element linksXml, java.lang.String adminKey, Service s)` Parse the links descriptions and add to the service.
    `static java.lang.Object` | `xmlToService(org.licas_xml.abs.Element serviceXml, java.lang.String password)` Create the service from the description using the `ServiceSerialize` class.

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

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

- - ### Field Detail

    - #### syncOn

          protected java.lang.Object syncOn

      To synchronize this service internally on

  - ### Constructor Detail

    - #### ServiceHandler

          public ServiceHandler()

      Creates a new instance of ServiceHandler.

  - ### Method Detail

    - #### createMetaFull

          public static ServiceMeta createMetaFull(java.util.ArrayList<java.lang.String> jarFile,
                                                   java.lang.String theAdminKey,
                                                   Service service)
                                            throws java.lang.Exception

      Create a full metadata description of this service. The description describes only this service and no nested services.
      Parameters:
        `jarFile` - list of remote jar files if loaded remotely.
        `theAdminKey` - the unique service key for admin purposes.
        `service` - the service the operation is for.
      Returns:
        a metadata description of this service.
      Throws:
        `java.lang.Exception` - any error.

    - #### createMetaForRepos

          public static ServiceMeta createMetaForRepos(java.lang.String theAdminKey,
                                                       Service service)
                                                throws java.lang.Exception

      Create a metadata description of this service for the server repository. Note that you can change this method in a derived class, to change the metadata that is stored in the server repository to represent this service. You can also dynamically update the contents. A Service also contains a metadata description in its admin objects, that might be changed separately. The description describes only this service and no nested services.
      Parameters:
        `theAdminKey` - the unique service key for admin purposes.
        `service` - the service the operation is for.
      Returns:
        a metadata description of this service.
      Throws:
        `java.lang.Exception` - any error.

    - #### serviceToXml

          public static org.licas_xml.abs.Element serviceToXml(java.lang.String adminKey,
                                                               Service service)
                                                        throws java.lang.Exception

      Serialize the service using the `ServiceSerialize` class.
      Parameters:
        `adminKey` - the service admin key.
        `service` - the service the operation is for.
      Returns:
        an XML representation of all named elements, or null if the admin key is incorrect.
      Throws:
        `java.lang.Exception` - any error.

    - #### serviceToXml

          public static org.licas_xml.abs.Element serviceToXml(java.lang.String adminKey,
                                                               java.util.ArrayList<java.lang.String> adminToRemove,
                                                               java.util.ArrayList<java.lang.String> partsToKeep,
                                                               Service toSerialize)
                                                        throws java.lang.Exception

      Serialize the service using the `ServiceSerialize` class.
      Parameters:
        `adminKey` - the service admin key.
        `adminToRemove` - if any section is indicated here through the XML tag name, it is removed first.
        `partsToKeep` - list of service-local variable names to serialize.
        `toSerialize` - the service that is being serialized.
      Returns:
        an XML representation of all named elements, or null if the admin key is incorrect.
      Throws:
        `java.lang.Exception` - any error.

    - #### xmlToService

          public static java.lang.Object xmlToService(org.licas_xml.abs.Element serviceXml,
                                                      java.lang.String password)
                                               throws java.lang.Exception

      Create the service from the description using the `ServiceSerialize` class.
      Parameters:
        `serviceXml` - a full XML description of the service.
        `password` - parent password, probably the server currently running. Need to use this instead of the stored value if a server.
      Returns:
        the re-created service, probably derived from `Service`, but it might be a wrapped object.
      Throws:
        `java.lang.Exception` - any error.

    - #### passwordsStateToXml

          public static org.licas_xml.abs.Element passwordsStateToXml(java.lang.String adminKey,
                                                                      Service toSerialize)
                                                               throws java.lang.Exception

      Serialize the stored passwords list and the service state, and return as an XML-based description. This is used more internally, to save the whole server or SOA to a file. You can also use `PasswordHandler`.{code toXml} or {code fromXml} to serialize just the passwords.
      Parameters:
        `adminKey` - the service admin key.
        `toSerialize` - the service being serialized.
      Returns:
        an XML representation of all passwords, or null if the admin key is incorrect.
      Throws:
        `java.lang.Exception` - any error.

    - #### dynamicLinkQuery

          public static org.licas_xml.abs.Element dynamicLinkQuery(LinkQueryConfig queryConfig,
                                                                   Service s)
                                                            throws java.lang.Exception

      Perform a query over the link paths to return matching sources. Note that a linking service must be added first.
      Parameters:
        `queryConfig` - the query configuration.
        `s` - the service the operation is for.
      Returns:
        a list of source uris that match with the query.
      Throws:
        `java.lang.Exception` - any error.

    - #### linksToXml

          public static org.licas_xml.abs.Element linksToXml(java.lang.String adminKey,
                                                             Service s)
                                                      throws java.lang.Exception

      Return all linked references in XML format.
      Parameters:
        `adminKey` - the service admin key.
        `s` - the service the operation is for.
      Returns:
        an XML representation of all linked source references.
      Throws:
        `java.lang.Exception` - any error.

    - #### permanentLinksToXml

          public static org.licas_xml.abs.Element permanentLinksToXml(Service s)
                                                               throws java.lang.Exception

      Return all permanent linked-t0 services in XML format.
      Parameters:
        `s` - the service the operation is for.
      Returns:
        an XML representation of all permanent links.
      Throws:
        `java.lang.Exception` - any error.

    - #### dynamicLinksToXml

          public static org.licas_xml.abs.Element dynamicLinksToXml(Service s)
                                                             throws java.lang.Exception

      Return all linked sources in XML format. This returns a list of link URIs only. To retrieve all information, try the linking service `dynamicLinksToXml(adminKey)` or use `LinksParser` locally. Note that a linking service must be added first.
      Parameters:
        `s` - the service the operation is for.
      Returns:
        an XML representation of all linked sources.
      Throws:
        `java.lang.Exception` - any error.

    - #### dynamicLinksToXml

          public static org.licas_xml.abs.Element dynamicLinksToXml(java.lang.String adminKey,
                                                                    Service s)
                                                             throws java.lang.Exception

      Return all linked sources in XML format, including all link levels and the source weight values. Note that a linking service must be added first.
      Parameters:
        `adminKey` - the service admin key.
        `s` - the service the operation is for.
      Returns:
        an full XML representation of all linked sources, or null if the admin key is incorrect.
      Throws:
        `java.lang.Exception` - any error.

    - #### xmlToDynamicLinks

          public static boolean xmlToDynamicLinks(org.licas_xml.abs.Element linksXml,
                                                  java.lang.String adminKey,
                                                  Service s)
                                           throws java.lang.Exception

      Parse the links descriptions and add to the service.
      Parameters:
        `linksXml` - a full set of links descriptions for the service.
        `adminKey` - the admin key.
        `s` - the service the operation is for.
      Returns:
        true if the links were parsed, false otherwise, for example, incorrect admin key.
      Throws:
        `java.lang.Exception` - any error.