Skip to content

Commit 6a0abf7

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

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 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,22 @@ 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(
104+
"Skipping draft cancel processing for entity {} because this is a bulk operation (no WHERE clause found in context).",
105+
context.getTarget().getQualifiedName());
106+
return true;
107+
}
108+
String entityName = context.getTarget().getName();
109+
if (entityName.contains(".")) {
110+
logger.debug(
111+
"Skipping draft cancel processing for entity {} because this is a composition/association entity (contains dots indicating nested path).",
112+
entityName);
113+
return true;
114+
}
115+
// Do not skip processing for other cases
116+
return false;
103117
}
104118

105119
private List<Attachments> readAttachments(

0 commit comments

Comments
 (0)