Skip to content

Commit 69c1750

Browse files
authored
Merge branch 'develop' into mofterdinger-patch-1
2 parents 39b4fbe + c12dc37 commit 69c1750

14 files changed

Lines changed: 1018 additions & 689 deletions

File tree

.github/actions/build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
distribution: sapmachine
2424
cache: maven
2525

26-
- name: Setup Maven ${{ inputs.maven-version }}
26+
- name: Set up Maven ${{ inputs.maven-version }}
2727
uses: stCarolas/setup-maven@v5
2828
with:
2929
maven-version: ${{ inputs.maven-version }}

.github/actions/deploy-release/action.yml

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ runs:
3838
with:
3939
distribution: 'sapmachine'
4040
java-version: '17'
41-
server-id: ossrh
41+
cache: maven
42+
server-id: central
4243
server-username: MAVEN_CENTRAL_USER
4344
server-password: MAVEN_CENTRAL_PASSWORD
4445

@@ -55,43 +56,58 @@ runs:
5556
ls -al ./deploy-oss
5657
shell: bash
5758

58-
- name: "Deploy Locally"
59-
run: |
60-
echo "Deploying artifacts locally..."
61-
mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \
62-
-Durl=file:./temp_local_repo \
63-
-Dmaven.install.skip=true \
64-
-Dmaven.test.skip=true \
65-
-Dgpg.passphrase="$GPG_PASSPHRASE" \
66-
-Dgpg.keyname="$GPG_PUB_KEY" \
67-
-Drevision="${{ inputs.revision }}" \
68-
deploy
69-
working-directory: ./deploy-oss
59+
- name: Deploy to Maven Central
60+
run: >
61+
mvn -B -ntp --show-version
62+
-Dmaven.install.skip=true
63+
-Dmaven.test.skip=true
64+
-Dgpg.passphrase="$GPG_PASSPHRASE"
65+
-Dgpg.keyname="$GPG_PUB_KEY"
66+
clean deploy -P deploy-release
7067
shell: bash
7168
env:
7269
MAVEN_CENTRAL_USER: ${{ inputs.user }}
7370
MAVEN_CENTRAL_PASSWORD: ${{ inputs.password }}
7471
GPG_PASSPHRASE: ${{ inputs.pgp-passphrase }}
7572
GPG_PUB_KEY: ${{ inputs.pgp-pub-key }}
7673

77-
- name: "List Contents of Local Repo"
78-
run: |
79-
echo "Contents of temp_local_repo:"
80-
ls -al ./deploy-oss/temp_local_repo
81-
shell: bash
74+
# - name: "Deploy Locally"
75+
# run: |
76+
# echo "Deploying artifacts locally..."
77+
# mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \
78+
# -Durl=file:./temp_local_repo \
79+
# -Dmaven.install.skip=true \
80+
# -Dmaven.test.skip=true \
81+
# -Dgpg.passphrase="$GPG_PASSPHRASE" \
82+
# -Dgpg.keyname="$GPG_PUB_KEY" \
83+
# -Drevision="${{ inputs.revision }}" \
84+
# deploy
85+
# working-directory: ./deploy-oss
86+
# shell: bash
87+
# env:
88+
# MAVEN_CENTRAL_USER: ${{ inputs.user }}
89+
# MAVEN_CENTRAL_PASSWORD: ${{ inputs.password }}
90+
# GPG_PASSPHRASE: ${{ inputs.pgp-passphrase }}
91+
# GPG_PUB_KEY: ${{ inputs.pgp-pub-key }}
8292

