Skip to content

Commit fa78ddd

Browse files
committed
Update Readme & revert pom version workflow changes
1 parent 4848474 commit fa78ddd

7 files changed

Lines changed: 250 additions & 122 deletions

File tree

.github/workflows/cfdeploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ jobs:
5555
- name: Verify and Checkout Deploy Branch 🔄
5656
run: |
5757
git fetch origin
58-
echo "📂 Verifying 'changesForChangeLogSupport' branch..."
59-
if git rev-parse --verify origin/changesForChangeLogSupport; then
60-
git checkout changesForChangeLogSupport
58+
echo "📂 Verifying 'local_deploy' branch..."
59+
if git rev-parse --verify origin/local_deploy; then
60+
git checkout local_deploy
6161
echo "✅ Branch checked out successfully!"
6262
else
63-
echo "❌ Branch 'changesForChangeLogSupport' not found. Please verify the branch name."
63+
echo "❌ Branch 'local_deploy' not found. Please verify the branch name."
6464
exit 1
6565
fi
6666

README.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
2121
- Link as attachments: Provides the capability to support link or URL as attachments.
2222
- Edit Link-type attachments: Provides the capability to update URL of link-type attachments.
2323
- Move attachments: Provides the capability to move attachments from one entity to another entity.
24+
- Attachment changelog: Provides the capability to view complete audit trail of attachments.
2425
- Localization of error messages and UI fields: Provides the capability to have the UI fields and error messages translated to the local language of the leading application.
2526
## Table of Contents
2627

