Search in sources :

Example 91 with Address

use of okhttp3.Address in project okhttp by square.

the class RouteSelector method next.

public Route next() throws IOException {
    // Compute the next route to attempt.
    if (!hasNextInetSocketAddress()) {
        if (!hasNextProxy()) {
            if (!hasNextPostponed()) {
                throw new NoSuchElementException();
            }
            return nextPostponed();
        }
        lastProxy = nextProxy();
    }
    lastInetSocketAddress = nextInetSocketAddress();
    Route route = new Route(address, lastProxy, lastInetSocketAddress);
    if (routeDatabase.shouldPostpone(route)) {
        postponedRoutes.add(route);
        // We will only recurse in order to skip previously failed routes. They will be tried last.
        return next();
    }
    return route;
}
Also used : NoSuchElementException(java.util.NoSuchElementException) Route(okhttp3.Route)

Example 92 with Address

use of okhttp3.Address in project okhttp by square.

the class RetryAndFollowUpInterceptor method createAddress.

private Address createAddress(HttpUrl url) {
    SSLSocketFactory sslSocketFactory = null;
    HostnameVerifier hostnameVerifier = null;
    CertificatePinner certificatePinner = null;
    if (url.isHttps()) {
        sslSocketFactory = client.sslSocketFactory();
        hostnameVerifier = client.hostnameVerifier();
        certificatePinner = client.certificatePinner();
    }
    return new Address(url.host(), url.port(), client.dns(), client.socketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner, client.proxyAuthenticator(), client.proxy(), client.protocols(), client.connectionSpecs(), client.proxySelector());
}
Also used : Address(okhttp3.Address) CertificatePinner(okhttp3.CertificatePinner) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Example 93 with Address

use of okhttp3.Address in project u2020 by JakeWharton.

the class DebugView method showNewNetworkProxyDialog.

