com.ansys.ingress.client.api

## Class ConnectionFactory

- java.lang.Object
- - com.ansys.ingress.client.api.ConnectionFactory

-     public final class ConnectionFactory
      extends java.lang.Object

  ConnectionFactory is used to open connections to an EKM server. These can be transient connections or persistent connections that were previously saved.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConnectionFactory.TokenUserType` TokenUserType defines the user types that can login to EKM using a special token.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `EKM_CONNECTION_FACTORY_PROVIDER` EKM_CONNECTION_FACTORY_PROVIDER is an evnironment variable that can be set to change the default connection factory provider.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectionFactory()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Connection` | `connect(java.lang.String host, java.lang.String userId, java.lang.String token, java.lang.String workspace)` Connects to an EKM server using the user's archive ID and an authentication token from a previously established session.
    `static void` | `deleteConnection(java.lang.String name)` Deletes the connection with the given name.
    `static ConnectionDetails` | `findConnection(java.lang.String url, java.lang.String workspace)` Finds a connection based on a URL and workspace.
    `static ConnectionDetails` | `findConnection(java.lang.String url, java.lang.String username, java.lang.String password)` Finds a conneciton with a matching location, username, and password.
    `static Connection` | `getConnection(java.lang.String name)` Gets the connection with the specified name.
    `static ConnectionDetails` | `getConnectionDetails(java.lang.String name)` Gets information about a specific connection.
    `static java.util.List<java.lang.String>` | `getConnectionNames()` Gets the names of all connections saved on this computer.
    `static java.util.Map<java.lang.String,ConnectionDetails>` | `getConnections()` Gets information about all of the connections currently available.
    `static java.lang.Throwable` | `getLastConnectionError()` Gets the last error that occurred related to connections.
    `static boolean` | `hasConnection(java.lang.String name)` Determines if a saved connection exists.
    `static Connection` | `load(java.lang.String name)` Opens a saved connection to an EKM server using saved credentials.
    `static Connection` | `load(java.lang.String name, boolean closeExistingSession)` Loads a saved connectino.
    `static Connection` | `load(java.lang.String name, ConnectionFactory.TokenUserType userType, java.lang.String token)` Opens a persisted connection to an EKM server.
    `static Connection` | `load(java.lang.String name, java.lang.String username, java.lang.String password)` Opens a saved connection to an EKM server.
    `static Connection` | `load(java.lang.String name, java.lang.String username, java.lang.String password, boolean closeExistingSession)` Opens a saved connection to an EKM server.
    `static Connection` | `open(java.lang.String host, ConnectionFactory.TokenUserType userType, java.lang.String token, java.lang.String workspace)` Opens a connection to an EKM server.
    `static Connection` | `open(java.lang.String host, java.lang.String username, java.lang.String password)` Opens a connection to an EKM server.
    `static Connection` | `open(java.lang.String host, java.lang.String username, java.lang.String password, java.util.Locale locale)` Opens a connection to an EKM server.
    `static Connection` | `open(java.lang.String host, java.lang.String username, java.lang.String password, java.lang.String workspace)` Opens a connection to an EKM server.
    `static Connection` | `open(java.lang.String host, java.lang.String username, java.lang.String password, java.lang.String workspace, java.util.Locale locale)` Opens a connection to an EKM server.
    `static Connection` | `open(java.lang.String host, java.lang.String username, java.lang.String password, java.lang.String workspace, java.util.Locale locale, boolean closeExistingSession)` Opens a connection to an EKM server.

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

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

