Skip to content

Commit 182c2e2

Browse files
committed
Add check 'skipBeforeDraftCancel' to processBeforeDraftCancel method, this method was possibly called on composition/association entities before
1 parent db8229d commit 182c2e2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/draftservice/DraftCancelAttachmentsHandler.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public DraftCancelAttachmentsHandler(
5858
@Before
5959
@HandlerOrder(HandlerOrder.LATE)
6060
void processBeforeDraftCancel(DraftCancelEventContext context) {
61-
if (isWhereEmpty(context)) {
61+
if (!skipBeforeDraftCancel(context)) {
6262
logger.debug(
6363
"Processing before {} event for entity {}", context.getEvent(), context.getTarget());
6464

@@ -98,8 +98,18 @@ private Validator buildDeleteContentValidator(
9898
};
9999
}
100100

101-
private boolean isWhereEmpty(DraftCancelEventContext context) {
102-
return context.getCqn().where().isEmpty();
101+
private boolean skipBeforeDraftCancel(DraftCancelEventContext context) {
102+
if (context.getCqn().where().isEmpty()) {
103+
logger.debug("Skipping draft cancel processing for entity {} because this is a bulk operation (no WHERE clause found in context).", context.getTarget().getQualifiedName());
104+
return true;
105+
}
106+
String entityName = context.getTarget().getName();
107+
if (entityName.contains(".")) {
108+
logger.debug("Skipping draft cancel processing for entity {} because this is a composition/association entity (contains dots indicating nested path).", entityName);
109+
return true;
110+
}
111+
// Do not skip processing for other cases
112+
return false;
103113
}
104114

105115
private List<Attachments> readAttachments(

0 commit comments

Comments
 (0)