CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-liferay-portal--com-liferay-portal-impl

Core implementation module containing the fundamental services, utilities, and infrastructure components for the Liferay Digital Experience Platform.

Pending
Overview
Eval results
Files

portlet-framework.mddocs/

Portlet Framework

Complete portlet framework implementation including containers, request/response handling, asset management, document library functionality, and custom fields (expando) support for the Liferay portal platform.

Capabilities

Core Portlet Framework

Foundation portlet framework providing complete portlet container implementation with lifecycle management.

/**
 * Base portlet implementation providing common portlet functionality
 */
public abstract class BasePortlet implements Portlet {
    
    /**
     * Initializes the portlet with portal-specific configuration
     * @param portletConfig portlet configuration
     * @throws PortletException if initialization fails
     */
    @Override
    public void init(PortletConfig portletConfig) throws PortletException;
    
    /**
     * Processes action requests from portlet forms
     * @param actionRequest portlet action request
     * @param actionResponse portlet action response
     * @throws PortletException if action processing fails
     * @throws IOException if I/O error occurs
     */
    @Override
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
        throws PortletException, IOException;
    
    /**
     * Renders portlet content for display
     * @param renderRequest portlet render request
     * @param renderResponse portlet render response
     * @throws PortletException if rendering fails
     * @throws IOException if I/O error occurs
     */
    @Override
    public void render(RenderRequest renderRequest, RenderResponse renderResponse)
        throws PortletException, IOException;
    
    /**
     * Cleans up portlet resources
     */
    @Override
    public void destroy();
}

/**
 * Portlet container managing portlet lifecycle and execution
 */
public class PortletContainer {
    
    /**
     * Deploys portlet application
     * @param portletApp portlet application descriptor
     * @throws PortletException if deployment fails
     */
    public void deployPortlet(PortletApp portletApp) throws PortletException;
    
    /**
     * Undeploys portlet application
     * @param portletName portlet name to undeploy
     * @throws PortletException if undeployment fails
     */
    public void undeployPortlet(String portletName) throws PortletException;
    
    /**
     * Gets deployed portlet instance
     * @param portletName portlet name
     * @return Portlet instance or null if not found
     */
    public Portlet getPortlet(String portletName);
    
    /**
     * Lists all deployed portlets
     * @return Set of deployed portlet names
     */
    public Set<String> getDeployedPortlets();
}

Asset Framework

Comprehensive asset management system for handling content assets, metadata, and relationships.

/**
 * Asset entry representing any content asset in the portal
 */
public class AssetEntry {
    
    /**
     * Gets asset entry ID
     * @return asset entry ID
     */
    public long getEntryId();
    
    /**
     * Gets asset title
     * @return asset title
     */
    public String getTitle();
    
    /**
     * Sets asset title
     * @param title asset title
     */
    public void setTitle(String title);
    
    /**
     * Gets asset description
     * @return asset description
     */
    public String getDescription();
    
    /**
     * Sets asset description
     * @param description asset description
     */
    public void setDescription(String description);
    
    /**
     * Gets asset categories
     * @return List of asset categories
     */
    public List<AssetCategory> getCategories();
    
    /**
     * Gets asset tags
     * @return List of asset tags
     */
    public List<AssetTag> getTags();
}

/**
 * Asset service for managing content assets
 */
public interface AssetEntryService {
    
    /**
     * Adds new asset entry
     * @param className asset class name
     * @param classPK asset class primary key
     * @param title asset title
     * @param description asset description
     * @param serviceContext service context
     * @return created AssetEntry
     * @throws PortalException if creation fails
     */
    AssetEntry addEntry(String className, long classPK, String title, String description,
        ServiceContext serviceContext) throws PortalException;
    
    /**
     * Updates existing asset entry
     * @param entryId asset entry ID
     * @param title updated title
     * @param description updated description
     * @param serviceContext service context
     * @return updated AssetEntry
     * @throws PortalException if update fails
     */
    AssetEntry updateEntry(long entryId, String title, String description,
        ServiceContext serviceContext) throws PortalException;
    
