Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ The following table gives an overview of the fields and the i18n codes:
| ---------- | --------------------- |
| `content` | `attachment_content` |
| `mimeType` | `attachment_mimeType` |
| `fileName` | `attachment_fileName` |
| `filename` | `attachment_fileName` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: i18n code in README table is stale after the rename

The table claims the i18n code for filename is attachment_fileName, but all i18n property files were updated to use attachment_filename. This mismatch will mislead consumers who look up the key to override the translation.

Suggested change
| `filename` | `attachment_fileName` |
| `filename` | `attachment_filename` |

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

| `status` | `attachment_status` |
| `note` | `attachment_note` |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import com.sap.cds.CdsDataProcessor;
import com.sap.cds.CdsDataProcessor.Converter;
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.Attachments;
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.StatusCode;
import com.sap.cds.feature.attachments.handler.applicationservice.readhelper.AttachmentStatusValidator;
import com.sap.cds.feature.attachments.handler.applicationservice.readhelper.BeforeReadItemsModifier;
import com.sap.cds.feature.attachments.handler.applicationservice.readhelper.LazyProxyInputStream;
import com.sap.cds.feature.attachments.handler.common.ApplicationHandlerHelper;
import com.sap.cds.feature.attachments.service.AttachmentService;
import com.sap.cds.feature.attachments.service.malware.AsyncMalwareScanExecutor;
import com.sap.cds.feature.attachments.service.model.StatusCode;
import com.sap.cds.ql.CQL;
import com.sap.cds.ql.cqn.CqnSelect;
import com.sap.cds.ql.cqn.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void preserveReadonlyFields(CdsEntity target, List<CdsData> data,
Attachments attachment = Attachments.create();
attachment.setContentId(values.getContentId());
attachment.setStatus(values.getStatus());
attachment.setScannedAt(values.getScannedAt());
attachment.setLastScan(values.getLastScan());
path.target().values().put(DRAFT_READONLY_CONTEXT, attachment);
} else {
path.target().values().remove(DRAFT_READONLY_CONTEXT);
Expand All @@ -62,7 +62,7 @@ public static void restoreReadonlyFields(CdsData data) {
if (Objects.nonNull(readOnlyData)) {
data.put(Attachments.CONTENT_ID, readOnlyData.get(Attachments.CONTENT_ID));
data.put(Attachments.STATUS, readOnlyData.get(Attachments.STATUS));
data.put(Attachments.SCANNED_AT, readOnlyData.get(Attachments.SCANNED_AT));
data.put(Attachments.LAST_SCAN, readOnlyData.get(Attachments.LAST_SCAN));
data.remove(DRAFT_READONLY_CONTEXT);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public InputStream processEvent(
Map<String, Object> values = path.target().values();
Map<String, Object> keys = ApplicationHandlerHelper.removeDraftKey(path.target().keys());
Optional<String> mimeTypeOptional = getFieldValue(MediaData.MIME_TYPE, values, attachment);
Optional<String> fileNameOptional = getFieldValue(MediaData.FILE_NAME, values, attachment);
Optional<String> fileNameOptional = getFieldValue(MediaData.FILENAME, values, attachment);

CreateAttachmentInput createEventInput =
new CreateAttachmentInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public InputStream processEvent(
|| !path.target().values().containsKey(Attachments.CONTENT_ID)) {
path.target().values().put(Attachments.CONTENT_ID, null);
path.target().values().put(Attachments.STATUS, null);
path.target().values().put(Attachments.SCANNED_AT, null);
path.target().values().put(Attachments.LAST_SCAN, null);
}
}
return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
package com.sap.cds.feature.attachments.handler.applicationservice.readhelper;

import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.StatusCode;
import com.sap.cds.feature.attachments.service.model.StatusCode;

/**
* The class {@link AttachmentStatusValidator} is responsible for validating the status of an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface AttachmentService extends Service {
* <ul>
* <li>attachmentIds - list of keys for attachment entity
* <li>attachmentEntity - cds entity in which the attachment will be stored
* <li>fileName
* <li>filename
* <li>mimeType
* <li>content (mandatory)
* </ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AttachmentModificationResult createAttachment(CreateAttachmentInput input
createContext.setAttachmentIds(input.attachmentIds());
createContext.setAttachmentEntity(input.attachmentEntity());
var mediaData = MediaData.create();
mediaData.setFileName(input.fileName());
mediaData.setFilename(input.filename());
mediaData.setMimeType(input.mimeType());
mediaData.setContent(input.content());
createContext.setData(mediaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.sap.cds.feature.attachments.service.handler;

import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.Attachments;
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.StatusCode;
import com.sap.cds.feature.attachments.service.AttachmentService;
import com.sap.cds.feature.attachments.service.handler.transaction.EndTransactionMalwareScanProvider;
import com.sap.cds.feature.attachments.service.model.StatusCode;
import com.sap.cds.feature.attachments.service.model.servicehandler.AttachmentCreateEventContext;
import com.sap.cds.feature.attachments.service.model.servicehandler.AttachmentMarkAsDeletedEventContext;
import com.sap.cds.feature.attachments.service.model.servicehandler.AttachmentReadEventContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import com.google.common.annotations.VisibleForTesting;
import com.sap.cds.Result;
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.Attachments;
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.StatusCode;
import com.sap.cds.feature.attachments.service.AttachmentService;
import com.sap.cds.feature.attachments.service.malware.client.MalwareScanClient;
import com.sap.cds.feature.attachments.service.malware.client.MalwareScanResultStatus;
import com.sap.cds.feature.attachments.service.model.StatusCode;
import com.sap.cds.ql.Select;
import com.sap.cds.ql.Update;
import com.sap.cds.ql.cqn.CqnSelect;
Expand Down Expand Up @@ -160,7 +160,7 @@ private void updateData(
CdsEntity attachmentEntity, String contentId, MalwareScanResultStatus status) {
Attachments updateData = Attachments.create();
updateData.setStatus(mapStatus(status));
updateData.setScannedAt(Instant.now());
updateData.setLastScan(Instant.now());

CqnUpdate update =
Update.entity(attachmentEntity)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* © 2024-2025 SAP SE or an SAP affiliate company and cds-feature-attachments contributors.
*/
package com.sap.cds.feature.attachments.service.model;

/**
* Status codes for the malware scan status of attachments. These constants correspond to the {@code
* sap.attachments.ScanStates} code list values defined in the CDS model.
*/
public final class StatusCode {
public static final String UNSCANNED = "Unscanned";
public static final String SCANNING = "Scanning";
public static final String CLEAN = "Clean";
public static final String INFECTED = "Infected";
public static final String FAILED = "Failed";

private StatusCode() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*
* @param attachmentIds The keys for the attachment entity
* @param attachmentEntity The {@link CdsEntity entity} in which the attachment will be stored
* @param fileName The file name of the content
* @param filename The file name of the content
* @param mimeType The mime type of the content
* @param content The input stream of the content
*/
public record CreateAttachmentInput(
Map<String, Object> attachmentIds,
CdsEntity attachmentEntity,
String fileName,
String filename,
String mimeType,
InputStream content) {}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static AttachmentReadEventContext create() {
* <ul>
* <li>content
* <li>mimeType
* <li>fileName
* <li>filename
* </ul>
*/
MediaData getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Attachment
#XTIT: File name of the attachment
attachment_fileName=Filename
attachment_filename=Filename
#XTIT: Malware scan status of the attachment
attachment_status=Scan Status
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u0627\u0644\u0645\u0631\u0641\u0642
#XTIT: File name of the attachment
attachment_fileName=\u0627\u0633\u0645 \u0627\u0644\u0645\u0644\u0641
attachment_filename=\u0627\u0633\u0645 \u0627\u0644\u0645\u0644\u0641
#XTIT: Malware scan status of the attachment
attachment_status=\u062D\u0627\u0644\u0629 \u0627\u0644\u0641\u062D\u0635
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435
#XTIT: File name of the attachment
attachment_fileName=\u0418\u043C\u0435 \u043D\u0430 \u0444\u0430\u0439\u043B
attachment_filename=\u0418\u043C\u0435 \u043D\u0430 \u0444\u0430\u0439\u043B
#XTIT: Malware scan status of the attachment
attachment_status=\u0421\u0442\u0430\u0442\u0443\u0441 \u043D\u0430 \u0441\u043A\u0430\u043D\u0438\u0440\u0430\u043D\u0435
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=P\u0159\u00EDloha
#XTIT: File name of the attachment
attachment_fileName=N\u00E1zev souboru
attachment_filename=N\u00E1zev souboru
#XTIT: Malware scan status of the attachment
attachment_status=Status skenov\u00E1n\u00ED
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Vedh\u00E6ftet fil
#XTIT: File name of the attachment
attachment_fileName=Filnavn
attachment_filename=Filnavn
#XTIT: Malware scan status of the attachment
attachment_status=Scanningsstatus
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Anhang
#XTIT: File name of the attachment
attachment_fileName=Dateiname
attachment_filename=Dateiname
#XTIT: Malware scan status of the attachment
attachment_status=Scan-Status
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u03A3\u03C5\u03BD\u03B7\u03BC\u03BC\u03AD\u03BD\u03BF
#XTIT: File name of the attachment
attachment_fileName=\u038C\u03BD\u03BF\u03BC\u03B1 \u0391\u03C1\u03C7\u03B5\u03AF\u03BF\u03C5
attachment_filename=\u038C\u03BD\u03BF\u03BC\u03B1 \u0391\u03C1\u03C7\u03B5\u03AF\u03BF\u03C5
#XTIT: Malware scan status of the attachment
attachment_status=\u039A\u03B1\u03C4\u03AC\u03C3\u03C4\u03B1\u03C3\u03B7 \u03A3\u03AC\u03C1\u03C9\u03C3\u03B7\u03C2
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Attachment
#XTIT: File name of the attachment
attachment_fileName=Filename
attachment_filename=Filename
#XTIT: Malware scan status of the attachment
attachment_status=Scan Status
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

attachment_content=wQr/9eWFnes2IgBQA5Ymhg_Attachment
attachment_fileName=48nzhFP8mYDdsDuZRZrc2Q_Filename
attachment_filename=48nzhFP8mYDdsDuZRZrc2Q_Filename
attachment_status=Zbg2G212YCQZ7mHrJgoiWg_Scan Status
attachment_mimeType=4bkPrEZMtvN+M0ZRH7hTCw_Media Type
attachment_note=65iTWMei6Iz166KSH/TdXg_Note
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Anexo
#XTIT: File name of the attachment
attachment_fileName=Nombre de archivo
attachment_filename=Nombre de archivo
#XTIT: Malware scan status of the attachment
attachment_status=Estado de escaneo
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Anexo
#XTIT: File name of the attachment
attachment_fileName=Nombre de archivo
attachment_filename=Nombre de archivo
#XTIT: Malware scan status of the attachment
attachment_status=Estado de escaneo
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Liite
#XTIT: File name of the attachment
attachment_fileName=Tiedostonimi
attachment_filename=Tiedostonimi
#XTIT: Malware scan status of the attachment
attachment_status=Skannauksen tila
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Pi\u00E8ce jointe
#XTIT: File name of the attachment
attachment_fileName=Nom du fichier
attachment_filename=Nom du fichier
#XTIT: Malware scan status of the attachment
attachment_status=Statut de l'analyse
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u05E7\u05D5\u05D1\u05E5 \u05DE\u05E6\u05D5\u05E8\u05E3
#XTIT: File name of the attachment
attachment_fileName=\u05E9\u05DD \u05E7\u05D5\u05D1\u05E5
attachment_filename=\u05E9\u05DD \u05E7\u05D5\u05D1\u05E5
#XTIT: Malware scan status of the attachment
attachment_status=\u05E1\u05D8\u05D0\u05D8\u05D5\u05E1 \u05E1\u05E8\u05D9\u05E7\u05D4
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Prilog
#XTIT: File name of the attachment
attachment_fileName=Naziv datoteke
attachment_filename=Naziv datoteke
#XTIT: Malware scan status of the attachment
attachment_status=Status skeniranja
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Mell\u00E9klet
#XTIT: File name of the attachment
attachment_fileName=F\u00E1jln\u00E9v
attachment_filename=F\u00E1jln\u00E9v
#XTIT: Malware scan status of the attachment
attachment_status=Beolvas\u00E1si st\u00E1tus
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Allegato
#XTIT: File name of the attachment
attachment_fileName=Nome file
attachment_filename=Nome file
#XTIT: Malware scan status of the attachment
attachment_status=Stato di scansione
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u6DFB\u4ED8\u6587\u66F8
#XTIT: File name of the attachment
attachment_fileName=\u30D5\u30A1\u30A4\u30EB\u540D
attachment_filename=\u30D5\u30A1\u30A4\u30EB\u540D
#XTIT: Malware scan status of the attachment
attachment_status=\u30B9\u30AD\u30E3\u30F3\u30B9\u30C6\u30FC\u30BF\u30B9
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\u0422\u0456\u0440\u043A\u0435\u043C\u0435
#XTIT: File name of the attachment
attachment_fileName=\u0424\u0430\u0439\u043B \u0430\u0442\u044B
attachment_filename=\u0424\u0430\u0439\u043B \u0430\u0442\u044B
#XTIT: Malware scan status of the attachment
attachment_status=\u0421\u043A\u0430\u043D\u0435\u0440\u043B\u0435\u0443 \u043A\u04AF\u0439\u0456
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=\uCCA8\uBD80\uD30C\uC77C
#XTIT: File name of the attachment
attachment_fileName=\uD30C\uC77C \uC774\uB984
attachment_filename=\uD30C\uC77C \uC774\uB984
#XTIT: Malware scan status of the attachment
attachment_status=\uC2A4\uCE94 \uC0C1\uD0DC
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Lampiran
#XTIT: File name of the attachment
attachment_fileName=Nama Lampiran
attachment_filename=Nama Lampiran
#XTIT: Malware scan status of the attachment
attachment_status=Status Imbasan
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Bijlage
#XTIT: File name of the attachment
attachment_fileName=Bestandsnaam
attachment_filename=Bestandsnaam
#XTIT: Malware scan status of the attachment
attachment_status=Scanstatus
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Vedlegg
#XTIT: File name of the attachment
attachment_fileName=Filnavn
attachment_filename=Filnavn
#XTIT: Malware scan status of the attachment
attachment_status=Skanningsstatus
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Za\u0142\u0105cznik
#XTIT: File name of the attachment
attachment_fileName=Nazwa pliku
attachment_filename=Nazwa pliku
#XTIT: Malware scan status of the attachment
attachment_status=Status skanowania
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Anexo
#XTIT: File name of the attachment
attachment_fileName=Nome do arquivo
attachment_filename=Nome do arquivo
#XTIT: Malware scan status of the attachment
attachment_status=Status da verifica\u00E7\u00E3o
#XTIT: Mime type of the attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#XTIT: Content link of the attachment
attachment_content=Anex\u0103
#XTIT: File name of the attachment
attachment_fileName=Nume fi\u0219ier
attachment_filename=Nume fi\u0219ier
#XTIT: Malware scan status of the attachment
attachment_status=Stare scanare
#XTIT: Mime type of the attachment
Expand Down
Loading
Loading