From 4173ea4c6c38c9a2cd221c3a67dcca78acb94a60 Mon Sep 17 00:00:00 2001 From: Feliphe Marinho Date: Thu, 23 Jan 2025 16:47:15 -0300 Subject: [PATCH] LPD-47069 Simplify --- .../sample/ObjectAction2RestController.java | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/workspaces/liferay-sample-workspace/client-extensions/liferay-sample-etc-spring-boot/src/main/java/com/liferay/sample/ObjectAction2RestController.java b/workspaces/liferay-sample-workspace/client-extensions/liferay-sample-etc-spring-boot/src/main/java/com/liferay/sample/ObjectAction2RestController.java index 29503a10006ea0..263b216d18c700 100644 --- a/workspaces/liferay-sample-workspace/client-extensions/liferay-sample-etc-spring-boot/src/main/java/com/liferay/sample/ObjectAction2RestController.java +++ b/workspaces/liferay-sample-workspace/client-extensions/liferay-sample-etc-spring-boot/src/main/java/com/liferay/sample/ObjectAction2RestController.java @@ -6,13 +6,10 @@ package com.liferay.sample; import com.liferay.client.extension.util.spring.boot.BaseRestController; -import com.liferay.petra.string.StringBundler; import org.json.JSONObject; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.oauth2.jwt.Jwt; @@ -20,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.reactive.function.client.WebClient; /** * @author Raymond Augé @@ -45,28 +41,15 @@ public ResponseEntity post( } return new ResponseEntity<>( - WebClient.create( - StringBundler.concat( - lxcDXPServerProtocol, "://", lxcDXPMainDomain, - "/o/headless-admin-user/v1.0/user-accounts/", - modelDTOAccountJSONObject.getLong("id")) - ).patch( - ).accept( - MediaType.APPLICATION_JSON - ).contentType( - MediaType.APPLICATION_JSON - ).bodyValue( + patch( + "Bearer " + jwt.getTokenValue(), new JSONObject( ).put( "alternateName", modelDTOAccountJSONObject.getString("givenName") - ).toString() - ).header( - HttpHeaders.AUTHORIZATION, "Bearer " + jwt.getTokenValue() - ).retrieve( - ).bodyToMono( - String.class - ).block(), + ).toString(), + "/o/headless-admin-user/v1.0/user-accounts/" + + modelDTOAccountJSONObject.getLong("id")), HttpStatus.OK); }