    /**
     * Deletes asset entry
     * @param entryId asset entry ID
     * @throws PortalException if deletion fails
     */
    void deleteEntry(long entryId) throws PortalException;
    
    /**
     * Searches for asset entries
     * @param keywords search keywords
     * @param categoryIds category filter IDs
     * @param tagNames tag filter names
     * @return List of matching AssetEntry objects
     */
    List<AssetEntry> searchEntries(String keywords, long[] categoryIds, String[] tagNames);
}

Document Library Framework

Complete document management system with storage backends, version control, and metadata management.

/**
 * Document library folder for organizing documents
 */
public class DLFolder {
    
    /**
     * Gets folder ID
     * @return folder ID
     */
    public long getFolderId();
    
    /**
     * Gets folder name
     * @return folder name
     */
    public String getName();
    
    /**
     * Sets folder name
     * @param name folder name
     */
    public void setName(String name);
    
    /**
     * Gets parent folder ID
     * @return parent folder ID
     */
    public long getParentFolderId();
    
    /**
     * Gets folder description
     * @return folder description
     */
    public String getDescription();
}

/**
 * Document library file entry representing uploaded documents
 */
public class DLFileEntry {
    
    /**
     * Gets file entry ID
     * @return file entry ID
     */
    public long getFileEntryId();
    
    /**
     * Gets file name
     * @return file name
     */
    public String getFileName();
    
    /**
     * Gets file title
     * @return file title
     */
    public String getTitle();
    
    /**
     * Gets file MIME type
     * @return MIME type
     */
    public String getMimeType();
    
    /**
     * Gets file size in bytes
     * @return file size
     */
    public long getSize();
    
    /**
     * Gets file version
     * @return version string
     */
    public String getVersion();
    
    /**
     * Gets file content as input stream
     * @return InputStream for file content
     * @throws IOException if content cannot be accessed
     */
    public InputStream getContentStream() throws IOException;
}

/**
 * Document library service for managing documents
 */
public interface DLFileEntryService {
    
    /**
     * Adds new file entry
     * @param folderId parent folder ID
     * @param fileName file name
     * @param mimeType MIME type
     * @param title file title
     * @param description file description
     * @param changeLog change log message
     * @param bytes file content bytes
     * @param serviceContext service context
     * @return created DLFileEntry
     * @throws PortalException if creation fails
     */
    DLFileEntry addFileEntry(long folderId, String fileName, String mimeType,
        String title, String description, String changeLog, byte[] bytes,
        ServiceContext serviceContext) throws PortalException;
    
    /**
     * Updates file entry content
     * @param fileEntryId file entry ID
     * @param fileName updated file name
     * @param mimeType updated MIME type
     * @param title updated title
     * @param description updated description
     * @param changeLog change log message
     * @param bytes updated file content
     * @param serviceContext service context
     * @return updated DLFileEntry
     * @throws PortalException if update fails
     */
    DLFileEntry updateFileEntry(long fileEntryId, String fileName, String mimeType,
        String title, String description, String changeLog, byte[] bytes,
        ServiceContext serviceContext) throws PortalException;
    
    /**
     * Deletes file entry
     * @param fileEntryId file entry ID
     * @throws PortalException if deletion fails
     */
    void deleteFileEntry(long fileEntryId) throws PortalException;
    
    /**
     * Gets file entries in folder
     * @param folderId folder ID
     * @return List of DLFileEntry objects in folder
     */
    List<DLFileEntry> getFileEntries(long folderId);
}

Document Storage Backends

Flexible document storage implementations supporting various storage backends and configurations.

/**
 * Abstract document store providing storage backend interface
 */
public abstract class Store {
    
    /**
     * Stores file content with specified key
     * @param companyId company ID
     * @param repositoryId repository ID
     * @param fileName file name
     * @param versionLabel version label
     * @param inputStream file content stream
     * @throws SystemException if storage fails
     */
    public abstract void addFile(long companyId, long repositoryId, String fileName,
        String versionLabel, InputStream inputStream) throws SystemException;
    
