protected AsyncHttpClient getClient( final ProxyRepository repository ) throws RemoteStorageException { RemoteStorageContext ctx = getRemoteStorageContext( repository ); AsyncHttpClient httpClient = (AsyncHttpClient) ctx.getContextObject( CTX_KEY_CLIENT ); return httpClient; }
&& !( (DefaultRemoteStorageContext.BooleanFlagHolder) ctx.getContextObject( getS3FlagKey() ) ).isNull() ) ( (DefaultRemoteStorageContext.BooleanFlagHolder) ctx.getContextObject( getS3FlagKey() ) ).setFlag( isAmazonS3 );
/** * Returns {@code true} if only and only if we are positive that remote peer (remote URL of passed in * ProxyRepository) points to a remote repository that is hosted by Amazon S3 Storage. This method will return false * as long as we don't make very 1st HTTP request to remote peer. After that 1st request, we retain the status until * ProxyRepository configuration changes. See NEXUS-3338 for more. * * @param repository that needs to be checked. * @return true only if we know that ProxyRepository in question points to Amazon S3 storage. * @throws RemoteStorageException in case of some error. */ public boolean isRemotePeerAmazonS3Storage( final ProxyRepository repository ) throws RemoteStorageException { RemoteStorageContext ctx = getRemoteStorageContext( repository ); // it is S3 if we have CTX_KEY_S3_FLAG set, the flag value is not null, and flag value is true // if flag is False, we know it is not S3 // if flag is null, we still did not contact remote, so we were not able to tell yet return ctx.hasContextObject( getS3FlagKey() ) && ( (DefaultRemoteStorageContext.BooleanFlagHolder) ctx.getContextObject( getS3FlagKey() ) ).isFlag(); }
final HttpClient httpClient = (HttpClient) ctx.getContextObject( CTX_KEY_CLIENT );
@Override protected void updateContext( ProxyRepository repository, RemoteStorageContext context ) throws RemoteStorageException { if ( context.hasContextObject( CTX_KEY_CLIENT ) ) { // proper shutdown of AHC, but cannot call getClient() here that would result in endless loop! AsyncHttpClient oldClient = (AsyncHttpClient) context.getContextObject( CTX_KEY_CLIENT ); // TODO: AHC-26: current solution would kill ongoing downloads, be smarter oldClient.close(); } final AsyncHttpClientConfig.Builder clientConfigBuilder = ahcProvider.getAsyncHttpClientConfigBuilder( repository, context ); final AsyncHttpClient client = new AsyncHttpClient( clientConfigBuilder.build() ); context.putContextObject( CTX_KEY_CLIENT, client ); context.putContextObject( CTX_KEY_S3_FLAG, new BooleanFlagHolder() ); }
HttpClient httpClient = (HttpClient) ctx.getContextObject( CTX_KEY_CLIENT ); HostConfiguration httpConfiguration = (HostConfiguration) ctx.getContextObject( CTX_KEY_HTTP_CONFIGURATION ); Boolean isNtlmUsed = (Boolean) ctx.getContextObject( HttpClientProxyUtil.NTLM_IS_IN_USE_KEY );
final Boolean isNtlmUsedOldValue = (Boolean) ctx.getContextObject( NTLM_IS_IN_USE_KEY ); if ( isNtlmUsedOldValue == null || isNtlmUsedOldValue.booleanValue() != isNtlmUsed )