<commit_before>/*
 * Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
 */
package com.gooddata;

import com.gooddata.account.AccountService;
import com.gooddata.dataset.DatasetService;
import com.gooddata.gdc.DataStoreService;
import com.gooddata.gdc.GdcService;
import com.gooddata.http.client.GoodDataHttpClient;
import com.gooddata.http.client.LoginSSTRetrievalStrategy;
import com.gooddata.http.client.SSTRetrievalStrategy;
import com.gooddata.md.MetadataService;
import com.gooddata.model.ModelService;
import com.gooddata.project.ProjectService;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;

import static java.util.Collections.singletonMap;

/**
 */
public class GoodData {

    private static final String PROTOCOL = "https";
    private static final int PORT = 443;
    private static final String HOSTNAME = "secure.gooddata.com";

    private final RestTemplate restTemplate;
    private final HttpClientBuilder httpClientBuilder;
    private final String login;
    private final String password;
    private AccountService accountService;
    private ProjectService projectService;
    private MetadataService metadataService;
    private ModelService modelService;
    private GdcService gdcService;
    private DataStoreService dataStoreService;
    private DatasetService datasetService;

    public GoodData(String login, String password) {
        this(login, password, HOSTNAME);
    }

    public GoodData(String hostname, String login, String password) {
        this.login = login;
        this.password = password;
        final HttpHost host = new HttpHost(hostname, PORT, PROTOCOL);

        httpClientBuilder = HttpClientBuilder.create();
        final CloseableHttpClient httpClient = httpClientBuilder.build();
        final SSTRetrievalStrategy strategy = new LoginSSTRetrievalStrategy(httpClient, host, login, password);

        final HttpClient client = new GoodDataHttpClient(httpClient, strategy);

        final UriPrefixingClientHttpRequestFactory factory = new UriPrefixingClientHttpRequestFactory(
                new HttpComponentsClientHttpRequestFactory(client), hostname, PORT, PROTOCOL);
        restTemplate = new RestTemplate(factory);
        restTemplate.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
                new HeaderAddingRequestInterceptor(singletonMap("Accept", MediaType.APPLICATION_JSON_VALUE))));

        initServices();
    }

    public void logout() {
        getAccountService().logout();
    }

    public ProjectService getProjectService() {
        return projectService;
    }

    public AccountService getAccountService() {
        return accountService;
    }

    public MetadataService getMetadataService() {
        return metadataService;
    }

    public ModelService getModelService() {
        return modelService;
    }

    public GdcService getGdcService() {
        return gdcService;
    }

    public DataStoreService getDataStoreService() {
        return dataStoreService;
    }

    public DatasetService getDatasetService() {
        return datasetService;
    }

    private void initServices() {
        accountService = new AccountService(restTemplate);
        projectService = new ProjectService(restTemplate, getAccountService());
        metadataService = new MetadataService(restTemplate);
        modelService = new ModelService(restTemplate);
        gdcService = new GdcService(restTemplate);
        dataStoreService = new DataStoreService(httpClientBuilder, getGdcService(), login, password);
        datasetService = new DatasetService(restTemplate, getDataStoreService());
    }
}<commit_msg>make services final<commit_after>/*
 * Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
 */
package com.gooddata;

import com.gooddata.account.AccountService;
import com.gooddata.dataset.DatasetService;
import com.gooddata.gdc.DataStoreService;
import com.gooddata.gdc.GdcService;
import com.gooddata.http.client.GoodDataHttpClient;
import com.gooddata.http.client.LoginSSTRetrievalStrategy;
import com.gooddata.http.client.SSTRetrievalStrategy;
import com.gooddata.md.MetadataService;
import com.gooddata.model.ModelService;
import com.gooddata.project.ProjectService;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;

import static java.util.Collections.singletonMap;

/**
 */
public class GoodData {

    private static final String PROTOCOL = "https";
    private static final int PORT = 443;
    private static final String HOSTNAME = "secure.gooddata.com";

    private final AccountService accountService;
    private final ProjectService projectService;
    private final MetadataService metadataService;
    private final ModelService modelService;
    private final GdcService gdcService;
    private final DataStoreService dataStoreService;
    private final DatasetService datasetService;

    public GoodData(String login, String password) {
        this(login, password, HOSTNAME);
    }

    public GoodData(String hostname, String login, String password) {
        final HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
        final RestTemplate restTemplate = createRestTemplate(hostname, login, password, httpClientBuilder);

        accountService = new AccountService(restTemplate);
        projectService = new ProjectService(restTemplate, accountService);
        metadataService = new MetadataService(restTemplate);
        modelService = new ModelService(restTemplate);
        gdcService = new GdcService(restTemplate);
        dataStoreService = new DataStoreService(httpClientBuilder, gdcService, login, password);
        datasetService = new DatasetService(restTemplate, dataStoreService);
    }

    private RestTemplate createRestTemplate(String hostname, String login, String password, HttpClientBuilder httpClientBuilder) {
        final HttpHost host = new HttpHost(hostname, PORT, PROTOCOL);
        final CloseableHttpClient httpClient = httpClientBuilder.build();
        final SSTRetrievalStrategy strategy = new LoginSSTRetrievalStrategy(httpClient, host, login, password);

        final HttpClient client = new GoodDataHttpClient(httpClient, strategy);

        final UriPrefixingClientHttpRequestFactory factory = new UriPrefixingClientHttpRequestFactory(
                new HttpComponentsClientHttpRequestFactory(client), hostname, PORT, PROTOCOL);
        final RestTemplate restTemplate = new RestTemplate(factory);
        restTemplate.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
                new HeaderAddingRequestInterceptor(singletonMap("Accept", MediaType.APPLICATION_JSON_VALUE))));
        return restTemplate;
    }

    public void logout() {
        getAccountService().logout();
    }

    public ProjectService getProjectService() {
        return projectService;
    }

    public AccountService getAccountService() {
        return accountService;
    }

    public MetadataService getMetadataService() {
        return metadataService;
    }

    public ModelService getModelService() {
        return modelService;
    }

    public GdcService getGdcService() {
        return gdcService;
    }

    public DataStoreService getDataStoreService() {
        return dataStoreService;
    }

    public DatasetService getDatasetService() {
        return datasetService;
    }

}
{'fraction_non_alphanumeric': 0.07485581052889925, 'fraction_numerical': 0.002699717756779973, 'mean_word_length': 4.20434227330779, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4879321', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2044, 'n_words': 492}