    /**
     * Retrieves file content as input stream
     * @param companyId company ID
     * @param repositoryId repository ID
     * @param fileName file name
     * @param versionLabel version label
     * @return InputStream for file content
     * @throws SystemException if retrieval fails
     */
    public abstract InputStream getFileAsStream(long companyId, long repositoryId,
        String fileName, String versionLabel) throws SystemException;
    
    /**
     * Deletes file from storage
     * @param companyId company ID
     * @param repositoryId repository ID
     * @param fileName file name
     * @param versionLabel version label
     * @throws SystemException if deletion fails
     */
    public abstract void deleteFile(long companyId, long repositoryId, String fileName,
        String versionLabel) throws SystemException;
    
    /**
     * Checks if file exists in storage
     * @param companyId company ID
     * @param repositoryId repository ID
     * @param fileName file name
     * @param versionLabel version label
     * @return true if file exists
     */
    public abstract boolean hasFile(long companyId, long repositoryId, String fileName,
        String versionLabel);
}

/**
 * File system storage implementation
 */
public class FileSystemStore extends Store {
    // File system-based storage implementation
}

/**
 * Database storage implementation using BLOB fields
 */
public class DBStore extends Store {
    // Database BLOB-based storage implementation
}

/**
 * Amazon S3 storage implementation
 */
public class S3Store extends Store {
    // Amazon S3-based storage implementation
}

Expando (Custom Fields) Framework

Custom fields system allowing dynamic attribute addition to any portal entity.

/**
 * Expando table representing custom field container for entity type
 */
public class ExpandoTable {
    
    /**
     * Gets table ID
     * @return table ID
     */
    public long getTableId();
    
    /**
     * Gets table name
     * @return table name
     */
    public String getName();
    
    /**
     * Gets entity class name this table is for
     * @return entity class name
     */
    public String getClassName();
}

/**
 * Expando column representing individual custom field definition
 */
public class ExpandoColumn {
    
    /**
     * Gets column ID
     * @return column ID
     */
    public long getColumnId();
    
    /**
     * Gets column name
     * @return column name
     */
    public String getName();
    
    /**
     * Gets column data type
     * @return data type constant
     */
    public int getType();
    
    /**
     * Gets default value for column
     * @return default value
     */
    public Serializable getDefaultValue();
    
    /**
     * Sets default value for column
     * @param defaultValue default value
     */
    public void setDefaultValue(Serializable defaultValue);
}

/**
 * Expando value representing actual custom field data for entity instance
 */
public class ExpandoValue {
    
    /**
     * Gets value ID
     * @return value ID
     */
    public long getValueId();
    
    /**
     * Gets entity class primary key this value belongs to
     * @return entity class primary key
     */
    public long getClassPK();
    
    /**
     * Gets column ID this value is for
     * @return column ID
     */
    public long getColumnId();
    
    /**
     * Gets the stored value
     * @return stored value
     */
    public Serializable getValue();
    
    /**
     * Sets the stored value
     * @param value value to store
     */
    public void setValue(Serializable value);
}

/**
 * Expando service for managing custom fields
 */
public interface ExpandoValueService {
    
    /**
     * Adds custom field value for entity
     * @param className entity class name
     * @param tableName table name
     * @param columnName column name
     * @param classPK entity primary key
     * @param value value to store
     * @return created ExpandoValue
     * @throws PortalException if creation fails
     */
    ExpandoValue addValue(String className, String tableName, String columnName,
        long classPK, Serializable value) throws PortalException;
    
    /**
     * Gets custom field value for entity
     * @param className entity class name
     * @param tableName table name
     * @param columnName column name
     * @param classPK entity primary key
     * @return ExpandoValue or null if not found
     */
    ExpandoValue getValue(String className, String tableName, String columnName, long classPK);
    
    /**
     * Updates custom field value
     * @param className entity class name
     * @param tableName table name
     * @param columnName column name
     * @param classPK entity primary key
     * @param value new value
     * @return updated ExpandoValue
     * @throws PortalException if update fails
     */
    ExpandoValue updateValue(String className, String tableName, String columnName,
        long classPK, Serializable value) throws PortalException;
    
