|
32 | 32 | import io.minio.errors.XmlParserException;
|
33 | 33 | import io.minio.http.HttpUtils;
|
34 | 34 | import io.minio.http.Method;
|
| 35 | +import io.minio.messages.AccessControlPolicy; |
35 | 36 | import io.minio.messages.Bucket;
|
36 | 37 | import io.minio.messages.CopyObjectResult;
|
37 | 38 | import io.minio.messages.CreateBucketConfiguration;
|
38 | 39 | import io.minio.messages.DeleteError;
|
39 | 40 | import io.minio.messages.DeleteObject;
|
| 41 | +import io.minio.messages.GetObjectAttributesOutput; |
40 | 42 | import io.minio.messages.Item;
|
41 | 43 | import io.minio.messages.LegalHold;
|
42 | 44 | import io.minio.messages.LifecycleConfiguration;
|
|
66 | 68 | import java.nio.file.StandardOpenOption;
|
67 | 69 | import java.security.InvalidKeyException;
|
68 | 70 | import java.security.NoSuchAlgorithmException;
|
| 71 | +import java.time.ZonedDateTime; |
69 | 72 | import java.util.Arrays;
|
70 | 73 | import java.util.Date;
|
71 | 74 | import java.util.Iterator;
|
@@ -3151,6 +3154,111 @@ public CompletableFuture<Void> deleteObjectTags(DeleteObjectTagsArgs args)
|
3151 | 3154 | return executeDeleteAsync(args, null, queryParams).thenAccept(response -> response.close());
|
3152 | 3155 | }
|
3153 | 3156 |
|
| 3157 | + /** |
| 3158 | + * Gets access control policy of an object. |
| 3159 | + * |
| 3160 | + * <pre>Example:{@code |
| 3161 | + * CompletableFuture<AccessControlPolicy> future = |
| 3162 | + * minioAsyncClient.getObjectAcl( |
| 3163 | + * GetObjectAclArgs.builder().bucket("my-bucketname").object("my-objectname").build()); |
| 3164 | + * }</pre> |
| 3165 | + * |
| 3166 | + * @param args {@link GetObjectAclArgs} object. |
| 3167 | + * @return {@link CompletableFuture}<{@link AccessControlPolicy}> object. |
| 3168 | + * @throws InsufficientDataException thrown to indicate not enough data available in InputStream. |
| 3169 | + * @throws InternalException thrown to indicate internal library error. |
| 3170 | + * @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library. |
| 3171 | + * @throws IOException thrown to indicate I/O error on S3 operation. |
| 3172 | + * @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library. |
| 3173 | + * @throws XmlParserException thrown to indicate XML parsing error. |
| 3174 | + */ |
| 3175 | + public CompletableFuture<AccessControlPolicy> getObjectAcl(GetObjectAclArgs args) |
| 3176 | + throws InsufficientDataException, InternalException, InvalidKeyException, IOException, |
| 3177 | + NoSuchAlgorithmException, XmlParserException { |
| 3178 | + checkArgs(args); |
| 3179 | + Multimap<String, String> queryParams = newMultimap("acl", ""); |
| 3180 | + if (args.versionId() != null) queryParams.put("versionId", args.versionId()); |
| 3181 | + return executeGetAsync(args, null, queryParams) |
| 3182 | + .thenApply( |
| 3183 | + response -> { |
| 3184 | + try { |
| 3185 | + return Xml.unmarshal(AccessControlPolicy.class, response.body().charStream()); |
| 3186 | + } catch (XmlParserException e) { |
| 3187 | + throw new CompletionException(e); |
| 3188 | + } finally { |
| 3189 | + response.close(); |
| 3190 | + } |
| 3191 | + }); |
| 3192 | + } |
| 3193 | + |
| 3194 | + /** |
| 3195 | + * Gets attributes of an object. |
| 3196 | + * |
| 3197 | + * <pre>Example:{@code |
| 3198 | + * CompletableFuture<GetObjectAttributesResponse> future = |
| 3199 | + * minioAsyncClient.getObjectAttributes( |
| 3200 | + * GetObjectAttributesArgs.builder() |
| 3201 | + * .bucket("my-bucketname") |
| 3202 | + * .object("my-objectname") |
| 3203 | + * .objectAttributes( |
| 3204 | + * new String[] { |
| 3205 | + * "ETag", "Checksum", "ObjectParts", "StorageClass", "ObjectSize" |
| 3206 | + * }) |
| 3207 | + * .build()); |
| 3208 | + * }</pre> |
| 3209 | + * |
| 3210 | + * @param args {@link GetObjectAttributesArgs} object. |
| 3211 | + * @return {@link CompletableFuture}<{@link GetObjectAttributesResponse}> object. |
| 3212 | + * @throws InsufficientDataException thrown to indicate not enough data available in InputStream. |
| 3213 | + * @throws InternalException thrown to indicate internal library error. |
| 3214 | + * @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library. |
| 3215 | + * @throws IOException thrown to indicate I/O error on S3 operation. |
| 3216 | + * @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library. |
| 3217 | + * @throws XmlParserException thrown to indicate XML parsing error. |
| 3218 | + */ |
| 3219 | + public CompletableFuture<GetObjectAttributesResponse> getObjectAttributes( |
| 3220 | + GetObjectAttributesArgs args) |
| 3221 | + throws InsufficientDataException, InternalException, InvalidKeyException, IOException, |
| 3222 | + NoSuchAlgorithmException, XmlParserException { |
| 3223 | + checkArgs(args); |
| 3224 | + |
| 3225 | + Multimap<String, String> queryParams = newMultimap("attributes", ""); |
| 3226 | + if (args.versionId() != null) queryParams.put("versionId", args.versionId()); |
| 3227 | + |
| 3228 | + Multimap<String, String> headers = HashMultimap.create(); |
| 3229 | + if (args.maxParts() != null) headers.put("x-amz-max-parts", args.maxParts().toString()); |
| 3230 | + if (args.partNumberMarker() != null) { |
| 3231 | + headers.put("x-amz-part-number-marker", args.partNumberMarker().toString()); |
| 3232 | + } |
| 3233 | + for (String attribute : args.objectAttributes()) { |
| 3234 | + if (attribute != null) headers.put("x-amz-object-attributes", attribute); |
| 3235 | + } |
| 3236 | + |
| 3237 | + return executeGetAsync(args, headers, queryParams) |
| 3238 | + .thenApply( |
| 3239 | + response -> { |
| 3240 | + try { |
| 3241 | + GetObjectAttributesOutput result = |
| 3242 | + Xml.unmarshal(GetObjectAttributesOutput.class, response.body().charStream()); |
| 3243 | + |
| 3244 | + String value = response.headers().get("x-amz-delete-marker"); |
| 3245 | + if (value != null) result.setDeleteMarker(Boolean.valueOf(value)); |
| 3246 | + value = response.headers().get("Last-Modified"); |
| 3247 | + if (value != null) { |
| 3248 | + result.setLastModified(ZonedDateTime.parse(value, Time.HTTP_HEADER_DATE_FORMAT)); |
| 3249 | + } |
| 3250 | + result.setVersionId(response.headers().get("x-amz-version-id")); |
| 3251 | + |
| 3252 | + return new GetObjectAttributesResponse( |
| 3253 | + response.headers(), args.bucket(), args.region(), args.object(), result); |
| 3254 | + } catch (XmlParserException e) { |
| 3255 | + throw new CompletionException(e); |
| 3256 | + } finally { |
| 3257 | + response.close(); |
| 3258 | + } |
| 3259 | + }); |
| 3260 | + } |
| 3261 | + |
3154 | 3262 | /**
|
3155 | 3263 | * Uploads multiple objects in a single put call. It is done by creating intermediate TAR file
|
3156 | 3264 | * optionally compressed which is uploaded to S3 service.
|
|
0 commit comments