|
20 | 20 | import com.sap.cds.sdm.service.SDMService; |
21 | 21 | import com.sap.cds.sdm.utilities.SDMUtils; |
22 | 22 | import com.sap.cds.services.ServiceException; |
| 23 | +import com.sap.cds.services.draft.DraftService; |
23 | 24 | import com.sap.cds.services.handler.EventHandler; |
24 | 25 | import com.sap.cds.services.handler.annotations.On; |
25 | 26 | import com.sap.cds.services.handler.annotations.ServiceName; |
|
35 | 36 |
|
36 | 37 | @ServiceName( |
37 | 38 | value = "*", |
38 | | - type = {AttachmentService.class}) |
| 39 | + type = {AttachmentService.class, DraftService.class}) |
39 | 40 | public class SDMAttachmentsServiceHandler implements EventHandler { |
40 | 41 | private final PersistenceService persistenceService; |
41 | 42 | private final SDMService sdmService; |
@@ -174,22 +175,21 @@ private void validateRepository(AttachmentCreateEventContext eventContext) |
174 | 175 | } |
175 | 176 | String len = eventContext.getParameterInfo().getHeaders().get("content-length"); |
176 | 177 | 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); |
193 | 193 | } |
194 | 194 | } |
195 | 195 |
|
|
0 commit comments