Skip to content

Commit aa1ebd2

Browse files
merging develop
2 parents 3dbadd4 + c12dc37 commit aa1ebd2

8 files changed

Lines changed: 561 additions & 86 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 1.4.0
8+
9+
### Added
10+
- Support technical user flow.
11+
- Support codelist for custom properties.
12+
13+
### Fixed
14+
- An issue where attachments uploaded with one repository was visible when application is redeployed with another repository.
15+
716
## Version 1.3.1
817

918
### Fixed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
1515
- Display attachments specific to repository: Lists attachments contained in the repository that is configured with the CAP application.
1616
- Maximum allowed uploads: Provides the capability to define the maximum number of uploads allowed for the user.
1717
- Multiple attachment facets: Provides the capability to define multiple attachment facets/sections in the CAP Entity.
18+
- Technical user support: Provides the capability to consume the plugin using technical user.
1819

1920
## Table of Contents
2021

@@ -26,6 +27,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
2627
- [Support for Custom Properties](#support-for-custom-properties)
2728
- [Support for Maximum allowed uploads](#support-for-maximum-allowed-uploads)
2829
- [Support for Multiple attachment facets](#support-for-multiple-attachment-facets)
30+
- [Support for Technical user](#support-for-technical-user)
2931
- [Known Restrictions](#known-restrictions)
3032
- [Support, Feedback, Contributing](#support-feedback-contributing)
3133
- [Code of Conduct](#code-of-conduct)
@@ -465,6 +467,24 @@ Add the following facet in _fiori-service.cds_ in the _app_ folder. Refer the fo
465467
>
466468
> Once a facet or section name is defined in the CDS file, it is strongly recommended not to modify it. For instance, in the example provided, section names such as attachments, references, and footnotes should remain unchanged after initial configuration. Renaming these sections will result in the creation of new tables, causing any data associated with the original sections to become inaccessible in the UI.
467469
470+
## Support for technical user
471+
The CAP OData operations can be performed on attachments using a technical user. This flow can be used for machine-to-machine (M2M) interactions, where user involvement is not necessary.
472+
473+
A leading CAP application's service should add the requires with annotation "system-user". For more detailed information on "system-user" within the SAP CAP framework, refer to the [Capire documentation](https://cap.cloud.sap/docs/guides/security/authorization#pseudo-roles). Here is an [example](https://github.com/cap-java/sdm/blob/develop_deploy/cap-notebook/demoapp/srv/admin-service.cds) from a sample Bookshop app demonstrating the implementation.
474+
```cds
475+
service AdminService @(requires: ['admin', 'system-user'])
476+
```
477+
478+
The plugin supports technical users using oAuth 2.0 client credentials flow. Refer the following [example](https://github.com/cap-java/sdm/blob/a1bd1a0d829e6f25e4db349143b621757e0274d1/sdm/src/test/java/integration/com/sap/cds/sdm/IntegrationTest_SingleFacet.java#L80) of an OData call.
479+
```java
480+
request =
481+
new Request.Builder()
482+
.url(authUrl + "/oauth/token?grant_type=client_credentials")
483+
.method("POST", body)
484+
.addHeader("Authorization", basicAuth)
485+
.build();
486+
```
487+
468488
## Known Restrictions
469489

470490
- UI5 Version 1.135.0: This version causes error in upload of attachments.

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.3.2-SNAPSHOT</revision>
26+
<revision>1.4.1-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/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
<groupId>org.apache.httpcomponents</groupId>
115115
<artifactId>httpasyncclient</artifactId>
116116
<version>${httpasyncclient-version}</version>
117+
<exclusions>
118+
<exclusion>
119+
<groupId>commons-logging</groupId>
120+
<artifactId>commons-logging</artifactId>
121+
</exclusion>
122+
</exclusions>
117123
</dependency>
118124
<!-- Log4j dependencies -->
119125
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->

sdm/src/test/java/integration/com/sap/cds/sdm/Api.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public String saveEntityDraft(
139139
System.out.println("Save entity failed. Error : " + draftResponseBodyString);
140140
return (draftResponseBodyString);
141141
}
142+
String sapMessages = draftResponse.header("sap-messages");
143+
if (sapMessages != null && !sapMessages.isEmpty()) {
144+
return sapMessages;
145+
}
142146
return "Saved";
143147
} catch (IOException e) {
144148
System.out.println("Could not save entity : " + e);
@@ -387,11 +391,11 @@ public String readAttachment(
387391
Response response = httpClient.newCall(request).execute();
388392
if (!response.isSuccessful()) {
389393
System.out.println(
390-
"Read Attachnent failed in the"
394+
"Read Attachment failed in the"
391395
+ facetName
392396
+ " section. Error :"
393397
+ response.body().string());
394-
throw new IOException("Read Attachnent failed in the" + facetName + " section");
398+
throw new IOException("Read Attachment failed in the" + facetName + " section");
395399
}
396400
return "OK";
397401
} catch (IOException e) {

sdm/src/test/java/integration/com/sap/cds/sdm/ApiMT.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ public String saveEntityDraft(
134134
System.out.println("Save entity failed. Error : " + draftResponseBodyString);
135135
return (draftResponseBodyString);
136136
}
137+
String sapMessages = draftResponse.header("sap-messages");
138+
if (sapMessages != null && !sapMessages.isEmpty()) {
139+
System.out.println("Save entity failed. SAP Messages: " + sapMessages);
140+
return sapMessages;
141+
}
137142
return "Saved";
138143
} catch (IOException e) {
139144
System.out.println("Could not save entity : " + e);
@@ -328,10 +333,10 @@ public List<String> createAttachment(
328333
createResponse.add(ID);
329334
return createResponse;
330335
} catch (IOException e) {
331-
System.out.println("Attachment was not created in section: " + facetName + " : " + e);
336+
System.out.println("Attachment was not created in section1: " + facetName + " : " + e);
332337
}
333338
} catch (IOException e) {
334-
System.out.println("Attachment was not created in section: " + facetName + " : " + e);
339+
System.out.println("Attachment was not created in section2: " + facetName + " : " + e);
335340
}
336341
List<String> createResponse = new ArrayList<>();
337342
createResponse.add("Attachment was not created in section: " + facetName);
@@ -374,7 +379,7 @@ public String readAttachment(
374379
+ facetName
375380
+ " section. Error :"
376381
+ response.body().string());
377-
throw new IOException("Read Attachnent failed in the" + facetName + " section");
382+
throw new IOException("Read Attachment failed in the" + facetName + " section");
378383
}
379384
return "OK";
380385
} catch (IOException e) {

0 commit comments

Comments
 (0)