Package org.sonatype.nexus.proxy.storage.remote

Examples of org.sonatype.nexus.proxy.storage.remote.RemoteStorageContext


          || statusCode == HttpStatus.SC_NOT_FOUND) {
        if (RepositoryItemUid.PATH_ROOT.equals(request.getRequestPath()) && statusCode == HttpStatus.SC_NOT_FOUND) {
          // NEXUS-5944: Give it a chance: it might be remote Nexus with browsing disabled?
          // to check that, we will check is remote is Nexus by pinging "well know" location
          // if we got it, we will know it's only browsing forbidden on remote
          final RemoteStorageContext ctx = getRemoteStorageContext(repository);
          final HttpClient httpClient = (HttpClient) ctx.getContextObject(CTX_KEY_CLIENT);
          final PageContext pageContext = new RepositoryPageContext(httpClient, repository);
          final ResourceStoreRequest rmRequest = new ResourceStoreRequest("/.meta/repository-metadata.xml");
          final URL nxRepoMetadataUrl = appendQueryString(
              repository, rmRequest,
              getAbsoluteUrlFromBase(repository, rmRequest));
View Full Code Here


    if (log.isDebugEnabled()) {
      log.debug("Invoking HTTP {} method against remote location {}", httpRequest.getMethod(), methodUri);
    }

    final RemoteStorageContext ctx = getRemoteStorageContext(repository);

    final HttpClient httpClient = (HttpClient) ctx.getContextObject(CTX_KEY_CLIENT);

    httpRequest.setHeader("Accept", "*/*");
    httpRequest.setHeader("Accept-Language", "en-us");
    httpRequest.setHeader("Accept-Encoding", "gzip,deflate,identity");
    httpRequest.setHeader("Cache-Control", "no-cache");
View Full Code Here

   * @throws RemoteStorageException if query string could not be appended (resulted in an Malformed URL exception)
   */
  private URL appendQueryString(final ProxyRepository repository, final ResourceStoreRequest request, final URL url)
      throws RemoteStorageException
  {
    final RemoteStorageContext ctx = getRemoteStorageContext(repository);
    final String queryString = queryStringBuilder.getQueryString(ctx, repository);
    if (StringUtils.isNotBlank(queryString)) {
      try {
        if (StringUtils.isBlank(url.getQuery())) {
          return new URL(url.toExternalForm() + "?" + queryString);
View Full Code Here

                    final @QueryParam("host") String host,
                    final @QueryParam("port") String port,
                    final @QueryParam("protocolHint") String protocolHint)
      throws Exception
  {
    RemoteStorageContext remoteStorageContext = applicationConfiguration.getGlobalRemoteStorageContext();
    String actualProtocolHint = protocolHint;
    String actualHost = host;
    String actualPort = port;
    if (repositoryId != null) {
      final ProxyRepository repository = repositoryRegistry.getRepositoryWithFacet(
View Full Code Here

    }
  }

  @Override
  public HttpClient create() {
    RemoteStorageContext context = globalRemoteStorageContextProvider.get();
    Builder builder = prepare(new RemoteStorageContextCustomizer(context));

    // FIXME: Why is this here and not general?
    boolean reuseConnections = reuseConnectionsNeeded(context);
    if (!reuseConnections) {
View Full Code Here

            configRemoteStorage.validateStorageUrl(repo.getRemoteStorage().getUrl());

            // set the chosen remote storage
            prepository.setRemoteStorage(configRemoteStorage);
            // mark remote storage context dirty, if applicable
            final RemoteStorageContext ctx = prepository.getRemoteStorageContext();
            if (ctx != null) {
              ctx.incrementGeneration();
            }
          }
          else {
            // just validate
            oldRemoteStorage.validateStorageUrl(repo.getRemoteStorage().getUrl());
View Full Code Here

      // FIXME: hm, we are called when we are dirty, so....
      CRepository repoConfig = coreConfiguration.getConfiguration(true);

      if (repoConfig.getRemoteStorage() != null) {
        RemoteStorageContext rsc = prepository.getRemoteStorageContext();

        // NEXUS-5258 Do not persist storage provider hint if it's the default one
        if (remoteProviderHintFactory.getDefaultHttpRoleHint().equals(
            prepository.getRemoteStorage().getProviderId())) {
          repoConfig.getRemoteStorage().setProvider(null);
        }

        if (rsc.hasRemoteAuthenticationSettings()) {
          repoConfig.getRemoteStorage().setAuthentication(
              authenticationInfoConverter.convertToModel(rsc.getRemoteAuthenticationSettings()));
        }
        else {
          repoConfig.getRemoteStorage().setAuthentication(null);
        }

        if (rsc.hasRemoteConnectionSettings()) {
          repoConfig.getRemoteStorage().setConnectionSettings(
              globalRemoteConnectionSettings.convertToModel(rsc.getRemoteConnectionSettings()));
        }
        else {
          repoConfig.getRemoteStorage().setConnectionSettings(null);
        }
      }
View Full Code Here

  {
    setParameters();
    HttpClientFactoryImpl httpClientFactory = null;
    try {
      // the foreplay: setting up
      final RemoteStorageContext globalRemoteStorageContext = new DefaultRemoteStorageContext(null);
      final DefaultRemoteConnectionSettings rcs = new DefaultRemoteConnectionSettings();
      rcs.setConnectionTimeout(86400000);
      globalRemoteStorageContext.setRemoteConnectionSettings(new DefaultRemoteConnectionSettings());
      globalRemoteStorageContext.setRemoteProxySettings(mock(RemoteProxySettings.class));

      // real provider and initializing it with NexusStarted event
      httpClientFactory = new HttpClientFactoryImpl(
          Providers.of(mock(SystemStatus.class)),
          Providers.of(globalRemoteStorageContext),
          mock(EventBus.class),
          mock(PoolingClientConnectionManagerMBeanInstaller.class),
          null
      );

      // the RRS instance we test
      final HttpClientRemoteStorage underTest =
          new HttpClientRemoteStorage(Providers.of(mock(SystemStatus.class)),
              mock(MimeSupport.class), mock(QueryStringBuilder.class), new HttpClientManagerImpl(httpClientFactory));

      // a mock proxy repository with some mocks to make RRS work
      final RemoteStorageContext proxyContext = new DefaultRemoteStorageContext(globalRemoteStorageContext);
      final ProxyRepository repository = mock(ProxyRepository.class);
      when(repository.getId()).thenReturn("foo");
      when(repository.getName()).thenReturn("foo");
      when(repository.getRemoteStorageContext()).thenReturn(proxyContext);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.storage.remote.RemoteStorageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.