### Run Liferay DXP Locally using Blade CLI Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md These commands demonstrate how to initialize a Liferay DXP bundle, deploy it, and start the server locally using Blade CLI and Gradle Wrapper. This is a common workflow for local development and testing. ```Shell my-project $ blade gw initBundle my-project $ blade gw deploy my-project $ blade server run ``` -------------------------------- ### Run Liferay DXP in Docker using Blade CLI Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md These commands show how to create and start a Docker container for Liferay DXP using Blade CLI and Gradle Wrapper. This provides an isolated and consistent environment for development and deployment. ```Shell my-project $ blade gw createDockerContainer my-project $ blade gw startDockerContainer ``` -------------------------------- ### Create Liferay DXP Bundle as Zip Archive Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command generates a Liferay DXP distribution bundle in a .zip archive format. It's an alternative packaging option for deployment or sharing. ```Shell my-project $ blade gw distBundleZip ``` -------------------------------- ### Create Liferay DXP Bundle as Tar Archive Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command generates a Liferay DXP distribution bundle in a .tar archive format. It's useful for packaging the application for deployment or sharing. ```Shell my-project $ blade gw distBundleTar ``` -------------------------------- ### Resolve Modules Against Target Liferay Version Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md Command to invoke the operation that resolves each module against the target version of Liferay using the platform.bndrun file. ```Shell ./gradlew resolve ``` -------------------------------- ### Liferay Workspace Configuration Properties Reference Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md Reference documentation for various Liferay Workspace configuration properties, detailing their purpose, default values, and impact on the build and development environment. ```APIDOC liferay.workspace.bundle.dist.include.metadata: Description: Set to true to append metadata for the current environment settings and timestamp. Default: false liferay.workspace.dir.excludes.globs: Description: Set a list of glob patterns to exclude from the build lifecycle. All glob patterns start relative to the workspace root directory. liferay.workspace.docker.local.registry.address: Description: Set to the host and port of the local Docker registry. This will enable the user to interact with a Docker registry other than DockerHub (e.g. myregistryaddress.org:5000). liferay.workspace.docker.pull.policy: Description: Set to false to pull the user's local Docker cache first. Default: true liferay.workspace.docker.username: Description: Set this property to the registered user name on DockerHub to avoid conflicts with DockerHub. liferay.workspace.docker.user.access.token: Description: See https://docs.docker.com/docker-hub/access-tokens on how to generate a Docker access token. liferay.workspace.ext.dir: Description: Set the folder that contains all Ext OSGi modules and Ext plugins. Default: ext liferay.workspace.home.dir: Description: Set the folder that contains the Liferay bundle downloaded from the liferay.workspace.bundle.url property. Default: bundles liferay.workspace.java.ee.use.jakarta: Description: Set this to true to opt into Jakarta-compatible tooling and dependencies. Workspace will try to determine whether to use Jakarta dependencies based on the product version, but setting this property will force the use of certain Jakarta dependencies irrespective of the product version. Currently this will affect JSP pre-compilation. Default: false liferay.workspace.modules.default.repository.enabled: Description: Set this to true to configure Liferay CDN as the default repository for module/OSGi projects. Default: true liferay.workspace.modules.dir: Description: Set the folder that contains all module projects. Set to * to search all subdirectories. Default: modules liferay.workspace.modules.jsp.precompile.enabled: Description: Set this to true to compile the JSP files in OSGi modules and have them added to the distributable Zip/Tar. Default: false liferay.workspace.node.lts.codename: Description: Set this property to a Node.js LTS release codename to automatically use the latest Node version and NPM version for that LTS release. See https://github.com/nodejs/Release/blob/main/CODENAMES.md for the list of valid codenames. This file is refreshed once every 30 days. To force workspace to check for new releases, use the system property -Dliferay.workspace.refresh.node.releases. liferay.workspace.node.package.manager: Description: Set this property to npm to build Node.js-style projects using NPM. Default: yarn liferay.workspace.plugins.sdk.dir: Description: Set the folder that contains the Plugins SDK environment. Default: plugins-sdk liferay.workspace.themes.dir: Description: Set the folder that contains Node.js-style theme projects. Default: themes liferay.workspace.themes.java.build: Description: Set this to true to build the theme projects using the Liferay Portal Tools Theme Builder. Default: false liferay.workspace.wars.dir: Description: Set the folder that contains all legacy WAR projects. Set to * to search all subdirectories. Default: modules microsoft.translator.subscription.key: Description: Set the subscription key for Microsoft Translation integration. This is service is used to provide automatic translations for buildLang. target.platform.index.sources: Description: Set this to true if you have enabled the Target Platform plugin (i.e. you have set the above property) and you want to apply the TargetPlatformIDE plugin to the root workspace project. This will cause all of the BOM artifacts jars and their Java sources to be indexed by your IDE. Setting this property to true can slow down your IDE's project synchronization. ``` -------------------------------- ### Build Liferay DXP Docker Image Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command builds a Docker image for the Liferay DXP application. This image can then be used to deploy Liferay DXP in containerized environments. ```Shell my-project $ blade gw buildDockerImage ``` -------------------------------- ### Create All Liferay DXP Bundles as Zip Archives Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command generates all available Liferay DXP distribution bundles in .zip archive format. It's an alternative for creating multiple deployment artifacts simultaneously. ```Shell my-project $ blade gw distBundleZipAll ``` -------------------------------- ### Create All Liferay DXP Bundles as Tar Archives Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command generates all available Liferay DXP distribution bundles in .tar archive format. It's useful for creating multiple deployment artifacts simultaneously. ```Shell my-project $ blade gw distBundleTarAll ``` -------------------------------- ### Liferay Workspace Project Folder Structure Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This snippet illustrates the standard directory layout for a Liferay Workspace project, organizing configurations, modules, and themes into distinct folders. It provides a clear overview of where different project components reside. ```Text my-project ├── configs │ ├── common │ ├── dev │ ├── docker │ ├── local │ ├── prod │ └── uat ├── modules │ ├── apis │ ├── services │ ├── java widgets │ ├── js widgets │ ├── java ee widgets (spring mvc, jsf, etc) │ └── java themes └── themes └── js themes ``` -------------------------------- ### Start Faro Docker Image Source: https://github.com/liferay/liferay-portal/blob/master/modules/dxp/apps/osb/osb-faro/README.md Use this command to start the previously created Faro Docker image, making the Experience Cloud environment available. ```Gradle ./gradlew startDocker ``` -------------------------------- ### Start Liferay Tag Descriptions with a Verb Source: https://github.com/liferay/liferay-portal/blob/master/readme/TAGLIBDOC_GUIDELINES.md Demonstrates the guideline to begin all descriptions with an action verb, providing a clear and concise purpose for the tag, as shown with the 'flags' tag example. ```XML Creates a flag icon that lets users report inappropriate content. flags ... ``` -------------------------------- ### Liferay Workspace Gradle Configuration Properties Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This section documents key Gradle properties used to configure Liferay Workspace behavior. These properties allow customization of product versions, bundle URLs, Docker images, target platforms, and cache directories. ```APIDOC liferay.workspace.product: Description: Sets the Liferay product version, bundle URL, Docker image, and target platform. Individual settings can override this. Value can be 'null' or a 'releaseKey' from https://releases.liferay.com/releases.json. Refreshed every 30 days; force refresh with -Dliferay.workspace.refresh.liferay.releases. app.server.tomcat.version: Description: Overrides the default Tomcat version provided by 'liferay.workspace.product'. Must match the bundled Tomcat version. Default: '9.0.40' if 'liferay.workspace.product' is not set. liferay.workspace.bundle.url: Description: Overrides the default bundle URL provided by 'liferay.workspace.product'. Points to the bundle Zip to download. Default: 'https://releases-cdn.liferay.com/portal/7.3.6-ga7/liferay-ce-portal-tomcat-7.3.6-ga7-20210301155526191.tar.gz' if 'liferay.workspace.product' is not set. liferay.workspace.docker.image.liferay: Description: Overrides the default Docker image provided by 'liferay.workspace.product'. Sets the Liferay Portal Docker image for container creation. Default: 'liferay/portal:7.4.0-ga1' if 'liferay.workspace.product' is not set. liferay.workspace.target.platform.version: Description: Overrides the default target platform version provided by 'liferay.workspace.product'. Sets the Liferay Portal or DXP version for development and testing, enabling target platform features. Must match the bundle version. See GETTING_STARTED#Overwrite-specific-dependency-in-one-project for overrides. Available versions: https://bit.ly/2IkAwwW (Portal), https://bit.ly/2GIyfZF (DXP). Default: '7.4.0' if 'liferay.workspace.product' is not set. liferay.workspace.bundle.cache.dir: Description: Sets the directory where downloaded bundle Zip files are stored. Default: '~/.liferay/bundles'. liferay.workspace.default.repository.enabled: Description: If 'true', configures Liferay CDN as the default repository in the root project. Default: 'true'. liferay.workspace.environment: Description: Sets the environment for current development, using settings from the 'configs' folder. Supports environments like 'common', 'dev', 'docker', 'local', 'prod', 'uat'. ``` -------------------------------- ### Install DB Upgrade Client using JPM Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/portal-tools-db-upgrade-client/README.md Steps to install the DB Upgrade Client using JPM, including installing JPM and then the client. ```Shell jpm install com.liferay.portal.tools.db.upgrade.client liferay-upgrade-db ``` -------------------------------- ### GNU GPL Interactive Program Startup Message Source: https://github.com/liferay/liferay-portal/blob/master/oss-licenses/development/gpl-2.0.txt For interactive programs, this short notice should be displayed when the program starts in interactive mode. It informs users about the program's warranty status and licensing conditions, guiding them to further details via hypothetical commands. ```TEXT Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Configure Liferay Workspace Directory Exclusions Example Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md Example of setting glob patterns to exclude specific directories or files from the Liferay Workspace build lifecycle. Patterns are relative to the workspace root. ```Configuration liferay.workspace.dir.excludes.globs=\\ **/some-wip-project,\\ dependencies/**,\\ modules/**/*-test ``` -------------------------------- ### Create New Liferay JavaScript Theme Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command uses Blade CLI to generate a new Liferay JavaScript theme. Themes define the look and feel of a Liferay portal. ```Shell my-project $ blade create -t js-theme my-theme ``` -------------------------------- ### Liferay Headless Module Path Examples Source: https://github.com/liferay/liferay-portal/blob/master/modules/etl/talend/README.md Examples of valid Open API Module Paths for Liferay I/O components, which must start with `/headless-` and include a version sub-path for REST Builder generated modules. ```APIDOC /headless-delivery-api /headless-commerce-admin-catalog/v1.0 /headless-commerce-delivery-catalog/v1.0 ``` -------------------------------- ### Prepare Talend Studio Environment for Component Installation Source: https://github.com/liferay/liferay-portal/blob/master/modules/etl/talend/README.md Demonstrates how to navigate to a temporary directory, download and unzip the Talend Studio distribution archive, and set the `STUDIO_ROOT` environment variable. This sets up the base directory for subsequent component installation steps. ```Shell cd $HOME/tmp ... download distribution archive ... unzip TOS_ESB-Version.zip STUDIO_ROOT=$HOME/tmp/TOS_ESB-Version ``` -------------------------------- ### Create New Liferay Service Builder Module Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command uses Blade CLI to generate a new Liferay Service Builder module. Service Builder is a Liferay framework for creating and managing data services. ```Shell my-project $ blade create -t service-builder my-service ``` -------------------------------- ### Install DB Upgrade Client by Extracting ZIP Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/portal-tools-db-upgrade-client/README.md Steps to install the DB Upgrade Client by unzipping it into the Liferay instance and running the batch/shell script. ```Shell # Windows db_upgrade_client.bat # Unix db_upgrade_client.sh ``` -------------------------------- ### Create New Liferay JavaScript Widget Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command uses Blade CLI to generate a new Liferay JavaScript widget. JS widgets provide a modern approach to building interactive components in Liferay. ```Shell my-project $ blade create -t js-widget "my-js-widget" ``` -------------------------------- ### Example @see Tag Declaration for Method Reference Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md Provides an example of how to declare an `@see` tag to refer to another method or class for more detailed information. This specific example references the `clearCache()` method within `BasePersistence`. ```Java @see com.liferay.portal.service.persistence.BasePersistence#clearCache() ``` -------------------------------- ### Start Liferay Attribute Descriptions with Noun Source: https://github.com/liferay/liferay-portal/blob/master/readme/TAGLIBDOC_GUIDELINES.md Provides an alternative guideline for starting `` descriptions directly with a noun. This is useful when an article doesn't fit naturally. ```XML Text to display next to the flag icon. ... message ... ``` -------------------------------- ### Example Usage of Database Partition Schema Validator Tool Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/portal-tools-db-partition-schema-validator/README.md Examples demonstrating how to run the Database Partition Schema Validator tool for MySQL and PostgreSQL databases, specifying database name, type, user, and password. ```java java -jar com.liferay.portal.tools.db.partition.schema.validator.jar --db-name xyz123 --db-type mysql --password xyz123 --user xyz123 java -jar com.liferay.portal.tools.db.partition.schema.validator.jar --db-name xyz123 --db-type postgresql --password xyz123 --user xyz123 ``` -------------------------------- ### Correct Liferay Java Method Description Example Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md An example of a well-written Javadoc method description that provides a clear and specific explanation of the method's purpose, demonstrating best practices. ```Java /** * Updates the localized string for the language in the localizations XML. */ public String updateLocalization(String xml, String key, String value, String requestedLanguageId); ``` -------------------------------- ### JSP Function Naming Convention Example Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/src/main/resources/documentation/check/jsp_function_name_check.md Illustrates the correct naming convention for JavaScript functions embedded within JSP files. Function names must start with a lowercase letter or digit, followed by alphanumeric characters and underscores. The example shows an incorrect function name (starting with an uppercase 'P') and its corrected version (starting with a lowercase 'p'). ```JavaScript function PrintPage() { window.open('<%= printPageURL %>'); } ``` ```JavaScript function printPage() { window.open('<%= printPageURL %>'); } ``` -------------------------------- ### Java Javadoc Example for Class Description Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md This Javadoc example illustrates how to provide both an initial concise description and a detailed second paragraph for a Java class, focusing on the `Localization` interface's purpose and caching mechanisms. ```Java Stores and retrieves localized strings from XML, and provides utility methods for updating localizations from JSON, portlet requests, and maps. Used for adding localization to strings, most often for model properties.

