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,23 @@ 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 String taggingMarker = queryParams (). get ( QueryParams .TAGGING );
233+ final String uploadID = queryParams (). get ( QueryParams . UPLOAD_ID );
236234 long startNanos = Time .monotonicNowNanos ();
237235 S3GAction s3GAction = S3GAction .CREATE_KEY ;
238236 boolean auditSuccess = true ;
239237 PerformanceStringBuilder perf = new PerformanceStringBuilder ();
240238
241- String copyHeader = null , storageType = null , storageConfig = null ;
239+ String copyHeader = null ;
242240 MultiDigestInputStream multiDigestInputStream = null ;
243241 try {
244242 if (aclMarker != null ) {
@@ -261,17 +259,13 @@ public Response put(
261259 }
262260 // If uploadID is specified, it is a request for upload part
263261 return createMultipartKey (volume , bucket , keyPath , length ,
264- partNumber , uploadID , body , perf );
262+ body , perf );
265263 }
266264
267265 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 );
271266
272267 // Normal put object
273- ReplicationConfig replicationConfig =
274- getReplicationConfig (bucket , storageType , storageConfig );
268+ ReplicationConfig replicationConfig = getReplicationConfig (bucket );
275269
276270 boolean enableEC = false ;
277271 if ((replicationConfig != null &&
@@ -284,8 +278,7 @@ public Response put(
284278 //Copy object, as copy source available.
285279 s3GAction = S3GAction .COPY_OBJECT ;
286280 CopyObjectResponse copyObjectResponse = copyObject (volume ,
287- copyHeader , bucketName , keyPath , replicationConfig ,
288- storageTypeDefault , perf );
281+ bucketName , keyPath , replicationConfig , perf );
289282 return Response .status (Status .OK ).entity (copyObjectResponse ).header (
290283 "Connection" , "close" ).build ();
291284 }
@@ -431,17 +424,18 @@ public Response put(
431424 * https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadListParts.html
432425 * for more details.
433426 */
434- @ SuppressWarnings ({ "checkstyle:MethodLength" , "checkstyle:ParameterNumber" } )
427+ @ SuppressWarnings ("checkstyle:MethodLength" )
435428 @ GET
436429 public Response get (
437430 @ 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 {
431+ @ PathParam (PATH ) String keyPath
432+ ) throws IOException , OS3Exception {
433+ final int maxParts = queryParams ().getInt (QueryParams .MAX_PARTS , 1000 );
434+ final int partNumber = queryParams ().getInt (QueryParams .PART_NUMBER , 0 );
435+ final String partNumberMarker = queryParams ().get (QueryParams .PART_NUMBER_MARKER );
436+ final String taggingMarker = queryParams ().get (QueryParams .TAGGING );
437+ final String uploadId = queryParams ().get (QueryParams .UPLOAD_ID );
438+
445439 long startNanos = Time .monotonicNowNanos ();
446440 S3GAction s3GAction = S3GAction .GET_KEY ;
447441 PerformanceStringBuilder perf = new PerformanceStringBuilder ();
@@ -748,10 +742,11 @@ private Response abortMultipartUpload(OzoneVolume volume, String bucket,
748742 @ SuppressWarnings ("emptyblock" )
749743 public Response delete (
750744 @ 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 {
745+ @ PathParam (PATH ) String keyPath
746+ ) throws IOException , OS3Exception {
747+ final String taggingMarker = queryParams ().get (QueryParams .TAGGING );
748+ final String uploadId = queryParams ().get (QueryParams .UPLOAD_ID );
749+
755750 long startNanos = Time .monotonicNowNanos ();
756751 S3GAction s3GAction = S3GAction .DELETE_KEY ;
757752
@@ -826,24 +821,20 @@ public Response delete(
826821 public Response initializeMultipartUpload (
827822 @ PathParam (BUCKET ) String bucket ,
828823 @ PathParam (PATH ) String key
829- )
830- throws IOException , OS3Exception {
824+ ) throws IOException , OS3Exception {
831825 long startNanos = Time .monotonicNowNanos ();
832826 S3GAction s3GAction = S3GAction .INIT_MULTIPART_UPLOAD ;
833827
834828 try {
835829 OzoneBucket ozoneBucket = getBucket (bucket );
836830 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 );
839831
840832 Map <String , String > customMetadata =
841833 getCustomMetadataFromHeaders (getHeaders ().getRequestHeaders ());
842834
843835 Map <String , String > tags = getTaggingFromHeaders (getHeaders ());
844836
845- ReplicationConfig replicationConfig =
846- getReplicationConfig (ozoneBucket , storageType , storageConfig );
837+ ReplicationConfig replicationConfig = getReplicationConfig (ozoneBucket );
847838
848839 OmMultipartInfo multipartInfo =
849840 ozoneBucket .initiateMultipartUpload (key , replicationConfig , customMetadata , tags );
@@ -873,8 +864,9 @@ public Response initializeMultipartUpload(
873864 }
874865 }
875866
876- private ReplicationConfig getReplicationConfig (OzoneBucket ozoneBucket ,
877- String storageType , String storageConfig ) throws OS3Exception {
867+ private ReplicationConfig getReplicationConfig (OzoneBucket ozoneBucket ) throws OS3Exception {
868+ String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
869+ String storageConfig = getHeaders ().getHeaderString (CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER );
878870
879871 ReplicationConfig clientConfiguredReplicationConfig =
880872 OzoneClientUtils .getClientConfiguredReplicationConfig (getOzoneConfiguration ());
@@ -891,9 +883,9 @@ private ReplicationConfig getReplicationConfig(OzoneBucket ozoneBucket,
891883 public Response completeMultipartUpload (
892884 @ PathParam (BUCKET ) String bucket ,
893885 @ PathParam (PATH ) String key ,
894- @ QueryParam ( QueryParams . UPLOAD_ID ) @ DefaultValue ( "" ) String uploadID ,
895- CompleteMultipartUploadRequest multipartUploadRequest )
896- throws IOException , OS3Exception {
886+ CompleteMultipartUploadRequest multipartUploadRequest
887+ ) throws IOException , OS3Exception {
888+ final String uploadID = queryParams (). get ( QueryParams . UPLOAD_ID , "" );
897889 long startNanos = Time .monotonicNowNanos ();
898890 S3GAction s3GAction = S3GAction .COMPLETE_MULTIPART_UPLOAD ;
899891 OzoneVolume volume = getVolume ();
@@ -962,12 +954,14 @@ public Response completeMultipartUpload(
962954 }
963955 }
964956
965- @ SuppressWarnings ({ "checkstyle:MethodLength" , "checkstyle:ParameterNumber" } )
957+ @ SuppressWarnings ("checkstyle:MethodLength" )
966958 private Response createMultipartKey (OzoneVolume volume , OzoneBucket ozoneBucket ,
967- String key , long length , int partNumber , String uploadID ,
959+ String key , long length ,
968960 final InputStream body , PerformanceStringBuilder perf )
969961 throws IOException , OS3Exception {
970962 long startNanos = Time .monotonicNowNanos ();
963+ final String uploadID = queryParams ().get (QueryParams .UPLOAD_ID );
964+ final int partNumber = queryParams ().getInt (QueryParams .PART_NUMBER , 0 );
971965 String copyHeader = null ;
972966 MultiDigestInputStream multiDigestInputStream = null ;
973967 final String bucketName = ozoneBucket .getName ();
@@ -979,10 +973,7 @@ private Response createMultipartKey(OzoneVolume volume, OzoneBucket ozoneBucket,
979973 length = chunkInputStreamInfo .getEffectiveLength ();
980974
981975 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 );
976+ ReplicationConfig replicationConfig = getReplicationConfig (ozoneBucket );
986977
987978 boolean enableEC = false ;
988979 if ((replicationConfig != null &&
@@ -1227,12 +1218,14 @@ void copy(OzoneVolume volume, DigestInputStream src, long srcKeyLen,
12271218 perf .appendSizeBytes (copyLength );
12281219 }
12291220
1230- @ SuppressWarnings ("checkstyle:ParameterNumber" )
12311221 private CopyObjectResponse copyObject (OzoneVolume volume ,
1232- String copyHeader , String destBucket , String destkey ,
1233- ReplicationConfig replicationConfig , boolean storageTypeDefault ,
1222+ String destBucket , String destkey , ReplicationConfig replicationConfig ,
12341223 PerformanceStringBuilder perf )
12351224 throws OS3Exception , IOException {
1225+ String copyHeader = getHeaders ().getHeaderString (COPY_SOURCE_HEADER );
1226+ String storageType = getHeaders ().getHeaderString (STORAGE_CLASS_HEADER );
1227+ boolean storageTypeDefault = StringUtils .isEmpty (storageType );
1228+
12361229 long startNanos = Time .monotonicNowNanos ();
12371230 Pair <String , String > result = parseSourceHeader (copyHeader );
12381231
0 commit comments