Search in sources :

Example 1 with RestClient

use of com.opentext.ia.sdk.support.http.rest.RestClient in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class PropertiesBasedConfigurer method initRestClient.

private void initRestClient() throws IOException {
    if (restClient == null) {
        HttpClient httpClient = NewInstance.fromConfiguration(configuration, HTTP_CLIENT_CLASSNAME, ApacheHttpClient.class.getName()).as(HttpClient.class);
        AuthenticationStrategy authentication = new AuthenticationStrategyFactory(getServerConfiguration()).getAuthenticationStrategy(() -> httpClient, () -> clock);
        restClient = new RestClient(httpClient);
        restClient.init(authentication);
    }
    cache.setServices(restClient.get(configured(SERVER_URI), Services.class));
}
Also used : AuthenticationStrategyFactory(com.opentext.ia.sdk.client.api.AuthenticationStrategyFactory) ApacheHttpClient(com.opentext.ia.sdk.support.http.apache.ApacheHttpClient) AuthenticationStrategy(com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy) RestClient(com.opentext.ia.sdk.support.http.rest.RestClient)

Example 2 with RestClient

use of com.opentext.ia.sdk.support.http.rest.RestClient in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class ArchiveClients method configuringServerUsing.

/**
   * Returns an ArchiveClient instance and configures the InfoArchive server that it communicates with.
   * @param configurer How to configure InfoArchive
   * @param optionalClient The REST client to use for communication with the server
   * @param optionalClock The clock to use
   * @return An ArchiveClient
   */
public static ArchiveClient configuringServerUsing(InfoArchiveConfigurer configurer, RestClient optionalClient, Clock optionalClock) {
    ServerConfiguration serverConfiguration = configurer.getServerConfiguration();
    Clock clock = Optional.ofNullable(optionalClock).orElseGet(DefaultClock::new);
    RestClient client = Optional.ofNullable(optionalClient).orElseGet(() -> createRestClient(serverConfiguration, clock));
    configurer.configure();
    return usingAlreadyConfiguredServer(serverConfiguration, client, clock);
}
Also used : DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock) ServerConfiguration(com.opentext.ia.sdk.client.api.ServerConfiguration) InfoArchiveRestClient(com.opentext.ia.sdk.client.impl.InfoArchiveRestClient) RestClient(com.opentext.ia.sdk.support.http.rest.RestClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock)

Example 3 with RestClient

use of com.opentext.ia.sdk.support.http.rest.RestClient in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class ArchiveClients method createRestClient.

private static RestClient createRestClient(ServerConfiguration configuration, Clock clock) {
    HttpClient httpClient = NewInstance.of(configuration.getHttpClientClassName(), ApacheHttpClient.class.getName()).as(HttpClient.class);
    AuthenticationStrategy authentication = new AuthenticationStrategyFactory(configuration).getAuthenticationStrategy(() -> httpClient, () -> clock);
    RestClient result = new RestClient(httpClient);
    result.init(authentication);
    return result;
}
Also used : AuthenticationStrategyFactory(com.opentext.ia.sdk.client.api.AuthenticationStrategyFactory) HttpClient(com.opentext.ia.sdk.support.http.HttpClient) ApacheHttpClient(com.opentext.ia.sdk.support.http.apache.ApacheHttpClient) AuthenticationStrategy(com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy) InfoArchiveRestClient(com.opentext.ia.sdk.client.impl.InfoArchiveRestClient) RestClient(com.opentext.ia.sdk.support.http.rest.RestClient)

Example 4 with RestClient

use of com.opentext.ia.sdk.support.http.rest.RestClient in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class ArchiveClients method usingAlreadyConfiguredServer.

/**
   * Creates a new ArchiveClient instance without installing any artifacts in the archive using the default RestClient.
   * @param serverConfiguration How to communicate with the server
   * @return An ArchiveClient
   */
public static ArchiveClient usingAlreadyConfiguredServer(ServerConfiguration serverConfiguration) {
    Clock clock = new DefaultClock();
    RestClient restClient = createRestClient(serverConfiguration, clock);
    return usingAlreadyConfiguredServer(serverConfiguration, restClient, clock);
}
Also used : DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock) InfoArchiveRestClient(com.opentext.ia.sdk.client.impl.InfoArchiveRestClient) RestClient(com.opentext.ia.sdk.support.http.rest.RestClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock)

Aggregations

RestClient (com.opentext.ia.sdk.support.http.rest.RestClient)4 InfoArchiveRestClient (com.opentext.ia.sdk.client.impl.InfoArchiveRestClient)3 AuthenticationStrategyFactory (com.opentext.ia.sdk.client.api.AuthenticationStrategyFactory)2 Clock (com.opentext.ia.sdk.support.datetime.Clock)2 DefaultClock (com.opentext.ia.sdk.support.datetime.DefaultClock)2 ApacheHttpClient (com.opentext.ia.sdk.support.http.apache.ApacheHttpClient)2 AuthenticationStrategy (com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy)2 ServerConfiguration (com.opentext.ia.sdk.client.api.ServerConfiguration)1 HttpClient (com.opentext.ia.sdk.support.http.HttpClient)1