|
31 | 31 | import com.azure.storage.file.share.implementation.util.ShareSasImplUtil; |
32 | 32 | import com.azure.storage.file.share.models.CloseHandlesInfo; |
33 | 33 | import com.azure.storage.file.share.models.FilePermissionFormat; |
| 34 | +import com.azure.storage.file.share.models.FilePosixProperties; |
34 | 35 | import com.azure.storage.file.share.models.HandleItem; |
35 | 36 | import com.azure.storage.file.share.models.NtfsFileAttributes; |
36 | 37 | import com.azure.storage.file.share.models.ShareDirectoryInfo; |
|
39 | 40 | import com.azure.storage.file.share.models.ShareErrorCode; |
40 | 41 | import com.azure.storage.file.share.models.ShareFileHttpHeaders; |
41 | 42 | import com.azure.storage.file.share.models.ShareFileItem; |
| 43 | +import com.azure.storage.file.share.models.ShareFilePermission; |
42 | 44 | import com.azure.storage.file.share.models.ShareRequestConditions; |
43 | 45 | import com.azure.storage.file.share.models.ShareStorageException; |
44 | 46 | import com.azure.storage.file.share.options.ShareDirectoryCreateOptions; |
@@ -310,7 +312,8 @@ public Mono<ShareDirectoryInfo> create() { |
310 | 312 | public Mono<Response<ShareDirectoryInfo>> createWithResponse(FileSmbProperties smbProperties, String filePermission, |
311 | 313 | Map<String, String> metadata) { |
312 | 314 | try { |
313 | | - return withContext(context -> createWithResponse(smbProperties, filePermission, null, metadata, context)); |
| 315 | + return withContext( |
| 316 | + context -> createWithResponse(smbProperties, filePermission, null, null, metadata, context)); |
314 | 317 | } catch (RuntimeException ex) { |
315 | 318 | return monoError(LOGGER, ex); |
316 | 319 | } |
@@ -350,32 +353,28 @@ public Mono<Response<ShareDirectoryInfo>> createWithResponse(FileSmbProperties s |
350 | 353 | public Mono<Response<ShareDirectoryInfo>> createWithResponse(ShareDirectoryCreateOptions options) { |
351 | 354 | try { |
352 | 355 | return withContext(context -> createWithResponse(options.getSmbProperties(), options.getFilePermission(), |
353 | | - options.getFilePermissionFormat(), options.getMetadata(), context)); |
| 356 | + options.getFilePermissionFormat(), options.getPosixProperties(), options.getMetadata(), context)); |
354 | 357 | } catch (RuntimeException ex) { |
355 | 358 | return monoError(LOGGER, ex); |
356 | 359 | } |
357 | 360 | } |
358 | 361 |
|
359 | 362 | Mono<Response<ShareDirectoryInfo>> createWithResponse(FileSmbProperties smbProperties, String filePermission, |
360 | | - FilePermissionFormat filePermissionFormat, Map<String, String> metadata, Context context) { |
361 | | - FileSmbProperties properties = smbProperties == null ? new FileSmbProperties() : smbProperties; |
| 363 | + FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Map<String, String> metadata, |
| 364 | + Context context) { |
| 365 | + context = context == null ? Context.NONE : context; |
| 366 | + smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; |
| 367 | + posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; |
362 | 368 |
|
363 | 369 | // Checks that file permission and file permission key are valid |
364 | | - ModelHelper.validateFilePermissionAndKey(filePermission, properties.getFilePermissionKey()); |
365 | | - |
366 | | - // If file permission and file permission key are both not set then set default value |
367 | | - filePermission = properties.setFilePermission(filePermission, FileConstants.FILE_PERMISSION_INHERIT); |
368 | | - String filePermissionKey = properties.getFilePermissionKey(); |
369 | | - |
370 | | - String fileAttributes = properties.setNtfsFileAttributes(FileConstants.FILE_ATTRIBUTES_NONE); |
371 | | - String fileCreationTime = properties.setFileCreationTime(FileConstants.FILE_TIME_NOW); |
372 | | - String fileLastWriteTime = properties.setFileLastWriteTime(FileConstants.FILE_TIME_NOW); |
373 | | - String fileChangeTime = properties.getFileChangeTimeString(); |
374 | | - context = context == null ? Context.NONE : context; |
| 370 | + ModelHelper.validateFilePermissionAndKey(filePermission, smbProperties.getFilePermissionKey()); |
375 | 371 |
|
376 | 372 | return azureFileStorageClient.getDirectories() |
377 | | - .createWithResponseAsync(shareName, directoryPath, fileAttributes, null, metadata, filePermission, |
378 | | - filePermissionFormat, filePermissionKey, fileCreationTime, fileLastWriteTime, fileChangeTime, context) |
| 373 | + .createWithResponseAsync(shareName, directoryPath, null, metadata, filePermission, filePermissionFormat, |
| 374 | + smbProperties.getFilePermissionKey(), smbProperties.getNtfsFileAttributesString(), |
| 375 | + smbProperties.getFileCreationTimeString(), smbProperties.getFileLastWriteTimeString(), |
| 376 | + smbProperties.getFileChangeTimeString(), posixProperties.getOwner(), posixProperties.getGroup(), |
| 377 | + posixProperties.getFileMode(), context) |
379 | 378 | .map(ModelHelper::mapShareDirectoryInfo); |
380 | 379 | } |
381 | 380 |
|
@@ -455,14 +454,15 @@ Mono<Response<ShareDirectoryInfo>> createIfNotExistsWithResponse(ShareDirectoryC |
455 | 454 | Context context) { |
456 | 455 | try { |
457 | 456 | options = options == null ? new ShareDirectoryCreateOptions() : options; |
458 | | - return createWithResponse(options.getSmbProperties(), options.getFilePermission(), null, |
459 | | - options.getMetadata(), context).onErrorResume( |
460 | | - t -> t instanceof ShareStorageException && ((ShareStorageException) t).getStatusCode() == 409, |
461 | | - t -> { |
462 | | - HttpResponse response = ((ShareStorageException) t).getResponse(); |
463 | | - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), |
464 | | - response.getHeaders(), null)); |
465 | | - }); |
| 457 | + return createWithResponse(options.getSmbProperties(), options.getFilePermission(), |
| 458 | + options.getFilePermissionFormat(), options.getPosixProperties(), options.getMetadata(), context) |
| 459 | + .onErrorResume( |
| 460 | + t -> t instanceof ShareStorageException && ((ShareStorageException) t).getStatusCode() == 409, |
| 461 | + t -> { |
| 462 | + HttpResponse response = ((ShareStorageException) t).getResponse(); |
| 463 | + return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), |
| 464 | + response.getHeaders(), null)); |
| 465 | + }); |
466 | 466 | } catch (RuntimeException ex) { |
467 | 467 | return monoError(LOGGER, ex); |
468 | 468 | } |
@@ -729,7 +729,8 @@ public Mono<ShareDirectoryInfo> setProperties(FileSmbProperties smbProperties, S |
729 | 729 | public Mono<Response<ShareDirectoryInfo>> setPropertiesWithResponse(FileSmbProperties smbProperties, |
730 | 730 | String filePermission) { |
731 | 731 | try { |
732 | | - return withContext(context -> setPropertiesWithResponse(smbProperties, filePermission, null, context)); |
| 732 | + return withContext( |
| 733 | + context -> setPropertiesWithResponse(smbProperties, filePermission, null, null, context)); |
733 | 734 | } catch (RuntimeException ex) { |
734 | 735 | return monoError(LOGGER, ex); |
735 | 736 | } |
@@ -763,35 +764,31 @@ public Mono<Response<ShareDirectoryInfo>> setPropertiesWithResponse(FileSmbPrope |
763 | 764 | @ServiceMethod(returns = ReturnType.SINGLE) |
764 | 765 | public Mono<Response<ShareDirectoryInfo>> setPropertiesWithResponse(ShareDirectorySetPropertiesOptions options) { |
765 | 766 | try { |
766 | | - return withContext(context -> setPropertiesWithResponse(options.getSmbProperties(), |
767 | | - options.getFilePermissions().getPermission(), options.getFilePermissions().getPermissionFormat(), |
768 | | - context)); |
| 767 | + ShareFilePermission filePermission |
| 768 | + = options.getFilePermissions() == null ? new ShareFilePermission() : options.getFilePermissions(); |
| 769 | + return withContext( |
| 770 | + context -> setPropertiesWithResponse(options.getSmbProperties(), filePermission.getPermission(), |
| 771 | + filePermission.getPermissionFormat(), options.getPosixProperties(), context)); |
769 | 772 | } catch (RuntimeException ex) { |
770 | 773 | return monoError(LOGGER, ex); |
771 | 774 | } |
772 | 775 | } |
773 | 776 |
|
774 | 777 | Mono<Response<ShareDirectoryInfo>> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission, |
775 | | - FilePermissionFormat filePermissionFormat, Context context) { |
776 | | - |
777 | | - FileSmbProperties properties = smbProperties == null ? new FileSmbProperties() : smbProperties; |
| 778 | + FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Context context) { |
| 779 | + context = context == null ? Context.NONE : context; |
| 780 | + smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; |
| 781 | + posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; |
778 | 782 |
|
779 | 783 | // Checks that file permission and file permission key are valid |
780 | | - ModelHelper.validateFilePermissionAndKey(filePermission, properties.getFilePermissionKey()); |
| 784 | + ModelHelper.validateFilePermissionAndKey(filePermission, smbProperties.getFilePermissionKey()); |
781 | 785 |
|
782 | | - // If file permission and file permission key are both not set then set default value |
783 | | - filePermission = properties.setFilePermission(filePermission, FileConstants.PRESERVE); |
784 | | - String filePermissionKey = properties.getFilePermissionKey(); |
785 | | - |
786 | | - String fileAttributes = properties.setNtfsFileAttributes(FileConstants.PRESERVE); |
787 | | - String fileCreationTime = properties.setFileCreationTime(FileConstants.PRESERVE); |
788 | | - String fileLastWriteTime = properties.setFileLastWriteTime(FileConstants.PRESERVE); |
789 | | - String fileChangeTime = properties.getFileChangeTimeString(); |
790 | | - |
791 | | - context = context == null ? Context.NONE : context; |
792 | 786 | return azureFileStorageClient.getDirectories() |
793 | | - .setPropertiesWithResponseAsync(shareName, directoryPath, fileAttributes, null, filePermission, |
794 | | - filePermissionFormat, filePermissionKey, fileCreationTime, fileLastWriteTime, fileChangeTime, context) |
| 787 | + .setPropertiesWithResponseAsync(shareName, directoryPath, null, filePermission, filePermissionFormat, |
| 788 | + smbProperties.getFilePermissionKey(), smbProperties.getNtfsFileAttributesString(), |
| 789 | + smbProperties.getFileCreationTimeString(), smbProperties.getFileLastWriteTimeString(), |
| 790 | + smbProperties.getFileChangeTimeString(), posixProperties.getOwner(), posixProperties.getGroup(), |
| 791 | + posixProperties.getFileMode(), context) |
795 | 792 | .map(ModelHelper::mapSetPropertiesResponse); |
796 | 793 | } |
797 | 794 |
|
@@ -1388,7 +1385,7 @@ public Mono<Response<ShareDirectoryAsyncClient>> createSubdirectoryWithResponse( |
1388 | 1385 | Mono<Response<ShareDirectoryAsyncClient>> createSubdirectoryWithResponse(String subdirectoryName, |
1389 | 1386 | FileSmbProperties smbProperties, String filePermission, Map<String, String> metadata, Context context) { |
1390 | 1387 | ShareDirectoryAsyncClient createSubClient = getSubdirectoryClient(subdirectoryName); |
1391 | | - return createSubClient.createWithResponse(smbProperties, filePermission, null, metadata, context) |
| 1388 | + return createSubClient.createWithResponse(smbProperties, filePermission, null, null, metadata, context) |
1392 | 1389 | .map(response -> new SimpleResponse<>(response, createSubClient)); |
1393 | 1390 | } |
1394 | 1391 |
|
@@ -1774,8 +1771,8 @@ Mono<Response<ShareFileAsyncClient>> createFileWithResponse(String fileName, lon |
1774 | 1771 | Map<String, String> metadata, ShareRequestConditions requestConditions, Context context) { |
1775 | 1772 | ShareFileAsyncClient shareFileAsyncClient = getFileClient(fileName); |
1776 | 1773 | return shareFileAsyncClient |
1777 | | - .createWithResponse(maxSize, httpHeaders, smbProperties, filePermission, null, metadata, requestConditions, |
1778 | | - context) |
| 1774 | + .createWithResponse(maxSize, httpHeaders, smbProperties, filePermission, null, null, metadata, |
| 1775 | + requestConditions, context) |
1779 | 1776 | .map(response -> new SimpleResponse<>(response, shareFileAsyncClient)); |
1780 | 1777 | } |
1781 | 1778 |
|
|
0 commit comments