8383import javax .annotation .PostConstruct ;
8484import javax .ws .rs .Consumes ;
8585import javax .ws .rs .DELETE ;
86- import javax .ws .rs .DefaultValue ;
8786import javax .ws .rs .GET ;
8887import javax .ws .rs .HEAD ;
8988import javax .ws .rs .HeaderParam ;
9291import javax .ws .rs .Path ;
9392import javax .ws .rs .PathParam ;
9493import javax .ws .rs .Produces ;
95- import javax .ws .rs .QueryParam ;
9694import javax .ws .rs .core .HttpHeaders ;
9795import javax .ws .rs .core .MediaType ;
9896import javax .ws .rs .core .MultivaluedMap ;
@@ -222,23 +220,24 @@ public void init() {
222220 * See: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html for
223221 * more details.
224222 */
225- @ SuppressWarnings ({ "checkstyle:MethodLength" , "checkstyle:ParameterNumber" } )
223+ @ SuppressWarnings ("checkstyle:MethodLength" )
226224 @ PUT
227225 public Response put (
228226 @ PathParam (BUCKET ) String bucketName ,
229227 @ PathParam (PATH ) String keyPath ,
230228 @ HeaderParam (HttpHeaders .CONTENT_LENGTH ) long length ,
231- @ QueryParam (QueryParams .PART_NUMBER ) int partNumber ,
232- @ QueryParam (QueryParams .UPLOAD_ID ) @ DefaultValue ("" ) String uploadID ,
233- @ QueryParam (QueryParams .TAGGING ) String taggingMarker ,
234- @ QueryParam (QueryParams .ACL ) String aclMarker ,
235- final InputStream body ) throws IOException , OS3Exception {
229+ final InputStream body
230+ ) throws IOException , OS3Exception {
231+ final String aclMarker = queryParams ().get (QueryParams .ACL );
232+ final int partNumber = queryParams ().getInt (QueryParams .PART_NUMBER , 0 );
233+ final String taggingMarker = queryParams ().get (QueryParams .TAGGING );
234+ final String uploadID = queryParams ().get (QueryParams .UPLOAD_ID );
236235 long startNanos = Time .monotonicNowNanos ();
237236 S3GAction s3GAction = S3GAction .CREATE_KEY ;
238237 boolean auditSuccess = true ;
239238 PerformanceStringBuilder perf = new PerformanceStringBuilder ();
240239
241- String copyHeader = null , storageType = null , storageConfig = null ;
240+ String copyHeader = null ;
242241 MultiDigestInputStream multiDigestInputStream = null ;
243242 try {
244243 if (aclMarker != null ) {
@@ -261,17 +260,13 @@ public Response put(
261260 }
262261 // If uploadID is specified, it is a request for upload part
263262 return createMultipartKey (volume , bucket , keyPath , length ,
264- partNumber , uploadID , body , perf );
263+ body , perf );
265264 }
266265
267266 copyHeader = getHeaders ().getHeaderString (COPY_SOURCE_HEADER );
268- storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
269- storageConfig = getHeaders ().getHeaderString (CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER );
270- boolean storageTypeDefault = StringUtils .isEmpty (storageType );
271267
272268 // Normal put object
273- ReplicationConfig replicationConfig =
274- getReplicationConfig (bucket , storageType , storageConfig );
269+ ReplicationConfig replicationConfig = getReplicationConfig (bucket );
275270
276271 boolean enableEC = false ;
277272 if ((replicationConfig != null &&
@@ -284,8 +279,7 @@ public Response put(
284279 //Copy object, as copy source available.
285280 s3GAction = S3GAction .COPY_OBJECT ;
286281 CopyObjectResponse copyObjectResponse = copyObject (volume ,
287- copyHeader , bucketName , keyPath , replicationConfig ,
288- storageTypeDefault , perf );
282+ bucketName , keyPath , replicationConfig , perf );
289283 return Response .status (Status .OK ).entity (copyObjectResponse ).header (
290284 "Connection" , "close" ).build ();
291285 }
@@ -431,17 +425,18 @@ public Response put(
431425 * https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadListParts.html
432426 * for more details.
433427 */
434- @ SuppressWarnings ({ "checkstyle:MethodLength" , "checkstyle:ParameterNumber" } )
428+ @ SuppressWarnings ("checkstyle:MethodLength" )
435429 @ GET
436430 public Response get (
437431 @ PathParam (BUCKET ) String bucketName ,
438- @ PathParam (PATH ) String keyPath ,
439- @ QueryParam (QueryParams .PART_NUMBER ) int partNumber ,
440- @ QueryParam (QueryParams .UPLOAD_ID ) String uploadId ,
441- @ QueryParam (QueryParams .MAX_PARTS ) @ DefaultValue ("1000" ) int maxParts ,
442- @ QueryParam (QueryParams .PART_NUMBER_MARKER ) String partNumberMarker ,
443- @ QueryParam (QueryParams .TAGGING ) String taggingMarker )
444- throws IOException , OS3Exception {
432+ @ PathParam (PATH ) String keyPath
433+ ) throws IOException , OS3Exception {
434+ final int maxParts = queryParams ().getInt (QueryParams .MAX_PARTS , 1000 );
435+ final int partNumber = queryParams ().getInt (QueryParams .PART_NUMBER , 0 );
436+ final String partNumberMarker = queryParams ().get (QueryParams .PART_NUMBER_MARKER );
437+ final String taggingMarker = queryParams ().get (QueryParams .TAGGING );
438+ final String uploadId = queryParams ().get (QueryParams .UPLOAD_ID );
439+
445440 long startNanos = Time .monotonicNowNanos ();
446441 S3GAction s3GAction = S3GAction .GET_KEY ;
447442 PerformanceStringBuilder perf = new PerformanceStringBuilder ();
@@ -748,10 +743,11 @@ private Response abortMultipartUpload(OzoneVolume volume, String bucket,
748743 @ SuppressWarnings ("emptyblock" )
749744 public Response delete (
750745 @ PathParam (BUCKET ) String bucketName ,
751- @ PathParam (PATH ) String keyPath ,
752- @ QueryParam (QueryParams .UPLOAD_ID ) @ DefaultValue ("" ) String uploadId ,
753- @ QueryParam (QueryParams .TAGGING ) String taggingMarker ) throws
754- IOException , OS3Exception {
746+ @ PathParam (PATH ) String keyPath
747+ ) throws IOException , OS3Exception {
748+ final String taggingMarker = queryParams ().get (QueryParams .TAGGING );
749+ final String uploadId = queryParams ().get (QueryParams .UPLOAD_ID );
750+
755751 long startNanos = Time .monotonicNowNanos ();
756752 S3GAction s3GAction = S3GAction .DELETE_KEY ;
757753
@@ -826,24 +822,20 @@ public Response delete(
826822 public Response initializeMultipartUpload (
827823 @ PathParam (BUCKET ) String bucket ,
828824 @ PathParam (PATH ) String key
829- )
830- throws IOException , OS3Exception {
825+ ) throws IOException , OS3Exception {
831826 long startNanos = Time .monotonicNowNanos ();
832827 S3GAction s3GAction = S3GAction .INIT_MULTIPART_UPLOAD ;
833828
834829 try {
835830 OzoneBucket ozoneBucket = getBucket (bucket );
836831 S3Owner .verifyBucketOwnerCondition (getHeaders (), bucket , ozoneBucket .getOwner ());
837- String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
838- String storageConfig = getHeaders ().getHeaderString (CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER );
839832
840833 Map <String , String > customMetadata =
841834 getCustomMetadataFromHeaders (getHeaders ().getRequestHeaders ());
842835
843836 Map <String , String > tags = getTaggingFromHeaders (getHeaders ());
844837
845- ReplicationConfig replicationConfig =
846- getReplicationConfig (ozoneBucket , storageType , storageConfig );
838+ ReplicationConfig replicationConfig = getReplicationConfig (ozoneBucket );
847839
848840 OmMultipartInfo multipartInfo =
849841 ozoneBucket .initiateMultipartUpload (key , replicationConfig , customMetadata , tags );
@@ -873,8 +865,9 @@ public Response initializeMultipartUpload(
873865 }
874866 }
875867
876- private ReplicationConfig getReplicationConfig (OzoneBucket ozoneBucket ,
877- String storageType , String storageConfig ) throws OS3Exception {
868+ private ReplicationConfig getReplicationConfig (OzoneBucket ozoneBucket ) throws OS3Exception {
869+ String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
870+ String storageConfig = getHeaders ().getHeaderString (CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER );
878871
879872 ReplicationConfig clientConfiguredReplicationConfig =
880873 OzoneClientUtils .getClientConfiguredReplicationConfig (getOzoneConfiguration ());
@@ -891,9 +884,9 @@ private ReplicationConfig getReplicationConfig(OzoneBucket ozoneBucket,
891884 public Response completeMultipartUpload (
892885 @ PathParam (BUCKET ) String bucket ,
893886 @ PathParam (PATH ) String key ,
894- @ QueryParam ( QueryParams . UPLOAD_ID ) @ DefaultValue ( "" ) String uploadID ,
895- CompleteMultipartUploadRequest multipartUploadRequest )
896- throws IOException , OS3Exception {
887+ CompleteMultipartUploadRequest multipartUploadRequest
888+ ) throws IOException , OS3Exception {
889+ final String uploadID = queryParams (). get ( QueryParams . UPLOAD_ID , "" );
897890 long startNanos = Time .monotonicNowNanos ();
898891 S3GAction s3GAction = S3GAction .COMPLETE_MULTIPART_UPLOAD ;
899892 OzoneVolume volume = getVolume ();
@@ -962,12 +955,14 @@ public Response completeMultipartUpload(
962955 }
963956 }
964957
965- @ SuppressWarnings ({ "checkstyle:MethodLength" , "checkstyle:ParameterNumber" } )
958+ @ SuppressWarnings ("checkstyle:MethodLength" )
966959 private Response createMultipartKey (OzoneVolume volume , OzoneBucket ozoneBucket ,
967- String key , long length , int partNumber , String uploadID ,
960+ String key , long length ,
968961 final InputStream body , PerformanceStringBuilder perf )
969962 throws IOException , OS3Exception {
970963 long startNanos = Time .monotonicNowNanos ();
964+ final String uploadID = queryParams ().get (QueryParams .UPLOAD_ID );
965+ final int partNumber = queryParams ().getInt (QueryParams .PART_NUMBER , 0 );
971966 String copyHeader = null ;
972967 MultiDigestInputStream multiDigestInputStream = null ;
973968 final String bucketName = ozoneBucket .getName ();
@@ -979,10 +974,7 @@ private Response createMultipartKey(OzoneVolume volume, OzoneBucket ozoneBucket,
979974 length = chunkInputStreamInfo .getEffectiveLength ();
980975
981976 copyHeader = getHeaders ().getHeaderString (COPY_SOURCE_HEADER );
982- String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
983- String storageConfig = getHeaders ().getHeaderString (CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER );
984- ReplicationConfig replicationConfig =
985- getReplicationConfig (ozoneBucket , storageType , storageConfig );
977+ ReplicationConfig replicationConfig = getReplicationConfig (ozoneBucket );
986978
987979 boolean enableEC = false ;
988980 if ((replicationConfig != null &&
@@ -1227,12 +1219,14 @@ void copy(OzoneVolume volume, DigestInputStream src, long srcKeyLen,
12271219 perf .appendSizeBytes (copyLength );
12281220 }
12291221
1230- @ SuppressWarnings ("checkstyle:ParameterNumber" )
12311222 private CopyObjectResponse copyObject (OzoneVolume volume ,
1232- String copyHeader , String destBucket , String destkey ,
1233- ReplicationConfig replicationConfig , boolean storageTypeDefault ,
1223+ String destBucket , String destkey , ReplicationConfig replicationConfig ,
12341224 PerformanceStringBuilder perf )
12351225 throws OS3Exception , IOException {
1226+ String copyHeader = getHeaders ().getHeaderString (COPY_SOURCE_HEADER );
1227+ String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
1228+ boolean storageTypeDefault = StringUtils .isEmpty (storageType );
1229+
12361230 long startNanos = Time .monotonicNowNanos ();
12371231 Pair <String , String > result = parseSourceHeader (copyHeader );
12381232
0 commit comments