Package org.sonatype.nexus.proxy

Examples of org.sonatype.nexus.proxy.RemoteStorageException


  {
    try {
      URI u = new URI(url);

      if (!"http".equals(u.getScheme().toLowerCase()) && !"https".equals(u.getScheme().toLowerCase())) {
        throw new RemoteStorageException("Unsupported protocol, only HTTP/HTTPS protocols are supported: "
            + u.getScheme().toLowerCase());
      }
    }
    catch (URISyntaxException e) {
      throw new RemoteStorageException("Malformed URL", e);
    }
  }
View Full Code Here


    try {
      return new URL(urlStr.toString());
    }
    catch (MalformedURLException e) {
      throw new RemoteStorageException("The repository has broken URL!", e);
    }

  }
View Full Code Here

    }
    catch (RemoteStorageException e) {
      throw e;
    }
    catch (IOException e) {
      throw new RemoteStorageException("Could not update context of " + repository, e);
    }
  }
View Full Code Here

        actualFailCount = this.valueUrlFailResultMap.get(requestUrl);
      }

      if (actualFailCount < expectedFailCount) {
        this.valueUrlFailResultMap.put(requestUrl, actualFailCount + 1);
        throw new RemoteStorageException("Mock Remote Storage is pretending to be down.");
      }
    }

    if (this.downUrls.contains(baseUrl)) {
      throw new RemoteStorageException("Mock " + baseUrl + " is expected to be down.");
    }

    if (this.validUrlContentMap.containsKey(requestUrl)) {
      return new DefaultStorageFileItem(repository, request, true, false,
          new ByteArrayContentLocator(
View Full Code Here

        return httpItem;
      }
      catch (IOException ex) {
        release(httpResponse);
        throw new RemoteStorageException("IO Error during response stream handling [repositoryId=\""
            + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\""
            + remoteURL.toString() + "\"]!", ex);
      }
      catch (RuntimeException ex) {
        release(httpResponse);
        throw ex;
      }
    }
    else {
      release(httpResponse);
      if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
        throw new RemoteItemNotFoundException(request, repository, "NotFound", remoteURL.toString());
      }
      else if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY
          || httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY) {
        // NEXUS-5125 unfollowed redirect means collection (path.endsWith("/"))
        // see also HttpClientUtil#configure
        throw new RemoteItemNotFoundException(request, repository, "redirected", remoteURL.toString());
      }
      else {
        throw new RemoteStorageException("The method execution returned result code "
            + httpResponse.getStatusLine().getStatusCode() + " (expected 200). [repositoryId=\""
            + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\""
            + remoteURL.toString() + "\"]");
      }
    }
View Full Code Here

    try {
      validatePath(repository, request);
    }
    catch (ItemNotFoundException e) {
      throw new RemoteStorageException("Invalid path to store", e);
    }

    final URL remoteUrl = appendQueryString(repository, request, getAbsoluteUrlFromBase(repository, request));

    final HttpPut method = new HttpPut(remoteUrl.toExternalForm());

    final InputStreamEntity entity;
    try {
      entity =
          new InputStreamEntity(new InterruptableInputStream(fileItem.getInputStream()), fileItem.getLength());
    }
    catch (IOException e) {
      throw new RemoteStorageException(e.getMessage() + " [repositoryId=\"" + repository.getId()
          + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]",
          e);
    }

    entity.setContentType(fileItem.getMimeType());
    method.setEntity(entity);

    final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method, repository.getRemoteUrl());
    final int statusCode = httpResponse.getStatusLine().getStatusCode();

    if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED
        && statusCode != HttpStatus.SC_NO_CONTENT && statusCode != HttpStatus.SC_ACCEPTED) {
      throw new RemoteStorageException("Unexpected response code while executing " + method.getMethod()
          + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
          + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]. Expected: \"any success (2xx)\". Received: "
          + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase());
    }
  }
View Full Code Here

    final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method, repository.getRemoteUrl());
    final int statusCode = httpResponse.getStatusLine().getStatusCode();

    if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT
        && statusCode != HttpStatus.SC_ACCEPTED) {
      throw new RemoteStorageException("The response to HTTP " + method.getMethod()
          + " was unexpected HTTP Code " + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase()
          + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
          + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]");
    }
  }
View Full Code Here

          }
        }
        return false;
      }
      else {
        throw new RemoteStorageException("Unexpected response code while executing " + method.getMethod()
            + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
            + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]. Expected: \"SUCCESS (200)\". Received: "
            + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase());
      }
    }
View Full Code Here

      ctx.putContextObject(CTX_KEY_CLIENT, httpClient);
      // NEXUS-3338: we don't know after config change is remote S3 (url changed maybe)
      ctx.putContextObject(CTX_KEY_S3_FLAG, new BooleanFlagHolder());
    }
    catch (IllegalStateException e) {
      throw new RemoteStorageException("Could not create HTTPClient4x instance!", e);
    }
  }
View Full Code Here

      else if (statusCode == HttpStatus.SC_UNAUTHORIZED) {
        throw new RemoteAuthenticationNeededException(repository,
            httpResponse.getStatusLine().getReasonPhrase());
      }
      else if (statusCode == HttpStatus.SC_OK && proxyReturnedError) {
        throw new RemoteStorageException(
            "Invalid artifact found, most likely a proxy redirected to an HTML error page.");
      }

      return httpResponse;
    }
    catch (RemoteStorageException ex) {
      release(httpResponse);
      throw ex;
    }
    catch (ClientProtocolException ex) {
      release(httpResponse);
      throw new RemoteStorageException("Protocol error while executing " + httpRequest.getMethod()
          + " method. [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
          + "\", remoteUrl=\"" + methodUri.toASCIIString() + "\"]", ex);
    }
    catch (ConnectionPoolTimeoutException ex) {
      release(httpResponse);
      throw new RemoteStorageTransportOverloadedException(repository,
          "Connection pool timeout error while executing " + httpRequest.getMethod() + " method [repositoryId=\""
              + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\""
              + methodUri.toASCIIString() + "\"]", ex);
    }
    catch (IOException ex) {
      release(httpResponse);
      throw new RemoteStorageException("Transport error while executing " + httpRequest.getMethod()
          + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
          + "\", remoteUrl=\"" + methodUri.toASCIIString() + "\"]", ex);
    }
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.RemoteStorageException

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.