Localized values are cached in this class rather than in the value object since value objects get flushed from cache fairly quickly. Though lookups performed on a key based on an XML file are slower than lookups done at the value object level in general, the value object will get flushed at a rate which works against the performance gain. The cache is a soft hash map which prevents memory leaks within the system while enabling the cache to live longer than in a weak hash map.

``` -------------------------------- ### Run Faro Frontend Development Server Source: https://github.com/liferay/liferay-portal/blob/master/modules/dxp/apps/osb/osb-faro/README.md This command starts the frontend development server for Faro. Once running, the application can be accessed in a web browser at `http://localhost:3000`. ```Gradle ./gradlew packageRunStart ``` -------------------------------- ### Example FreeMarker Application Display Template for Liferay Source: https://github.com/liferay/liferay-portal/blob/master/portal-web/test/functional/com/liferay/portalweb/tests/enduser/collaboration/knowledgebase/dependencies/KBArticlesWithMetadata.zip/articles/adt/knowledge-base-article-parent-title-1-child-1.md This FreeMarker template provides a basic example of an Application Display Template (ADT) for Liferay. It checks if `entries` (a list of entities) has content and, if so, iterates through them to display a 'Quick List' with each entity's name, street address, city, and state/province in an unordered list. ```FreeMarker <#if entries?has_content> Quick List:
    <#list entries as curEntry>
  • ${curEntry.name} - ${curEntry.streetAddress}, ${curEntry.city}, ${curEntry.stateOrProvince}
