/** * Creates a client configuration object that contains client configuration options such as proxy settings and max retry attempts. * * @param awsParamsDto the AWS related parameters that contain optional proxy information * * @return the client configuration object */ public ClientConfiguration getClientConfiguration(AwsParamsDto awsParamsDto) { ClientConfiguration clientConfiguration = new ClientConfiguration(); // Set a retry policy. clientConfiguration.withRetryPolicy(retryPolicyFactory.getRetryPolicy()); // If the proxy hostname and port both are configured, set the HTTP proxy information. if (StringUtils.isNotBlank(awsParamsDto.getHttpProxyHost()) && awsParamsDto.getHttpProxyPort() != null) { clientConfiguration.withProxyHost(awsParamsDto.getHttpProxyHost()).withProxyPort(awsParamsDto.getHttpProxyPort()); } return clientConfiguration; }
/** * Creates a client configuration object that contains client configuration options such as proxy settings and max retry attempts. * * @param awsParamsDto the AWS related parameters that contain optional proxy information * * @return the client configuration object */ public ClientConfiguration getClientConfiguration(AwsParamsDto awsParamsDto) { ClientConfiguration clientConfiguration = new ClientConfiguration(); // Set a retry policy. clientConfiguration.withRetryPolicy(retryPolicyFactory.getRetryPolicy()); // If the proxy hostname and port both are configured, set the HTTP proxy information. if (StringUtils.isNotBlank(awsParamsDto.getHttpProxyHost()) && awsParamsDto.getHttpProxyPort() != null) { clientConfiguration.withProxyHost(awsParamsDto.getHttpProxyHost()).withProxyPort(awsParamsDto.getHttpProxyPort()); } return clientConfiguration; }
/** * Gets a JMS connection factory. * * @return the JMS connection factory. */ @Bean public ConnectionFactory jmsConnectionFactory() { AwsParamsDto awsParamsDto = awsHelper.getAwsParamsDto(); ClientConfiguration clientConfiguration = new ClientConfiguration(); // Only set the proxy hostname and/or port if they're configured. if (StringUtils.isNotBlank(awsParamsDto.getHttpProxyHost())) { clientConfiguration.setProxyHost(awsParamsDto.getHttpProxyHost()); } if (awsParamsDto.getHttpProxyPort() != null) { clientConfiguration.setProxyPort(awsParamsDto.getHttpProxyPort()); } return SQSConnectionFactory.builder().withClientConfiguration(clientConfiguration).build(); }
/** * Gets a JMS connection factory. * * @return the JMS connection factory. */ @Bean public ConnectionFactory jmsConnectionFactory() { AwsParamsDto awsParamsDto = awsHelper.getAwsParamsDto(); ClientConfiguration clientConfiguration = new ClientConfiguration(); // Only set the proxy hostname and/or port if they're configured. if (StringUtils.isNotBlank(awsParamsDto.getHttpProxyHost())) { clientConfiguration.setProxyHost(awsParamsDto.getHttpProxyHost()); } if (awsParamsDto.getHttpProxyPort() != null) { clientConfiguration.setProxyPort(awsParamsDto.getHttpProxyPort()); } return SQSConnectionFactory.builder().withClientConfiguration(clientConfiguration).build(); }
@Override public void assertS3ObjectKeyDoesNotExist(String bucketName, String key) { S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3BucketName(bucketName); s3FileTransferRequestParamsDto.setS3KeyPrefix(key); AwsParamsDto awsParamsDto = awsHelper.getAwsParamsDto(); String httpProxyHost = awsParamsDto.getHttpProxyHost(); s3FileTransferRequestParamsDto.setHttpProxyHost(httpProxyHost); Integer httpProxyPort = awsParamsDto.getHttpProxyPort(); s3FileTransferRequestParamsDto.setHttpProxyPort(httpProxyPort); Assert.isTrue(!s3Dao.s3FileExists(s3FileTransferRequestParamsDto), String.format("A S3 object already exists in bucket \"%s\" and key \"%s\".", bucketName, key)); }
@Override public void assertS3ObjectKeyDoesNotExist(String bucketName, String key) { S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3BucketName(bucketName); s3FileTransferRequestParamsDto.setS3KeyPrefix(key); AwsParamsDto awsParamsDto = awsHelper.getAwsParamsDto(); String httpProxyHost = awsParamsDto.getHttpProxyHost(); s3FileTransferRequestParamsDto.setHttpProxyHost(httpProxyHost); Integer httpProxyPort = awsParamsDto.getHttpProxyPort(); s3FileTransferRequestParamsDto.setHttpProxyPort(httpProxyPort); Assert.isTrue(!s3Dao.s3FileExists(s3FileTransferRequestParamsDto), String.format("A S3 object already exists in bucket \"%s\" and key \"%s\".", bucketName, key)); }
/** * Deletes a source S3 object based on the given bucket name and file path. * * @param s3BucketName the S3 bucket name * @param storageFilePath the storage file path * @param businessObjectDataKey the business object key */ private void deleteSourceS3ObjectAfterError(String s3BucketName, String storageFilePath, BusinessObjectDataKey businessObjectDataKey) { // Delete the file from S3 if storage file information exists. if (!StringUtils.isEmpty(storageFilePath)) { try { // Delete the source file from S3. AwsParamsDto awsParams = awsHelper.getAwsParamsDto(); S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(s3BucketName).withS3KeyPrefix(storageFilePath) .withHttpProxyHost(awsParams.getHttpProxyHost()).withHttpProxyPort(awsParams.getHttpProxyPort()).build(); s3Dao.deleteDirectory(s3FileTransferRequestParamsDto); } catch (Exception e) { LOGGER.error("Failed to delete source business object data file. s3Key=\"{}\" sourceS3BucketName=\"{}\" sourceBusinessObjectDataKey={}", storageFilePath, s3BucketName, jsonHelper.objectToJson(businessObjectDataKey), e); } } }
/** * Deletes a source S3 object based on the given bucket name and file path. * * @param s3BucketName the S3 bucket name * @param storageFilePath the storage file path * @param businessObjectDataKey the business object key */ private void deleteSourceS3ObjectAfterError(String s3BucketName, String storageFilePath, BusinessObjectDataKey businessObjectDataKey) { // Delete the file from S3 if storage file information exists. if (!StringUtils.isEmpty(storageFilePath)) { try { // Delete the source file from S3. AwsParamsDto awsParams = awsHelper.getAwsParamsDto(); S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(s3BucketName).withS3KeyPrefix(storageFilePath) .withHttpProxyHost(awsParams.getHttpProxyHost()).withHttpProxyPort(awsParams.getHttpProxyPort()).build(); s3Dao.deleteDirectory(s3FileTransferRequestParamsDto); } catch (Exception e) { LOGGER.error("Failed to delete source business object data file. s3Key=\"{}\" sourceS3BucketName=\"{}\" sourceBusinessObjectDataKey={}", storageFilePath, s3BucketName, jsonHelper.objectToJson(businessObjectDataKey), e); } } }
if (awsParamsDto.getHttpProxyPort() != null) clientConfiguration.setProxyPort(awsParamsDto.getHttpProxyPort());
if (awsParamsDto.getHttpProxyPort() != null) clientConfiguration.setProxyPort(awsParamsDto.getHttpProxyPort());
/** * Delete the source file from S3 * * @param completeUploadSingleParamsDto the DTO that contains complete upload single message parameters */ protected void deleteSourceFileFromS3Impl(CompleteUploadSingleParamsDto completeUploadSingleParamsDto) { try { // Delete the source file from S3. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(completeUploadSingleParamsDto.getSourceBucketName()) .withS3KeyPrefix(completeUploadSingleParamsDto.getSourceFilePath()) .withHttpProxyHost(completeUploadSingleParamsDto.getAwsParams().getHttpProxyHost()) .withHttpProxyPort(completeUploadSingleParamsDto.getAwsParams().getHttpProxyPort()).build(); s3Dao.deleteDirectory(s3FileTransferRequestParamsDto); } catch (Exception e) { // Log the error if failed to delete the file from source S3 bucket. LOGGER.error("Failed to delete the upload single file. s3Key=\"{}\" sourceS3BucketName=\"{}\" sourceBusinessObjectDataKey={}", completeUploadSingleParamsDto.getSourceFilePath(), completeUploadSingleParamsDto.getSourceBucketName(), jsonHelper.objectToJson(completeUploadSingleParamsDto.getSourceBusinessObjectDataKey()), e); } }
theHttpProxyPort = this.getHttpProxyPort(); strategy.appendField(locator, this, "httpProxyPort", buffer, theHttpProxyPort, (this.httpProxyPort!= null));
/** * Delete the source file from S3 * * @param completeUploadSingleParamsDto the DTO that contains complete upload single message parameters */ protected void deleteSourceFileFromS3Impl(CompleteUploadSingleParamsDto completeUploadSingleParamsDto) { try { // Delete the source file from S3. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(completeUploadSingleParamsDto.getSourceBucketName()) .withS3KeyPrefix(completeUploadSingleParamsDto.getSourceFilePath()) .withHttpProxyHost(completeUploadSingleParamsDto.getAwsParams().getHttpProxyHost()) .withHttpProxyPort(completeUploadSingleParamsDto.getAwsParams().getHttpProxyPort()).build(); s3Dao.deleteDirectory(s3FileTransferRequestParamsDto); } catch (Exception e) { // Log the error if failed to delete the file from source S3 bucket. LOGGER.error("Failed to delete the upload single file. s3Key=\"{}\" sourceS3BucketName=\"{}\" sourceBusinessObjectDataKey={}", completeUploadSingleParamsDto.getSourceFilePath(), completeUploadSingleParamsDto.getSourceBucketName(), jsonHelper.objectToJson(completeUploadSingleParamsDto.getSourceBusinessObjectDataKey()), e); } }
lhsHttpProxyPort = this.getHttpProxyPort(); Integer rhsHttpProxyPort; rhsHttpProxyPort = that.getHttpProxyPort(); if (!strategy.equals(LocatorUtils.property(thisLocator, "httpProxyPort", lhsHttpProxyPort), LocatorUtils.property(thatLocator, "httpProxyPort", rhsHttpProxyPort), lhsHttpProxyPort, rhsHttpProxyPort, (this.httpProxyPort!= null), (that.httpProxyPort!= null))) { return false;
@Test public void testGetAwsParamsDto() throws Exception { // Get AWS parameters DTO. AwsParamsDto resultAwsParamsDto = awsHelper.getAwsParamsDto(); // Validate the results. // Since local users could set environment variables with a real HTTP proxy to test the real application, we can't update the environment to test // specific values. Instead, we can only test that the returned DTO contains the values in the environment. assertEquals(configurationHelper.getProperty(ConfigurationValue.HTTP_PROXY_HOST), resultAwsParamsDto.getHttpProxyHost()); assertEquals(configurationHelper.getProperty(ConfigurationValue.HTTP_PROXY_PORT, Integer.class), resultAwsParamsDto.getHttpProxyPort()); assertNotNull(resultAwsParamsDto); }
theHttpProxyPort = this.getHttpProxyPort(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "httpProxyPort", theHttpProxyPort), currentHashCode, theHttpProxyPort, (this.httpProxyPort!= null));
params.setKmsKeyId(completeUploadSingleParamsDto.getKmsKeyId()); params.setHttpProxyHost(completeUploadSingleParamsDto.getAwsParams().getHttpProxyHost()); params.setHttpProxyPort(completeUploadSingleParamsDto.getAwsParams().getHttpProxyPort());
params.setKmsKeyId(completeUploadSingleParamsDto.getKmsKeyId()); params.setHttpProxyHost(completeUploadSingleParamsDto.getAwsParams().getHttpProxyHost()); params.setHttpProxyPort(completeUploadSingleParamsDto.getAwsParams().getHttpProxyPort());
S3FileTransferRequestParamsDto.builder().withS3BucketName(completeUploadSingleParamsDto.getSourceBucketName()) .withS3KeyPrefix(completeUploadSingleParamsDto.getSourceFilePath()).withHttpProxyHost(awsParamsDto.getHttpProxyHost()) .withHttpProxyPort(awsParamsDto.getHttpProxyPort()).build(); s3Dao.validateS3File(s3FileTransferRequestParamsDto, sourceStorageFileEntity.getFileSizeBytes());
if (httpProxyPortShouldBeCopiedAndSet == Boolean.TRUE) { Integer sourceHttpProxyPort; sourceHttpProxyPort = this.getHttpProxyPort(); Integer copyHttpProxyPort = ((Integer) strategy.copy(LocatorUtils.property(locator, "httpProxyPort", sourceHttpProxyPort), sourceHttpProxyPort, (this.httpProxyPort!= null))); copy.setHttpProxyPort(copyHttpProxyPort);