Skip to content

Commit 9310aae

Browse files
Sonar
1 parent b0af7ab commit 9310aae

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.sap.cds.sdm.service.SDMService;
2121
import com.sap.cds.sdm.utilities.SDMUtils;
2222
import com.sap.cds.services.ServiceException;
23+
import com.sap.cds.services.draft.DraftService;
2324
import com.sap.cds.services.handler.EventHandler;
2425
import com.sap.cds.services.handler.annotations.On;
2526
import com.sap.cds.services.handler.annotations.ServiceName;
@@ -35,7 +36,7 @@
3536

3637
@ServiceName(
3738
value = "*",
38-
type = {AttachmentService.class})
39+
type = {AttachmentService.class, DraftService.class})
3940
public class SDMAttachmentsServiceHandler implements EventHandler {
4041
private final PersistenceService persistenceService;
4142
private final SDMService sdmService;
@@ -174,22 +175,21 @@ private void validateRepository(AttachmentCreateEventContext eventContext)
174175
}
175176
String len = eventContext.getParameterInfo().getHeaders().get("content-length");
176177
long contentLen = !StringUtils.isEmpty(len) ? Long.parseLong(len) : -1;
177-
if (!repoValue.getIsAsyncVirusScanEnabled()) {
178-
// Check if repository is virus scanned
179-
if (repoValue.getVirusScanEnabled()
180-
&& contentLen > 400 * 1024 * 1024
181-
&& !repoValue.getDisableVirusScannerForLargeFile()) {
182-
String errorMessage =
183-
eventContext
184-
.getCdsRuntime()
185-
.getLocalizedMessage(
186-
SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB_MESSAGE,
187-
null,
188-
eventContext.getParameterInfo().getLocale());
189-
if (errorMessage.equalsIgnoreCase(SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB_MESSAGE))
190-
throw new ServiceException(SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB);
191-
throw new ServiceException(errorMessage);
192-
}
178+
// Check if repository is virus scanned
179+
if (!repoValue.getIsAsyncVirusScanEnabled()
180+
&& repoValue.getVirusScanEnabled()
181+
&& contentLen > 400 * 1024 * 1024
182+
&& !repoValue.getDisableVirusScannerForLargeFile()) {
183+
String errorMessage =
184+
eventContext
185+
.getCdsRuntime()
186+
.getLocalizedMessage(
187+
SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB_MESSAGE,
188+
null,
189+
eventContext.getParameterInfo().getLocale());
190+
if (errorMessage.equalsIgnoreCase(SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB_MESSAGE))
191+
throw new ServiceException(SDMConstants.VIRUS_REPO_ERROR_MORE_THAN_400MB);
192+
throw new ServiceException(errorMessage);
193193
}
194194
}
195195

0 commit comments

Comments
 (0)