``` -------------------------------- ### REST Builder OpenAPI Path Definition Example Source: https://github.com/liferay/liferay-portal/blob/master/readme/REST_BUILDER_YAML_DOC_GUIDELINES.md An example of an OpenAPI path definition in REST Builder YAML, demonstrating a GET operation for retrieving segment user accounts. It includes parameters for `segmentId`, `page`, and `pageSize`, and defines the 200 response schema with a reference to `SegmentUser`. ```yaml paths: "/segments/{segmentId}/user-accounts": get: operationId: getSegmentUserAccountsPage description: Gets the segment's users. parameters: - description: The segment's ID. in: path name: segmentId required: true schema: format: int64 type: integer - description: The segment's page. in: query name: page schema: type: integer - description: The segment's page size. in: query name: pageSize schema: type: integer responses: 200: content: application/json: schema: items: $ref: "#/components/schemas/SegmentUser" type: array description: "" tags: ["SegmentUser"] ``` -------------------------------- ### Build Talend Components with Maven Source: https://github.com/liferay/liferay-portal/blob/master/modules/etl/talend/README.md This command navigates to the `modules/etl/talend` directory and executes Maven's `clean install` goals. This builds and installs the Talend components, publishing the resulting JAR files to the current user's local Maven repository upon successful completion of all tests. ```sh $ cd modules/etl/talend $ mvn clean install ``` -------------------------------- ### OSGi Bundle-SymbolicName Exceptions: .api and .test Suffixes Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/src/main/resources/documentation/check/java_package_path_check.md When a `Bundle-SymbolicName` ends with `.api` or `.test`, the package name for files inside the module should start with the base name, excluding the `.api` or `.test` suffix. This exception simplifies package naming for API and test modules. Examples include `com.liferay.blogs.api` and `com.liferay.blogs.test`, both leading to packages starting with `com.liferay.blogs`. ```bnd Bundle-SymbolicName: com.liferay.blogs.api ``` ```bnd Bundle-SymbolicName: com.liferay.blogs.test ``` -------------------------------- ### Liferay Language Key Sentence Examples for Form Fields Source: https://github.com/liferay/liferay-portal/blob/master/readme/LANGUAGE_KEY_GUIDELINES_EN.md Examples of language keys formatted as sentences for radio buttons, checkboxes, selectors, and text fields. This style is used particularly when the key starts with an action word followed by long descriptive text, or hints at more options upon selection. ```English Allow subsites to display content from this site. Use the default language options. Define social interactions for users. Define a custom default language and additional available languages for this site. ``` -------------------------------- ### Liferay Language Key Instruction Examples Source: https://github.com/liferay/liferay-portal/blob/master/readme/LANGUAGE_KEY_GUIDELINES_EN.md Examples of language keys used for instructions to the user about a user interface, but not a particular button, selector, or field. These instructions are formatted as sentences. ```English Please enter JDBC information for new database. Select the maps API provider to use when displaying geolocalized assets. ``` -------------------------------- ### Create Faro Docker Image Source: https://github.com/liferay/liferay-portal/blob/master/modules/dxp/apps/osb/osb-faro/README.md This command creates the initial Docker image required to run the Faro Experience Cloud. It only needs to be executed once during the initial setup. ```Gradle ./gradlew createDocker ``` -------------------------------- ### Example Javadoc for DLAppLocalServiceImpl Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md An example Javadoc comment for `DLAppLocalServiceImpl`, demonstrating the pattern for local service implementations. It details the service's purpose, including accessing, adding, deleting, moving, and updating document library entities. ```Java /** * Provides the local service for accessing, adding, deleting, moving, * subscription handling of, trash handling of, and updating document library * file entries, file ranks, and folders. All portlets should interact with * the document library through this class or through DLAppService, rather * than through the individual document library service classes. * * ... ``` -------------------------------- ### Overwrite Dependency Version Across Multiple Gradle Projects Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md Shows how to apply a forced dependency version across all subprojects in a Gradle build, ensuring consistent dependency resolution. ```Gradle subprojects { configurations.all { resolutionStrategy.force 'groupId:artifactId:version` } } ``` -------------------------------- ### Overwrite Specific Dependency Version in Gradle Project Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md Demonstrates how to force a specific version of a dependency within a single Gradle project's compileClasspath configuration using resolutionStrategy.force. ```Gradle configurations { compileClasspath { resolutionStrategy.force 'groupId:artifactId:version` } } ``` -------------------------------- ### Liferay Javadoc Initial Method Description Guidelines Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md Provides guidelines for writing concise initial method descriptions, emphasizing the use of verbs and specific phrasing for common method types like constructors, getters, and setters. Includes general rules for referring to the current instance and parameters. ```APIDOC Method Descriptions - Initial: General Rules: - Always use a verb to describe the method. - When referring to the current instance, say "this something" (e.g., "Returns true if this person is an administrator."). - When referring to parameters, use "the" instead of "a" (e.g., "Returns the localized preferences value for the key."). - Avoid simply restating the method name if its function is not immediately obvious. Preferred Formats: - constructor(value): Constructs a new ... with the *value*. - setSomething(value): Sets the *something of this thing*. - getSomething(): Returns the *something of this thing*. - getSomethings(): Returns the *somethings of this thing*. (Note: do NOT refer to collection type; instead, refer to the something in plural form.) - setSomething(boolean): Sets whether *this thing is something*. - isSomething(): Returns true if *this thing is something*. - deleteSomething(): Deletes the *something*. ``` -------------------------------- ### Example JSDoc Class Comment Structure Source: https://github.com/liferay/liferay-portal/blob/master/readme/JSDOC_GUIDELINES.md This snippet illustrates the recommended structure for JSDoc class comments in Liferay. It includes an initial concise description, a detailed second paragraph, and an example of the @see tag for linking to related classes, demonstrating proper formatting and content order. ```JS /** * Represents an example class. If a basic description requires more than one * sentence, include it in the first paragraph. * *

* Example of a second paragraph. Note the blank line between the first

tag * and the end of the first paragraph. *

* * @see BigExample */ class Example { ... } ``` -------------------------------- ### JSDoc Inline @link Tag Syntax Examples Source: https://github.com/liferay/liferay-portal/blob/master/readme/JSDOC_GUIDELINES.md Provides examples of the `{@link}` tag for creating inline links directly within JSDoc descriptions, referencing classes, methods, objects, and properties with optional display text. ```JSDoc This is similar to {@link class}. This is similar to {@link class#method}. This is similar to {@link class.object}. This is similar to {@link class#property}. This is similar to {@link class#method|method}. ``` -------------------------------- ### Example Database Import with MySQL Source and PostgreSQL Target Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/portal-tools-db-migration-importer/README.md Illustrates a complete command-line execution of the `db_migration_importer.sh` script, specifying source (MySQL) and target (PostgreSQL) JDBC URLs, user credentials, and the path to SQL files for a typical migration. ```Shell ./db_migration_importer.sh --path "/directory/" --source-jdbc-url "jdbc:mysql://localhost:3306/schema" --source-password "xyz123" --source-user "xyz123" --target-jdbc-url "jdbc:postgresql://localhost:5432/schema" --target-password "xyz321" --target-user "xyz321" ``` -------------------------------- ### Detailed Javadoc Validation Checks Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/src/main/resources/documentation/javadoc_checks.md A comprehensive list of Javadoc checks, including validation for `@deprecated` tags, general Javadoc formatting, `@author` presence, and consistency between `@Deprecated` annotation and `@deprecated` tag. ```APIDOC Check: JavaDeprecatedJavadocCheck File Extensions: .java Description: Checks if the `@deprecated` javadoc is pointing to the correct version. Check: JavadocCheck File Extensions: .java Description: Performs several checks on javadoc. Check: JavadocStyleCheck File Extensions: .java Description: Validates Javadoc comments to help ensure they are well formed. Source: https://checkstyle.sourceforge.io/checks/javadoc/javadocstyle.html Check: MissingAuthorCheck File Extensions: .java Description: Finds classes that have no `@author` specified. Check: MissingDeprecatedJavadocCheck File Extensions: .java Description: Verifies that the annotation @Deprecated and the Javadoc tag @deprecated are both present when either of them is present. ``` -------------------------------- ### HTML Links with Virtual Host (Initial Examples) Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/export-import/export-import-test/src/testIntegration/resources/com/liferay/exportimport/internal/content/processor/test/dependencies/dl_references.txt Demonstrates basic HTML `` tag usage for linking to Liferay documents, utilizing the `[$GROUP_PUBLIC_PAGES_VIRTUAL_HOST$]` variable for absolute paths and including `[$UUID$]`, `[$GROUP_ID$]`, `[$TITLE$]`, and `[$TIMESTAMP_ONLY$]` placeholders. ```HTML Link Link ``` -------------------------------- ### Execute Initialization Function Source: https://github.com/liferay/liferay-portal/blob/master/modules/test/jenkins-results-parser/src/main/resources/com/liferay/jenkins/results/parser/dependencies/job/summary/index.html This snippet demonstrates a simple call to an `initialize()` function, which is typically used to set up or prepare a system component or process. The exact functionality depends on the implementation of the `initialize` method. ```JavaScript initialize(); ``` -------------------------------- ### GNU GPL Source File Notice Source: https://github.com/liferay/liferay-portal/blob/master/oss-licenses/development/gpl-2.0.txt This block of text should be attached to the start of each source file of a program licensed under the GNU General Public License. It includes copyright information, redistribution terms, and a disclaimer of warranty, directing users to the full license text. ```TEXT Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ``` -------------------------------- ### LGPL License Notice for Source Files Source: https://github.com/liferay/liferay-portal/blob/master/modules/etl/talend/LICENSES/LGPL-2.1-or-later.txt This snippet provides the standard boilerplate text for the GNU Lesser General Public License (LGPL) to be included at the beginning of each source file of a new library. It includes copyright information, redistribution terms, and warranty disclaimers, along with instructions for obtaining the full license text. ```Plain Text one line to give the library's name and an idea of what it does. Copyright (C) year name of author This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. ``` -------------------------------- ### Liferay Portal Friendly URL Construction Examples Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/export-import/export-import-test/src/testIntegration/resources/com/liferay/exportimport/internal/content/processor/test/dependencies/layout_references.txt This snippet illustrates various methods for constructing friendly URLs in Liferay Portal. It covers different scenarios including links to control panel pages, private and public pages for groups and users, and direct links to specific content assets like web content, blog entries, and document library files. The examples utilize Liferay's placeholder variables to dynamically generate URLs. ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$CONTROL_PANEL_FRIENDLY_URL$][$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$CONTROL_PANEL_FRIENDLY_URL$][$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$CANONICAL_URL_SEPARATOR$][$CONTROL_PANEL_FRIENDLY_URL$][$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$CANONICAL_URL_SEPARATOR$][$CONTROL_PANEL_FRIENDLY_URL$][$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$CANONICAL_URL_SEPARATOR$][$CONTROL_PANEL_FRIENDLY_URL$][$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_GROUP$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$][$PRIVATE_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$LIVE_GROUP_FRIENDLY_URL$][$LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$LIVE_GROUP_FRIENDLY_URL$][$LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$LIVE_GROUP_FRIENDLY_URL$][$LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$PUBLIC_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$PUBLIC_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$PUBLIC_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$] ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$]#section ``` ```HTML [$PATH_CONTEXT$]/en[$PATH_FRIENDLY_URL_PRIVATE_USER$][$GROUP_FRIENDLY_URL$]/ ``` ```HTML [$PATH_CONTEXT$] ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$FRIENDLY_URL_SEPARATOR$]/wc1 ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$WEB_CONTENT_DISPLAY_SERVLET_MAPPING$]/wc1 ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$BLOG_ENTRY_DISPLAY_SERVLET_MAPPING$]/b1 ``` ```HTML [$PATH_CONTEXT$][$PATH_FRIENDLY_URL_PUBLIC$][$GROUP_FRIENDLY_URL$][$DL_ENTRY_DISPLAY_SERVLET_MAPPING$]/d1 ``` ```HTML [$GROUP_PRIVATE_PAGES_VIRTUAL_HOST$][$PATH_CONTEXT$][$NONREPLACEABLE_PRIVATE_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$GROUP_PRIVATE_PAGES_VIRTUAL_HOST$][$PATH_CONTEXT$][$NONREPLACEABLE_PRIVATE_LAYOUT_FRIENDLY_URL$]#section ``` ```HTML [$GROUP_PRIVATE_PAGES_VIRTUAL_HOST$][$PATH_CONTEXT$][$NONREPLACEABLE_PRIVATE_LAYOUT_FRIENDLY_URL$]/ ``` ```HTML [$GROUP_PUBLIC_PAGES_VIRTUAL_HOST$][$PATH_CONTEXT$][$NONREPLACEABLE_PUBLIC_LAYOUT_FRIENDLY_URL$] ``` ```HTML [$GROUP_PUBLIC_PAGES_VIRTUAL_HOST$][$PATH_CONTEXT$][$NONREPLACEABLE_PUBLIC_LAYOUT_FRIENDLY_URL$]#section ``` ```text ``` -------------------------------- ### Deploy all Liferay Client Extensions using Gradle Source: https://github.com/liferay/liferay-portal/blob/master/workspaces/liferay-sample-workspace/README.md This command deploys all client extensions present within the Liferay sample workspace. It should be executed from the root `liferay-sample-workspace` directory. ```Shell ./gradlew deploy ``` -------------------------------- ### Documenting Boolean Parameters in Liferay Javadoc Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md Outlines the rule for describing boolean parameters, stating that the description must always start with 'whether'. It provides examples for booleans indicating a condition or an action to be performed when true. ```Java /** * ... * @param male whether the user is male * @param sendEmail whether to send the user an email notification about * their new account * ... */ public User addUser(..., boolean male, boolean sendEmail, ...) ``` -------------------------------- ### Initialize Terraform for New EKS Cluster Source: https://github.com/liferay/liferay-portal/blob/master/cloud/terraform/aws/installation.md Initializes the Terraform working directory within the `eks` directory, downloading necessary providers and modules required for provisioning a new EKS cluster. ```bash terraform init ``` -------------------------------- ### FreeMarker User Navigation and Authentication Logic Source: https://github.com/liferay/liferay-portal/blob/master/modules/dxp/apps/osb/osb-site-initializer/osb-site-initializer-liferay-online/src/main/resources/site-initializer/fragments/liferay-online/fragments/liferay-online-navbar/index.html This FreeMarker snippet initializes variables for user-specific and public friendly URLs, and dynamically renders navigation options (Dashboard, Notifications, Sign Out) for signed-in users or a Sign In link for guests. It leverages Liferay's `themeDisplay` object for user and URL information, ensuring proper URL escaping for sign-out links. ```FreeMarker [#assign navUserClass = "" privateUserFriendlyURL = themeDisplay.getPathFriendlyURLPrivateUser() + "/" + themeDisplay.getUser().getFirstName() publicFriendlyURL = themeDisplay.getPathFriendlyURLPublic() + themeDisplay.getSiteGroup().getFriendlyURL() publicSiteNavbarClass ="" userName = themeDisplay.getUser().getFirstName() /] [#if !themeDisplay.isSignedIn()] [#assign publicSiteNavbarClass = "logged-in" /] [/#if] [![]([resources:liferay_online_logo.svg])](${publicFriendlyURL})![]([resources:icon_menu.svg]) ![]([resources:icon_close.svg]) [#if themeDisplay.isSignedIn()]* ![]([resources:icon_user_logged.svg]) ${userName} * [Dashboard](${privateUserFriendlyURL}) * [Notifications](${privateUserFriendlyURL}) * [Sign Out](${htmlUtil.escape(themeDisplay.getURLSignOut())}?referer=${publicFriendlyURL}) [#else]* [![]([resources:icon_user_not_logged.svg]) Sign In](${themeDisplay.getURLSignIn()}) [/#if] ``` -------------------------------- ### Create New Liferay Java MVC Portlet Widget Source: https://github.com/liferay/liferay-portal/blob/master/modules/sdk/project-templates/project-templates-workspace/src/main/resources/archetype-resources/GETTING_STARTED.md This command uses Blade CLI to generate a new Liferay Java MVC Portlet. MVC Portlets are standard Java EE web components used to build interactive user interfaces in Liferay. ```Shell my-project $ blade create -t mvc-portlet "my-java-widget" ``` -------------------------------- ### Safely Creating and Retrieving OSGi Configurations in Java Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/documentation/configuration_admin.md This example demonstrates the correct way to create and retrieve OSGi configurations using `ConfigurationAdmin` by specifying `StringPool.QUESTION` (which resolves to '?') for the location parameter. This ensures configurations are shared correctly across bundles and avoids potential errors. ```Java Configuration configuration = _configurationAdmin.createFactoryConfiguration( "com.liferay.captcha.configuration.CaptchaConfiguration", StringPool.QUESTION); Configuration configuration = _configurationAdmin.getConfiguration( "com.liferay.captcha.configuration.CaptchaConfiguration", StringPool.QUESTION); ``` -------------------------------- ### Javadoc for Getter Methods in Liferay Java Source: https://github.com/liferay/liferay-portal/blob/master/readme/ADVANCED_JAVADOC_GUIDELINES.md Illustrates the Javadoc convention for getter methods, requiring the description to start with 'Returns...' to clearly indicate the primary purpose of the method is to provide a value. This example retrieves an Organization object by its primary key. ```Java /** * Returns the organization with the primary key. * * ... */ public Organization getOrganization(long organizationId) ``` -------------------------------- ### FreeMarker Template for Generating Dynamic Tabs Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/site-initializer/site-initializer-extender/site-initializer-extender/src/main/resources/site-initializer/fragments/group/dialect/fragments/dialect-tabs/index.html This FreeMarker template iterates from 0 up to `configuration.numberOfTabs - 1` to create a list of tabs. Each tab's label is 'Tab ${i+1}'. It conditionally includes a Clay icon based on `configuration.iconName` and `configuration.iconAlignment` (left or right). The first line shows a static tab example. ```FreeMarker Tab 1 [@clay["icon"] symbol="caret-bottom" /] [#list 0..configuration.numberOfTabs-1 as i]* [#if configuration.iconAlignment == 'left'] [@clay["icon"] symbol="${configuration.iconName}" /] [/#if] Tab ${i+1} [#if configuration.iconAlignment == 'right'] [@clay["icon"] symbol="${configuration.iconName}" /] [/#if] [/#list] [#list 0..configuration.numberOfTabs-1 as i] [/#list] ``` -------------------------------- ### Creating a Basic Liferay MVC Portlet Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal/portal-zip/src/test/resources/com/liferay/portal/zip/internal/reader/dependencies/1/2/3.txt This Java code illustrates how to create a basic Liferay MVC Portlet. It uses OSGi annotations to define the component properties, including display category, instanceability, display name, and template paths. This serves as the entry point for a web application within the Liferay Portal. ```Java package com.liferay.docs.web; import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet; import javax.portlet.Portlet; import org.osgi.service.component.annotations.Component; @Component( immediate = true, property = { "com.liferay.portlet.display-category=category.sample", "com.liferay.portlet.instanceable=true", "javax.portlet.display-name=My Liferay Portlet", "javax.portlet.init-param.template-path=/", "javax.portlet.init-param.view-template=/view.jsp", "javax.portlet.resource-bundle=content.Language", "javax.portlet.security.role-ref=power-user,user" }, service = Portlet.class ) public class MyLiferayPortlet extends MVCPortlet { } ``` -------------------------------- ### OSGi Bundle-SymbolicName Exceptions for API and Test Modules Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/documentation/package.md These examples demonstrate exceptions to the Bundle-SymbolicName rule for modules ending with .api or .test. In such cases, the actual Java package names within the module should omit the .api or .test suffix, starting directly with the base name (e.g., com.liferay.blogs for com.liferay.blogs.api). ```Configuration Bundle-SymbolicName: com.liferay.blogs.api Bundle-SymbolicName: com.liferay.blogs.test ``` -------------------------------- ### OSGi Module Package Naming Based on Bundle-SymbolicName Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/src/main/resources/documentation/check/java_package_path_check.md For OSGi modules, the package name for all files within the module must align with the `Bundle-SymbolicName` defined in the BND settings. This ensures consistency and proper module identification within the OSGi framework. For example, if the `Bundle-SymbolicName` is `com.liferay.freemarker.osgi.bridge`, all packages in that module should start with this name. ```bnd `Bundle-SymbolicName`: com.liferay.freemarker.osgi.bridge ``` -------------------------------- ### FreeMarker: Iterate Over Tabs (Empty Body) Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/site-initializer/site-initializer-masterclass/src/main/resources/site-initializer/fragments/group/masterclass/fragments/masterclass-tabs/index.html This FreeMarker snippet demonstrates a basic loop iterating `numberOfTabs` times. Although the loop body is empty in this example, it serves as a placeholder for rendering content specific to each tab or for performing actions for each tab without explicit output. ```FreeMarker [#list 0..configuration.numberOfTabs-1 as i] [/#list] ``` -------------------------------- ### Poshi Script `setUp` and `tearDown` Blocks Source: https://github.com/liferay/liferay-portal/blob/master/modules/test/poshi/poshi-script.md `setUp` and `tearDown` blocks are optional but useful constructs in `.testcase` files. `setUp` runs before each `test` block, and `tearDown` runs after each `test` block, allowing for common setup and cleanup operations to be centralized. ```javascript setUp { ... } ``` ```javascript tearDown { ... } ``` -------------------------------- ### Liferay FooLocalService API Reference Source: https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal/portal-zip/src/test/resources/com/liferay/portal/zip/internal/reader/dependencies/1/2/3.txt This section provides a detailed API reference for the `com.liferay.docs.service.FooLocalService`. It outlines the available methods, their parameters with types and descriptions, return types, and potential exceptions. This documentation is crucial for developers consuming the service. ```APIDOC com.liferay.docs.service.FooLocalService Methods: - Foo addFoo(Foo foo, ServiceContext serviceContext) - Description: Adds a new Foo entity. - Parameters: - foo: com.liferay.docs.model.Foo - The Foo object to add. - serviceContext: com.liferay.portal.kernel.service.ServiceContext - The service context. - Returns: com.liferay.docs.model.Foo - The added Foo object. - Throws: com.liferay.portal.kernel.exception.PortalException - Foo createFoo(long fooId) - Description: Creates a new Foo entity with the given ID. - Parameters: - fooId: long - The ID for the new Foo. - Returns: com.liferay.docs.model.Foo - The new Foo object. - List getFoos(int start, int end) - Description: Retrieves a range of Foo entities. - Parameters: - start: int - The starting index. - end: int - The ending index. - Returns: java.util.List - A list of Foo objects. ``` -------------------------------- ### Build JSDoc HTML for an Entire App Suite Source: https://github.com/liferay/liferay-portal/blob/master/readme/JSDOC_GUIDELINES.md Generates JSDoc HTML documentation for an entire app suite. This task can take several minutes as it includes downloading Node. The generated `index.html` file can then be opened to view the comprehensive JSDoc. ```Bash ../../../gradlew appJSDoc ``` -------------------------------- ### FreeMarker Function to Get Core Activity Fields Source: https://github.com/liferay/liferay-portal/blob/master/workspaces/liferay-partner-workspace/client-extensions/liferay-partner-site-initializer-code/site-initializer/fragments/group/src/mdf-request-detail-collection/fragments/activities-list-panel/index.html This FreeMarker function `get_activity_fields` compiles a comprehensive list of fields for a given marketing activity. It includes general details like activity name, type, and tactic, then appends tactic-specific fields retrieved by `get_fields_by_activity`, and finally adds start and end dates. ```FreeMarker [#function get_activity_fields activity] [#return [{ "title": "Activity name", "value": (activity.name)!"-" }, { "title": "Type of Activity", "value": (activity.typeActivity.name)!"-" }, { "title": "Tactic", "value": (activity.tactic.name)!"-" }] + get_fields_by_activity(activity) + [{ "title": "Start Date", "value": (activity.startDate?date?string.short)!"-" }, { "title": "End Date", "value": (activity.endDate?date?string.short)!"-" }] /] [/#function] ``` -------------------------------- ### Creating CreationMenu Instances Using CreationMenuUtil in Java Source: https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/documentation/creation_menu_util.md This snippet illustrates the preferred method for building a `CreationMenu` object by utilizing `CreationMenuUtil`. It shows how to add primary and secondary dropdown items, including dynamic data population based on `AccountEntry` details, for user management actions like 'add user' and 'assign users'. The subsequent code blocks demonstrate less efficient or less readable alternatives to achieve the same outcome, emphasizing why `CreationMenuUtil` is recommended. ```java public CreationMenu getCreationMenu() { return CreationMenuUtil.addPrimaryDropdownItem( dropdownItem -> { dropdownItem.setLabel(LanguageUtil.get(request, "add-user")); } ).addDropdownItem( dropdownItem -> { dropdownItem.putData("action", "selectAccountUsers"); long accountEntryId = ParamUtil.getLong( request, "accountEntryId"); AccountEntry accountEntry = AccountEntryLocalServiceUtil.fetchAccountEntry( accountEntryId); if (accountEntry != null) { dropdownItem.putData( "accountEntryName", accountEntry.getName()); } dropdownItem.setLabel( LanguageUtil.get(request, "assign-users")); } ); } ``` ```java public CreationMenu getCreationMenu() { return new CreationMenu() { { addPrimaryDropdownItem( dropdownItem -> { dropdownItem.setLabel( LanguageUtil.get(request, "add-user")); }); addDropdownItem( dropdownItem -> { dropdownItem.putData("action", "selectAccountUsers"); long accountEntryId = ParamUtil.getLong( request, "accountEntryId"); AccountEntry accountEntry = AccountEntryLocalServiceUtil.fetchAccountEntry( accountEntryId); if (accountEntry != null) { dropdownItem.putData( "accountEntryName", accountEntry.getName()); } dropdownItem.setLabel( LanguageUtil.get(request, "assign-users")); }); } }; } ``` ```java public CreationMenu getCreationMenu() { CreationMenu creationMenu = new CreationMenu(); creationMenu.addPrimaryDropdownItem( dropdownItem -> { dropdownItem.setLabel(LanguageUtil.get(request, "add-user")); }); creationMenu.addDropdownItem( dropdownItem -> { dropdownItem.putData("action", "selectAccountUsers"); long accountEntryId = ParamUtil.getLong( request, "accountEntryId"); AccountEntry accountEntry = AccountEntryLocalServiceUtil.fetchAccountEntry( accountEntryId); if (accountEntry != null) { dropdownItem.putData( "accountEntryName", accountEntry.getName()); } dropdownItem.setLabel( LanguageUtil.get(request, "assign-users")); }); return creationMenu; } ``` -------------------------------- ### Configure Liferay Video Player with FreeMarker Source: https://github.com/liferay/liferay-portal/blob/master/workspaces/liferay-dotcom-workspace/client-extensions/liferay-dotcom-site-initializer-code/site-initializer/fragments/group/liferay-dotcom/fragments/video-embed/index.html This FreeMarker template snippet initializes variables for a video player component, including aspect ratio, overlay style, and IDs for Wistia, YouTube, or an HTML5 video URL. It then conditionally renders the appropriate video player or a placeholder based on the available video source, and optionally displays a play button. ```FreeMarker [#assign aspectRatioHash = { "16:9": "aspect-ratio-16-to-9", "15:7": "aspect-ratio-15-to-7", "8:5": "aspect-ratio-8-to-5", "4:3": "aspect-ratio-4-to-3", "3:2": "aspect-ratio-3-to-2", "1:1": "aspect-ratio", "none": "" }] [#assign aspectRatioClass = aspectRatioHash[configuration.videoPlayerAspectRatio]] [#assign overlayStyle = ""] [#assign overlayStyle += "background-image:url(" + configuration.overlayBackgroundImageUrl + ");"] [#assign wistiaId = configuration.wistiaId /] [#assign youtubeId = configuration.youtubeId /] [#assign html5videoUrl = configuration.html5videoUrl /] [#assign hideOverlay = configuration.hideOverlay] [#if wistiaId != ""] [#elseif youtubeId != ""] [#elseif html5videoUrl != ""] Your browser does not support the video tag. [#else] ![A video placeholder](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAYAAAA7KqwyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAkSURBVHgB7cxBEQAACAIwtH8Pzw52kxD8OBZgNXsPQUOUwCIgAz0DHTyygaAAAAAASUVORK5CYII=) [/#if] [#if configuration.showPlayButton] [/#if] ``` -------------------------------- ### REST Builder YAML Action Style Description Rules Source: https://github.com/liferay/liferay-portal/blob/master/readme/REST_BUILDER_YAML_DOC_GUIDELINES.md Defines the 'Action style' for descriptions in REST Builder YAML files, used for top-level sections. Rules include starting with an action word, capitalizing only the first word and proper nouns, using standard punctuation, and providing clear, concise descriptions with examples. ```APIDOC Rules: - Starts with an action word (e.g., Represents, Provides, Gets). - Capitalize only first word and all proper nouns. - Uses standard sentence punctuation (including periods). - The first sentence should describe the entity clearly. Additional sentences (if necessary) should provide additional details. Examples: - Gets the segment's users. - Represents the user account who created/authored the content. ``` -------------------------------- ### Get Records API Source: https://github.com/liferay/liferay-portal/blob/master/modules/etl/mulesoft/docs/liferay-connector-tech-ref.adoc Documents the Get operation, which exposes all endpoints manipulated by HTTP GET, detailing their parameters and error handling. ```APIDOC Operation: Get Records Description: The Get operation exposes all endpoints that are manipulated by HTTP GET. Parameters: - Endpoint: String Description: Drop down list of available endpoints that support get operation Required: Yes - Path Params: Object Description: Map with path parameter values Required: Yes (if required by endpoint) - Query Params: Object Description: Map with query parameter values Required: No Throws: - LIFERAY:BAD_REQUEST - LIFERAY:CONNECTION_TIMEOUT - LIFERAY:EXECUTION - LIFERAY:INVALID_OAS_DOCUMENT - LIFERAY:NOT_ACCEPTABLE - LIFERAY:NOT_ALLOWED - LIFERAY:NOT_FOUND - LIFERAY:NOT_IMPLEMENTED - LIFERAY:OAUTH2_ERROR - LIFERAY:SERVER_ERROR - LIFERAY:UNAUTHORIZED - LIFERAY:UNSUPPORTED_MEDIA_TYPE ```