Skip to content

Commit

Permalink
chore: auto update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 29, 2024
1 parent 544021d commit 30c23a0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions liferay-sample-etc-spring-boot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ apply plugin: "org.springframework.boot"

dependencies {
implementation group: "com.liferay", name: "com.liferay.client.extension.util.spring.boot", version: "latest.release"
implementation group: "com.liferay", name: "com.liferay.petra.string", version: "latest.release"
implementation group: "com.liferay", name: "org.apache.commons.logging", version: "1.2.LIFERAY-PATCHED-2"
implementation group: "net.datafaker", name: "datafaker", version: "1.9.0"
implementation group: "org.json", name: "json", version: "20231013"
Expand Down
1 change: 1 addition & 0 deletions liferay-sample-etc-spring-boot/client-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ liferay-sample-etc-spring-boot-oauth-application-user-agent:
.serviceScheme: http
name: Liferay Sample Etc Spring Boot OAuth Application User Agent
scopes:
- Liferay.Headless.Admin.User.everything
- Liferay.Headless.Admin.Workflow.everything
type: oAuthApplicationUserAgent
liferay-sample-etc-spring-boot-object-action-1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

package com.liferay.sample;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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;
import org.springframework.web.bind.annotation.PostMapping;
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é
Expand All @@ -30,12 +34,39 @@ public class ObjectAction2RestController extends BaseRestController {
public ResponseEntity<String> post(
@AuthenticationPrincipal Jwt jwt, @RequestBody String json) {

log(jwt, _log, json);
JSONObject jsonObject = new JSONObject(json);

return new ResponseEntity<>(json, HttpStatus.OK);
}
JSONObject modelDTOAccountJSONObject = jsonObject.getJSONObject(
"modelDTOAccount");

private static final Log _log = LogFactory.getLog(
ObjectAction2RestController.class);
if (modelDTOAccountJSONObject == null) {
return new ResponseEntity<>(json, HttpStatus.OK);
}

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(
new JSONObject(
).put(
"alternateName",
modelDTOAccountJSONObject.getString("givenName")
).toString()
).header(
HttpHeaders.AUTHORIZATION, "Bearer " + jwt.getTokenValue()
).retrieve(
).bodyToMono(
String.class
).block(),
HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#
# LXC
#

com.liferay.lxc.dxp.domains=localhost:8080
com.liferay.lxc.dxp.mainDomain=localhost:8080
com.liferay.lxc.dxp.server.protocol=http

#
# OAuth
#
Expand Down

0 comments on commit 30c23a0

Please sign in to comment.