@@ -35,6 +36,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
3536
- [Support for Technical user](#support-for-technical-user)
3637
- [Support for Copy attachments](#support-for-copy-attachments)
3738
- [Support for Move attachments](#support-for-move-attachments)
39+
- [Support for Attachment changelog](#support-for-attachment-changelog)
3840
- [Support for Link type attachments](#support-for-link-type-attachments)
3941
- [Support for Edit of Link type attachments](#support-for-edit-of-link-type-attachments)
4042
- [Support for Localization](#support-for-localization)
@@ -707,6 +709,224 @@ The move operation returns a list of failed attachments with detailed failure re
707709

708710
> **CRITICAL**: To preserve custom properties attached with attachments on UI, ensure these properties are defined in the target entity. If custom properties are not present in the target entity definition, they will be lost after the move and will not be visible on the UI.
709711
712+
## Support for attachment changelog
713+
714+
The changelog feature provides a complete audit trail of operations performed on an attachment throughout its lifecycle. It tracks creation, modifications with detailed metadata including who made the change, when it occurred.
715+
716+
### Overview
717+
718+
The changelog functionality retrieves the complete history of an attachment from SAP Document Management Service, including:
719+
720+
- **Creation events**: Initial upload information
721+
- **Modification events**: Updates to file properties
722+
- **Property changes**: Changes to metadata, description, or custom properties
723+
- **User information**: Who performed each action
724+
- **Timestamps**: When each change occurred
725+
726+
### Integration with UI
727+
728+
To enable changelog viewing in your CAP application:
729+
730+
1. **Add a custom controller extension**
731+
732+
In webapp/controller/custom.controller.js, copy and paste below content.
733+
734+
See this [example](https://github.com/cap-java/sdm/blob/develop_deploy/cap-notebook/demoapp/app/admin-books/webapp/controller/custom.controller.js) from a sample Bookshop app.
735+
736+
```js
737+
sap.ui.define(
738+
[
739+
"sap/ui/core/mvc/ControllerExtension",
740+
"sap/ui/core/format/DateFormat"
741+
],
742+
function (ControllerExtension, DateFormat) {
743+
"use strict";
744+
const ChangeCategoryEnum = {
745+
created: "Created",
746+
updated: "Changed"
747+
// Add more mappings as needed
748+
};
749+
750+
return ControllerExtension.extend("books.controller.custom", {
751+
onChangelogPress: function(oContext, aSelectedContexts) {
752+
var that =this;
753+
this.base.editFlow
754+
.invokeAction("AdminService.changelog", {
755+
contexts: aSelectedContexts
756+
})
757+
.then(function (res) {
758+
console.log("Result",res[0].value.getObject().value);
759+
that.updateChangeLogInPropertiesModel(res[0].value.getObject().value);
760+
});
761+
},
762+
updateChangeLogInPropertiesModel: function (oChangeLogsForObjectResponse) {
763+
const aChangeLogs = [];
764+
const fileName = JSON.parse(oChangeLogsForObjectResponse).filename;
765+
const aChangeLogsObject = JSON.parse(oChangeLogsForObjectResponse)["changeLogs"];
766+
// Take latest changes at the top
767+
for (let idx = aChangeLogsObject.length - 1; idx >= 0; idx--) {
768+
const oChangeLogEntry = aChangeLogsObject[idx];
769+
const sLastModifiedBy = oChangeLogEntry["user"];
770+
const sChangeType = oChangeLogEntry["operation"];
771+
const sChangeTime = oChangeLogEntry["time"];
772+
let dateTimeFormat = DateFormat.getDateTimeInstance(sap.ui.getCore().getConfiguration().getLocale());
773+
let changedDate = new Date(sChangeTime);
774+
let changedTime = changedDate?dateTimeFormat.format(new Date(changedDate)) : "" ;
775+
const oChangeLog = {
776+
changedOn: changedTime,
777+
changedBy: sLastModifiedBy,
778+
changeType: ChangeCategoryEnum[sChangeType]
779+
};
780+
aChangeLogs.push(oChangeLog);
781+
}
782+
783+
this.logFragment= this.base.getExtensionAPI().loadFragment({
784+
name: "books.fragments.changelog",
785+
controller: this
786+
});
787+
var that = this;
788+
this.logFragment.then(function (dialog) {
789+
if(dialog){
790+
dialog.attachEventOnce("afterClose", function () {
791+
dialog.destroy();
792+
});
793+
var oModel = new sap.ui.model.json.JSONModel();
794+
oModel.setSizeLimit(100000);
795+
oModel.setData(aChangeLogs);
796+
that.getView().setModel(oModel, "changelog");
797+
dialog.setTitle(fileName);
798+
dialog.open()
799+
}
800+
});
801+
},
802+
close: function (closeBtn) {
803+
closeBtn.getSource().getParent().close();
804+
}
805+
});
806+
});
807+
```
808+
809+
- Replace `books` in `ControllerExtension.extend` with the `SAPUI5.Component` name from your `app/appconfig/fioriSandboxConfig.json` file. See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86).
810+
- Replace `AdminService` in `invokeAction("AdminService.changelog")` with the name of your service.
811+
812+
2. **Add changelog.fragment.xml**
813+
814+
In webapp/fragments/changelog.fragment.xml, copy and paste below content.
815+
See this [example](https://github.com/cap-java/sdm/blob/develop_deploy/cap-notebook/demoapp/app/admin-books/webapp/fragments/changelog.fragment.xml) from a sample Bookshop app.
816+
817+
```xml
818+
<core:FragmentDefinition
819+
xmlns:core="sap.ui.core"
820+
xmlns:uxap="sap.uxap"
821+
xmlns="sap.m">
822+
<Dialog title="Change Log" id = "changelogDialog" resizable="true" contentWidth="50%"
823+
contentHeight="50%" draggable="true" class="sapUiSizeCompact" verticalScrolling="true">
824+
<content>
825+
826+
<IconTabBar
827+
id="idIconTabBarNoIcons"
828+
class="mcmPropertiesSections" isChildPage="true" enableLazyLoading="true" upperCaseAnchorBar="false" stretchContentHeight= "true">
829+
<items>
830+
<IconTabFilter text="Change Log" key="info">
831+
<Table id="idChangeLogTable" items="{path:'changelog>/', templateShareable:false}"
832+
noDataText="{i18n>LoadingData}">
833+
<columns>
834+
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
835+
<Text text="Category"/>
836+
</Column>
837+
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
838+
<Text text="Changed By"/>
839+
</Column>
840+
<Column demandPopin="true" popinDisplay="Inline" minScreenWidth="Large">
841+
<Text text="Changed On"/>
842+
</Column>
843+
</columns>
844+
<items>
845+
<ColumnListItem>
846+
<cells>
847+
<Text text="{changelog>changeType}"/>
848+
<Text text="{changelog>changedBy}"/>
849+
<Text text="{changelog>changedOn}"/>
850+
</cells>
851+
</ColumnListItem>
852+
</items>
853+
</Table>
854+
</IconTabFilter>
855+
</items>
856+
</IconTabBar>
857+
858+
</content>
859+
860+
<endButton>
861+
<Button text="Close" press=".close" />
862+
</endButton>
863+
</Dialog>
864+
</core:FragmentDefinition>
865+
```
866+
867+
3. **Add the `changelog` action to your application's service definition**
868+
869+
See this [example](https://github.com/cap-java/sdm/blob/396339d3182f1debe96a3134c42b17b609357d9a/cap-notebook/demoapp/srv/admin-service.cds#L39) from a sample Bookshop app.
870+
871+
```cds
872+
action changelog() returns String;
873+
```
874+
875+
4. **Custom Action Button Configuration**
876+
877+
To add a custom action button (e.g., "Change Log") to your table that is enabled only when a single row is selected, add the following configuration to your `manifest.json`.
878+
See this [example](https://github.com/cap-java/sdm/blob/396339d3182f1debe96a3134c42b17b609357d9a/cap-notebook/demoapp/app/admin-books/webapp/manifest.json#L143) from a sample Bookshop app.
879+
880+
```json
881+
"controlConfiguration": {
882+
"attachments/@com.sap.vocabularies.UI.v1.LineItem": {
883+
"tableSettings": {
884+
"type": "ResponsiveTable",
885+
"selectionMode": "Auto"
886+
},
887+
"actions": {
888+
"changelog": {
889+
"enableOnSelect": "single",
890+
"text": "Change Log",
891+
"requiresSelection": true,
892+
"press": ".extension.books.controller.custom.onChangelogPress",
893+
"command": "COMMON",
894+
"position": {
895+
"anchor": "StandardAction::Create",
896+
"placement": "After"
897+
}
898+
}
899+
}
900+
}
901+
}
902+
```
903+
- Replace `attachments` with your entity’s facet name as needed.
904+
- Repeat for other facets's if required.
905+
- Replace `books` in `"press": ".extension.books.controller.custom.onChangelogPress"` with the SAPUI5.Component name from your
906+
`app/appconfig/fioriSandboxConfig.json` file. Refer this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86) from a sample Bookshop app.
907+
908+
### Configuration Properties
909+
910+
| Property | Value | Description |
911+
|----------|-------|-------------|
912+
| `enableOnSelect` | `"single"` | Button is enabled only when exactly one row is selected |
913+
| `requiresSelection` | `true` | Button is disabled when no rows are selected |
914+
| `press` | `".extension.books.controller.custom.onChangelogPress"` | Reference to the controller method that handles the button click |
915+
| `command` | `"COMMON"` | Makes the button available in the table toolbar |
916+
| `position` | `{ "anchor": "StandardAction::Create", "placement": "After" }` | Controls where the button appears relative to standard actions (e.g., after the Create button) |
917+
918+
### Behavior
919+
920+
The button will automatically be:
921+
922+
| Status | Condition |
923+
|--------|-----------|
924+
| ✅ Enabled | When exactly one item is selected |
925+
| ❌ Disabled | When no items are selected |
926+
| ❌ Disabled | When multiple items are selected |
927+
928+
929+
710930
## Support for link type attachments
711931

712932
> **Note:** Row-press is the new recommended approach for handling actions on attachment rows. With row-press enabled, the Attachments column will no longer appear as a separate action button. Instead, clicking on a row will automatically perform the appropriate action — opening a link or downloading a file, based on the attachment type.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</developers>
2424

2525
<properties>
26-
<revision>1.0.0-RC1</revision>
26+
<revision>1.6.2-SNAPSHOT</revision>
2727
<java.version>17</java.version>
2828
<maven.compiler.source>${java.version}</maven.compiler.source>
2929
<maven.compiler.target>${java.version}</maven.compiler.target>

sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,7 @@ private void processAttachment(
221221
dbQuery.getPropertiesForID(
222222
attachmentEntity.get(), persistenceService, id, secondaryTypeProperties);
223223

224-
logger.info(
225-
"[SecondaryProperties Debug] CREATE - Fetched properties from DB for attachment ID '{}': {}",
226-
id,
227-
propertiesInDB);
228-
logger.info(
229-
"[SecondaryProperties Debug] CREATE - Calling getUpdatedSecondaryProperties for attachment: {}",
230-
attachment);
224+
logger.debug("Processing attachment creation - ID: {}, objectId: {}", id, objectId);
231225

232226
// Prepare document and updated properties
233227
Map<String, String> updatedSecondaryProperties =
@@ -238,9 +232,6 @@ private void processAttachment(
238232
secondaryTypeProperties,
239233
propertiesInDB);
240234

241-
logger.info(
242-
"[SecondaryProperties Debug] CREATE - Received updatedSecondaryProperties: {}",
243-
updatedSecondaryProperties);
244235
CmisDocument cmisDocument =
245236
AttachmentsHandlerUtils.prepareCmisDocument(
246237
filenameInRequest, descriptionInRequest, objectId);
@@ -256,10 +247,10 @@ private void processAttachment(
256247
false);
257248

258249
// Send update to SDM and handle response
259-
logger.info(
260-
"[SecondaryProperties Debug] CREATE - Sending update to SDM for attachment ID '{}' with properties: {}",
250+
logger.debug(
251+
"Creating attachment in SDM - ID: {}, properties count: {}",
261252
id,
262-
updatedSecondaryProperties);
253+
updatedSecondaryProperties.size());
263254

264255
try {
265256
int responseCode =
@@ -270,8 +261,7 @@ private void processAttachment(
270261
secondaryPropertiesWithInvalidDefinitions,
271262
context.getUserInfo().isSystemUser());
272263

273-
logger.info(
274-
"[SecondaryProperties Debug] CREATE - SDM update response code: {}", responseCode);
264+
logger.debug("SDM create response code: {} for attachment ID: {}", responseCode, id);
275265
AttachmentsHandlerUtils.handleSDMUpdateResponse(
276266
responseCode,
277267
attachment,

0 commit comments

Comments
 (0)