@ExceptionHandler(AmazonS3Exception.class) public ResponseEntity<StandardError> amazonS3(AmazonS3Exception e, HttpServletRequest request) { StandardError err = new StandardError(System.currentTimeMillis(), HttpStatus.BAD_REQUEST.value(), "Erro S3", e.getMessage(), request.getRequestURI()); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(err); } }
@Nullable public ObjectMetadata getObjectMetadata(String key) throws StorageException { ObjectMetadata obj = null; try { obj = conn.getObjectMetadata(bucketName, key); } catch (AmazonS3Exception e) { if (404 != e.getStatusCode()) { // 404 == not found throw new StorageException( "Error checking existence of " + key + ": " + e.getMessage(), e); } } return obj; }
@Nullable public ObjectMetadata getObjectMetadata(String key) throws StorageException { ObjectMetadata obj = null; try { obj = conn.getObjectMetadata(bucketName, key); } catch (AmazonS3Exception e) { if (404 != e.getStatusCode()) { // 404 == not found throw new StorageException( "Error checking existence of " + key + ": " + e.getMessage(), e); } } return obj; }
public InputStream getS3ObjectInputStream(final String bucketName, final String filePath) { try { return amazonS3Client.getObject(bucketName, filePath).getObjectContent(); } catch (AmazonS3Exception e) { logFailedDownloadWarning(filePath, e.getMessage()); } catch (AmazonClientException e) { logFailedDownloadWarning(filePath, e.getMessage()); } return null; }
@Nullable public S3Object getObject(String key) throws StorageException { final S3Object object; try { object = conn.getObject(bucketName, key); } catch (AmazonS3Exception e) { if (404 == e.getStatusCode()) { // 404 == not found return null; } throw new StorageException("Error fetching " + key + ": " + e.getMessage(), e); } if (isPendingDelete(object)) { closeObject(object); return null; } return object; }
LOG.warning(String.format("Exception while trying to read bucket:%s, key:%s. Exception code:%s, message:%s. Retrying.", bucket, key, e.getErrorCode(), e.getMessage())); resetS3Client(); retry--;
@Nullable public S3Object getObject(String key) throws StorageException { final S3Object object; try { object = conn.getObject(bucketName, key); } catch (AmazonS3Exception e) { if (404 == e.getStatusCode()) { // 404 == not found return null; } throw new StorageException("Error fetching " + key + ": " + e.getMessage(), e); } if (isPendingDelete(object)) { closeObject(object); return null; } return object; }
public static boolean checkACLAccess(AmazonS3Client awsS3Client, String s3BucketName, String accessType) { logger.info("inside the checkACLAccess method"); Boolean openAcces = false; AccessControlList bucketAcl; List<Permission> permissionList = null; try { bucketAcl = awsS3Client.getBucketAcl(s3BucketName); List<Grant> grants = bucketAcl.getGrantsAsList(); // Check grants has which permission if (!CollectionUtils.isNullOrEmpty(grants)) { permissionList = checkAnyGrantHasOpenToReadOrWriteAccess(grants, accessType); if (!CollectionUtils.isNullOrEmpty(permissionList)) { openAcces = true; } } } catch (AmazonS3Exception s3Exception) { logger.error("error : ", s3Exception); throw new RuleExecutionFailedExeption(s3Exception.getMessage()); } return openAcces; }
/** * POST /analyse/update/source * Require Auth (token) * Body: UpdateAnalyzeSourceRequest (JSON) * Responds: SUCCESS or ERROR */ public void updateAnalyzeSource(UpdateAnalyzeSourceRequest req, RequestContext ctx) { try { logsStorageProvider.get(req.sourceType, Utils.fromString(req.sourceConfig)); } catch (AmazonS3Exception t) { ctx.finish(ErrorMessages.buildJson(ErrorMessages.GC_ANALYZE_SOURCE_ERROR, t.getMessage())); return; } catch (Throwable t) { LOG.info(t.getMessage(), t); } finally { analyseRepository.perform(new UpdateAnalyzeSourceOperation(account(ctx).id(), req.id, req.sourceType, req.sourceConfig)); } ctx.response(SUCCESS); }
LOGGER.error(String.format("AmazonS3Exception in revokeACLPublicPermission: %s", s3Exception.getMessage())); throw new RuleEngineRunTimeException(s3Exception);
logger.error("validateOnS3() " + payload.tocInfo.getPath() + " unexpected error: " + e.getMessage(),e); "s3.check.error", "error getting object metadata: " + e.getMessage());