    /**
     * Deletes custom field value
     * @param className entity class name
     * @param tableName table name
     * @param columnName column name
     * @param classPK entity primary key
     * @throws PortalException if deletion fails
     */
    void deleteValue(String className, String tableName, String columnName, long classPK)
        throws PortalException;
}

Usage Examples

Portlet Development:

public class CustomPortlet extends BasePortlet {
    
    @Override
    public void render(RenderRequest renderRequest, RenderResponse renderResponse)
            throws PortletException, IOException {
        
        // Get portlet preferences
        PortletPreferences preferences = renderRequest.getPreferences();
        String title = preferences.getValue("title", "Default Title");
        
        // Set render attributes
        renderRequest.setAttribute("title", title);
        renderRequest.setAttribute("data", getPortletData());
        
        // Forward to JSP
        PortletRequestDispatcher dispatcher = getPortletContext()
            .getRequestDispatcher("/html/view.jsp");
        dispatcher.include(renderRequest, renderResponse);
    }
    
    @Override
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
            throws PortletException, IOException {
        
        String action = actionRequest.getParameter("action");
        
        if ("updateSettings".equals(action)) {
            // Update portlet preferences
            PortletPreferences preferences = actionRequest.getPreferences();
            preferences.setValue("title", actionRequest.getParameter("title"));
            preferences.store();
        }
    }
}

Asset Management:

// Create asset entry for custom content
ServiceContext serviceContext = new ServiceContext();
serviceContext.setUserId(userId);
serviceContext.setScopeGroupId(groupId);

AssetEntry entry = assetEntryService.addEntry(
    "com.company.model.CustomContent",
    customContent.getId(),
    customContent.getTitle(),
    customContent.getDescription(),
    serviceContext
);

// Add categories and tags
String[] categoryNames = {"Technology", "Tutorial"};
String[] tagNames = {"java", "portlet", "liferay"};
assetEntryService.updateEntry(entry.getEntryId(), categoryNames, tagNames);

Document Library Usage:

// Upload document
byte[] fileBytes = FileUtil.getBytes(uploadedFile);
DLFileEntry fileEntry = dlFileEntryService.addFileEntry(
    folderId,
    uploadedFile.getName(),
    uploadedFile.getContentType(),
    "Uploaded Document",
    "Document uploaded by user",
    "Initial upload",
    fileBytes,
    serviceContext
);

// Download document
InputStream contentStream = fileEntry.getContentStream();
// Stream content to response

Custom Fields (Expando):

// Add custom field to User entity
expandoValueService.addValue(
    User.class.getName(),
    "CUSTOM_FIELDS",
    "department",
    user.getUserId(),
    "Engineering"
);

// Retrieve custom field value
ExpandoValue departmentValue = expandoValueService.getValue(
    User.class.getName(),
    "CUSTOM_FIELDS", 
    "department",
    user.getUserId()
);

String department = (String) departmentValue.getValue();

Integration with Portal Framework

The portlet framework integrates with:

  • Portal Services - Access to all portal functionality
  • Security Framework - Permission checking and user context
  • Asset Framework - Content tagging and categorization
  • Workflow Engine - Business process integration
  • Search Framework - Content indexing and search
  • Cache Framework - Performance optimization

Error Handling

Common portlet framework exceptions:

  • PortletException - General portlet processing errors
  • PortalException - Portal service operation failures
  • SystemException - System-level errors
  • PrincipalException - Permission and security violations
  • DocumentLibraryException - Document management errors

Best practices include proper exception handling, resource cleanup, comprehensive logging, and graceful error recovery to maintain portal stability.

Install with Tessl CLI

npx tessl i tessl/maven-com-liferay-portal--com-liferay-portal-impl

docs

bean-management.md

database-orm.md

database-upgrades.md

framework-integration.md

index.md

lifecycle-events.md

portlet-framework.md

service-layer.md

template-processing.md

utility-services.md

web-security.md

tile.json