private void showNewNetworkProxyDialog(final ProxyAdapter proxyAdapter) {
    final int originalSelection = networkProxyAddress.isSet() ? ProxyAdapter.PROXY : ProxyAdapter.NONE;
    View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_proxy, null);
    final EditText hostView = findById(view, R.id.debug_drawer_network_proxy_host);
    if (networkProxyAddress.isSet()) {
        String host = networkProxyAddress.get().getHostName();
        // Set the current host.
        hostView.setText(host);
        // Pre-select it for editing.
        hostView.setSelection(0, host.length());
        // Show the keyboard. Post this to the next frame when the dialog has been attached.
        hostView.post(() -> Keyboards.showKeyboard(hostView));
    }
    //
    new AlertDialog.Builder(getContext()).setTitle("Set Network Proxy").setView(view).setNegativeButton("Cancel", (dialog, i) -> {
        networkProxyView.setSelection(originalSelection);
        dialog.cancel();
    }).setPositiveButton("Use", (dialog, i) -> {
        String in = hostView.getText().toString();
        InetSocketAddress address = InetSocketAddressPreferenceAdapter.parse(in);
        if (address != null) {
            networkProxyAddress.set(address);
            // Force a restart to re-initialize the app with the new proxy.
            ProcessPhoenix.triggerRebirth(getContext());
        } else {
            networkProxyView.setSelection(originalSelection);
        }
    }).setOnCancelListener(dialogInterface -> networkProxyView.setSelection(originalSelection)).show();
}
Also used : EditText(android.widget.EditText) BuildConfig(com.jakewharton.u2020.BuildConfig) LinearLayout(android.widget.LinearLayout) Switch(android.widget.Switch) Cache(okhttp3.Cache) CaptureIntents(com.jakewharton.u2020.data.CaptureIntents) FrameLayout(android.widget.FrameLayout) OnClick(butterknife.OnClick) BindView(butterknife.BindView) NetworkDelay(com.jakewharton.u2020.data.NetworkDelay) Picasso(com.squareup.picasso.Picasso) AttributeSet(android.util.AttributeSet) AnimationSpeed(com.jakewharton.u2020.data.AnimationSpeed) InetSocketAddressPreferenceAdapter(com.jakewharton.u2020.data.prefs.InetSocketAddressPreferenceAdapter) Locale(java.util.Locale) Strings(com.jakewharton.u2020.util.Strings) ContextThemeWrapper(android.view.ContextThemeWrapper) PicassoDebugging(com.jakewharton.u2020.data.PicassoDebugging) TemporalAccessor(org.threeten.bp.temporal.TemporalAccessor) View(android.view.View) Method(java.lang.reflect.Method) LumberYard(com.jakewharton.u2020.data.LumberYard) DebugAction(com.jakewharton.u2020.ui.debug.ContextualDebugActions.DebugAction) NetworkVariancePercent(com.jakewharton.u2020.data.NetworkVariancePercent) Set(java.util.Set) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) R(com.jakewharton.u2020.R) InetSocketAddress(java.net.InetSocketAddress) DisplayMetrics(android.util.DisplayMetrics) Timber(timber.log.Timber) ApiEndpoint(com.jakewharton.u2020.data.ApiEndpoint) ButterKnife.findById(butterknife.ButterKnife.findById) TextView(android.widget.TextView) Application(android.app.Application) MockRepositoriesResponse(com.jakewharton.u2020.data.api.MockRepositoriesResponse) DateTimeFormatter(org.threeten.bp.format.DateTimeFormatter) Context(android.content.Context) RxAdapterView(com.jakewharton.rxbinding.widget.RxAdapterView) EnumAdapter(com.jakewharton.u2020.ui.misc.EnumAdapter) ButterKnife(butterknife.ButterKnife) NetworkBehavior(retrofit2.mock.NetworkBehavior) Intent(android.content.Intent) IsMockMode(com.jakewharton.u2020.data.IsMockMode) NetworkFailurePercent(com.jakewharton.u2020.data.NetworkFailurePercent) PixelRatioEnabled(com.jakewharton.u2020.data.PixelRatioEnabled) DisplayLeakActivity(com.squareup.leakcanary.internal.DisplayLeakActivity) ProcessPhoenix(com.jakewharton.processphoenix.ProcessPhoenix) Inject(javax.inject.Inject) LogsDialog(com.jakewharton.u2020.ui.logs.LogsDialog) Instant(org.threeten.bp.Instant) ApiEndpoints(com.jakewharton.u2020.data.ApiEndpoints) Injector(com.jakewharton.u2020.data.Injector) ScalpelEnabled(com.jakewharton.u2020.data.ScalpelEnabled) Keyboards(com.jakewharton.u2020.util.Keyboards) ZoneId(org.threeten.bp.ZoneId) Named(javax.inject.Named) Build(android.os.Build) ScalpelWireframeEnabled(com.jakewharton.u2020.data.ScalpelWireframeEnabled) MockGithubService(com.jakewharton.u2020.data.api.MockGithubService) LayoutInflater(android.view.LayoutInflater) Preference(com.f2prateek.rx.preferences.Preference) PixelGridEnabled(com.jakewharton.u2020.data.PixelGridEnabled) Spinner(android.widget.Spinner) AlertDialog(android.support.v7.app.AlertDialog) OkHttpClient(okhttp3.OkHttpClient) StatsSnapshot(com.squareup.picasso.StatsSnapshot) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) InetSocketAddress(java.net.InetSocketAddress) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RxAdapterView(com.jakewharton.rxbinding.widget.RxAdapterView) ApiEndpoint(com.jakewharton.u2020.data.ApiEndpoint)

Example 94 with Address

use of okhttp3.Address in project ORCID-Source by ORCID.

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(Addresses addresses) {
    if (addresses != null && addresses.getAddress() != null && !addresses.getAddress().isEmpty()) {
        LastModifiedDate latest = null;
        for (Address address : addresses.getAddress()) {
            if (address.getLastModifiedDate() != null && address.getLastModifiedDate().after(latest)) {
                latest = address.getLastModifiedDate();
            }
        }
        addresses.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) Address(org.orcid.jaxb.model.record_rc3.Address)

Example 95 with Address

use of okhttp3.Address in project ORCID-Source by ORCID.

the class Api2_0_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(Addresses addresses) {
    if (addresses != null && addresses.getAddress() != null && !addresses.getAddress().isEmpty()) {
        LastModifiedDate latest = null;
        for (Address address : addresses.getAddress()) {
            if (address.getLastModifiedDate() != null && address.getLastModifiedDate().after(latest)) {
                latest = address.getLastModifiedDate();
            }
        }
        addresses.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Address(org.orcid.jaxb.model.record_v2.Address)

Aggregations

Test (org.junit.Test)92 Address (org.orcid.jaxb.model.record_v2.Address)84 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)43 Addresses (org.orcid.jaxb.model.record_v2.Addresses)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)30 DBUnitTest (org.orcid.test.DBUnitTest)20 Response (javax.ws.rs.core.Response)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18