Skip to content

Commit

Permalink
Address more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaashish committed Jun 19, 2020
1 parent 99b7354 commit 788562e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 48 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/io/minio/ComposeObjectArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Builder sources(List<ComposeSource> sources) {
}

private void validateSources(List<ComposeSource> sources) {
if (sources == null) {
if (sources == null || sources.isEmpty()) {
throw new IllegalArgumentException("compose sources cannot be empty");
}
}
Expand Down
24 changes: 3 additions & 21 deletions api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2500,31 +2500,13 @@ public ObjectWriteResponse copyObject(CopyObjectArgs args)
null,
0)) {

String bodyContent = new String(response.body().bytes(), StandardCharsets.UTF_8);
bodyContent = bodyContent.trim();
if (!bodyContent.isEmpty()) {
try {
CopyObjectResult result = Xml.unmarshal(CopyObjectResult.class, bodyContent);
return new ObjectWriteResponse(
response.headers(),
args.bucket(),
args.region(),
args.object(),
result.etag(),
response.header("x-amz-version-id"));
} catch (XmlParserException e) {
// As this CopyObjectResult REST call succeeded, just log it.
Logger.getLogger(MinioClient.class.getName())
.warning(
"S3 service returned unknown XML for CopyObjectResult REST API. " + bodyContent);
}
}
CopyObjectResult result = Xml.unmarshal(CopyObjectResult.class, response.body().charStream());
return new ObjectWriteResponse(
response.headers(),
args.bucket(),
getRegion(args.bucket()),
args.region(),
args.object(),
null,
result.etag(),
response.header("x-amz-version-id"));
}
}
Expand Down
10 changes: 5 additions & 5 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,8 @@ minioClient.setDefaultRetention(

## 3. Object operations

<a name="composeObject"></a>
### composeObject(ComposeObjectArgs args)
<a name="composeObject"></a>
### composeObject(ComposeObjectArgs args)
`public ObjectWriteResponse composeObject(ComposeObjectArgs args)` _[[Javadoc]](http://minio.github.io/minio-java/io/minio/MinioClient.html#composeObject-io.minio.ComposeObjectArgs--)_

Creates an object by combining data from different source objects using server-side copy.
Expand All @@ -989,7 +989,7 @@ Creates an object by combining data from different source objects using server-s

| Returns |
|:----------------------------------------------------------------------------|
| _[ObjectWriteResponse]_ - Contains object versionId, etag and headers. |
| _[ObjectWriteResponse]_ - Contains information of created object. |

__Example__
```java
Expand Down Expand Up @@ -1044,7 +1044,7 @@ __Parameters__

| Returns |
|:----------------------------------------------------------------------------|
| _[ObjectWriteResponse]_ - Contains object versionId, etag and headers. |
| _[ObjectWriteResponse]_ - Contains information of created object. |

__Example__

Expand Down Expand Up @@ -1477,7 +1477,7 @@ __Parameters__

| Returns |
|:----------------------------------------------------------------------------|
| _[ObjectWriteResponse]_ - Contains object versionId, etag and headers. |
| _[ObjectWriteResponse]_ - Contains information of created object. |

__Example__
```java
Expand Down
22 changes: 1 addition & 21 deletions functional/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,32 +422,12 @@ private static void handleException(String methodName, String args, long startTi
throw e;
}

// private static void deleteFilesAndObjects(String bucketName, String[] filenames) throws
// Exception {
// for (String filename : filenames) {
// Files.delete(Paths.get(filename));
//
// client.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(filename).build());
// }
// }

private static void deleteFilesAndObjects(String bucketName, String[] filenames)
throws Exception {
removeObjects(bucketName, filenames);
for (String filename : filenames) {
Files.delete(Paths.get(filename));
}
List<DeleteObject> objects =
Arrays.stream(filenames)
.map(
name -> {
return new DeleteObject(name);
})
.collect(Collectors.toList());
for (Result<?> r :
client.removeObjects(
RemoveObjectsArgs.builder().bucket(bucketName).objects(objects).build())) {
ignore(r.get());
}
}

/** Test: makeBucket(MakeBucketArgs args). */
Expand Down

0 comments on commit 788562e

Please sign in to comment.