- - ### Field Detail

    - #### EKM_CONNECTION_FACTORY_PROVIDER

          public static final java.lang.String EKM_CONNECTION_FACTORY_PROVIDER

      EKM_CONNECTION_FACTORY_PROVIDER is an evnironment variable that can be set to change the default connection factory provider. The value for the variable is the fully qualified class name of the provider.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConnectionFactory

          public ConnectionFactory()

  - ### Method Detail

    - #### connect

          public static Connection connect(java.lang.String host,
                                           java.lang.String userId,
                                           java.lang.String token,
                                           java.lang.String workspace)
                                    throws ConnectionException

      Connects to an EKM server using the user's archive ID and an authentication token from a previously established session.
      Parameters:
        `host` - the URL of the EKM server
        `userId` - the user's archive ID
        `token` - the user's authentication token
        `workspace` - the workspace to which the user is connecting.
      Returns:
        Returns the connection to the server.
      Throws:
        `ConnectionException` - if the connection could not be established.

    - #### deleteConnection

          public static void deleteConnection(java.lang.String name)

      Deletes the connection with the given name.
      Parameters:
        `name` - the name of the connection to delete

    - #### getConnection

          public static Connection getConnection(java.lang.String name)

      Gets the connection with the specified name.
      Parameters:
        `name` - the name of the connection
      Returns:
        Returns the connection or null.

    - #### getConnections

          public static java.util.Map<java.lang.String,ConnectionDetails> getConnections()

      Gets information about all of the connections currently available.
      Returns:
        Returns a dictionary with information about the connections.

    - #### getLastConnectionError

          public static java.lang.Throwable getLastConnectionError()

      Gets the last error that occurred related to connections.
      Returns:
        Returns the last connection error received.

    - #### findConnection

          public static ConnectionDetails findConnection(java.lang.String url,
                                                         java.lang.String workspace)

      Finds a connection based on a URL and workspace.
      Parameters:
        `url` - the URL of the connection
        `workspace` - the workspace of the connection
      Returns:
        Returns the connection details or null if no connection matches the URL and workspace. Since multiple connections could have the same URL and workspace, this method will simply return the first one it finds.

    - #### findConnection

          public static ConnectionDetails findConnection(java.lang.String url,
                                                         java.lang.String username,
                                                         java.lang.String password)

      Finds a conneciton with a matching location, username, and password.
      Parameters:
        `url` - the location
        `username` - the username
        `password` - the password
      Returns:
        Returns the conneciton details or null if no connection matches the URL and credentials.

    - #### getConnectionNames

          public static java.util.List<java.lang.String> getConnectionNames()

      Gets the names of all connections saved on this computer.
      Returns:
        Returns the collection of connection names. This will never be null, but it may be an empty list if no connections have been saved.

    - #### getConnectionDetails

          public static ConnectionDetails getConnectionDetails(java.lang.String name)

      Gets information about a specific connection.
      Parameters:
        `name` - the name of the connection
      Returns:
        Returns the information or null if no connection exists with the given name.

    - #### hasConnection

          public static boolean hasConnection(java.lang.String name)

      Determines if a saved connection exists.
      Parameters:
        `name` - the name of the connection to check
      Returns:
        Returns true if the connection exists.

    - #### load

          public static Connection load(java.lang.String name)
                                 throws ConnectionException

      Opens a saved connection to an EKM server using saved credentials. Users will be logged into the EKM workspace last accessed by this connection.
      Parameters:
        `name` - The name of the connection to open
      Returns:
        Returns a Connection.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### load

          public static Connection load(java.lang.String name,
                                        boolean closeExistingSession)
                                 throws ConnectionException

      Loads a saved connectino.
      Parameters:
        `name` - the name of the connection to load
        `closeExistingSession` - if an existing session on the server should be closed or not.
      Returns:
        Returns the loaded connection.
      Throws:
        `ConnectionException` - if the connection could not be loaded.

    - #### load

          public static Connection load(java.lang.String name,
                                        java.lang.String username,
                                        java.lang.String password)
                                 throws ConnectionException

      Opens a saved connection to an EKM server. Users will be logged into the EKM workspace last accessed by this connection.
      Parameters:
        `name` - The name of the connection to open
        `username` - The EKM user
        `password` - The EKM user's password
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### load

          public static Connection load(java.lang.String name,
                                        java.lang.String username,
                                        java.lang.String password,
                                        boolean closeExistingSession)
                                 throws ConnectionException

      Opens a saved connection to an EKM server. Users will be logged into the EKM workspace last accessed by this connection.
      Parameters:
        `name` - The name of the connection to open
        `username` - The EKM user
        `password` - The EKM user's password
        `closeExistingSession` - if an existing session should be closed or not
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### load

          public static Connection load(java.lang.String name,
                                        ConnectionFactory.TokenUserType userType,
                                        java.lang.String token)
                                 throws ConnectionException

      Opens a persisted connection to an EKM server. Users will be logged into the workspace last accessed by this connection.
      Parameters:
        `name` - The name of the connection to open
        `userType` - The type of user logging in
        `token` - The token for the type of user logging in
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        java.lang.String username,
                                        java.lang.String password)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into the default workspace assigned to them.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `username` - The EKM user
        `password` - The EKM user's password
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        java.lang.String username,
                                        java.lang.String password,
                                        java.util.Locale locale)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into the default workspace assigned to them.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `username` - The EKM user
        `password` - The EKM user's password
        `locale` - The locale to be used by this connection
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        java.lang.String username,
                                        java.lang.String password,
                                        java.lang.String workspace)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into the specified workspace if permitted.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `username` - The EKM user
        `password` - The EKM user's password
        `workspace` - The EKM workspace to use
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        java.lang.String username,
                                        java.lang.String password,
                                        java.lang.String workspace,
                                        java.util.Locale locale)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into the specified workspace if permitted.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `username` - The EKM user
        `password` - The EKM user's password
        `workspace` - The EKM workspace to use
        `locale` - The locale to be used by this connection
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        java.lang.String username,
                                        java.lang.String password,
                                        java.lang.String workspace,
                                        java.util.Locale locale,
                                        boolean closeExistingSession)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into the specified workspace if permitted.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `username` - The EKM user
        `password` - The EKM user's password
        `workspace` - The EKM workspace to use
        `locale` - The locale to be used by this connection
        `closeExistingSession` - if an existing session should be closed or not
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.

    - #### open

          public static Connection open(java.lang.String host,
                                        ConnectionFactory.TokenUserType userType,
                                        java.lang.String token,
                                        java.lang.String workspace)
                                 throws ConnectionException

      Opens a connection to an EKM server. Users will be logged into their default workspace.
      Parameters:
        `host` - The address of the EKM server (e.g. http://localhost:8080)
        `userType` - The type of user logging in
        `token` - The token for the type of user logging in
        `workspace` - The workspace to use
      Returns:
        Returns a Connection instance.
      Throws:
        `ConnectionException` - if the connection could not be opened.