Skip to content

Commit 024319a

Browse files
committed
Cleanup JavaDoc for stores.
The API doc and function signatures describe what the functions do, let's describe what they do differently from what is described in the API instead of stating the obvious.
1 parent 1572b18 commit 024319a

File tree

3 files changed

+4
-252
lines changed

3 files changed

+4
-252
lines changed

server/src/main/java/com/adobe/testing/s3mock/store/BucketStore.java

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public BucketStore(File rootFolder,
6565
this.objectMapper = objectMapper;
6666
}
6767

68-
/**
69-
* Lists all BucketMetadata managed by this store.
70-
*
71-
* @return List of all BucketMetadata.
72-
*/
7368
public List<BucketMetadata> listBuckets() {
7469
return findBucketPaths()
7570
.stream()
@@ -78,13 +73,6 @@ public List<BucketMetadata> listBuckets() {
7873
.toList();
7974
}
8075

81-
/**
82-
* Retrieves BucketMetadata identified by its name.
83-
*
84-
* @param bucketName name of the bucket to be retrieved
85-
*
86-
* @return the BucketMetadata or null if not found
87-
*/
8876
public BucketMetadata getBucketMetadata(String bucketName) {
8977
try {
9078
var metaFilePath = getMetaFilePath(bucketName);
@@ -99,13 +87,6 @@ public BucketMetadata getBucketMetadata(String bucketName) {
9987
}
10088
}
10189

102-
/**
103-
* Adds key to a bucket.
104-
*
105-
* @param key the key to add
106-
* @param bucketName name of the bucket to be retrieved
107-
* @return UUID assigned to key
108-
*/
10990
public synchronized UUID addKeyToBucket(String key, String bucketName) {
11091
synchronized (lockStore.get(bucketName)) {
11192
var bucketMetadata = getBucketMetadata(bucketName);
@@ -115,13 +96,6 @@ public synchronized UUID addKeyToBucket(String key, String bucketName) {
11596
}
11697
}
11798

118-
/**
119-
* Look up keys by prefix in a bucket.
120-
*
121-
* @param prefix the prefix to filter on
122-
* @param bucketName name of the bucket to be retrieved
123-
* @return List of UUIDs of keys matching the prefix
124-
*/
12599
public List<UUID> lookupKeysInBucket(String prefix, String bucketName) {
126100
var bucketMetadata = getBucketMetadata(bucketName);
127101
var normalizedPrefix = prefix == null ? "" : prefix;
@@ -135,13 +109,6 @@ public List<UUID> lookupKeysInBucket(String prefix, String bucketName) {
135109
}
136110
}
137111

138-
/**
139-
* Removes key from a bucket.
140-
*
141-
* @param key the key to remove
142-
* @param bucketName name of the bucket to be retrieved
143-
* @return true if key existed and was removed
144-
*/
145112
public synchronized boolean removeFromBucket(String key, String bucketName) {
146113
synchronized (lockStore.get(bucketName)) {
147114
var bucketMetadata = getBucketMetadata(bucketName);
@@ -151,11 +118,6 @@ public synchronized boolean removeFromBucket(String key, String bucketName) {
151118
}
152119
}
153120

154-
/**
155-
* Searches for folders in the rootFolder.
156-
*
157-
* @return List of found Folders.
158-
*/
159121
private List<Path> findBucketPaths() {
160122
var bucketPaths = new ArrayList<Path>();
161123
try (var stream = Files.newDirectoryStream(rootFolder.toPath(), Files::isDirectory)) {
@@ -169,16 +131,6 @@ private List<Path> findBucketPaths() {
169131
return bucketPaths;
170132
}
171133

172-
/**
173-
* Creates a new bucket.
174-
*
175-
* @param bucketName of the Bucket to be created.
176-
*
177-
* @return the newly created Bucket.
178-
*
179-
* @throws IllegalStateException if the bucket cannot be created or the bucket already exists but
180-
* is not a directory.
181-
*/
182134
public BucketMetadata createBucket(String bucketName,
183135
boolean objectLockEnabled,
184136
ObjectOwnership objectOwnership,
@@ -215,10 +167,6 @@ public BucketMetadata createBucket(String bucketName,
215167
* Checks if the specified bucket exists. Amazon S3 buckets are named in a global namespace; use
216168
* this method to determine if a specified bucket name already exists, and therefore can't be used
217169
* to create a new bucket.
218-
*
219-
* @param bucketName of the bucket to check for existence
220-
*
221-
* @return true if Bucket exists
222170
*/
223171
public boolean doesBucketExist(String bucketName) {
224172
return getBucketMetadata(bucketName) != null;
@@ -253,14 +201,6 @@ public void storeBucketLifecycleConfiguration(BucketMetadata metadata,
253201
}
254202
}
255203

256-
257-
/**
258-
* Checks if the specified bucket exists and if it is empty.
259-
*
260-
* @param bucketName of the bucket to check for existence
261-
*
262-
* @return true if Bucket is empty
263-
*/
264204
public boolean isBucketEmpty(String bucketName) {
265205
var bucketMetadata = getBucketMetadata(bucketName);
266206
if (bucketMetadata != null) {
@@ -270,13 +210,6 @@ public boolean isBucketEmpty(String bucketName) {
270210
}
271211
}
272212

273-
/**
274-
* Deletes a Bucket and all of its contents.
275-
*
276-
* @param bucketName of the bucket to be deleted.
277-
*
278-
* @return true if deletion succeeded.
279-
*/
280213
public boolean deleteBucket(String bucketName) {
281214
try {
282215
synchronized (lockStore.get(bucketName)) {
@@ -296,8 +229,6 @@ public boolean deleteBucket(String bucketName) {
296229

297230
/**
298231
* Used to load metadata for all buckets when S3Mock starts.
299-
* @param bucketNames names of existing buckets.
300-
* @return ID of the loaded buckets.
301232
*/
302233
List<UUID> loadBuckets(List<String> bucketNames) {
303234
var objectIds = new ArrayList<UUID>();

server/src/main/java/com/adobe/testing/s3mock/store/MultipartStore.java

Lines changed: 4 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
import org.slf4j.LoggerFactory;
6060
import org.springframework.http.HttpRange;
6161

62-
/**
63-
* Stores parts and their metadata created in S3Mock.
64-
*/
6562
public 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

Comments
 (0)