• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VersionListing类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.s3.model.VersionListing的典型用法代码示例。如果您正苦于以下问题:Java VersionListing类的具体用法?Java VersionListing怎么用?Java VersionListing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VersionListing类属于com.amazonaws.services.s3.model包,在下文中一共展示了VersionListing类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listNextBatchOfVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listNextBatchOfVersions(ListNextBatchOfVersionsRequest listNextBatchOfVersionsRequest) {
    listNextBatchOfVersionsRequest = beforeClientExecution(listNextBatchOfVersionsRequest);
    rejectNull(listNextBatchOfVersionsRequest,
            "The request object parameter must be specified when listing the next batch of versions in a bucket");
    VersionListing previousVersionListing = listNextBatchOfVersionsRequest.getPreviousVersionListing();

    if (!previousVersionListing.isTruncated()) {
        VersionListing emptyListing = new VersionListing();
        emptyListing.setBucketName(previousVersionListing.getBucketName());
        emptyListing.setDelimiter(previousVersionListing.getDelimiter());
        emptyListing.setKeyMarker(previousVersionListing.getNextKeyMarker());
        emptyListing.setVersionIdMarker(previousVersionListing.getNextVersionIdMarker());
        emptyListing.setMaxKeys(previousVersionListing.getMaxKeys());
        emptyListing.setPrefix(previousVersionListing.getPrefix());
        emptyListing.setEncodingType(previousVersionListing.getEncodingType());
        emptyListing.setTruncated(false);

        return emptyListing;
    }

    return listVersions(listNextBatchOfVersionsRequest.toListVersionsRequest());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:AmazonS3Client.java


示例2: listVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listVersions(ListVersionsRequest listVersionsRequest)
        throws SdkClientException, AmazonServiceException {
    listVersionsRequest = beforeClientExecution(listVersionsRequest);
    rejectNull(listVersionsRequest.getBucketName(), "The bucket name parameter must be specified when listing versions in a bucket");

    /**
     * This flag shows whether we need to url decode S3 key names. This flag is enabled
     * only when the customers don't explicitly call {@link listVersionsRequest#setEncodingType(String)},
     * otherwise, it will be disabled for maintaining backwards compatibility.
     */
    final boolean shouldSDKDecodeResponse = listVersionsRequest.getEncodingType() == null;

    Request<ListVersionsRequest> request = createRequest(listVersionsRequest.getBucketName(), null, listVersionsRequest, HttpMethodName.GET);
    request.addParameter("versions", null);

    addParameterIfNotNull(request, "prefix", listVersionsRequest.getPrefix());
    addParameterIfNotNull(request, "key-marker", listVersionsRequest.getKeyMarker());
    addParameterIfNotNull(request, "version-id-marker", listVersionsRequest.getVersionIdMarker());
    addParameterIfNotNull(request, "delimiter", listVersionsRequest.getDelimiter());

    if (listVersionsRequest.getMaxResults() != null && listVersionsRequest.getMaxResults() >= 0) request.addParameter("max-keys", listVersionsRequest.getMaxResults().toString());
    request.addParameter("encoding-type", shouldSDKDecodeResponse ? Constants.URL_ENCODING : listVersionsRequest.getEncodingType());

    return invoke(request, new Unmarshallers.VersionListUnmarshaller(shouldSDKDecodeResponse), listVersionsRequest.getBucketName(), null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AmazonS3Client.java


示例3: emptyBucket

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
/**
 * Empties the contents of the given bucket and optionally deletes the bucket
 * 
 * @param s3 The S3 client object to use
 * @param bucketName The bucket to empty
 * @param deleteBucket Flag to determine whether to delete the bucket after emptying
 * @param context Lambda context object
 */
public static void emptyBucket(AmazonS3 s3, String bucketName, boolean deleteBucket, Context context)
{
    if (s3.doesBucketExistV2(bucketName))
    {
        logDebug("Emptying bucket '" + bucketName + "'...", context);
        
        VersionListing versionListing = s3.listVersions(new ListVersionsRequest().withBucketName(bucketName));
        while (true) 
        {
            for (S3VersionSummary vs : versionListing.getVersionSummaries()) 
            {
                s3.deleteVersion(bucketName, vs.getKey(), vs.getVersionId());
            }
            
            if (versionListing.isTruncated()) 
            {
                logDebug("Fetching next batch of versions for bucket '" + bucketName + "'", context);
                versionListing = s3.listNextBatchOfVersions(versionListing);
            } 
            else 
            {
                break;
            }
        }
        
        logInfo("Successfully emptied bucket '" + bucketName + "'", context);
        
        if (deleteBucket)
        {
            logDebug("Deleting bucket '" + bucketName + "'...", context);
            s3.deleteBucket(bucketName);
            logInfo("Successfully deleted bucket '" + bucketName + "'", context);
        }
    }
    else
    {
        logWarn("Bucket '" + bucketName + "' does not exist", context);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-lambda-java-utils,代码行数:48,代码来源:S3Cleaner.java


示例4: deleteAngularjsApp

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
void deleteAngularjsApp(String websiteBucket, LambdaLogger logger) {
  logger.log("Removing AngularjsApp content from website versioned S3 bucket");

  // We need to delete every version of every key
  ListVersionsRequest listVersionsRequest = new ListVersionsRequest()
      .withBucketName(websiteBucket);
  VersionListing versionListing;

  AmazonS3 client = TransferManagerBuilder.defaultTransferManager().getAmazonS3Client();
  do {
    versionListing = client.listVersions(listVersionsRequest);
    versionListing
        .getVersionSummaries()
        .stream()
        .filter(k -> (k.getKey().startsWith("app")))
        .forEach(
            k -> {
              logger.log("About to delete version: " + k.getVersionId()
                  + " of AngularjsApp page: " + k.getKey());
              DeleteVersionRequest deleteVersionRequest = new DeleteVersionRequest(websiteBucket,
                  k.getKey(), k.getVersionId());
              client.deleteVersion(deleteVersionRequest);
              logger.log("Successfully deleted version: " + k.getVersionId()
                  + " of AngularjsApp page: " + k.getKey());
            });

    listVersionsRequest.setKeyMarker(versionListing.getNextKeyMarker());
  } while (versionListing.isTruncated());
  logger.log("Finished removing AngularjsApp content from website S3 bucket");
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:31,代码来源:AngularjsAppCustomResourceLambda.java


示例5: removeSdkFromS3

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
void removeSdkFromS3(LambdaLogger logger) {
  logger.log("About to remove apigateway sdk from website versioned S3 bucket");
  // We need to delete every version of every key
  ListVersionsRequest listVersionsRequest = new ListVersionsRequest()
      .withBucketName(squashWebsiteBucket);
  VersionListing versionListing;
  IS3TransferManager transferManager = getS3TransferManager();
  AmazonS3 client = transferManager.getAmazonS3Client();
  do {
    versionListing = client.listVersions(listVersionsRequest);
    versionListing
        .getVersionSummaries()
        .stream()
        .filter(
            k -> !(k.getKey().startsWith("20") || k.getKey().equals("today.html") || k.getKey()
                .equals("bookings.html")))
        .forEach(
            k -> {
              logger.log("About to delete version: " + k.getVersionId() + " of API SDK: "
                  + k.getKey());
              DeleteVersionRequest deleteVersionRequest = new DeleteVersionRequest(
                  squashWebsiteBucket, k.getKey(), k.getVersionId());
              client.deleteVersion(deleteVersionRequest);
              logger.log("Successfully deleted version: " + k.getVersionId()
                  + " of API SDK key: " + k.getKey());
            });

    listVersionsRequest.setKeyMarker(versionListing.getNextKeyMarker());
  } while (versionListing.isTruncated());

  logger.log("Finished remove apigateway sdk from website S3 bucket");
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:33,代码来源:ApiGatewayCustomResourceLambda.java


示例6: testDeleteDirectoryAssertHandleAmazonClientException

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Test
public void testDeleteDirectoryAssertHandleAmazonClientException()
{
    S3Operations originalS3Operations = (S3Operations) ReflectionTestUtils.getField(s3Dao, "s3Operations");
    S3Operations mockS3Operations = mock(S3Operations.class);
    ReflectionTestUtils.setField(s3Dao, "s3Operations", mockS3Operations);

    try
    {
        S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
        s3FileTransferRequestParamsDto.setS3BucketName("s3BucketName");
        s3FileTransferRequestParamsDto.setS3KeyPrefix("s3KeyPrefix");

        VersionListing versionListing = new VersionListing();
        versionListing.getVersionSummaries().add(new S3VersionSummary());
        when(mockS3Operations.listVersions(any(), any())).thenReturn(versionListing);
        when(mockS3Operations.deleteObjects(any(), any())).thenThrow(new AmazonClientException("message"));

        try
        {
            s3Dao.deleteDirectory(s3FileTransferRequestParamsDto);
            fail();
        }
        catch (Exception e)
        {
            assertEquals(IllegalStateException.class, e.getClass());
            assertEquals("Failed to delete keys/key versions with prefix \"s3KeyPrefix\" from bucket \"s3BucketName\". Reason: message", e.getMessage());
        }
    }
    finally
    {
        ReflectionTestUtils.setField(s3Dao, "s3Operations", originalS3Operations);
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:35,代码来源:S3DaoTest.java


示例7: testDeleteDirectoryNoS3VersionsExist

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Test
public void testDeleteDirectoryNoS3VersionsExist()
{
    // Create an S3 file transfer request parameters DTO to access S3 objects.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    s3FileTransferRequestParamsDto.setS3BucketName(S3_BUCKET_NAME);
    s3FileTransferRequestParamsDto.setS3KeyPrefix(S3_KEY_PREFIX);

    // Create a retry policy.
    RetryPolicy retryPolicy =
        new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, INTEGER_VALUE, true);

    // Create an empty version listing.
    VersionListing versionListing = new VersionListing();

    // Mock the external calls.
    when(retryPolicyFactory.getRetryPolicy()).thenReturn(retryPolicy);
    when(s3Operations.listVersions(any(ListVersionsRequest.class), any(AmazonS3Client.class))).thenReturn(versionListing);

    // Call the method under test.
    s3DaoImpl.deleteDirectory(s3FileTransferRequestParamsDto);

    // Verify the external calls.
    verify(retryPolicyFactory).getRetryPolicy();
    verify(s3Operations).listVersions(any(ListVersionsRequest.class), any(AmazonS3Client.class));
    verifyNoMoreInteractionsHelper();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:28,代码来源:S3DaoImplTest.java


示例8: deleteAllVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
private void deleteAllVersions(String bucketName) {
    logger.info("Deleting all object versions from bucket '{}'", bucketName);
    VersionListing versionListing = s3.listVersions(bucketName, null);
    delete(versionListing);
    while (versionListing.isTruncated()) {
        versionListing = s3.listNextBatchOfVersions(versionListing);
        delete(versionListing);
    }
}
 
开发者ID:cloudfoundry-community,项目名称:s3-cf-service-broker,代码行数:10,代码来源:S3.java


示例9: listVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listVersions(String bucketName, String prefix) throws AmazonClientException, AmazonServiceException {
    return delegate.listVersions(bucketName, prefix);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonS3Wrapper.java


示例10: listNextBatchOfVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listNextBatchOfVersions(VersionListing previousVersionListing) throws AmazonClientException, AmazonServiceException {
    return delegate.listNextBatchOfVersions(previousVersionListing);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonS3Wrapper.java


示例11: listNextBatchOfVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listNextBatchOfVersions(VersionListing previousVersionListing) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:5,代码来源:AmazonS3ClientMock.java


示例12: listVersions

import com.amazonaws.services.s3.model.VersionListing; //导入依赖的package包/类
@Override
public VersionListing listVersions(String bucketName, String prefix) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:5,代码来源:AmazonS3ClientMock.java



注:本文中的com.amazonaws.services.s3.model.VersionListing类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICombinatoricsVector类代码示例发布时间:2022-05-21
下一篇:
Java BoringLayout类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap