Skip to content

Liferay REST Patterns

Liferay REST modules are OSGi-based components that allow developers to create custom RESTful endpoints within the Liferay platform. These modules follow JAX-RS standards while integrating seamlessly with Liferay’s security and dependency injection systems.

graph TD
    A[REST Module] --> B[OSGi Component]
    A --> C[JAX-RS Implementation]
    A --> D[Liferay Integration]
    D --> E[Security]
    D --> F[Service Builder]
    D --> G[DTOs]

The simplest form of REST modules that expose standard CRUD operations.

classDiagram
    class BasicResourceModule {
        +@Path("/basic")
        +@GET getItems()
        +@POST createItem()
        +@PUT updateItem()
        +@DELETE removeItem()
    }

Extensions of Liferay’s headless delivery system for custom content types.

graph LR
    H[Headless Delivery Module] --> A[Content]
    H --> B[Documents]
    H --> C[Custom Types]
    H --> D[Structured Content]

For administrative operations that require elevated permissions.

pie
    title Admin Module Endpoints
    "User Management" : 40
    "Role Management" : 30
    "Site Configuration" : 20
    "System Settings" : 10

Modules that aggregate multiple resources or services into single endpoints.

flowchart TB
    subgraph CompositeModule
        A[User Data] --> C[Endpoint]
        B[Profile Data] --> C
        D[Preferences] --> C
    end

Modules that act as intermediaries between Liferay and external systems.

sequenceDiagram
    Client->>ProxyModule: Request
    ProxyModule->>ExternalSystem: Forward
    ExternalSystem->>ProxyModule: Response
    ProxyModule->>Client: Return
graph TD
    Module --> ApplicationClass
    Module --> ResourceClasses
    Module --> ExceptionMappers
    Module --> Filters

    ApplicationClass -->|Registers| ResourceClasses
    ApplicationClass -->|Configures| Filters
pie
    title Common REST Module Annotations
    "@Path" : 30
    "@GET/POST/PUT/DELETE" : 25
    "@Produces/@Consumes" : 20
    "@Provider" : 15
    "Liferay-specific" : 10
graph LR
    Resources --> Users
    Resources --> Documents
    Resources --> Blogs

    %% Each resource has full CRUD operations
    Users -->|GET| ReadUser
    Users -->|POST| CreateUser
    Documents -->|PUT| UpdateDocument
    Blogs -->|DELETE| RemoveBlog
flowchart TB
    Controller --> Service1
    Controller --> Service2
    Controller --> UnifiedResponse

    Service1 -->|Business Logic| Database
    Service2 -->|Business Logic| ExternalSystem
graph TD
    GatewayModule --> ServiceA
    GatewayModule --> ServiceB
    GatewayModule --> ServiceC

    ServiceA -->|Data| MicroserviceA
    ServiceB -->|Data| MicroserviceB
    ServiceC -->|Data| MicroserviceC

Key Characteristics of Liferay REST Modules

Section titled “Key Characteristics of Liferay REST Modules”
  1. OSGi-based: Deployed as modular components
  2. JAX-RS Compliant: Standard implementation
  3. Liferay Integrated: Security, DTOs, exceptions
  4. Versionable: Support for API versioning
  5. Documentable: OpenAPI/Swagger support
graph LR
    Characteristics --> Scalability
    Characteristics --> Security
    Characteristics --> Maintainability
    Characteristics --> StandardCompliance