5959import org .slf4j .LoggerFactory ;
6060import org .springframework .http .HttpRange ;
6161
62- /**
63- * Stores parts and their metadata created in S3Mock.
64- */
6562public class MultipartStore extends StoreBase {
6663 private static final Logger LOG = LoggerFactory .getLogger (MultipartStore .class );
6764 private static final String PART_SUFFIX = ".part" ;
@@ -81,19 +78,6 @@ public MultipartStore(ObjectStore objectStore, ObjectMapper objectMapper) {
8178 this .objectMapper = objectMapper ;
8279 }
8380
84- /**
85- * Prepares everything to store an object uploaded as multipart upload.
86- *
87- * @param bucket Bucket to upload object in
88- * @param key object to upload
89- * @param id ID of the object
90- * @param contentType the content type
91- * @param storeHeaders various headers to store
92- * @param owner owner of the upload
93- * @param initiator initiator of the upload
94- * @param userMetadata custom metadata
95- * @return upload result
96- */
9781 public MultipartUpload createMultipartUpload (
9882 BucketMetadata bucket ,
9983 String key ,
@@ -141,22 +125,16 @@ public MultipartUpload createMultipartUpload(
141125 return upload ;
142126 }
143127
144- /**
145- * Lists all not-yet completed parts of multipart uploads in a bucket.
146- *
147- * @param bucketMetadata the bucket to use as a filter
148- * @param prefix the prefix use as a filter
149- *
150- * @return the list of not-yet completed multipart uploads.
151- */
152128 public List <MultipartUpload > listMultipartUploads (BucketMetadata bucketMetadata , String prefix ) {
153129 var multipartsFolder = getMultipartsFolder (bucketMetadata );
154130 if (!multipartsFolder .toFile ().exists ()) {
155131 return Collections .emptyList ();
156132 }
157133 try (var paths = Files .newDirectoryStream (multipartsFolder )) {
158- return Streams .of (paths )
159- .map (path -> {
134+ return Streams
135+ .of (paths )
136+ .map (
137+ path -> {
160138 var fileName = path .getFileName ().toString ();
161139 return getUploadMetadata (bucketMetadata , fileName ).upload ();
162140 }
@@ -173,12 +151,6 @@ public MultipartUploadInfo getMultipartUploadInfo(BucketMetadata bucketMetadata,
173151 return getUploadMetadata (bucketMetadata , uploadId );
174152 }
175153
176- /**
177- * Get MultipartUpload, if it was not completed.
178- * @param uploadId id of the upload
179- *
180- * @return the multipart upload, if it exists, throws IllegalArgumentException otherwise.
181- */
182154 public MultipartUpload getMultipartUpload (BucketMetadata bucketMetadata , String uploadId ) {
183155 var uploadMetadata = getUploadMetadata (bucketMetadata , uploadId );
184156 if (uploadMetadata != null ) {
@@ -188,13 +160,6 @@ public MultipartUpload getMultipartUpload(BucketMetadata bucketMetadata, String
188160 }
189161 }
190162
191- /**
192- * Aborts the upload.
193- *
194- * @param bucket to which was uploaded
195- * @param id of the object
196- * @param uploadId of the upload
197- */
198163 public void abortMultipartUpload (BucketMetadata bucket , UUID id , String uploadId ) {
199164 var multipartUploadInfo = getMultipartUploadInfo (bucket , uploadId );
200165 if (multipartUploadInfo != null ) {
@@ -209,17 +174,6 @@ public void abortMultipartUpload(BucketMetadata bucket, UUID id, String uploadId
209174 }
210175 }
211176
212- /**
213- * Uploads a part of a multipart upload.
214- *
215- * @param bucket in which to upload
216- * @param id of the object to upload
217- * @param uploadId id of the upload
218- * @param partNumber number of the part to store
219- * @param path file data to be stored
220- *
221- * @return the md5 digest of this part
222- */
223177 public String putPart (BucketMetadata bucket ,
224178 UUID id ,
225179 String uploadId ,
@@ -231,17 +185,6 @@ public String putPart(BucketMetadata bucket,
231185 return hexDigest (encryptionHeaders .get (X_AMZ_SERVER_SIDE_ENCRYPTION_AWS_KMS_KEY_ID ), file );
232186 }
233187
234- /**
235- * Completes a Multipart Upload for the given ID.
236- *
237- * @param bucket in which to upload.
238- * @param key of the object to upload.
239- * @param id id of the object
240- * @param uploadId id of the upload.
241- * @param parts to concatenate.
242- *
243- * @return etag of the uploaded file.
244- */
245188 public CompleteMultipartUploadResult completeMultipartUpload (
246189 BucketMetadata bucket ,
247190 String key ,
@@ -348,13 +291,6 @@ private String checksumFor(List<Path> paths, MultipartUploadInfo uploadInfo) {
348291 return null ;
349292 }
350293
351- /**
352- * Get all multipart upload parts.
353- * @param bucket name of the bucket
354- * @param id object ID
355- * @param uploadId upload identifier
356- * @return List of Parts
357- */
358294 public List <Part > getMultipartUploadParts (BucketMetadata bucket , UUID id , String uploadId ) {
359295 var partsPath = getPartsFolder (bucket , uploadId );
360296 try (var directoryStream = newDirectoryStream (partsPath ,
@@ -377,20 +313,6 @@ public List<Part> getMultipartUploadParts(BucketMetadata bucket, UUID id, String
377313 }
378314 }
379315
380- /**
381- * Copies the range, define by from/to, from the S3 Object, identified by the given key to given
382- * destination into the given bucket.
383- *
384- * @param bucket The source Bucket.
385- * @param id Identifies the S3 Object.
386- * @param copyRange Byte range to copy. Optional.
387- * @param partNumber The part to copy.
388- * @param destinationBucket The Bucket the target object (will) reside in.
389- * @param destinationId The target object ID.
390- * @param uploadId id of the upload.
391- *
392- * @return etag of the uploaded file.
393- */
394316 public String copyPart (BucketMetadata bucket ,
395317 UUID id ,
396318 HttpRange copyRange ,
@@ -407,11 +329,6 @@ public String copyPart(BucketMetadata bucket,
407329 createPartFile (destinationBucket , destinationId , uploadId , partNumber ), versionId );
408330 }
409331
410- /**
411- * Returns an InputStream containing InputStreams from each path element.
412- * @param paths the paths to read
413- * @return an InputStream containing all data.
414- */
415332 private static InputStream toInputStream (List <Path > paths ) {
416333 var result = new ArrayList <InputStream >();
417334 for (var path : paths ) {
0 commit comments