项目:ibm-cos-sdk-java
文件:XmlResponsesSaxParser.java
@Override
protected void doStartElement(
String uri,String name,String qName,Attributes attrs) {
if (in("ListInventoryConfigurationsResult")) {
if (name.equals("InventoryConfiguration")) {
currentConfiguration = new InventoryConfiguration();
}
} else if (in("ListInventoryConfigurationsResult","InventoryConfiguration")) {
if (name.equals("Destination")) {
currentDestination = new InventoryDestination();
} else if(name.equals("Filter")) {
currentFilter = new InventoryFilter();
} else if(name.equals("Schedule")) {
currentSchedule = new InventorySchedule();
} else if(name.equals("OptionalFields")) {
currentOptionalFieldsList = new ArrayList<String>();
}
} else if (in("ListInventoryConfigurationsResult","InventoryConfiguration","Destination")) {
if (name.equals("S3BucketDestination")) {
currentS3BucketDestination = new InventoryS3BucketDestination();
}
}
}
项目:unitstack
文件:MockS3Test.java
@Test
public void testNonInjectableMocks_shouldReturnnormal() {
assertNotNull(getBuckets());
String leadBucket = "lead-maybe-gold";
assertNotNull(s3.deleteBucketAnalyticsConfiguration(new DeleteBucketAnalyticsConfigurationRequest()
.withBucketName(leadBucket).withId("very analytic")));
s3.deleteBucketCrossOriginConfiguration(new DeleteBucketCrossOriginConfigurationRequest(leadBucket));
assertNotNull(s3.deleteBucketInventoryConfiguration(new DeleteBucketInventoryConfigurationRequest().withBucketName(leadBucket).withId("1")));
s3.deleteBucketLifecycleConfiguration(new DeleteBucketLifecycleConfigurationRequest(leadBucket));
assertNotNull(s3.deleteBucketMetricsConfiguration(new DeleteBucketMetricsConfigurationRequest().withBucketName(leadBucket).withId("1")));
s3.deleteBucketReplicationConfiguration(new DeleteBucketReplicationConfigurationRequest(leadBucket));
s3.deleteBucketTaggingConfiguration(new DeleteBucketTaggingConfigurationRequest(leadBucket));
s3.deleteBucketWebsiteConfiguration(new DeleteBucketWebsiteConfigurationRequest(leadBucket));
assertNotNull(s3.deleteObjectTagging(new DeleteObjectTaggingRequest(leadBucket,"1")));
s3.disableRequesterPays(leadBucket);
s3.enableRequesterPays(leadBucket);
assertNotNull(s3.getBucketAccelerateConfiguration(new GetBucketAccelerateConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketAnalyticsConfiguration(new GetBucketAnalyticsConfigurationRequest().withBucketName(leadBucket).withId("1")));
assertNotNull(s3.getBucketCrossOriginConfiguration(new GetBucketCrossOriginConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketInventoryConfiguration(new GetBucketInventoryConfigurationRequest().withBucketName(leadBucket).withId("1")));
assertNotNull(s3.getBucketLifecycleConfiguration(new GetBucketLifecycleConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketLoggingConfiguration(new GetBucketLoggingConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketMetricsConfiguration(new GetBucketMetricsConfigurationRequest().withBucketName(leadBucket).withId("1")));
assertNotNull(s3.getBucketNotificationConfiguration(new GetBucketNotificationConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketReplicationConfiguration(new GetBucketReplicationConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketTaggingConfiguration(new GetBucketTaggingConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketVersioningConfiguration(new GetBucketVersioningConfigurationRequest(leadBucket)));
assertNotNull(s3.getBucketWebsiteConfiguration(new GetBucketWebsiteConfigurationRequest(leadBucket)));
assertNotNull(s3.listBucketAnalyticsConfigurations(new ListBucketAnalyticsConfigurationsRequest().withBucketName(leadBucket)));
assertNotNull(s3.listBucketInventoryConfigurations(new ListBucketInventoryConfigurationsRequest().withBucketName(leadBucket)));
assertNotNull(s3.listBucketMetricsConfigurations(new ListBucketMetricsConfigurationsRequest().withBucketName(leadBucket)));
s3.setBucketAccelerateConfiguration(new SetBucketAccelerateConfigurationRequest(leadBucket,new BucketAccelerateConfiguration("")));
assertNotNull(s3.setBucketInventoryConfiguration(new SetBucketInventoryConfigurationRequest().withBucketName(leadBucket).withInventoryConfiguration(new InventoryConfiguration().withId("1"))));
s3.setBucketLoggingConfiguration(new SetBucketLoggingConfigurationRequest(leadBucket,new BucketLoggingConfiguration()));
assertNotNull(s3.setBucketMetricsConfiguration(new SetBucketMetricsConfigurationRequest().withBucketName(leadBucket).withMetricsConfiguration(new MetricsConfiguration().withId("1"))));
s3.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(leadBucket,new BucketVersioningConfiguration().withStatus("ENABLED")));
BucketWebsiteConfiguration bucketWebsiteConfig = new BucketWebsiteConfiguration();
bucketWebsiteConfig.setIndexDocumentSuffix("1");
s3.setBucketWebsiteConfiguration(new SetBucketWebsiteConfigurationRequest(leadBucket,bucketWebsiteConfig));
assertNotNull(s3.headBucket(new HeadBucketRequest(leadBucket)));
assertNotNull(s3.getBucketPolicy(leadBucket));
s3.setBucketPolicy(new SetBucketPolicyRequest(leadBucket,"very strict policy"));
s3.deleteBucketPolicy(leadBucket);
try {
assertNotNull(s3.getobjectMetadata(new GetobjectMetadataRequest(leadBucket,"23423kjh")));
} catch(AmazonS3Exception s3Exception) {
assertEquals("should return not found",404,s3Exception.getStatusCode());
}
s3.restoreObject(new RestoreObjectRequest(leadBucket,"bullet.jpg").withExpirationInDays(23));
s3.deleteVersion(new DeleteVersionRequest(leadBucket,"bullet.exe","v3"));
assertNotNull(s3.listNextBatchOfVersions(new ListNextBatchOfVersionsRequest(new VersionListing())));
assertNotNull(s3.generatePresignedUrl("nonExistante","somekey",new Date()));
assertNotNull(s3.getS3AccountOwner());
}
/**
* Converts the specified {@link InventoryConfiguration} object to an XML fragment that
* can be sent to Amazon S3.
*
* @param config
* The {@link InventoryConfiguration}
*/
/*
<?xml version="1.0" encoding="UTF-8"?>
<InventoryConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Destination>
<S3BucketDestination>
<AccountId>A2OCNCIEQW9MSG</AccountId>
<Bucket>s3-object-inventory-list-gamma-us-east-1</Bucket>
<Format>CSV</Format>
<Prefix>string</Prefix>
</S3BucketDestination>
</Destination>
<IsEnabled>true</IsEnabled>
<Filter>
<Prefix>string</Prefix>
</Filter>
<Id>configId</Id>
<IncludedobjectVersions>All</IncludedobjectVersions>
<OptionalFields>
<Field>Size</Field>
<Field>LastModifiedDate</Field>
<Field>StorageClass</Field>
<Field>ETag</Field>
<Field>IsMultipartUploaded</Field>
<Field>ReplicationStatus</Field>
</OptionalFields>
<Schedule>
<Frequency>Daily</Frequency>
</Schedule>
</InventoryConfiguration>
*/
public byte[] convertToXmlByteArray(InventoryConfiguration config) throws SdkClientException {
XmlWriter xml = new XmlWriter();
xml.start("InventoryConfiguration","xmlns",Constants.XML_NAMESPACE);
xml.start("Id").value(config.getId()).end();
xml.start("IsEnabled").value(String.valueOf(config.isEnabled())).end();
xml.start("IncludedobjectVersions").value(config.getIncludedobjectVersions()).end();
writeInventoryDestination(xml,config.getDestination());
writeInventoryFilter(xml,config.getInventoryFilter());
addInventorySchedule(xml,config.getSchedule());
addInventoryOptionalFields(xml,config.getoptionalFields());
xml.end(); // </InventoryConfiguration>
return xml.getBytes();
}
项目:ibm-cos-sdk-java
文件:XmlResponsesSaxParser.java
@Override
protected void doEndElement(String uri,String qName) {
if (in("ListInventoryConfigurationsResult")) {
if (name.equals("InventoryConfiguration")) {
if (result.getInventoryConfigurationList() == null) {
result.setInventoryConfigurationList(new ArrayList<InventoryConfiguration>());
}
result.getInventoryConfigurationList().add(currentConfiguration);
currentConfiguration = null;
} else if (name.equals("IsTruncated")) {
result.setTruncated("true".equals(getText()));
} else if (name.equals("ContinuationToken")) {
result.setContinuationToken(getText());
} else if (name.equals("NextContinuationToken")) {
result.setNextContinuationToken(getText());
}
}
else if (in("ListInventoryConfigurationsResult","InventoryConfiguration")) {
if (name.equals("Id")) {
currentConfiguration.setId(getText());
} else if (name.equals("Destination")) {
currentConfiguration.setDestination(currentDestination);
currentDestination = null;
} else if (name.equals("IsEnabled")) {
currentConfiguration.setEnabled("true".equals(getText()));
} else if (name.equals("Filter")) {
currentConfiguration.setInventoryFilter(currentFilter);
currentFilter = null;
} else if (name.equals("IncludedobjectVersions")) {
currentConfiguration.setIncludedobjectVersions(getText());
} else if (name.equals("Schedule")) {
currentConfiguration.setSchedule(currentSchedule);
currentSchedule = null;
} else if (name.equals("OptionalFields")) {
currentConfiguration.setoptionalFields(currentOptionalFieldsList);
currentOptionalFieldsList = null;
}
} else if (in("ListInventoryConfigurationsResult","Destination")) {
if ( name.equals("S3BucketDestination") ) {
currentDestination.setS3BucketDestination(currentS3BucketDestination);
currentS3BucketDestination = null;
}
} else if (in("ListInventoryConfigurationsResult","Destination","S3BucketDestination")) {
if (name.equals("AccountId")) {
currentS3BucketDestination.setAccountId(getText());
} else if (name.equals("Bucket")) {
currentS3BucketDestination.setBucketArn(getText());
} else if (name.equals("Format")) {
currentS3BucketDestination.setFormat(getText());
} else if (name.equals("Prefix")) {
currentS3BucketDestination.setPrefix(getText());
}
} else if (in("ListInventoryConfigurationsResult","Filter")) {
if (name.equals("Prefix")) {
currentFilter.setPredicate(new InventoryPrefixPredicate(getText()));
}
} else if (in("ListInventoryConfigurationsResult","Schedule")) {
if (name.equals("Frequency")) {
currentSchedule.setFrequency(getText());
}
} else if (in("ListInventoryConfigurationsResult","OptionalFields")) {
if (name.equals("Field")) {
currentOptionalFieldsList.add(getText());
}
}
}
/**
* Returns the list of inventory configurations for a bucket and returns
* {@link ListBucketInventoryConfigurationsResult} object for method chaining.
*/
public ListBucketInventoryConfigurationsResult withInventoryConfigurationList(List<InventoryConfiguration> inventoryConfigurationList) {
setInventoryConfigurationList(inventoryConfigurationList);
return this;
}
项目:S3Decorators
文件:S3Decorator.java
@Override
public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(String bucketName,InventoryConfiguration inventoryConfiguration) throws AmazonServiceException,AmazonServiceException {
return call(() -> getDelegate().setBucketInventoryConfiguration(bucketName,inventoryConfiguration));
}
/**
* Sets the inventory configuration and returns the
* {@link SetBucketInventoryConfigurationRequest} object
* for method chaining.
*/
public SetBucketInventoryConfigurationRequest withInventoryConfiguration(InventoryConfiguration inventoryConfiguration) {
setInventoryConfiguration(inventoryConfiguration);
return this;
}
/**
* Sets the inventory configuration and returns the
* {@link GetBucketInventoryConfigurationResult} object
* for method chaining.
*/
public GetBucketInventoryConfigurationResult withInventoryConfiguration(InventoryConfiguration inventoryConfiguration) {
setInventoryConfiguration(inventoryConfiguration);
return this;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。