@Test public void getBucketLifecycleTest() throws Exception { final BucketLifecycleManager bucketLifecycleManagerMock = context.mock(BucketLifecycleManager.class); final BucketMetadataManager bucketManagerMock = context.mock(BucketMetadataManager.class); final RequestAuthorizationHandler requestAuthorizationHandlerMock = context.mock(RequestAuthorizationHandler.class); BucketLifecycleManagers.setInstance(bucketLifecycleManagerMock); BucketMetadataManagers.setInstance(bucketManagerMock); final String bucketName = "my-test-bucket"; final Bucket bucket = new Bucket(); bucket.setBucketName(bucketName); bucket.setState(BucketState.extant); final String fakeUuid = "fakeuuid"; bucket.withUuid(fakeUuid); final GetBucketLifecycleType request = new GetBucketLifecycleType(); request.setBucket(bucketName); context.checking(new Expectations() { { oneOf(bucketManagerMock).lookupExtantBucket(bucketName); will(returnValue(bucket)); oneOf(requestAuthorizationHandlerMock).operationAllowed(request, bucket, null, 0); will(returnValue(true)); oneOf(bucketLifecycleManagerMock).getLifecycleRules(fakeUuid); will(returnValue(Collections.EMPTY_LIST)); } }); ObjectStorageGateway osg = new ObjectStorageGateway( requestAuthorizationHandlerMock ); GetBucketLifecycleResponseType response = osg.getBucketLifecycle(request); assertTrue("expected a response", response != null); assertTrue("expected response to contain an empty set of lifecycle rules", response.getLifecycleConfiguration().getRules().size() == 0); }
@Override public GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request) throws S3Exception { Bucket bucket = getBucketAndCheckAuthorization(request); GetBucketLifecycleResponseType reply = request.getReply(); try { LifecycleConfiguration lifecycle = new LifecycleConfiguration(); List<LifecycleRule> responseRules = BucketLifecycleManagers.getInstance().getLifecycleRules(bucket.getBucketUuid()); lifecycle.setRules(responseRules); reply.setLifecycleConfiguration(lifecycle); } catch (Exception e) { throw new InternalErrorException(request.getBucket()); } setCorsInfo(request, reply, bucket); return reply; }
ObjectStorageGateway implements ObjectStorageService { @Override public GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request) throws S3Exception { Bucket bucket = getBucketAndCheckAuthorization(request); GetBucketLifecycleResponseType reply = request.getReply(); try { LifecycleConfiguration lifecycle = new LifecycleConfiguration(); List<LifecycleRule> responseRules = BucketLifecycleManagers.getInstance().getLifecycleRules(bucket.getBucketUuid()); lifecycle.setRules(responseRules); reply.setLifecycleConfiguration(lifecycle); } catch (Exception e) { throw new InternalErrorException(request.getBucket()); } setCorsInfo(request, reply, bucket); return reply; } }
ObjectStorageGateway implements ObjectStorageService { @Override public GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request) throws S3Exception { Bucket bucket = getBucketAndCheckAuthorization(request); GetBucketLifecycleResponseType reply = request.getReply(); try { LifecycleConfiguration lifecycle = new LifecycleConfiguration(); List<LifecycleRule> responseRules = BucketLifecycleManagers.getInstance().getLifecycleRules(bucket.getBucketUuid()); lifecycle.setRules(responseRules); reply.setLifecycleConfiguration(lifecycle); } catch (Exception e) { throw new InternalErrorException(request.getBucket()); } setCorsInfo(request, reply, bucket); return reply; } @Inject  ObjectStorageGateway(
      final RequestAuthorizationHandler authorizationHandler
  ); }