83-
- name: "Deploy Staging"
84-
run: |
85-
mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \
86-
org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:deploy-staged-repository \
87-
-DserverId=ossrh \
88-
-DnexusUrl=https://oss.sonatype.org \
89-
-DrepositoryDirectory=./temp_local_repo \
90-
-DstagingProfileId="$MAVEN_CENTRAL_PROFILE_ID" \
91-
-Drevision="${{ inputs.revision }}"
92-
working-directory: ./deploy-oss
93-
shell: bash
94-
env:
95-
MAVEN_CENTRAL_USER: ${{ inputs.user }}
96-
MAVEN_CENTRAL_PASSWORD: ${{ inputs.password }}
97-
MAVEN_CENTRAL_PROFILE_ID: ${{ inputs.profile }}
93+
# - name: "List Contents of Local Repo"
94+
# run: |
95+
# echo "Contents of temp_local_repo:"
96+
# ls -al ./deploy-oss/temp_local_repo
97+
# shell: bash
98+
99+
# - name: "Deploy Staging"
100+
# run: |
101+
# mvn --batch-mode --no-transfer-progress --fail-at-end --show-version \
102+
# org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:deploy-staged-repository \
103+
# -DserverId=ossrh \
104+
# -DnexusUrl=https://oss.sonatype.org \
105+
# -DrepositoryDirectory=./temp_local_repo \
106+
# -DstagingProfileId="$MAVEN_CENTRAL_PROFILE_ID" \
107+
# -Drevision="${{ inputs.revision }}"
108+
# working-directory: ./deploy-oss
109+
# shell: bash
110+
# env:
111+
# MAVEN_CENTRAL_USER: ${{ inputs.user }}
112+
# MAVEN_CENTRAL_PASSWORD: ${{ inputs.password }}
113+
# MAVEN_CENTRAL_PROFILE_ID: ${{ inputs.profile }}

.github/actions/newrelease/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
distribution: sapmachine
2121
cache: maven
2222

23-
- name: Setup Maven ${{ inputs.maven-version }}
23+
- name: Set up Maven ${{ inputs.maven-version }}
2424
uses: stCarolas/setup-maven@v5
2525
with:
2626
maven-version: ${{ inputs.maven-version }}

.github/workflows/main-build-and-deploy-oss.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to OSS
1+
name: Deploy to Maven Central
22

