public InputStream retrieve(String key) throws IOException { try { S3Object object = s3Service.getObject(bucket, key); return object.getDataInputStream(); } catch (S3ServiceException e) { if ("NoSuchKey".equals(e.getS3ErrorCode())) { return null; } if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
@Override protected String getBucketPolicyImpl(String bucketName) throws S3ServiceException { try { Map<String, String> requestParameters = new HashMap<String, String>(); requestParameters.put("policy", ""); HttpResponse httpResponse = performRestGet(bucketName, null, requestParameters, null); return EntityUtils.toString(httpResponse.getEntity()); } catch (ServiceException se) { throw new S3ServiceException(se); } catch (IOException e) { throw new S3ServiceException(e); } }
protected static IOException getIOException(S3ServiceException e, FileURL fileURL) throws IOException { handleAuthException(e, fileURL); Throwable cause = e.getCause(); if(cause instanceof IOException) return (IOException)cause; if(JavaVersion.JAVA_1_6.isCurrentOrHigher()) return new IOException(e); return new IOException(e.getMessage()); }
if (s3se.getS3ErrorCode() != null) { detailsText.append("<tr><td><b>S3 Error Code</b></td><td>").append(s3se.getS3ErrorCode()).append("</td></tr>"); } else { String msg = throwable.getMessage(); if (s3se.getS3ErrorMessage() != null) { detailsText.append("<tr><td><b>S3 Message</b></td><td>") .append(s3se.getS3ErrorMessage()).append("</td></tr>"); .append(s3se.getResponseCode()) .append("</td></tr>"); if (s3se.getS3ErrorRequestId() != null) { detailsText.append("<tr><td><b>S3 Request Id</b></td><td>") .append(s3se.getS3ErrorRequestId()).append("</td></tr>"); if (s3se.getS3ErrorHostId() != null) { detailsText.append("<tr><td><b>S3 Host Id</b></td><td>") .append(s3se.getS3ErrorHostId()).append("</td></tr>"); Throwable cause = s3se.getCause(); while (cause != null && cause.getMessage() != null) { if (firstCause) {
LOG.debug( "S3ServiceException: {}: {} : {}", se.getS3ErrorCode(), se.getS3ErrorMessage(), se, se); if ("InvalidRange".equals(se.getS3ErrorCode())) { result = new EOFException(FSExceptionMessages.CANNOT_SEEK_PAST_EOF); } else {
e.printStackTrace(); s3Service.getObject(vBucketName, "versioned-object"); } catch (S3ServiceException e) { if (e.getResponseCode() == 404) { System.out.println("Is deleted object versioned? " + e.getResponseHeaders().get(Constants.AMZ_DELETE_MARKER)); System.out.println("Delete marker version ID: " + e.getResponseHeaders().get(Constants.AMZ_VERSION_ID));
private S3Object get(String key) { try { return s3Service.getObject(bucket, key); } catch (S3ServiceException e) { if ("NoSuchKey".equals(e.getS3ErrorCode())) { return null; } } return null; }
protected static void handleAuthException(S3ServiceException e, FileURL fileURL) throws AuthException { int code = e.getResponseCode(); if(code==401 || code==403) throw new AuthException(fileURL); }
/** * @return The service-specific Error Code returned by S3, if an S3 response is available. * For example "AccessDenied", "InternalError" * Null otherwise. */ public String getS3ErrorCode() { return this.getErrorCode(); }
/** * @return The Error Host ID returned by S3, if an S3 response is available. * Null otherwise. */ public String getS3ErrorHostId() { return this.getErrorHostId(); }
/** * @return The service-specific Error Message returned by S3, if an S3 response is available. * For example: "Access Denied", "We encountered an internal error. Please try again." */ public String getS3ErrorMessage() { return this.getErrorMessage(); }
if (s3se.getS3ErrorCode() != null) { detailsText.append("<tr><td><b>S3 Error Code</b></td><td>").append(s3se.getS3ErrorCode()).append("</td></tr>"); } else { String msg = throwable.getMessage(); if (s3se.getS3ErrorMessage() != null) { detailsText.append("<tr><td><b>S3 Message</b></td><td>") .append(s3se.getS3ErrorMessage()).append("</td></tr>"); .append(s3se.getResponseCode()) .append("</td></tr>"); if (s3se.getS3ErrorRequestId() != null) { detailsText.append("<tr><td><b>S3 Request Id</b></td><td>") .append(s3se.getS3ErrorRequestId()).append("</td></tr>"); if (s3se.getS3ErrorHostId() != null) { detailsText.append("<tr><td><b>S3 Host Id</b></td><td>") .append(s3se.getS3ErrorHostId()).append("</td></tr>"); Throwable cause = s3se.getCause(); while (cause != null && cause.getMessage() != null) { if (firstCause) {
e.printStackTrace(); s3Service.getObject(vBucketName, "versioned-object"); } catch (S3ServiceException e) { if (e.getResponseCode() == 404) { System.out.println("Is deleted object versioned? " + e.getResponseHeaders().get(Constants.AMZ_DELETE_MARKER)); System.out.println("Delete marker version ID: " + e.getResponseHeaders().get(Constants.AMZ_VERSION_ID));
private S3Object get(String key) { try { return s3Service.getObject(bucket, key); } catch (S3ServiceException e) { if ("NoSuchKey".equals(e.getS3ErrorCode())) { return null; } } return null; }
/** * Retrieve the JSON access control policy document for a bucket, * or null if the bucket does not have a policy. * * @param bucketName Name of the bucket * @return * JSON policy document for bucket, or null if the bucket has no policy. * @throws S3ServiceException */ public String getBucketPolicy(String bucketName) throws S3ServiceException { try { return getBucketPolicyImpl(bucketName); } catch (S3ServiceException e) { if (e.getResponseCode() == 404) { return null; } else { throw e; } } }
/** * @return The service-specific Error Code returned by S3, if an S3 response is available. * For example "AccessDenied", "InternalError" * Null otherwise. */ public String getS3ErrorCode() { return this.getErrorCode(); }
/** * @return The Error Host ID returned by S3, if an S3 response is available. * Null otherwise. */ public String getS3ErrorHostId() { return this.getErrorHostId(); }
/** * @return The service-specific Error Message returned by S3, if an S3 response is available. * For example: "Access Denied", "We encountered an internal error. Please try again." */ public String getS3ErrorMessage() { return this.getErrorMessage(); }