本文整理汇总了Java中com.amazonaws.services.s3.event.S3EventNotification.S3Entity类的典型用法代码示例。如果您正苦于以下问题:Java S3Entity类的具体用法?Java S3Entity怎么用?Java S3Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
S3Entity类属于com.amazonaws.services.s3.event.S3EventNotification包,在下文中一共展示了S3Entity类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestEvent
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Override
public S3EventNotification getTestEvent() throws Exception {
/*
* Upload a test resoruce to the mock S3
*/
String payload = IOUtils.toString(
new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
this.client.putObject(S3_BUCKET, "basic_input.log", payload);
/*
* Create a S3EventNotification event
*/
S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
S3BucketEntity bucketEntity = new S3BucketEntity(S3_BUCKET, null, null);
S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
"1970-01-01T00:00:00.000Z", null, null, null, entity, null);
List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
notifications.add(rec);
return new S3EventNotification(notifications);
}
示例2: getTestEvent
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
private S3EventNotification getTestEvent(String bucket, boolean doPut) throws Exception {
/*
* Upload a test resoruce to the mock S3
*/
if (doPut) {
String payload = IOUtils.toString(
new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
this.client.putObject(bucket, "basic_input.log", payload);
}
/*
* Create a S3EventNotification event
*/
S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
S3BucketEntity bucketEntity = new S3BucketEntity(bucket, null, null);
S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
"1970-01-01T00:00:00.000Z", null, null, null, entity, null);
List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
notifications.add(rec);
return new S3EventNotification(notifications);
}
示例3: testS3MessageS3FileNoExists
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3MessageS3FileNoExists() throws Exception
{
setLogLevel(UploadDownloadHelperServiceImpl.class, LogLevel.OFF);
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper
.createUploadSingleInitiationRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2,
FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, TARGET_S3_KEY));
String filePath = resultUploadSingleInitiationResponse.getSourceBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath();
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, 0L, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF);
setLogLevel(HerdJmsMessageListener.class, LogLevel.OFF);
// Try to process an S3 JMS message, when source S3 file does not exist.
herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
}
示例4: getS3Notification
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
public static S3EventNotification getS3Notification(String key, String bucket, long size) {
S3ObjectEntity objEntity = new S3ObjectEntity(key, size, null, null);
S3BucketEntity bucketEntity = new S3BucketEntity(bucket, null, null);
S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
String timestamp = formatter.print(System.currentTimeMillis());
S3EventNotificationRecord rec =
new S3EventNotificationRecord(null, null, null, timestamp, null, null, null, entity, null);
List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(1);
notifications.add(rec);
return new S3EventNotification(notifications);
}
示例5: testS3MessageWithWrongFormat
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3MessageWithWrongFormat() throws Exception
{
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE,
Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)));
// Create a business object definition.
BusinessObjectDefinitionCreateRequest request =
new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME,
businessObjectDefinitionServiceTestHelper.getNewAttributes());
businessObjectDefinitionService.createBusinessObjectDefinition(request);
String fileName = "test1.csv";
String filePath = NAMESPACE + "/" + BDEF_NAME + fileName;
long fileSize = 1024L;
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, fileSize, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
try
{
sampleDataJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
}
catch (IllegalArgumentException ex)
{
//this exception should be caught inside the processMessage method
fail();
}
}
示例6: testS3MessageNoKey
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3MessageNoKey() throws Exception
{
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity("key_does_not_exist", 0L, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF);
setLogLevel(HerdJmsMessageListener.class, LogLevel.OFF);
herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
}
示例7: doForward
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Override
protected AmazonS3Object doForward(S3EventNotificationRecord a) {
final S3Entity s3 = a.getS3();
final S3ObjectEntity object = s3.getObject();
return new AmazonS3Object(a.getAwsRegion(), s3.getBucket().getName(),
object.getKey(), object.getSizeAsLong(), object.geteTag(),
object.getVersionId());
}
示例8: doBackward
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Override
protected S3EventNotificationRecord doBackward(AmazonS3Object b) {
final S3BucketEntity bucket = new S3BucketEntity(b.getBucketName(),
null, null);
final S3ObjectEntity object = new S3ObjectEntity(b.getKey(),
b.getSize(), b.getETag().orElse(null),
b.getVersionId().orElse(null), null);
final S3Entity s3 = new S3Entity(null, bucket, object, null);
return new S3EventNotificationRecord(null, null, null, null, null, null,
null, s3, null);
}
示例9: setUp
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Before
public void setUp() {
reset(mockS3);
final S3BucketEntity bucket = new S3BucketEntity("bucket-name", null,
null);
final S3ObjectEntity object = new S3ObjectEntity("object-key", 100L,
"object eTag", "object version", null);
final S3Entity s3 = new S3Entity(null, bucket, object, null);
record = new S3EventNotificationRecord("us-east-1", null, "aws:s3",
"1970-01-01T00:00:00.000Z", "2.0", null, null, s3, null);
}
示例10: getTestEvent
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Override
public SNSEvent getTestEvent() throws Exception {
/*
* Upload a test resoruce to the mock S3
*/
String payload = IOUtils.toString(
new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
this.client.putObject(S3_BUCKET, "basic_input.log", payload);
/*
* Create a S3EventNotification event
*/
S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
S3BucketEntity bucketEntity = new S3BucketEntity(S3_BUCKET, null, null);
S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
"1970-01-01T00:00:00.000Z", null, null, null, entity, null);
List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
notifications.add(rec);
/*
* Wrap as an SNS Event
*/
S3EventNotification event = new S3EventNotification(notifications);
SNSEvent.SNS sns = new SNSEvent.SNS();
sns.setMessage(event.toJson());
SNSEvent snsEvent = new SNSEvent();
ArrayList<SNSRecord> snsRecords = new ArrayList<SNSRecord>(1);
SNSRecord snsRecord = new SNSRecord();
snsRecord.setEventSource("aws:sns");
snsRecord.setEventVersion("1.0");
snsRecord.setEventSubscriptionArn("arn");
snsRecord.setSns(sns);
snsRecords.add(snsRecord);
snsEvent.setRecords(snsRecords);
return snsEvent;
}
示例11: getTestEvent
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
private SNSEvent getTestEvent(String bucket, boolean doPut) throws Exception {
/*
* Upload a test resoruce to the mock S3
*/
if (doPut) {
String payload = IOUtils.toString(
new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
this.client.putObject(bucket, "basic_input.log", payload);
}
/*
* Create a S3EventNotification event
*/
S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
S3BucketEntity bucketEntity = new S3BucketEntity(bucket, null, null);
S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
"1970-01-01T00:00:00.000Z", null, null, null, entity, null);
List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
notifications.add(rec);
/*
* Wrap as an SNS Event
*/
S3EventNotification event = new S3EventNotification(notifications);
SNSEvent.SNS sns = new SNSEvent.SNS();
sns.setMessage(event.toJson());
SNSEvent snsEvent = new SNSEvent();
ArrayList<SNSRecord> snsRecords = new ArrayList<SNSRecord>(1);
SNSRecord snsRecord = new SNSRecord();
snsRecord.setEventSource("aws:sns");
snsRecord.setEventVersion("1.0");
snsRecord.setEventSubscriptionArn("arn");
snsRecord.setSns(sns);
snsRecords.add(snsRecord);
snsEvent.setRecords(snsRecords);
return snsEvent;
}
示例12: testS3Message
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3Message() throws Exception
{
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE,
Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)));
// Create a business object definition.
BusinessObjectDefinitionCreateRequest request =
new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME,
businessObjectDefinitionServiceTestHelper.getNewAttributes());
businessObjectDefinitionService.createBusinessObjectDefinition(request);
// Get the business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity =
businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
assertNotNull(businessObjectDefinitionEntity);
String fileName = "test1.csv";
String filePath = NAMESPACE + "/" + BDEF_NAME + "/" + fileName;
long fileSize = 1024L;
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, fileSize, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
sampleDataJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
BusinessObjectDefinition updatedBusinessObjectDefinition =
businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, false);
List<SampleDataFile> sampleDataFiles = Arrays.asList(new SampleDataFile(NAMESPACE + "/" + BDEF_NAME + "/", fileName));
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(updatedBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION,
NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT,
sampleDataFiles, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(),
HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS),
updatedBusinessObjectDefinition);
}
示例13: testS3MessageWithDashCharacterName
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3MessageWithDashCharacterName() throws Exception
{
String namespace = "testnamespace-1";
String businessObjectDefinitionName = "testbdefname-1";
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting(namespace, DATA_PROVIDER_NAME);
storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE,
Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)));
// Create a business object definition.
BusinessObjectDefinitionCreateRequest request =
new BusinessObjectDefinitionCreateRequest(namespace, businessObjectDefinitionName, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME,
businessObjectDefinitionServiceTestHelper.getNewAttributes());
businessObjectDefinitionService.createBusinessObjectDefinition(request);
// Get the business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity =
businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(namespace, businessObjectDefinitionName));
assertNotNull(businessObjectDefinitionEntity);
String fileName = "test1.csv";
String filePath = namespace + "/" + businessObjectDefinitionName + "/" + fileName;
long fileSize = 1024L;
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, fileSize, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
sampleDataJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(namespace, businessObjectDefinitionName);
BusinessObjectDefinition updatedBusinessObjectDefinition =
businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, false);
List<SampleDataFile> sampleDataFiles = Arrays.asList(new SampleDataFile(namespace + "/" + businessObjectDefinitionName + "/", fileName));
// Validate the returned object.
assertEquals(
new BusinessObjectDefinition(updatedBusinessObjectDefinition.getId(), namespace, businessObjectDefinitionName, DATA_PROVIDER_NAME, BDEF_DESCRIPTION,
NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(),
NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, sampleDataFiles, businessObjectDefinitionEntity.getCreatedBy(),
businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()),
NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS),
updatedBusinessObjectDefinition);
}
示例14: testS3Message
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; //导入依赖的package包/类
@Test
public void testS3Message() throws Exception
{
setLogLevel(UploadDownloadHelperServiceImpl.class, LogLevel.OFF);
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
UploadSingleInitiationResponse resultUploadSingleInitiationResponse =
uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest());
String filePath = resultUploadSingleInitiationResponse.getSourceBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath();
S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, 0L, null, null), null);
List<S3EventNotificationRecord> records = new ArrayList<>();
records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
S3EventNotification s3EventNotification = new S3EventNotification(records);
setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF);
setLogLevel(HerdJmsMessageListener.class, LogLevel.DEBUG);
herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
}