3030import static org .apache .hadoop .ozone .s3 .util .S3Consts .ENCODING_TYPE ;
3131import static org .apache .hadoop .ozone .s3 .util .S3Utils .wrapInQuotes ;
3232
33- import com .google .common .annotations .VisibleForTesting ;
3433import java .io .IOException ;
3534import java .io .InputStream ;
3635import java .util .ArrayList ;
4241import java .util .Objects ;
4342import java .util .Set ;
4443import javax .annotation .PostConstruct ;
45- import javax .inject .Inject ;
4644import javax .ws .rs .DELETE ;
4745import javax .ws .rs .DefaultValue ;
4846import javax .ws .rs .GET ;
5351import javax .ws .rs .PathParam ;
5452import javax .ws .rs .Produces ;
5553import javax .ws .rs .QueryParam ;
56- import javax .ws .rs .core .Context ;
57- import javax .ws .rs .core .HttpHeaders ;
5854import javax .ws .rs .core .MediaType ;
5955import javax .ws .rs .core .Response ;
6056import org .apache .commons .lang3 .StringUtils ;
61- import org .apache .hadoop .hdds .conf .OzoneConfiguration ;
6257import org .apache .hadoop .ozone .OzoneAcl ;
6358import org .apache .hadoop .ozone .audit .S3GAction ;
6459import org .apache .hadoop .ozone .client .OzoneBucket ;
@@ -94,15 +89,9 @@ public class BucketEndpoint extends EndpointBase {
9489 private static final Logger LOG =
9590 LoggerFactory .getLogger (BucketEndpoint .class );
9691
97- @ Context
98- private HttpHeaders headers ;
99-
10092 private boolean listKeysShallowEnabled ;
10193 private int maxKeysLimit = 1000 ;
10294
103- @ Inject
104- private OzoneConfiguration ozoneConfiguration ;
105-
10695 /**
10796 * Rest endpoint to list objects in a specific bucket.
10897 * <p>
@@ -171,7 +160,7 @@ public Response get(
171160 && OZONE_URI_DELIMITER .equals (delimiter );
172161
173162 bucket = getBucket (bucketName );
174- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
163+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
175164
176165 ozoneKeyIterator = bucket .listKeys (prefix , prevKey , shallow );
177166
@@ -369,7 +358,7 @@ public Response listMultipartUploads(
369358 OzoneBucket bucket = getBucket (bucketName );
370359
371360 try {
372- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
361+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
373362 OzoneMultipartUploadList ozoneMultipartUploadList =
374363 bucket .listMultipartUploads (prefix , keyMarker , uploadIdMarker , maxUploads );
375364
@@ -423,7 +412,7 @@ public Response head(@PathParam("bucket") String bucketName)
423412 S3GAction s3GAction = S3GAction .HEAD_BUCKET ;
424413 try {
425414 OzoneBucket bucket = getBucket (bucketName );
426- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
415+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
427416 AUDIT .logReadSuccess (
428417 buildAuditMessageForSuccess (s3GAction , getAuditParameters ()));
429418 getMetrics ().updateHeadBucketSuccessStats (startNanos );
@@ -448,9 +437,9 @@ public Response delete(@PathParam("bucket") String bucketName)
448437 S3GAction s3GAction = S3GAction .DELETE_BUCKET ;
449438
450439 try {
451- if (S3Owner .hasBucketOwnershipVerificationConditions (headers )) {
440+ if (S3Owner .hasBucketOwnershipVerificationConditions (getHeaders () )) {
452441 OzoneBucket bucket = getBucket (bucketName );
453- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
442+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
454443 }
455444 deleteS3Bucket (bucketName );
456445 } catch (OMException ex ) {
@@ -506,7 +495,7 @@ public MultiDeleteResponse multiDelete(@PathParam("bucket") String bucketName,
506495 }
507496 long startNanos = Time .monotonicNowNanos ();
508497 try {
509- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
498+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
510499 undeletedKeyResultMap = bucket .deleteKeys (deleteKeys , true );
511500 for (DeleteObject d : request .getObjects ()) {
512501 ErrorInfo error = undeletedKeyResultMap .get (d .getKey ());
@@ -555,7 +544,7 @@ public S3BucketAcl getAcl(String bucketName)
555544 S3BucketAcl result = new S3BucketAcl ();
556545 try {
557546 OzoneBucket bucket = getBucket (bucketName );
558- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
547+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
559548 S3Owner owner = S3Owner .of (bucket .getOwner ());
560549 result .setOwner (owner );
561550
@@ -597,15 +586,15 @@ public S3BucketAcl getAcl(String bucketName)
597586 public Response putAcl (String bucketName ,
598587 InputStream body ) throws IOException , OS3Exception {
599588 long startNanos = Time .monotonicNowNanos ();
600- String grantReads = headers .getHeaderString (S3Acl .GRANT_READ );
601- String grantWrites = headers .getHeaderString (S3Acl .GRANT_WRITE );
602- String grantReadACP = headers .getHeaderString (S3Acl .GRANT_READ_CAP );
603- String grantWriteACP = headers .getHeaderString (S3Acl .GRANT_WRITE_CAP );
604- String grantFull = headers .getHeaderString (S3Acl .GRANT_FULL_CONTROL );
589+ String grantReads = getHeaders () .getHeaderString (S3Acl .GRANT_READ );
590+ String grantWrites = getHeaders () .getHeaderString (S3Acl .GRANT_WRITE );
591+ String grantReadACP = getHeaders () .getHeaderString (S3Acl .GRANT_READ_CAP );
592+ String grantWriteACP = getHeaders () .getHeaderString (S3Acl .GRANT_WRITE_CAP );
593+ String grantFull = getHeaders () .getHeaderString (S3Acl .GRANT_FULL_CONTROL );
605594
606595 try {
607596 OzoneBucket bucket = getBucket (bucketName );
608- S3Owner .verifyBucketOwnerCondition (headers , bucketName , bucket .getOwner ());
597+ S3Owner .verifyBucketOwnerCondition (getHeaders () , bucketName , bucket .getOwner ());
609598 OzoneVolume volume = getVolume ();
610599
611600 List <OzoneAcl > ozoneAclListOnBucket = new ArrayList <>();
@@ -774,28 +763,13 @@ private void addKey(ListObjectResponse response, OzoneKey next) {
774763 response .addKey (keyMetadata );
775764 }
776765
777- @ VisibleForTesting
778- public void setOzoneConfiguration (OzoneConfiguration config ) {
779- this .ozoneConfiguration = config ;
780- }
781-
782- @ VisibleForTesting
783- public OzoneConfiguration getOzoneConfiguration () {
784- return this .ozoneConfiguration ;
785- }
786-
787- @ VisibleForTesting
788- public void setHeaders (HttpHeaders headers ) {
789- this .headers = headers ;
790- }
791-
792766 @ Override
793767 @ PostConstruct
794768 public void init () {
795- listKeysShallowEnabled = ozoneConfiguration .getBoolean (
769+ listKeysShallowEnabled = getOzoneConfiguration () .getBoolean (
796770 OZONE_S3G_LIST_KEYS_SHALLOW_ENABLED ,
797771 OZONE_S3G_LIST_KEYS_SHALLOW_ENABLED_DEFAULT );
798- maxKeysLimit = ozoneConfiguration .getInt (
772+ maxKeysLimit = getOzoneConfiguration () .getInt (
799773 OZONE_S3G_LIST_MAX_KEYS_LIMIT ,
800774 OZONE_S3G_LIST_MAX_KEYS_LIMIT_DEFAULT );
801775 }
0 commit comments