You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+139Lines changed: 139 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
20
20
- Copy attachments: Provides the capability to copy attachments from one entity to another entity.
21
21
- Link as attachments: Provides the capability to support link or URL as attachments.
22
22
- Edit Link-type attachments: Provides the capability to update URL of link-type attachments.
23
+
- Move attachments: Provides the capability to move attachments from one entity to another entity.
23
24
- Localization of error messages and UI fields: Provides the capability to have the UI fields and error messages translated to the local language of the leading application.
24
25
## Table of Contents
25
26
@@ -33,6 +34,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
33
34
-[Support for Multiple attachment facets](#support-for-multiple-attachment-facets)
34
35
-[Support for Technical user](#support-for-technical-user)
35
36
-[Support for Copy attachments](#support-for-copy-attachments)
37
+
-[Support for Move attachments](#support-for-move-attachments)
36
38
-[Support for Link type attachments](#support-for-link-type-attachments)
37
39
-[Support for Edit of Link type attachments](#support-for-edit-of-link-type-attachments)
38
40
-[Support for Localization](#support-for-localization)
@@ -568,6 +570,143 @@ This plugin provides capability to copy attachments from one entity to another.
568
570
}
569
571
```
570
572
573
+
## Support for move attachments
574
+
575
+
This plugin provides capability to move attachments from one entity to another entity. This capability will move attachments metadata on CAP as well as actual content on the SAP Document Management service repository. The move operation is performed in parallel for optimal performance and includes comprehensive error handling and rollback mechanisms.
576
+
577
+
### Key Features
578
+
579
+
-**Parallel Processing**: Move operations are executed in parallel using a thread pool for improved performance.
580
+
-**Custom Properties Support**: Preserves and validates custom properties during the move.
581
+
-**Automatic Rollback**: If database updates fail after a successful SDM move, the operation is automatically rolled back.
582
+
-**Comprehensive Error Handling**: Returns detailed failure information for each attachment that fails to move.
583
+
-**Folder Management**: Automatically creates target folders if they don't exist.
584
+
585
+
### Usage Methods
586
+
587
+
1.**A helper method to move attachments from one entity to another**
588
+
589
+
The `AttachmentService` instance can be used to call `moveAttachments` method. This method expects an object of `MoveAttachmentInput` which requires the source folder ID, target entity's ID (`up__Id`), the `attachments facet name` and the `list of objectIds` corresponding to attachments that are to be moved.
Note: The `facet` parameter should be the fully qualified name of the target attachment composition (e.g., `AdminService.Books.attachments`).
647
+
648
+
### Optional Parameters
649
+
650
+
When moving attachments, you can provide optional source facet information for proper cleanup:
651
+
652
+
```java
653
+
var moveEventInput =newMoveAttachmentInput(
654
+
sourceFolderId,
655
+
up__ID,
656
+
facet,
657
+
objectIds,
658
+
sourceFacet // Optional: Full facet path, e.g., "AdminService.Authors.attachments"
659
+
);
660
+
```
661
+
662
+
If `sourceFacet` is provided, the source entity metadata will be properly cleaned up after the move. If omitted, attachments are moved but source metadata cleanup is skipped.
663
+
664
+
For OData API calls, you can include the optional `sourceFacet` parameter in the request body:
665
+
```json
666
+
{
667
+
"sourceFolderId": "<source-folder-id>",
668
+
"up__ID": "<target-up-id>",
669
+
"facet": "AdminService.Books.attachments",
670
+
"objectIds": ["abc", "xyz"],
671
+
"sourceFacet": "AdminService.Authors.attachments"
672
+
}
673
+
```
674
+
675
+
### Response Format
676
+
677
+
The move operation returns a list of failed attachments with detailed failure reasons:
678
+
679
+
```json
680
+
[
681
+
{
682
+
"objectId": "abc",
683
+
"failureReason": "Attachment abc already exists in Target entity"
684
+
},
685
+
{
686
+
"objectId": "xyz",
687
+
"failureReason": "Invalid custom properties: customProp1, customProp2. These properties are not supported in the target entity."
688
+
}
689
+
]
690
+
```
691
+
692
+
### Common Failure Scenarios
693
+
694
+
-**MaxCount Exceeded**: Target entity has reached its maximum allowed attachments.
695
+
-**Invalid Custom Properties**: Attachment has custom properties not supported by the target entity.
696
+
-**Permission Denied**: User lacks authorization to move the attachment.
697
+
-**Duplicate File**: File with the same name already exists in the target folder.
698
+
-**Database Update Failed**: Move succeeded in SDM but database update failed (automatic rollback occurs).
699
+
-**Source Not Found**: Source attachment doesn't exist in SDM.
700
+
701
+
### Best Practices
702
+
703
+
1.**Always check the returned list of failed attachments** to inform users about partial failures.
704
+
2.**Validate maxCount constraints** before initiating large move operations.
705
+
3.**Ensure custom properties compatibility** between source and target entities.
706
+
5.**Handle rollback scenarios gracefully** - rolled back attachments remain in the source folder.
707
+
708
+
> **CRITICAL**: To preserve custom properties attached with attachments on UI, ensure these properties are defined in the target entity. If custom properties are not present in the target entity definition, they will be lost after the move and will not be visible on the UI.
709
+
571
710
## Support for link type attachments
572
711
573
712
> **Note:** Row-press is the new recommended approach for handling actions on attachment rows. With row-press enabled, the Attachments column will no longer appear as a separate action button. Instead, clicking on a row will automatically perform the appropriate action — opening a link or downloading a file, based on the attachment type.
0 commit comments