Class: ServerClient

ServerClient(config)

Implementation of the server operations.

If the server against which this client will be used has security enabled, then it should be configured with the username and password in the ServerClientConfig. In this case a login attempt is made before any API method to be executed. Upon successful login an User which holds the credentials and the authorization token in the context of the client is created. In all consecutive API calls the authorization token is sent as a http header.

By default ServerClientConfig is configured with keepAlive = true which means that upon authorization token expiration current logged in user would be re-logged automatically before next API call. This configuration can be changed within the configuration.

Constructor

new ServerClient(config)

Parameters:
Name Type Description
config ServerClientConfig

for the server client.

Author:
  • Mihail Radkov
  • Svilen Velikov
Source:

Methods

deleteRepository(id) → {Promise.<any>}

Delete repository with the provided id.

Parameters:
Name Type Description
id string

of the repository which should be deleted.

Source:
Returns:

promise which resolves with the delete result.

Type
Promise.<any>

execute(requestBuilder) → {Promise.<(HttpResponse|Error)>}

Executes http request wrapped in provided request builder. If the server config provides username and password, then a logging attempt is made. Upon successful login the auth data is stored for later requests.

Parameters:
Name Type Description
requestBuilder HttpRequestBuilder
Source:
Returns:

a promise which resolves to response wrapper or rejects with error if thrown during execution.

Type
Promise.<(HttpResponse|Error)>

getLoggedUser() → {User}

Logged user getter.

Source:
Returns:

user

Type
User

getRepository(id, config) → {Promise.<RDFRepositoryClient>}

Creates a repository client instance with the provided id and configuration.

Parameters:
Name Type Description
id string

of the repository

config RepositoryClientConfig

for the overridable repository configuration.

Source:
Returns:

promise which resolves with new RDFRepositoryClient instance.

Type
Promise.<RDFRepositoryClient>

getRepositoryIDs() → {Promise.<Array>}

Get an array of repository ids available in the server.

Source:
Returns:

promise which resolves with an Array with repository ids.

Type
Promise.<Array>

hasRepository(id) → {Promise.<boolean>}

Check if repository with the provided id exists.

Parameters:
Name Type Description
id string

of the repository which should be checked.

Source:
Returns:

promise which resolves with boolean value.

Type
Promise.<boolean>

initHttpClient()

Initializes the http client.

Source:

initLogger()

Initializes the logger.

Source:

setLoggedUser(user) → {ServerClient}

User setter

Parameters:
Name Type Description
user User
Source:
Returns:
Type
ServerClient