class TimeoutsConfigurer {

    public void configure(ConfigurerParameters parameters, PreferencesRegistry prefsRegistry, ServerToolbox serverTools)
    {
        HttpClient client = parameters.getClient();
        String host = parameters.getHost();

        ServerListManager serverManager = serverTools.getServerLayerListManager();
        Collection<ServerConnectionParams> activeServers = serverManager.getActiveServers();

        int readTimeout = -1;
        int connectTimeout = -1;
        for (ServerConnectionParams activeServer : activeServers)
        {
            ServerConfiguration serverConfig = activeServer.getServerConfiguration();
            if (host.equals(serverConfig.getHost()))
            {
                readTimeout = serverConfig.getReadTimeout();
                connectTimeout = serverConfig.getConnectTimeout();
                break;
            }
        }

        if (readTimeout <= 0)
        {
            readTimeout = ServerConstants.getDefaultServerReadTimeoutFromPrefs(prefsRegistry);
        }

        if (connectTimeout <= 0)
        {
            connectTimeout = ServerConstants.getDefaultServerConnectTimeoutFromPrefs(prefsRegistry);
        }

        client.getOptions().setReadTimeout(readTimeout / 1000);
        client.getOptions().setConnectTimeout(connectTimeout / 1000);
    }

}