33
env:
44
JAVA_VERSION: '17'
@@ -96,9 +96,8 @@ jobs:
9696
- name: Deploy
9797
uses: ./.github/actions/deploy-release
9898
with:
99-
user: ${{ secrets.OSSRH_SONATYPE_ORG_API_USER }}
100-
password: ${{ secrets.OSSRH_SONATYPE_ORG_API_PASSWD }}
101-
profile: ${{ secrets.OSSRH_SONATYPE_ORG_PROFILE_ID }}
99+
user: ${{ secrets.CENTRAL_REPOSITORY_USER }}
100+
password: ${{ secrets.CENTRAL_REPOSITORY_PASS }}
102101
pgp-pub-key: ${{ secrets.PGP_PUBKEY_ID }}
103102
pgp-private-key: ${{ secrets.PGP_PRIVATE_KEY }}
104103
pgp-passphrase: ${{ secrets.PGP_PASSPHRASE }}

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: 84 additions & 4 deletions
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>
@@ -269,9 +269,84 @@
269269
</execution>
270270
</executions>
271271
</plugin>
272-
273272
</plugins>
273+
274+
<pluginManagement>
275+
<plugins>
276+
<plugin>
277+
<artifactId>maven-gpg-plugin</artifactId>
278+
<version>3.2.7</version>
279+
</plugin>
280+
<plugin>
281+
<groupId>org.sonatype.central</groupId>
282+
<artifactId>central-publishing-maven-plugin</artifactId>
283+
<version>0.7.0</version>
284+
<extensions>true</extensions>
285+
</plugin>
286+
<plugin>
287+
<artifactId>maven-clean-plugin</artifactId>
288+
<version>3.5.0</version>
289+
</plugin>
290+
<plugin>
291+
<artifactId>maven-compiler-plugin</artifactId>
292+
<version>3.14.0</version>
293+
</plugin>
294+
<plugin>
295+
<artifactId>maven-source-plugin</artifactId>
296+
<version>3.3.1</version>
297+
</plugin>
298+
<plugin>
299+
<artifactId>maven-deploy-plugin</artifactId>
300+
<version>3.1.4</version>
301+
</plugin>
302+
<plugin>
303+
<artifactId>maven-javadoc-plugin</artifactId>
304+
<version>3.11.2</version>
305+
</plugin>
306+
<plugin>
307+
<artifactId>maven-surefire-plugin</artifactId>
308+
<version>3.5.3</version>
309+
</plugin>
310+
<plugin>
311+
<artifactId>maven-pmd-plugin</artifactId>
312+
<version>3.26.0</version>
313+
</plugin>
314+
<plugin>
315+
<artifactId>maven-enforcer-plugin</artifactId>
316+
<version>3.5.0</version>
317+
</plugin>
318+
</plugins>
319+
</pluginManagement>
274320
</build>
321+
<profiles>
322+
<profile>
323+
<id>deploy-release</id>
324+
<build>
325+
<plugins>
326+
<plugin>
327+
<artifactId>maven-gpg-plugin</artifactId>
328+
<executions>
329+
<execution>
330+
<id>sign-artifacts</id>
331+
<phase>deploy</phase>
332+
<goals>
333+
<goal>sign</goal>
334+
</goals>
335+
</execution>
336+
</executions>
337+
</plugin>
338+
339+
<plugin>
340+
<groupId>org.sonatype.central</groupId>
341+
<artifactId>central-publishing-maven-plugin</artifactId>
342+
<configuration>
343+
<publishingServerId>central</publishingServerId>
344+
</configuration>
345+
</plugin>
346+
</plugins>
347+
</build>
348+
</profile>
349+
</profiles>
275350
<distributionManagement>
276351
<!-- <snapshotRepository>
277352
<id>artifactory</id>
@@ -284,16 +359,21 @@
284359
<url>https://common.repositories.cloud.sap/artifactory/cap-sdm-java</url>
285360
</repository> -->
286361
<!-- GitHub Packages Repositories -->
287-
<repository>
362+
<!-- <repository>
288363
<id>github-release</id>
289364
<name>GitHub Packages</name>
290365
<url>https://maven.pkg.github.com/cap-java/sdm</url>
291-
</repository>
366+
</repository> -->
292367
<snapshotRepository>
293368
<id>github-snapshot</id>
294369
<name>GitHub Packages Snapshots</name>
295370
<url>https://maven.pkg.github.com/cap-java/sdm</url>
296371
</snapshotRepository>
372+
<repository>
373+
<id>central</id>
374+
<name>MavenCentral</name>
375+
<url>https://central.sonatype.com</url>
376+
</repository>
297377
</distributionManagement>
298378

299379
<scm>

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package integration.com.sap.cds.sdm;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import java.io.File;
5-
import java.io.IOException;
4+
import java.io.*;
65
import java.util.*;
76
import okhttp3.*;
87
import okio.ByteString;
@@ -140,6 +139,10 @@ public String saveEntityDraft(
140139
System.out.println("Save entity failed. Error : " + draftResponseBodyString);
141140
return (draftResponseBodyString);
142141
}
142+
String sapMessages = draftResponse.header("sap-messages");
143+
if (sapMessages != null && !sapMessages.isEmpty()) {
144+
return sapMessages;
145+
}
143146
return "Saved";
144147
} catch (IOException e) {
145148
System.out.println("Could not save entity : " + e);
@@ -588,7 +591,7 @@ public String updateInvalidSecondaryProperty(
588591
String ID,
589592
String invalidSecondaryProperty) {
590593
MediaType mediaType = MediaType.parse("application/json");
591-
String jsonPayload = "{\n \"abc___myId1\": \"" + invalidSecondaryProperty + "\"\n}";
594+
String jsonPayload = "{\n \"customProperty3\": \"" + invalidSecondaryProperty + "\"\n}";
592595
RequestBody body = RequestBody.create(mediaType, ByteString.encodeUtf8(jsonPayload));
593596
Request request =
594597
new Request.Builder()

0 commit comments

Comments
 (0)