Skip to content

Commit 671f4d6

Browse files
Merge branch 'develop' into largeFileUploadFixWithouRestTemplate
2 parents c9cc062 + bef8d6a commit 671f4d6

File tree

23 files changed

+2736
-757
lines changed

23 files changed

+2736
-757
lines changed

.github/actions/newrelease/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ runs:
3434
#./ensure-license.sh
3535
git config --global user.name 'github-actions[bot]'
3636
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
37-
git checkout -b Release_v1.0.2
37+
git checkout -b Release_v1.1.0
38+
git add cap-notebook/version.txt
3839
git commit -am "Update version to $VERSION"
39-
git push --set-upstream origin Release_v1.0.2
40+
git push --set-upstream origin Release_v1.1.0
4041
shell: bash

.github/workflows/sonarqube.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
-Dsonar.junit.reportPaths=sdm/target/surefire-reports \
5555
-Dsonar.coverage.jacoco.xmlReportPaths=sdm/target/site/jacoco/jacoco.xml \
5656
-Dsonar.inclusions=**/*.java \
57-
-Dsonar.exclusions=**/target/**,**/node_modules/**,sdm/src/main/test/**,cap-notebook/*.capnb,sdm/src/main/java/com/sap/cds/sdm/model/**,sdm/src/main/java/com/sap/cds/sdm/caching/CacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/RepoKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/TokenCacheKey.java \
57+
-Dsonar.exclusions=**/target/**,**/node_modules/**,sdm/src/main/test/**,cap-notebook/*.capnb,sdm/src/main/java/com/sap/cds/sdm/model/**,sdm/src/main/java/com/sap/cds/sdm/caching/CacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/RepoKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/TokenCacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/SecondaryTypesKey.java \
5858
-Dsonar.java.file.suffixes=.java \
5959
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
6060
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
@@ -70,7 +70,7 @@ jobs:
7070
-Dsonar.junit.reportPaths=sdm/target/surefire-reports \
7171
-Dsonar.coverage.jacoco.xmlReportPaths=sdm/target/site/jacoco/jacoco.xml \
7272
-Dsonar.inclusions=**/*.java \
73-
-Dsonar.exclusions=**/target/**,**/node_modules/**,sdm/src/main/test/**,cap-notebook/*.capnb,sdm/src/main/java/com/sap/cds/sdm/model/**,sdm/src/main/java/com/sap/cds/sdm/caching/CacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/RepoKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/TokenCacheKey.java \
73+
-Dsonar.exclusions=**/target/**,**/node_modules/**,sdm/src/main/test/**,cap-notebook/*.capnb,sdm/src/main/java/com/sap/cds/sdm/model/**,sdm/src/main/java/com/sap/cds/sdm/caching/CacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/RepoKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/TokenCacheKey.java,sdm/src/main/java/com/sap/cds/sdm/caching/SecondaryTypesKey.java \
7474
-Dsonar.java.file.suffixes=.java \
7575
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
7676
-Dsonar.login=${{ secrets.SONAR_TOKEN }}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ 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.1.0
8+
9+
### Fixed
10+
11+
- Allow any name in the primary key for the entity.
12+
- Duplicate filename check with multiple repository switch.
13+
- Error message for special characters in filename.
14+
15+
### Added
16+
17+
- Support repository onboarding for multitenant use case.
18+
719
## Version 1.0.2
820

921
### Added

README.md

Lines changed: 55 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
- [Deploying and testing the application](#deploying-and-testing-the-application)
2222
- [Use com.sap.cds:sdm dependency](#use-comsapcdssdm-dependency)
2323
- [Support for Multitenancy](#support-for-multitenancy)
24+
- [Support for Custom Properties](#support-for-custom-properties)
2425
- [Known Restrictions](#known-restrictions)
2526
- [Support, Feedback, Contributing](#support-feedback-contributing)
2627
- [Code of Conduct](#code-of-conduct)
@@ -317,10 +318,64 @@ String response = sdmAdminService.onboardRepository(repository);
317318
When the application is deployed as a SaaS application using the code above, tenants automatically onboard a repository upon subscription.
318319
- When the application is deployed as a SaaS application with above code, tenants on subscribing the SaaS application gets onboarded automatically.
319320

321+
## Support for Custom Properties
322+
323+
Custom properties are supported via the usage of CMIS secondary type properties. Follow the below steps to add and use custom properties.
324+
325+
1. If the repository does not contain secondary types and properties, create CMIS secondary types and properties using the [Create Secondary Type API](https://api.sap.com/api/CreateSecondaryTypeApi/overview). The property definition must contain the following section for the CAP plugin to process the property.
326+
327+
```json
328+
"mcm:miscellaneous": {
329+
"isPartOfTable": "true"
330+
}
331+
```
332+
333+
With this, the secondary type and properties definition will be as per the sample given below
334+
335+
```json
336+
{
337+
"id": "Working:DocumentInfo",
338+
"displayName": "Document Info",
339+
"baseId": "cmis:secondary",
340+
"parentId": "cmis:secondary",
341+
...
342+
},
343+
"propertyDefinitions": {
344+
"Working:DocumentInfoRecord": {
345+
"id": "Working:DocumentInfoRecord",
346+
"displayName": "Document Info Record",
347+
...
348+
"mcm:miscellaneous": { <-- Required section in the property definition
349+
"isPartOfTable": "true"
350+
}
351+
}
352+
}
353+
}
354+
```
355+
356+
2. Using secondary properties in CAP Application.
357+
- Extend the `Attachments` aspect with the secondary properties in the previously created _attachment-extension.cds_ file.
358+
- Annotate the secondary properties with `@SDM.Attachments.AdditionalProperty`.
359+
- If the property id contains a `:`, replace it with a triple underscore `___`.
360+
361+
Refer the following example from a sample Bookshop app:
362+
363+
```cds
364+
extend Attachments with {
365+
Working___DocumentInfoRecord : String @SDM.Attachments.AdditionalProperty @(title: '{i18n>property1}');
366+
}
367+
```
368+
369+
> **Note**
370+
>
371+
> SDM supports secondary properties with data types `String`, `Boolean`, `Decimal`, `Integer` and `DateTime`.
372+
373+
320374
## Known Restrictions
321375

322376
- Repository : This plugin does not support the use of versioned repositories.
323377
- File size : Attachments are limited to a maximum size of 700 MB. If the repository is [onboarded](https://help.sap.com/docs/document-management-service/sap-document-management-service/internal-repository?version=Cloud&locale=en-US) with virus scan enabled for all files, attachments are limited to a maximum size of 400 MB.
378+
- Datatypes for custom properties : Custom properties are supported for the following data types `String`, `Boolean`, `Decimal`, `Integer` and `DateTime`.
324379

325380
## Support, Feedback, Contributing
326381

pom.xml

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

2626
<properties>
27-
<revision>1.0.3-SNAPSHOT</revision>
27+
<revision>1.1.1-SNAPSHOT</revision>
2828
<java.version>17</java.version>
2929
<maven.compiler.source>${java.version}</maven.compiler.source>
3030
<maven.compiler.target>${java.version}</maven.compiler.target>

sdm/src/main/java/com/sap/cds/sdm/caching/CacheConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sap.cds.sdm.caching;
22

3+
import java.util.List;
34
import java.util.concurrent.TimeUnit;
45
import org.ehcache.Cache;
56
import org.ehcache.CacheManager;
@@ -16,6 +17,7 @@ public class CacheConfig {
1617
private static Cache<CacheKey, String> clientCredentialsTokenCache;
1718
private static Cache<TokenCacheKey, String> userAuthoritiesTokenCache;
1819
private static Cache<RepoKey, String> versionedRepoCache;
20+
private static Cache<SecondaryTypesKey, List<String>> secondaryTypesCache;
1921
private static final int HEAP_SIZE = 1000;
2022
private static final int USER_TOKEN_EXPIRY = 660;
2123
private static final int ACCESS_TOKEN_EXPIRY = 660;
@@ -63,6 +65,15 @@ public static void initializeCache() {
6365
.withExpiry(
6466
Expirations.timeToLiveExpiration(
6567
new Duration(USER_TOKEN_EXPIRY, TimeUnit.MINUTES))));
68+
69+
secondaryTypesCache =
70+
cacheManager.createCache(
71+
"secondaryTypes",
72+
CacheConfigurationBuilder.newCacheConfigurationBuilder(
73+
SecondaryTypesKey.class,
74+
(Class<List<String>>) (Class<?>) List.class,
75+
ResourcePoolsBuilder.heap(HEAP_SIZE))
76+
.withExpiry(Expirations.noExpiration()));
6677
}
6778

6879
public static Cache<CacheKey, String> getUserTokenCache() {
@@ -80,4 +91,8 @@ public static Cache<CacheKey, String> getClientCredentialsTokenCache() {
8091
public static Cache<RepoKey, String> getVersionedRepoCache() {
8192
return versionedRepoCache;
8293
}
94+
95+
public static Cache<SecondaryTypesKey, List<String>> getSecondaryTypesCache() {
96+
return secondaryTypesCache;
97+
}
8398
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.sap.cds.sdm.caching;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
@Data
8+
@NoArgsConstructor
9+
@AllArgsConstructor
10+
public class SecondaryTypesKey {
11+
private String repositoryId;
12+
}

sdm/src/main/java/com/sap/cds/sdm/configuration/Registration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void eventHandlers(CdsRuntimeConfigurer configurer) {
6262
SDMService sdmService = new SDMServiceImpl(binding, connectionPool);
6363
DocumentUploadService documentService = new DocumentUploadService();
6464
configurer.eventHandler(buildReadHandler());
65-
configurer.eventHandler(new SDMCreateAttachmentsHandler(sdmService));
65+
configurer.eventHandler(new SDMCreateAttachmentsHandler(persistenceService, sdmService));
6666
configurer.eventHandler(new SDMUpdateAttachmentsHandler(persistenceService, sdmService));
6767
configurer.eventHandler(
6868
new SDMAttachmentsServiceHandler(persistenceService, sdmService, documentService));

sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ private SDMConstants() {
88
}
99

1010
public static final String REPOSITORY_ID = System.getenv("REPOSITORY_ID");
11+
public static final String SDM_ANNOTATION_ADDITIONALPROPERTY =
12+
"@SDM.Attachments.AdditionalProperty";
1113
public static final String DUPLICATE_FILE_IN_DRAFT_ERROR_MESSAGE =
1214
"The file(s) %s have been added multiple times. Please rename and try again.";
1315
public static final String FILES_RENAME_WARNING_MESSAGE =
@@ -40,12 +42,13 @@ private SDMConstants() {
4042
public static final int CHUNK_SIZE = 100 * 1024 * 1024; // 100MB Chunk Size
4143
public static final String ONBOARD_REPO_MESSAGE =
4244
"Repository with name %s and id %s onboarded successfully";
43-
public static final String ONBOARD_REPO__ERROR_MESSAGE =
45+
public static final String ONBOARD_REPO_ERROR_MESSAGE =
4446
"Error in onboarding repository with name %s";
4547
public static final String NO_SDM_BINDING = "No SDM binding found";
4648
public static final String DI_TOKEN_EXCHANGE_ERROR = "Error fetching DI token with JWT bearer";
4749
public static final String DI_TOKEN_EXCHANGE_PARAMS =
4850
"/oauth/token?grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer";
51+
public static final String UPDATE_ATTACHMENT_ERROR = "Could not update the attachment";
4952

5053
public static String nameConstraintMessage(
5154
List<String> fileNameWithRestrictedCharacters, String operation) {
@@ -67,6 +70,22 @@ public static String nameConstraintMessage(
6770
return bulletPoints.toString();
6871
}
6972

73+
public static String secondaryPropertiesError(List<String> invalidSecondaryProperties) {
74+
// Create the base message
75+
String prefixMessage = "The following secondary properties are not supported.\n\n";
76+
77+
// Initialize the StringBuilder with the formatted message prefix
78+
StringBuilder bulletPoints = new StringBuilder(prefixMessage);
79+
80+
// Append each unsupported file name to the StringBuilder
81+
for (String file : invalidSecondaryProperties) {
82+
bulletPoints.append(String.format("\t• %s%n", file));
83+
}
84+
bulletPoints.append(
85+
"\nPlease contact your administrator for assistance with any necessary adjustments.");
86+
return bulletPoints.toString();
87+
}
88+
7089
public static String getDuplicateFilesError(String filename) {
7190
return String.format(DUPLICATE_FILES_ERROR, filename);
7291
}

sdm/src/main/java/com/sap/cds/sdm/handler/TokenHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public static HttpClient getHttpClient(
311311
DefaultHttpClientFactory.DefaultHttpClientFactoryBuilder builder =
312312
DefaultHttpClientFactory.builder();
313313
if (connectionPoolConfig == null) {
314-
Duration timeout = Duration.ofSeconds((long) SDMConstants.CONNECTION_TIMEOUT);
314+
Duration timeout = Duration.ofSeconds(SDMConstants.CONNECTION_TIMEOUT);
315315
builder.timeoutMilliseconds((int) timeout.toMillis());
316316
builder.maxConnectionsPerRoute(SDMConstants.MAX_CONNECTIONS);
317317
builder.maxConnectionsTotal(SDMConstants.MAX_CONNECTIONS);

0 commit comments

Comments
 (0)