From 0ea88e6baac7bf19cd786aca927b75f710f6b826 Mon Sep 17 00:00:00 2001 From: Marinov Date: Wed, 20 Aug 2025 09:16:17 +0300 Subject: [PATCH] Seamless handling of Cross-level consumption of destination-fragment pairs --- .../TransparentProxyDestination.java | 32 +++++++++++++++++++ .../TransparentProxyDestinationTest.java | 8 +++++ 2 files changed, 40 insertions(+) diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java index ef281cd72..0892eaf15 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java @@ -38,6 +38,8 @@ public class TransparentProxyDestination implements HttpDestination static final String TENANT_SUBDOMAIN_HEADER_KEY = "x-tenant-subdomain"; static final String TENANT_ID_HEADER_KEY = "x-tenant-id"; static final String FRAGMENT_OPTIONAL_HEADER_KEY = "x-fragment-optional"; + static final String DESTINATION_LEVEL_HEADER_KEY = "x-destination-level"; + static final String FRAGMENT_LEVEL_HEADER_KEY = "x-fragment-level"; static final String TOKEN_SERVICE_TENANT_HEADER_KEY = "x-token-service-tenant"; static final String CLIENT_ASSERTION_HEADER_KEY = "x-client-assertion"; static final String CLIENT_ASSERTION_TYPE_HEADER_KEY = "x-client-assertion-type"; @@ -675,6 +677,36 @@ public GatewayBuilder fragmentName( @Nonnull final String fragmentName ) return header(new Header(FRAGMENT_NAME_HEADER_KEY, fragmentName)); } + /** + * Sets the destination level for the destination-gateway. See https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations + * + * @param destinationLevel + * The level of the destination to use. + * @return This builder instance for method chaining. + */ + @Nonnull + public GatewayBuilder destinationLevel( + @Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope destinationLevel ) + { + return header(new Header(DESTINATION_LEVEL_HEADER_KEY, destinationLevel.toString())); + } + + /** + * Sets the fragment level for the destination-gateway. See https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations + * + * @param fragmentLevel + * The level of the fragment to use. + * @return This builder instance for method chaining. + */ + @Nonnull + public GatewayBuilder fragmentLevel( + @Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope fragmentLevel ) + { + return header(new Header(FRAGMENT_LEVEL_HEADER_KEY, fragmentLevel.toString())); + } + /** * Sets the fragment optional flag for the destination-gateway. See https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations diff --git a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java index 45539ba81..77408a4d5 100644 --- a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java +++ b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java @@ -75,14 +75,22 @@ void testGatewayHeaders() final TransparentProxyDestination destination = TransparentProxyDestination .gateway(TEST_DEST_NAME, VALID_URI.toString()) + .destinationLevel(DestinationServiceOptionsAugmenter.CrossLevelScope.SUBACCOUNT) .fragmentName("fragName") + .fragmentLevel(DestinationServiceOptionsAugmenter.CrossLevelScope.PROVIDER_SUBACCOUNT) .fragmentOptional(true) .build(); assertThat(destination.getHeaders(VALID_URI)) .contains( new Header(TransparentProxyDestination.DESTINATION_NAME_HEADER_KEY, TEST_DEST_NAME), + new Header( + TransparentProxyDestination.DESTINATION_LEVEL_HEADER_KEY, + DestinationServiceOptionsAugmenter.CrossLevelScope.SUBACCOUNT.toString()), new Header(TransparentProxyDestination.FRAGMENT_NAME_HEADER_KEY, "fragName"), + new Header( + TransparentProxyDestination.FRAGMENT_LEVEL_HEADER_KEY, + DestinationServiceOptionsAugmenter.CrossLevelScope.PROVIDER_SUBACCOUNT.toString()), new Header(TransparentProxyDestination.FRAGMENT_OPTIONAL_HEADER_KEY, "true")); }