}
try {
// -> does not matter what the ACLs say only the owner can turn on versioning on a bucket
// -> the bucket owner may want to restrict the IP address from which this can occur
SBucketDao bucketDao = new SBucketDao();
SBucket sbucket = bucketDao.getByName( bucketName );
String client = UserContext.current().getCanonicalUserId();
if (!client.equals( sbucket.getOwnerCanonicalId()))
throw new PermissionDeniedException( "Access Denied - only the owner can turn on versioing on a bucket" );
S3PolicyContext context = new S3PolicyContext( PolicyActions.PutBucketVersioning, bucketName );
if (PolicyAccess.DENY == S3Engine.verifyPolicy( context )) {
response.setStatus(403);
return;
}
if (versioningStatus.equalsIgnoreCase( "Enabled" )) sbucket.setVersioningStatus( 1 );
else if (versioningStatus.equalsIgnoreCase( "Suspended")) sbucket.setVersioningStatus( 2 );
else {
logger.error( "executePutBucketVersioning - unknown state: [" + versioningStatus + "]" );
response.setStatus( 400 );
return;
}
bucketDao.update( sbucket );
} catch( PermissionDeniedException e ) {
logger.error( "executePutBucketVersioning - failed due to " + e.getMessage(), e);
throw e;