Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Guide for CAP Java 3.0 #892

Merged
merged 48 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
adc39ac
Migration Guide for CAP Java 3.0 (#890)
beckermarc May 2, 2024
8987d74
Changes in cds-maven-plugin (#893)
mofterdinger May 3, 2024
7627561
Update migration.md
mofterdinger May 13, 2024
6671eac
Merge branch 'main' into cap-java-3.0
mofterdinger May 13, 2024
c75f147
Update java/migration.md
mofterdinger May 13, 2024
9c4303b
Fix typo
beckermarc May 14, 2024
4fc2a51
Update migration.md
mofterdinger May 15, 2024
47dd561
Fixed wrong property order (#935)
mofterdinger May 15, 2024
a437877
Merge branch 'main' into cap-java-3.0
beckermarc May 15, 2024
41ca6a9
[CAP Java 3.0] Explain removal of classic MTX in migration guide (#942)
beckermarc May 15, 2024
d12b265
Added table for removed properties (#936)
mofterdinger May 15, 2024
05a8f94
Update migration.md
agoerler Jun 5, 2024
1a8580c
Update java/migration.md
renejeglinsky Jun 6, 2024
a65d87d
describing new semantics of `cds.outbox.persistent.enabled` (#987)
t-bonk Jun 10, 2024
9b22651
Describe changes of goal generate (#993)
mofterdinger Jun 12, 2024
0848cfc
cds.sql.hana.optimizationMode: hex
MattSchur Jun 17, 2024
cbf1925
Java 3 Migration: CqnSearchTermPredicate (#1015)
MattSchur Jun 17, 2024
e1396d8
[3.0] Removal of `cds-feature-xsuaa` (#918)
StefanHenke Jun 18, 2024
95b48e9
Merge remote-tracking branch 'origin/main' into cap-java-3.0
beckermarc Jun 18, 2024
c4b476d
Add removed property
beckermarc Jun 18, 2024
fe7214b
cqn(String) methods
MattSchur Jun 18, 2024
45c9825
$user.tenant
MattSchur Jun 18, 2024
9acb1e8
Merge branch 'main' into cap-java-3.0
beckermarc Jun 19, 2024
120aa0e
3.0: Lazy localization by default (#1023)
beckermarc Jun 19, 2024
5fc2882
Merge branch 'main' into cap-java-3.0
beckermarc Jun 19, 2024
6a7ce06
$user.tenant deprecation
MattSchur Jun 19, 2024
a2b18c2
document cds.auditLog.personalData.throwOnMissingDataSubject change
beckermarc Jun 19, 2024
e5a5f02
Update migration.md
beckermarc Jun 19, 2024
e6d4d9d
CqnSearchPredicate
MattSchur Jun 20, 2024
18e6256
Session Context Variables
MattSchur Jun 20, 2024
72c0fe4
Prohibit star-expand and inline-all (#1039)
vmikhailenko Jun 20, 2024
cbf8639
Apply suggestions from code review
beckermarc Jun 21, 2024
993eda3
Remove warning
beckermarc Jun 21, 2024
0da0d0b
Update minimum versions in general docs
beckermarc Jun 21, 2024
68494d3
[3.0] IAS support in Remote Services and IAS migration guide (#1047)
StefanHenke Jun 25, 2024
97e5327
Merge branch 'main' into cap-java-3.0
smahati Jun 25, 2024
80b9d04
Update java/migration.md
BraunMatthias Jun 26, 2024
ced65c9
added new default value of message service structured flag
t-bonk Jun 26, 2024
4265fe7
changed default value in java messaging docs
t-bonk Jun 26, 2024
063b1e0
fixed link
t-bonk Jun 26, 2024
f130c8f
Update migration.md
beckermarc Jun 26, 2024
a7850c1
Update java/migration.md
beckermarc Jun 26, 2024
a04b33c
Merge branch 'main' into cap-java-3.0
renejeglinsky Jun 27, 2024
c3458aa
Update java/migration.md
renejeglinsky Jun 27, 2024
7cad927
Update java/migration.md
renejeglinsky Jun 27, 2024
ea3e64e
Merge branch 'main' into cap-java-3.0
renejeglinsky Jun 27, 2024
94ecf98
cosmetics
smahati Jul 1, 2024
4d2ccc2
Merge branch 'main' into cap-java-3.0
smahati Jul 1, 2024
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
4 changes: 2 additions & 2 deletions java/developing-applications/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Now, that you're familiar with how to configure your application, start to creat

When running your application in production, it makes sense to strictly disable some development-oriented features.
The production profile configures a set of selected property defaults, recommended for production deployments, at once.
To specify the production profile, set `cds.environment.production.profile` to a Spring profile used in production deployments.
By default the production profile is set to `cloud`. To specify a custom production profile, set `cds.environment.production.profile` to a Spring profile used in your production deployments.

::: tip Production profile = `cloud`
It is recommended to set `cds.environment.production.profile` to `cloud`. The Java Buildpacks set the `cloud` profile for applications by default.
The Java Buildpacks set the `cloud` profile for applications by default.
Other active profiles for production deployments are typically set using the environment variable `SPRING_PROFILES_ACTIVE` on your application in your deployment descriptors (`mta.yaml`, Helm charts, etc.).
:::

Expand Down
205 changes: 191 additions & 14 deletions java/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,198 @@ uacp: Used as link target from Help Portal at https://help.sap.com/products/BTP/

[[toc]]

## CAP Java 2.10 to CAP Java 3.0 { #two-to-three }

## CAP Java 1.34 to CAP Java 2.0 { #one-to-two}
::: warning
This is a **preview** of the changes planned for CAP Java 3.0 (planned to be released June 2024)
beckermarc marked this conversation as resolved.
Show resolved Hide resolved
:::

### Minimum Versions

CAP Java 3.0 increased some minimum required versions:

| Dependency | Minimum Version |
| --- | --- |
| @sap/cds-dk | ^7 |
| Maven | 3.6.3 |
| Cloud SDK | 5.9.0 |

CAP Java 3.0 no longer supports @sap/cds-dk ^6.

### Production Profile `cloud`

The Production Profile now defaults to `cloud`. This ensures that various property defaults suited for local development are changed to recommended secure values for production.

One of the effects of the production profile is that the index page is disabled by default.
If you are using the root path `/` as readiness or liveness probe in Kyma you will need to make adjustments.
It is recommended to use Spring Boot actuator's `/actuator/health` endpoint instead.

[Learn more about the Production Profile.](developing-applications/configuring#production-profile){.learn-more}

### Removed feature `cds-feature-xsuaa`

The feature `cds-feature-xsuaa` has been removed. Support for XSUAA and IAS has been unified under the umbrella of `cds-feature-identity`.

It utilizes [SAP´s `spring-security` library](https://github.com/SAP/cloud-security-services-integration-library/tree/main/spring-security) instead of the deprecated [`spring-xsuaa` library](https://github.com/SAP/cloud-security-services-integration-library/tree/main/spring-xsuaa).

If your application relies on the standard security configuration by CAP Java and depend on one of the CAP starter bundles, it is expected that you don't need to adapt code.

If you have customized the security configuration, you need to adapt it to the new library. If your application had a direct dependency to `cds-feature-xsuaa`, we recommend to adopt one of our starter bundler `cds-starter-cloudfoundry` or `cds-starter-k8s`.
beckermarc marked this conversation as resolved.
Show resolved Hide resolved
beckermarc marked this conversation as resolved.
Show resolved Hide resolved

[Learn more about the security configuration.](./security.md#configure-xsuaa-and-ias-authentication--xsuaa-ias){.learn-more}
renejeglinsky marked this conversation as resolved.
Show resolved Hide resolved
[Learn more about migration to SAP´s `spring-security` library.](https://github.com/SAP/cloud-security-services-integration-library/blob/main/spring-security/Migration_SpringXsuaaProjects.md)

### Removed MTX Classic Support

Support for classic MTX (@sap/cds-mtx) has been removed. For multitenancy using streamlined MTX (@sap/cds-mtxs) is mandatory.
If you are still using MTX Classic refer to the [multitenancy migration guide](../guides/multitenancy/old-mtx-migration).

In addition the deprecated `MtSubscriptionService` API, which has been superseeded by the `DeploymentService` API, has been removed.
As part of this change the compatibility mode for the `MtSubscriptionService` API has been removed. Besides the removal of the Java APIs this includes the following behavioural changes:

- During unsubscribe the tenant's content (e.g. HDI container) is now deleted by default when using the new `DeploymentService` API.
- The HTTP-based tenant upgrade APIs provided by the CAP Java app have been removed. This includes the following endpoints:
- `/mt/v1.0/subscriptions/deploy/**` (GET & POST)
- `/messaging/v1.0/em/<tenant>` (PUT)

### Lazy Localization by default

EDMX resources served by the OData V4 `/$metadata` endpoints are now localized lazily by default.
This significantly reduces EDMX cache memory consumption in case many languages are used.
Note, that this requires at least `@sap/cds-mtxs` in version `1.12.0`.

The cds build no longer generates localized EDMX files by default anymore, but instead generates templated EDMX files and a `i18n.json` containing text bundles.
In case localized EDMX files are still required to be generated, set `--opts contentLocalizedEdmx=true` when calling `cds build`.

### Star-expand and inline-all are no longer permitted

Previously, you could not use expand or inline without explicit paths on draft-enabled entities. Now they are rejected for all entities on application service level.

For example, following statement will not be executed when submitted to an instance of [`ApplicationService`](https://www.javadoc.io/doc/com.sap.cds/cds-services-api/latest/com/sap/cds/services/cds/ApplicationService.html).

```java
Select.from(Books_.class).columns(t -> t.expand());
beckermarc marked this conversation as resolved.
Show resolved Hide resolved
```

This does not impact the OData where the `expand=*` will be transformed to explicit association expand.
beckermarc marked this conversation as resolved.
Show resolved Hide resolved

### Adjusted POJO class generation

Some parameter defaults of the goal `generate` have been adjusted:

| Parameter | Old Value | New Value | Explanation |
| --- | --- | --- | --- |
| `sharedInterfaces` | `false` | `true` | Enables the usage of interfaces generated for the global types with inline anonymous arrayed types in the interfaces generated for actions and functions |
BraunMatthias marked this conversation as resolved.
Show resolved Hide resolved
| `uniqueEventContexts` | `false` | `true` | Determines whether the event context interfaces should be unique for bound actions and functions. |

Both changes are causing the generation of incompatible POJOs. The new defaults can be overwritten by setting the parameters to the old values to get the former POJOs.

### Adjusted Property Defaults

Some property defaults have been adjusted:

| Property | Old Value | New Value | Explanation |
| --- | --- | --- | --- |
| `cds.remote.services.<key>.http.csrf.enabled` | `true` | `false` | Most APIs don't require CSRF tokens. |
| `cds.sql.hana.optimizationMode` | `legacy` | `hex` | SQL for SAP HANA is optimized for the HEX engine. |
| `cds.odataV4.lazyI18n.enabled` | `null` | `true` | Lazy localization is now enabled by default in multitenant scenarios. |
| `cds.auditLog.personalData.throwOnMissingDataSubject` | `false` | `true` | Incomplete personal data annotations should result in an error by default. |

### Adjusted Property Behavior

| Property | New Behavior |
| --- | --- |
| `cds.outbox.persistent.enabled` | Disables all persistent outboxes independent of their specific configuration, if set to `false`. |

### Deprecated Session Context Variables

| Old Variable | Replacement |
| --- | --- |
| `$user.tenant` | `$tenant` |
| `$at.from` | `$valid.from` |
| `$at.to` | `$valid.to` |

### Removed Properties

The following table gives an overview about the removed properties:

| Removed Property | Replacement | Explanation |
| --- | --- | --- |
| `cds.auditlog.outbox.persistent.enabled` | `cds.auditlog.outbox.name` | |
| `cds.dataSource.csvFileSuffix` | `cds.dataSource.csv.fileSuffix` | |
| `cds.dataSource.csvInitializationMode` | `cds.dataSource.csv.initializationMode` | |
| `cds.dataSource.csvPaths` | `cds.dataSource.csv.paths` | |
| `cds.dataSource.csvSingleChangeset` | `cds.dataSource.csv.singleChangeset` | |
| `cds.identity.authConfig.enabled` | `cds.security.authentication.authConfig.enabled` | |
| `cds.messaging.services.<key>.outbox.persistent.enabled` | `cds.messaging.services.<key>.outbox.name` | |
| `cds.multiTenancy.compatibility.enabled` | | MtSubscriptionService API [has been removed](#removed-mtx-classic-support) and compatibility mode is no longer available. |
| `cds.multiTenancy.healthCheck.intervalMillis` | `cds.multiTenancy.healthCheck.interval` | |
| `cds.multiTenancy.mtxs.enabled` | | MTXS is enabled [by default](#removed-mtx-classic-support). |
| `cds.multiTenancy.security.deploymentScope` | | HTTP-based tenant upgrade endpoints [have been removed](#removed-mtx-classic-support). |
| `cds.odataV4.apply.inCqn.enabled` | `cds.odataV4.apply.transformations.enabled` | |
| `cds.odataV4.serializer.enabled` | | The legacy serializer has been removed. |
| `cds.outbox.persistent.maxAttempts` | `cds.outbox.services.<key>.maxAttempts` | |
| `cds.outbox.persistent.storeLastError` | `cds.outbox.services.<key>.storeLastError` | |
| `cds.outbox.persistent.ordered` | `cds.outbox.services.<key>.ordered` | |
| `cds.remote.<key>.destination.headers` | `cds.remote.services.<key>.http.headers` | |
| `cds.remote.<key>.destination.queries` | `cds.remote.services.<key>.http.queries` | |
| `cds.remote.<key>.destination.service` | `cds.remote.services.<key>.http.service` | |
| `cds.remote.<key>.destination.suffix` | `cds.remote.services.<key>.http.suffix` | |
| `cds.remote.<key>.destination.type` | `cds.remote.services.<key>.type` | |
| `cds.security.mock.users.<key>.unrestricted` | | Special handling of unrestricted attributes has been removed, in favor of [explicit modelling](../guides/security/authorization#unrestricted-xsuaa-attributes). |
| `cds.sql.search.useLocalizedView` | `cds.sql.search.model` | |
| `cds.sql.supportedLocales` | | All locales are supported by default for localized entities, as session variables can now be leveraged on all databases. |
| `cds.xsuaa.authConfig.enabled` | `cds.security.authentication.authConfig.enabled` | |

### Removed Java APIs

- Removed deprecated classes:
- `com.sap.cds.services.environment.ServiceBinding`
- `com.sap.cds.services.environment.ServiceBindingAdapter`
- `com.sap.cds.services.mt.MtAsyncDeployEventContext`
- `com.sap.cds.services.mt.MtAsyncDeployStatusEventContext`
- `com.sap.cds.services.mt.MtAsyncSubscribeEventContext`
- `com.sap.cds.services.mt.MtAsyncSubscribeFinishedEventContext`
- `com.sap.cds.services.mt.MtAsyncUnsubscribeEventContext`
- `com.sap.cds.services.mt.MtAsyncUnsubscribeFinishedEventContext`
- `com.sap.cds.services.mt.MtDeployEventContext`
- `com.sap.cds.services.mt.MtGetDependenciesEventContext`
- `com.sap.cds.services.mt.MtSubscribeEventContext`
- `com.sap.cds.services.mt.MtSubscriptionService`
- `com.sap.cds.services.mt.MtUnsubscribeEventContext`

- Removed deprecated methods:
- `com.sap.cds.services.request.ModifiableUserInfo.addUnrestrictedAttribute`
- `com.sap.cds.services.request.ModifiableUserInfo.setUnrestrictedAttributes`
- `com.sap.cds.services.request.ModifiableUserInfo.removeUnrestrictedAttribute`
- `com.sap.cds.services.request.UserInfo.getUnrestrictedAttributes`
- `com.sap.cds.services.request.UserInfo.isUnrestrictedAttribute`
- `com.sap.cds.ql.Insert.cqn(String)`
- `com.sap.cds.ql.Update.cqn(String)`
- `com.sap.cds.ql.Upsert.cqn(String)`

- Deprecations:
- `com.sap.cds.ql.cqn.CqnSearchPredicate`, instead use `CqnSearchTermPredicate`
- `com.sap.cds.ql.cqn.Modifier.search(String)`, instead use `searchTerm(CqnSearchTermPredicate)`

### Removed goals in `cds-maven-plugin`

The goal `addSample` is removed from the `cds-maven-plugin` and replaced with the goal `add` and property `-Dfeature=TINY_SAMPLE`.

## Cloud SDK 4 to 5 { #cloudsdk5 }

CAP Java `2.6.0` and higher is compatible with Cloud SDK in version 4 and 5. For reasons of backward compatibility, CAP Java assumes Cloud SDK 4 as the default. However, we highly recommend to use at least version `5.7.0` of Cloud SDK. To upgrade your CAP Java application to Cloud SDK 5, in most cases, you don't need to adapt any code if you rely on the Cloud SDK integration package (`cds-integration-cloud-sdk`). In these cases, it's sufficient to add the following maven dependency to your CAP Java application:

```xml
<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
<artifactId>connectivity-apache-httpclient4</artifactId>
</dependency>
```

If you are using Cloud SDK APIs explicitly in your code consider the migration guide for Cloud SDK 5 itself: https://sap.github.io/cloud-sdk/docs/java/guides/5.0-upgrade-steps

## CAP Java 1.34 to CAP Java 2.0 { #one-to-two }

This section describes the changes in CAP Java between the major versions 1.34 and 2.0. It provides also helpful information how to migrate a CAP Java application to the new major version 2.0.

Expand Down Expand Up @@ -1040,16 +1230,3 @@ After rebuilding and restarting your application, your Application Services are
<!-- TODO: Move this to "Development" section -->

<span id="afterenablingodata" />

## Cloud SDK 4 to 5 { #cloudsdk5 }

CAP Java `2.6.0` and higher is compatible with Cloud SDK in version 4 and 5. For reasons of backward compatibility, CAP Java assumes Cloud SDK 4 as the default. However, we highly recommend to use at least version `5.2.0` of Cloud SDK. To upgrade your CAP Java application to Cloud SDK 5, in most cases, you don't need to adapt any code if you rely on the Cloud SDK integration package (`cds-integration-cloud-sdk`). In these cases, it's sufficient to add the following maven dependency to your CAP Java application:

```xml
<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
<artifactId>connectivity-apache-httpclient4</artifactId>
</dependency>
```


47 changes: 0 additions & 47 deletions java/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,53 +63,6 @@ CAP Java picks only a single binding of each type. If you have multiple XSUAA or
Choose an appropriate XSUAA service plan to fit the requirements. For instance, if your service should be exposed as technical reuse service, make use of plan `broker`.
:::

### Transition from `cds-feature-xsuaa` to `cds-feature-identity`{ #transition-xsuaa-ias}
CAP also provides support for XSUAA-based authentication via the maven dependency `cds-feature-xsuaa` which is based on the [spring-xsuaa library](https://github.com/SAP/cloud-security-services-integration-library/tree/main/spring-xsuaa).
We recommend to move to `cds-feature-identity`, as the spring-xsuaa library is deprecated. When moving to `cds-feature-identity`, please keep the following in mind:

- As `cds-feature-xsuaa` still takes priority over `cds-feature-identity` for backward compatibility, remove all existing dependencies to `cds-feature-xsuaa` and `xsuaa-spring-boot-starter`.
- If you are using the `cds-starter-cloudfoundry` or the `cds-starter-k8s` starter bundle, make sure to **explicitly** exclude the mentioned dependencies using `<exclusions>...</exclusions>`.

::: code-group

```xml [srv/pom.xml (cds-starter-cloudfoundry)]
<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>cds-starter-cloudfoundry</artifactId>
<exclusions>
<exclusion>
<groupId>com.sap.cds</groupId>
<artifactId>cds-feature-xsuaa</artifactId>
</exclusion>
<exclusion>
<groupId>com.sap.cloud.security.xsuaa</groupId>
<artifactId>xsuaa-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
```

```xml [srv/pom.xml (cds-starter-k8s)]
<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>cds-starter-k8s</artifactId>
<exclusions>
<exclusion>
<groupId>com.sap.cds</groupId>
<artifactId>cds-feature-xsuaa</artifactId>
</exclusion>
<exclusion>
<groupId>com.sap.cloud.security.xsuaa</groupId>
<artifactId>xsuaa-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
```

:::

Now follow the description in [Configure XSUAA and IAS Authentication](#xsuaa-ias).

### Automatic Spring Boot Security Configuration { #spring-boot}

Only if **both, the library dependencies and an XSUAA/IAS service binding are in place**, the CAP Java SDK activates a Spring security configuration, which enforces authentication for all endpoints **automatically**:
Expand Down
Loading