-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: auto update client extensions samples
- Loading branch information
1 parent
182accb
commit 753468a
Showing
17 changed files
with
372 additions
and
25 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...feray-sample-workspace/client-extensions/liferay-sample-commerce-checkout-step/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM liferay/jar-runner:latest | ||
|
||
COPY *.jar /opt/liferay/jar-runner.jar | ||
|
||
#ENV LIFERAY_JAR_RUNNER_JAVA_OPTS="-Xmx512m" |
31 changes: 31 additions & 0 deletions
31
...liferay-sample-workspace/client-extensions/liferay-sample-commerce-checkout-step/LCP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"cpu": 1, | ||
"env": { | ||
"LIFERAY_ROUTES_CLIENT_EXTENSION": "/etc/liferay/lxc/ext-init-metadata", | ||
"LIFERAY_ROUTES_DXP": "/etc/liferay/lxc/dxp-metadata" | ||
}, | ||
"environments": { | ||
"infra": { | ||
"deploy": false | ||
} | ||
}, | ||
"id": "__PROJECT_ID__", | ||
"kind": "Deployment", | ||
"livenessProbe": { | ||
"httpGet": { | ||
"path": "/ready", | ||
"port": 58081 | ||
} | ||
}, | ||
"loadBalancer": { | ||
"targetPort": 58081 | ||
}, | ||
"memory": 512, | ||
"readinessProbe": { | ||
"httpGet": { | ||
"path": "/ready", | ||
"port": 58081 | ||
} | ||
}, | ||
"scale": 1 | ||
} |
23 changes: 23 additions & 0 deletions
23
...-sample-workspace/client-extensions/liferay-sample-commerce-checkout-step/assets/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com | ||
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
*/ | ||
|
||
export default function CommerceCheckoutStep() { | ||
const commerceCheckoutStepContainer = document.getElementById( | ||
'commerceCheckoutStepContainer' | ||
); | ||
|
||
const newInput = document.createElement('input'); | ||
|
||
const inputName = | ||
'_com_liferay_commerce_checkout_web_internal_portlet_CommerceCheckoutPortlet_pon'; | ||
|
||
newInput.setAttribute('id', inputName); | ||
newInput.setAttribute('name', inputName); | ||
|
||
newInput.setAttribute('placeholder', 'Purchase order number'); | ||
newInput.setAttribute('type', 'text'); | ||
|
||
commerceCheckoutStepContainer.appendChild(newInput); | ||
} |
40 changes: 40 additions & 0 deletions
40
...ray-sample-workspace/client-extensions/liferay-sample-commerce-checkout-step/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
buildscript { | ||
dependencies { | ||
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.defaults", version: "latest.release" | ||
classpath group: "org.springframework.boot", name: "spring-boot-gradle-plugin", version: "2.7.18" | ||
} | ||
|
||
repositories { | ||
maven { | ||
url new File(rootProject.projectDir, "../../.m2-tmp") | ||
} | ||
|
||
maven { | ||
url "https://repository-cdn.liferay.com/nexus/content/groups/public" | ||
} | ||
} | ||
} | ||
|
||
apply plugin: "com.liferay.source.formatter" | ||
apply plugin: "java-library" | ||
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: "5.3.4" | ||
implementation group: "com.liferay", name: "org.apache.commons.logging", version: "1.2.LIFERAY-PATCHED-2" | ||
implementation group: "org.json", name: "json", version: "20231013" | ||
implementation group: "org.springframework.boot", name: "spring-boot-starter-oauth2-resource-server", version: "2.7.18" | ||
implementation group: "org.springframework.boot", name: "spring-boot-starter-web", version: "2.7.18" | ||
implementation group: "org.springframework.boot", name: "spring-boot-starter-webflux", version: "2.7.18" | ||
} | ||
|
||
repositories { | ||
maven { | ||
url new File(rootProject.projectDir, "../../.m2-tmp") | ||
} | ||
|
||
maven { | ||
url "https://repository-cdn.liferay.com/nexus/content/groups/public" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...e-workspace/client-extensions/liferay-sample-commerce-checkout-step/client-extension.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
assemble: | ||
- from: assets | ||
into: static | ||
- fromTask: bootJar | ||
liferay-sample-commerce-checkout-step: | ||
active: true | ||
checkoutStepLabel: liferay-sample-commerce-checkout-step-label | ||
checkoutStepName: liferay-sample-commerce-checkout-step-name | ||
checkoutStepOrder: 25 | ||
name: Liferay Sample Commerce Checkout Step | ||
oAuth2ApplicationExternalReferenceCode: liferay-sample-commerce-checkout-step-oauth-application-user-agent | ||
order: true | ||
sennaDisabled: true | ||
showControls: true | ||
type: commerceCheckoutStep | ||
visible: true | ||
liferay-sample-commerce-checkout-step-oauth-application-user-agent: | ||
.serviceAddress: localhost:58081 | ||
.serviceScheme: http | ||
name: Liferay Sample Commerce Checkout Step OAuth Application User Agent | ||
scopes: | ||
- Liferay.Headless.Admin.Workflow.everything | ||
type: oAuthApplicationUserAgent |
13 changes: 13 additions & 0 deletions
13
...ray-sample-workspace/client-extensions/liferay-sample-commerce-checkout-step/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"dependencies": { | ||
"react": "16.12.0", | ||
"serve": "^14.2.0" | ||
}, | ||
"description": "Liferay Sample Commerce Checkout Step", | ||
"name": "liferay-sample-commerce-checkout-step", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"workspaces": [ | ||
"src/main/resources/assets/liferay-sample-commerce-checkout-step" | ||
] | ||
} |
62 changes: 62 additions & 0 deletions
62
...-sample-commerce-checkout-step/src/main/java/com/liferay/sample/ActionRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com | ||
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
*/ | ||
|
||
package com.liferay.sample; | ||
|
||
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 Andrea Sbarra | ||
*/ | ||
@RequestMapping("/action") | ||
@RestController | ||
public class ActionRestController extends BaseRestController { | ||
|
||
@PostMapping | ||
public ResponseEntity<String> post( | ||
@AuthenticationPrincipal Jwt jwt, @RequestBody String json) { | ||
|
||
JSONObject jsonObject = new JSONObject(json); | ||
|
||
return new ResponseEntity<>( | ||
WebClient.create( | ||
StringBundler.concat( | ||
lxcDXPServerProtocol, "://", lxcDXPMainDomain, | ||
"/o/headless-commerce-delivery-cart/v1.0/carts/", | ||
jsonObject.getLong("commerceOrderId")) | ||
).patch( | ||
).accept( | ||
MediaType.APPLICATION_JSON | ||
).contentType( | ||
MediaType.APPLICATION_JSON | ||
).bodyValue( | ||
new JSONObject( | ||
).put( | ||
"purchaseOrderNumber", jsonObject.getString("pon") | ||
).toString() | ||
).header( | ||
HttpHeaders.AUTHORIZATION, "Bearer " + jwt.getTokenValue() | ||
).retrieve( | ||
).bodyToMono( | ||
String.class | ||
).block(), | ||
HttpStatus.OK); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...ay-sample-commerce-checkout-step/src/main/java/com/liferay/sample/BaseRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com | ||
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
*/ | ||
|
||
package com.liferay.sample; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.commons.logging.Log; | ||
|
||
import org.json.JSONObject; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
|
||
/** | ||
* @author Raymond Augé | ||
* @author Gregory Amerson | ||
* @author Brian Wing Shun Chan | ||
*/ | ||
public abstract class BaseRestController { | ||
|
||
protected void log(Jwt jwt, Log log) { | ||
if (log.isInfoEnabled()) { | ||
log.info("JWT Claims: " + jwt.getClaims()); | ||
log.info("JWT ID: " + jwt.getId()); | ||
log.info("JWT Subject: " + jwt.getSubject()); | ||
} | ||
} | ||
|
||
protected void log(Jwt jwt, Log log, Map<String, String> parameters) { | ||
if (log.isInfoEnabled()) { | ||
log.info("JWT Claims: " + jwt.getClaims()); | ||
log.info("JWT ID: " + jwt.getId()); | ||
log.info("JWT Subject: " + jwt.getSubject()); | ||
log.info("Parameters: " + parameters); | ||
} | ||
} | ||
|
||
protected void log(Jwt jwt, Log log, String json) { | ||
if (log.isInfoEnabled()) { | ||
try { | ||
JSONObject jsonObject = new JSONObject(json); | ||
|
||
log.info("JSON: " + jsonObject.toString(4)); | ||
} | ||
catch (Exception exception) { | ||
log.error("JSON: " + json, exception); | ||
} | ||
|
||
log.info("JWT Claims: " + jwt.getClaims()); | ||
log.info("JWT ID: " + jwt.getId()); | ||
log.info("JWT Subject: " + jwt.getSubject()); | ||
} | ||
} | ||
|
||
@Value("${com.liferay.lxc.dxp.mainDomain}") | ||
protected String lxcDXPMainDomain; | ||
|
||
@Value("${com.liferay.lxc.dxp.server.protocol}") | ||
protected String lxcDXPServerProtocol; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...y-sample-commerce-checkout-step/src/main/java/com/liferay/sample/ReadyRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com | ||
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
*/ | ||
|
||
package com.liferay.sample; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author Raymond Augé | ||
* @author Gregory Amerson | ||
* @author Brian Wing Shun Chan | ||
*/ | ||
@RequestMapping("/ready") | ||
@RestController | ||
public class ReadyRestController extends BaseRestController { | ||
|
||
@GetMapping | ||
public String get() { | ||
return "READY"; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...-commerce-checkout-step/src/main/java/com/liferay/sample/SampleSpringBootApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com | ||
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
*/ | ||
|
||
package com.liferay.sample; | ||
|
||
import com.liferay.client.extension.util.spring.boot.ClientExtensionUtilSpringBootComponentScan; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Import; | ||
|
||
/** | ||
* @author Raymond Augé | ||
* @author Gregory Amerson | ||
* @author Brian Wing Shun Chan | ||
*/ | ||
@Import(ClientExtensionUtilSpringBootComponentScan.class) | ||
@SpringBootApplication | ||
public class SampleSpringBootApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SampleSpringBootApplication.class, args); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...s/liferay-sample-commerce-checkout-step/src/main/resources/application-default.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# LXC | ||
# | ||
|
||
com.liferay.lxc.dxp.domains=localhost:8080 | ||
com.liferay.lxc.dxp.mainDomain=localhost:8080 | ||
com.liferay.lxc.dxp.server.protocol=http | ||
|
||
# | ||
# OAuth | ||
# | ||
|
||
liferay.oauth.application.external.reference.codes=liferay-sample-commerce-checkout-step-oauth-application-user-agent | ||
liferay.oauth.urls.excludes=/ready | ||
|
||
# | ||
# Spring Boot | ||
# | ||
|
||
server.port=58081 |
4 changes: 4 additions & 0 deletions
4
...xtensions/liferay-sample-commerce-checkout-step/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring.config.import=\ | ||
classpath:/application-default.properties,\ | ||
optional:configtree:${LIFERAY_ROUTES_CLIENT_EXTENSION}/,\ | ||
optional:configtree:${LIFERAY_ROUTES_DXP}/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.