ObjectStorageGateway implements ObjectStorageService { @Override public GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request) throws S3Exception { Bucket bucket = getBucketAndCheckAuthorization(request); GetBucketLifecycleResponseType reply = request.getReply(); try { LifecycleConfiguration lifecycle = new LifecycleConfiguration(); List<LifecycleRule> responseRules = BucketLifecycleManagers.getInstance().getLifecycleRules(bucket.getBucketUuid()); lifecycle.setRules(responseRules); reply.setLifecycleConfiguration(lifecycle); } catch (Exception e) { throw new InternalErrorException(request.getBucket()); } setCorsInfo(request, reply, bucket); return reply; } @Inject  ObjectStorageGateway(
      final RequestAuthorizationHandler authorizationHandler
  ); static void checkPreconditions(); static void configure(); static void enable(); static void disable(); static void check(); static void stop(); @Override UpdateObjectStorageConfigurationResponseType updateObjectStorageConfiguration(UpdateObjectStorageConfigurationType request); @Override GetObjectStorageConfigurationResponseType getObjectStorageConfiguration(GetObjectStorageConfigurationType request); static boolean checkBucketNameValidity(String bucketName); @Override PutObjectResponseType putObject(final PutObjectType request); @Override HeadBucketResponseType headBucket(HeadBucketType request); @Override CreateBucketResponseType createBucket(final CreateBucketType request); @Override DeleteBucketResponseType deleteBucket(final DeleteBucketType request); @Override ListAllMyBucketsResponseType listAllMyBuckets(ListAllMyBucketsType request); @Override GetBucketAccessControlPolicyResponseType getBucketAccessControlPolicy(GetBucketAccessControlPolicyType request); @Override PostObjectResponseType postObject(PostObjectType request); @Override DeleteObjectResponseType deleteObject(final DeleteObjectType request); @Override ListBucketResponseType listBucket(ListBucketType request); @Override GetObjectAccessControlPolicyResponseType getObjectAccessControlPolicy(GetObjectAccessControlPolicyType request); @Override SetBucketAccessControlPolicyResponseType setBucketAccessControlPolicy(final SetBucketAccessControlPolicyType request); @Override SetObjectAccessControlPolicyResponseType setObjectAccessControlPolicy(final SetObjectAccessControlPolicyType request); @Override GetObjectResponseType getObject(final GetObjectType request); @Override GetObjectExtendedResponseType getObjectExtended(GetObjectExtendedType request); @Override HeadObjectResponseType headObject(HeadObjectType request); @Override GetBucketLocationResponseType getBucketLocation(GetBucketLocationType request); @Override CopyObjectResponseType copyObject(CopyObjectType request); @Override GetBucketLoggingStatusResponseType getBucketLoggingStatus(GetBucketLoggingStatusType request); @Override SetBucketLoggingStatusResponseType setBucketLoggingStatus(final SetBucketLoggingStatusType request); @Override GetBucketVersioningStatusResponseType getBucketVersioningStatus(GetBucketVersioningStatusType request); @Override SetBucketVersioningStatusResponseType setBucketVersioningStatus(final SetBucketVersioningStatusType request); @Override ListVersionsResponseType listVersions(ListVersionsType request); @Override DeleteVersionResponseType deleteVersion(final DeleteVersionType request); @Override GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request); @Override SetBucketLifecycleResponseType setBucketLifecycle(SetBucketLifecycleType request); @Override DeleteBucketLifecycleResponseType deleteBucketLifecycle(DeleteBucketLifecycleType request); @Override SetBucketTaggingResponseType setBucketTagging(SetBucketTaggingType request); @Override GetBucketTaggingResponseType getBucketTagging(GetBucketTaggingType request); @Override DeleteBucketTaggingResponseType deleteBucketTagging(DeleteBucketTaggingType request); @Override GetBucketCorsResponseType getBucketCors(GetBucketCorsType request); void setCorsInfo(ObjectStorageRequestType request, ObjectStorageCommonResponseType response, Bucket bucket); @Override SetBucketCorsResponseType setBucketCors(SetBucketCorsType request); @Override DeleteBucketCorsResponseType deleteBucketCors(DeleteBucketCorsType request); @Override PreflightCheckCorsResponseType preflightCors(PreflightCheckCorsType request); @Override GetBucketPolicyResponseType getBucketPolicy( final GetBucketPolicyType request ); @Override SetBucketPolicyResponseType setBucketPolicy( final SetBucketPolicyType request ); @Override DeleteBucketPolicyResponseType deleteBucketPolicy( final DeleteBucketPolicyType request ); @Override InitiateMultipartUploadResponseType initiateMultipartUpload(InitiateMultipartUploadType request); @Override UploadPartResponseType uploadPart(final UploadPartType request); @Override CompleteMultipartUploadResponseType completeMultipartUpload(final CompleteMultipartUploadType request); @Override AbortMultipartUploadResponseType abortMultipartUpload(AbortMultipartUploadType request); @Override ListPartsResponseType listParts(ListPartsType request); @Override ListMultipartUploadsResponseType listMultipartUploads(ListMultipartUploadsType request); @Override DeleteMultipleObjectsResponseType deleteMultipleObjects(DeleteMultipleObjectsType request); }
