Skip to content

Commit f2d8760

Browse files
committed
Fix type column value for link type of attachments
1 parent b6305ac commit f2d8760

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMCustomServiceHandler.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,32 +1034,26 @@ private void processSingleAttachmentMove(AttachmentMoveContext moveContext) {
10341034
String mimeType = succinctProperties.optString("cmis:contentStreamMimeType");
10351035
String description = succinctProperties.optString("cmis:description");
10361036
String movedObjectId = succinctProperties.optString("cmis:objectId");
1037+
String objectTypeId = succinctProperties.optString("cmis:objectTypeId");
10371038

1038-
// Extract linkUrl from SDM response if not already set (when sourceFacet not provided)
1039-
// This ensures link attachments are properly handled even without database fetch
1040-
if (cmisDocument.getUrl() == null) {
1041-
String urlFromSDM = succinctProperties.optString("sap:linkUrl", null);
1042-
cmisDocument.setUrl(urlFromSDM);
1043-
}
1039+
// Determine attachment type based on cmis:objectTypeId from SDM response
1040+
// Link attachments: "sap:link" -> "sap-icon://internet-browser"
1041+
// Document attachments: "cmis:document" -> "sap-icon://document"
1042+
String attachmentType =
1043+
"sap:link".equals(objectTypeId) ? "sap-icon://internet-browser" : "sap-icon://document";
1044+
cmisDocument.setType(attachmentType);
10441045

1045-
// Set type based on whether it's a link attachment or document attachment
1046-
// Link attachments: "sap-icon://internet-browser"
1047-
// Document attachments: "sap-icon://document"
1048-
// This should be done after extracting URL to properly determine the type
1049-
if (cmisDocument.getType() == null) {
1050-
String attachmentType =
1051-
(cmisDocument.getUrl() != null && !cmisDocument.getUrl().isEmpty())
1052-
? "sap-icon://internet-browser"
1053-
: "sap-icon://document";
1054-
cmisDocument.setType(attachmentType);
1055-
}
1046+
// For link attachments, extract the URL from database if sourceFacet was provided
1047+
// Note: sap:linkUrl is not in the SDM move response, so we rely on database fetch
1048+
// If sourceFacet not provided, linkUrl will remain null (which is acceptable for move)
10561049

10571050
logger.info(
1058-
"[Thread: {}] Successfully moved attachment {} to target folder. FileName: {}, MimeType: {}, Type: {}, LinkUrl: {}",
1051+
"[Thread: {}] Successfully moved attachment {} to target folder. FileName: {}, MimeType: {}, ObjectTypeId: {}, Type: {}, LinkUrl: {}",
10591052
Thread.currentThread().getName(),
10601053
moveContext.getObjectId(),
10611054
fileName,
10621055
mimeType,
1056+
objectTypeId,
10631057
cmisDocument.getType(),
10641058
cmisDocument.getUrl());
10651059
logger.info(

0 commit comments

Comments
 (0)