1414import org .glassfish .jersey .media .multipart .MultiPartFeature ;
1515
1616import com ._4point .aem .docservices .rest_services .client .RestClient ;
17+ import com ._4point .aem .docservices .rest_services .client .RestClient .GetRequest .Builder ;
1718import com ._4point .aem .docservices .rest_services .client .helpers .AemConfig ;
1819
1920import jakarta .ws .rs .client .Client ;
@@ -41,11 +42,10 @@ public class JerseyRestClient implements RestClient {
4142 * @param client Jersey Client object
4243 */
4344 public JerseyRestClient (AemConfig aemConfig , String target , Supplier <String > correlationIdFn , Client client ) {
44- this . target = configureClient (client ,aemConfig .user (), aemConfig .password ())
45+ this ( configureClient (client ,aemConfig .user (), aemConfig .password ())
4546 .target (aemConfig .url ())
46- .path (target )
47- ;
48- this .correlationIdFn = correlationIdFn ;
47+ .path (target ),
48+ correlationIdFn );
4949 }
5050
5151 /**
@@ -58,6 +58,11 @@ public JerseyRestClient(AemConfig aemConfig, String target, Supplier<String> cor
5858 this (aemConfig , target , correlationIdFn , getClient ());
5959 }
6060
61+ private JerseyRestClient (WebTarget target , Supplier <String > correlationIdFn ) {
62+ this .target = target ;
63+ this .correlationIdFn = correlationIdFn ;
64+ }
65+
6166 private static Client configureClient (Client client , String username , String password ) {
6267 return client .register (MultiPartFeature .class )
6368 .register (HttpAuthenticationFeature .basic (username , password ));
@@ -225,7 +230,7 @@ public MultipartPayload build() {
225230 * Singleton Client-related code
226231 *
227232 */
228- // Safe way to lazily initialize singeleton . See https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
233+ // Safe way to lazily initialize singleton . See https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
229234 private static class ClientHolder {
230235 static final Client INSTANCE = ClientBuilder .newClient ();
231236 }
@@ -249,6 +254,13 @@ public String target() {
249254 public GetRequest .Builder getRequestBuilder () {
250255 return new JerseyGetRequestBuilder ();
251256 }
257+
258+ @ Override
259+ public Builder getRequestBuilder (String additionalPath ) {
260+ WebTarget updatedPath = target .path (additionalPath .startsWith ("/" ) ? additionalPath : "/" + additionalPath );
261+ // Create a GetRequestBuilder for an updated JerseyRestClient path
262+ return new JerseyRestClient (updatedPath , correlationIdFn ).new JerseyGetRequestBuilder ();
263+ }
252264
253265 private final class JerseyGetRequestBuilder extends PayloadBuilder implements GetRequest .Builder {
254266
0 commit comments