Skip to content

Commit 29dd214

Browse files
committed
improvements
1 parent 0e26d1a commit 29dd214

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/UpdateAttachmentsHandler.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,7 @@ private void deleteRemovedAttachments(
112112
ApplicationHandlerHelper.condenseAttachments(requestData, entity);
113113

114114
for (Attachments dbAttachment : dbAttachments) {
115-
Map<String, Object> dbKeys = new HashMap<>();
116-
entity
117-
.keyElements()
118-
.forEach(
119-
keyElement -> {
120-
String keyName = keyElement.getName();
121-
Object value = dbAttachment.get(keyName);
122-
if (value != null) {
123-
dbKeys.put(keyName, value);
124-
}
125-
});
115+
Map<String, Object> dbKeys = ApplicationHandlerHelper.extractKeys(dbAttachment, entity);
126116
Map<String, Object> keys = ApplicationHandlerHelper.removeDraftKey(dbKeys);
127117

128118
boolean existsInRequest =

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.sap.cds.feature.attachments.handler.common.ApplicationHandlerHelper;
1414
import com.sap.cds.ql.cqn.Path;
1515
import com.sap.cds.reflect.CdsEntity;
16+
import com.sap.cds.services.ErrorStatus;
1617
import com.sap.cds.services.ErrorStatuses;
1718
import com.sap.cds.services.EventContext;
1819
import com.sap.cds.services.ServiceException;
@@ -84,12 +85,8 @@ public static InputStream handleAttachmentForEntity(
8485
}
8586
} catch (ArithmeticException e) {
8687
throw new ServiceException("Maximum file size value is too large", e);
87-
} catch (RuntimeException e) {
88-
throw new ServiceException(
89-
ExtendedErrorStatuses.CONTENT_TOO_LARGE, "AttachmentSizeExceeded", maxSizeStr);
90-
} catch (Exception e) {
91-
throw new ServiceException(
92-
ErrorStatuses.BAD_REQUEST, "Failed to process attachment size", e);
88+
} catch (IllegalArgumentException e) {
89+
throw new ServiceException(ErrorStatuses.BAD_REQUEST, "Failed to process attachment size");
9390
}
9491
}
9592

0 commit comments

Comments
 (0)