liferay-sample-workspace
folder, run blade gw initBundle
to download and install a bundles
subfolder into your workspace folder, containing all the components needed to start a Liferay local instance on your local machine../bundles/tomcat-9.X.X/bin
subfolder.blade server start
or blade server start -d
debug mode (for Linux users) to start a Liferay DXP local instance.deploy
folder to register a Liferay license for DXP Development.localhost:8080
.blade gw deploy
command to download aBadgend install the dependencies needed to deploy the modules.blade sh lb sample
.Active
state.Liferay.postman_collection.json
within the postman
folder. baseUrl
variable defined.Sample Module External API
and Sample Module Liferay API
collection, just opening the desired request and click on Send (Note: your Liferay DXP instance must be running!).GET Samples
request (for both collections) would be:OK
example file from the Sample Module External API
collection to represent the response of each request....
Liferay.mockoon_collection.json
within the mockoon
folder. http://localhost:3001/samples
docker build -t mock-server-image mock-server
docker run --rm -d -p 3000:3000 --name mock-server -v "$(pwd)/mock-server/samples:/db" mock-server-image
http://localhost:3000/samples
To stop, just run docker rm -f mock-server
api-base-url
and change it to http://localhost:3001
and update.The scheme below illustrates the workflow of a Liferay web service.
The Resilience4j library has some fault tolerance patterns and in this project, the Circuit Breaker pattern was implemented.
The application recognizes by pre-defined configurations, to make the transition from close state to open state and the reestablishment of the closed circuit.
Settings can be set in two places, in the project configuration file /liferay-sample-workspace/bundles/osgi/configs/com.liferay.sample.module.ws.config.RestAPIConfiguration.config
and in the portal control panel Control Panel -> System Settings -> category.liferay-confguration
.
For this project, three settings have been defined to recognize and initiate the open state: Minimum Number Of Calls, Failure Rate Threshold and Wait Duration In Open State.
Control Panel -> System Settings -> category.liferay-confguration -> api-base-url
in the portal or edit the value in line 1 of the /liferay-sample project file -workspace/bundles/osgi/configs/com.liferay.sample.module.ws.config.RestAPIConfiguration.config
for a url that has no service/content to return. Upon reaching the values configured for: Minimum Number Of Calls, Failure Rate Threshold and Wait Duration In Open State, fault tolerance will occur and the message will be displayed: CircuitBreaker 'api-name' is OPEN and does not allow further calls
at the Postman's response or in the browser's console.liferay-sample-module-js-web
module corresponds to the frontend layer of the entire module, i.e., the view layer of the MVC portlet architecture. liferay-sample-module-web-rest
.liferay-sample-module-web-rest
module corresponds to the application component, i.e., the controller layer of the MVC portlet architecture. liferay-sample-module-api
module.liferay-sample-module-api
module contains the model and service definition, in this project the SampleObject
model and the SampleService
interface.liferay-sample-module-service
module, both of these modules corresponds to the model layer of the MVC portlet architecture.liferay-sample-module-service
is responsable for implementing those methods defined within the SampleService
interface, at liferay-sample-module-api
module. liferay-sample-module-service
module sends the users' request to the liferay-sample-module-ws-client
module and takes its response, sending back to the previous modules.liferay-sample-module-service
module includes a SampleServiceMapper
class, which maps specific entities' properties from the client-side to corresponding attributes defined within the SampleObject
model.liferay-sample-module-js-web
).liferay-sample-module-ws-client
module is the responsable for sending requests to external APIs and sending a response
object back to the previous modules.liferay-sample-module-tests
module includes all functional tests related to the Page Objects defined, leveraging Selenium framework features.npm cypress:open
or yarn cypress:open
.
3001
.yarn
and yarn test
.blade gw deploy
and occur this error: Task :modules:liferay-sample-module:liferay-sample-module-js-web:packageRunTest FAILED
in you terminal go to the project workspace, in the modules folder, run the command nano build.gradle
and change the value of packageRunTest.enabled
to false, save the file, back to the project folder and run blade gw deploy
again.Create a Liferay Module Project inside a Liferay Workspace (modules
directory). Make sure to use the form-field
project template. For component class name, write Sample
and for package, com.liferay.sample.workspace
. A sample-custom-form-field
project would have the following default files:
SampleDDMFormFieldType.java
: defines the form field type in the back-end.Language_xx_XX.properties
: defines any terms that must be translated into different languages.sample-custom-form-field.es.js
: this is the JavaScript file that configures the template rendering (the sample-custom-form-field.soy rendering).sample-custom-form-field.soy
: the template that defines the appearance of the custom field.sample-custom-form-fieldRegister.soy
: it defines the delegated template for the custom field.bnd.bnd
: the module’s metadata.build.gradle
: the module’s dependencies and build properties.package-lock.json
: automatically generated (after deploying) to track the npm modules dependencies.package.json
: the npm module manager.It extends the BaseDDMFormFieldType
abstract class that implements the DDMFormFieldType
interface, including the default form configuration options for our new form field type. Also, it overrides the interface’s getName
method. DDMFormFieldType
Components can have several properties:
ddm.form.field.type.description
: an optional property describing the field type. Its localized value appears in the form builder’s sidebar, just below the field’s label.ddm.form.field.type.display.order
: an Integer defining the field type’s position in the sidebar.ddm.form.field.type.group
: a property describing the field type’s group.ddm.form.field.type.icon
: the icon for the field type. Choosing one of the Lexicon icons makes your form field blend in with the existing form field types.ddm.form.field.type.label
: the field type’s label. Its localized value appears in the form builder’s sidebar.ddm.form.field.type.name
: the field type’s name must be unique. Each Component in a field type module references the field type name, and it’s used by OSGi service trackers to filter the field’s capabilities (for example, rendering and validation).There are four important things to check in the template:
sample-custom-form-fieldRegister.soy
file, it is set the template that’s called to render the sample custom form field. The variant="'sampleCustomFormField'"
identifies the sample field, and the .render
names the template that renders it. The template itself follows and is defined through the block {template .render}...{/template}
.sample-custom-form-field.soy
file describes the template parameters. All listed parameters are available by default through the {template .render}...{/template}
block.{template .content}...{/template}
block.For branches, we have a set of two main information: the project's abbreviation, in this case, LSW, and the issue's number, for example: LSW-46
.
git checkout -b LSW-46
For commit messages, there are three main information: the branch's name, the key verb, and the message itself.
The key verb should always be capitalized (firt letter in uppercase), for example: Add
, Change
, Fix
, Remove
.
git commit -m "LSW-46 Add documentation on README.MD"
LSW-46 Add documentation on README.MD
LSW-46 Fix merge conflicts