ObjectStorageGateway implements ObjectStorageService { @Override public GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request) throws S3Exception { Bucket bucket = getBucketAndCheckAuthorization(request); GetBucketLifecycleResponseType reply = request.getReply(); try { LifecycleConfiguration lifecycle = new LifecycleConfiguration(); List<LifecycleRule> responseRules = BucketLifecycleManagers.getInstance().getLifecycleRules(bucket.getBucketUuid()); lifecycle.setRules(responseRules); reply.setLifecycleConfiguration(lifecycle); } catch (Exception e) { throw new InternalErrorException(request.getBucket()); } setCorsInfo(request, reply, bucket); return reply; } @Inject  ObjectStorageGateway(
      final RequestAuthorizationHandler authorizationHandler
  ); static void checkPreconditions(); static void configure(); static void enable(); static void disable(); static void check(); static void stop(); @Override UpdateObjectStorageConfigurationResponseType updateObjectStorageConfiguration(UpdateObjectStorageConfigurationType request); @Override GetObjectStorageConfigurationResponseType getObjectStorageConfiguration(GetObjectStorageConfigurationType request); static boolean checkBucketNameValidity(String bucketName); @Override PutObjectResponseType putObject(final PutObjectType request); @Override HeadBucketResponseType headBucket(HeadBucketType request); @Override CreateBucketResponseType createBucket(final CreateBucketType request); @Override DeleteBucketResponseType deleteBucket(final DeleteBucketType request); @Override ListAllMyBucketsResponseType listAllMyBuckets(ListAllMyBucketsType request); @Override GetBucketAccessControlPolicyResponseType getBucketAccessControlPolicy(GetBucketAccessControlPolicyType request); @Override PostObjectResponseType postObject(PostObjectType request); @Override DeleteObjectResponseType deleteObject(final DeleteObjectType request); @Override ListBucketResponseType listBucket(ListBucketType request); @Override GetObjectAccessControlPolicyResponseType getObjectAccessControlPolicy(GetObjectAccessControlPolicyType request); @Override SetBucketAccessControlPolicyResponseType setBucketAccessControlPolicy(final SetBucketAccessControlPolicyType request); @Override SetObjectAccessControlPolicyResponseType setObjectAccessControlPolicy(final SetObjectAccessControlPolicyType request); @Override GetObjectResponseType getObject(final GetObjectType request); @Override GetObjectExtendedResponseType getObjectExtended(GetObjectExtendedType request); @Override HeadObjectResponseType headObject(HeadObjectType request); @Override GetBucketLocationResponseType getBucketLocation(GetBucketLocationType request); @Override CopyObjectResponseType copyObject(CopyObjectType request); @Override GetBucketLoggingStatusResponseType getBucketLoggingStatus(GetBucketLoggingStatusType request); @Override SetBucketLoggingStatusResponseType setBucketLoggingStatus(final SetBucketLoggingStatusType request); @Override GetBucketVersioningStatusResponseType getBucketVersioningStatus(GetBucketVersioningStatusType request); @Override SetBucketVersioningStatusResponseType setBucketVersioningStatus(final SetBucketVersioningStatusType request); @Override ListVersionsResponseType listVersions(ListVersionsType request); @Override DeleteVersionResponseType deleteVersion(final DeleteVersionType request); @Override GetBucketLifecycleResponseType getBucketLifecycle(GetBucketLifecycleType request); @Override SetBucketLifecycleResponseType setBucketLifecycle(SetBucketLifecycleType request); @Override DeleteBucketLifecycleResponseType deleteBucketLifecycle(DeleteBucketLifecycleType request); @Override SetBucketTaggingResponseType setBucketTagging(SetBucketTaggingType request); @Override GetBucketTaggingResponseType getBucketTagging(GetBucketTaggingType request); @Override DeleteBucketTaggingResponseType deleteBucketTagging(DeleteBucketTaggingType request); @Override GetBucketCorsResponseType getBucketCors(GetBucketCorsType request); void setCorsInfo(ObjectStorageRequestType request, ObjectStorageCommonResponseType response, Bucket bucket); @Override SetBucketCorsResponseType setBucketCors(SetBucketCorsType request); @Override DeleteBucketCorsResponseType deleteBucketCors(DeleteBucketCorsType request); @Override PreflightCheckCorsResponseType preflightCors(PreflightCheckCorsType request); @Override GetBucketPolicyResponseType getBucketPolicy( final GetBucketPolicyType request ); @Override SetBucketPolicyResponseType setBucketPolicy( final SetBucketPolicyType request ); @Override DeleteBucketPolicyResponseType deleteBucketPolicy( final DeleteBucketPolicyType request ); @Override InitiateMultipartUploadResponseType initiateMultipartUpload(InitiateMultipartUploadType request); @Override UploadPartResponseType uploadPart(final UploadPartType request); @Override CompleteMultipartUploadResponseType completeMultipartUpload(final CompleteMultipartUploadType request); @Override AbortMultipartUploadResponseType abortMultipartUpload(AbortMultipartUploadType request); @Override ListPartsResponseType listParts(ListPartsType request); @Override ListMultipartUploadsResponseType listMultipartUploads(ListMultipartUploadsType request); @Override DeleteMultipleObjectsResponseType deleteMultipleObjects(DeleteMultipleObjectsType request);  }