Alfresco is a modern, open-source content management platform that enables organizations to manage enterprise documents, digital assets, and records with efficiency and control. Known for its scalability and compliance-ready architecture, Alfresco provides powerful capabilities such as document storage, versioning, collaboration, workflow automation, and access control. It is widely used across industries to centralize content operations, streamline business processes, and support digital transformation initiatives.
The ballerinax/alfresco
connector offers APIs to connect and interact with the Alfresco endpoints, specifically based on the Alfresco REST API Version 1. This connector allows Ballerina applications to perform core content operations such as uploading and downloading files, managing nodes and folders, setting metadata, and handling permissions. By using the Ballerina Alfresco Connector, developers can easily integrate content services into their workflows and build automation solutions that leverage the full capabilities of the Alfresco platform.
Before using this connector in your Ballerina application, complete the following:
- Create an Alfresco Account.
- Once registered, you will receive an email with instructions to set up your Alfresco environment, including the default username and password. Use these credentials to access the Alfresco Content Services API.
Note: This connector only supports Basic Authentication (username/password) and does not require or support bearer tokens.
To use the Alfresco connector in your Ballerina application, update the .bal file as follows:
First, import the ballerinax/alfresco
module into the Ballerina project.
import ballerinax/alfresco;
Create a alfresco:ConnectionConfig
using the Basic Authentication credentials (i.e: username and password), and initialize the connector with it.
configurable string username = ?;
configurable string password = ?;
configurable string serviceUrl = ?;
alfresco:ConnectionConfig alfrescoConfig = {
auth: {
username,
password
}
};
alfresco:Client alfresco = check new (alfrescoConfig, serviceUrl);
-
Now you can use the operations available within the connector. Note that they are in the form of remote operations.
Following is an example on how to get list of comments in a particular node.
public function main() returns error? { alfresco:CommentPaging response = check alfresco->listComments(nodeId); log:printInfo(response.toString()); }
Use the command below to run the Ballerina application
bal run
The ballerinax/alfresco
connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:
- Upload a Document - Create a new file in Alfresco and upload content to it under a specific folder or path.
- Download a Document - Retrieve a document stored in Alfresco.
-
Download and install Java SE Development Kit (JDK) version 21. You can download it from either of the following sources:
Note: After installation, remember to set the
JAVA_HOME
environment variable to the directory where JDK was installed. -
Download and install Ballerina Swan Lake.
-
Download and install Docker.
Note: Ensure that the Docker daemon is running before executing any tests.
-
Export Github Personal access token with read package permissions as follows,
export packageUser=<Username> export packagePAT=<Personal access token>
Execute the commands below to build from the source.
-
To build the package:
./gradlew clean build
-
To run the tests:
./gradlew clean test
-
To build the without the tests:
./gradlew clean build -x test
-
To run tests against different environments:
./gradlew clean test -Pgroups=<Comma separated groups/test cases>
-
To debug the package with a remote debugger:
./gradlew clean build -Pdebug=<port>
-
To debug with the Ballerina language:
./gradlew clean build -PbalJavaDebug=<port>
-
Publish the generated artifacts to the local Ballerina Central repository:
./gradlew clean build -PpublishToLocalCentral=true
-
Publish the generated artifacts to the Ballerina Central repository:
./gradlew clean build -PpublishToCentral=true
As an open-source project, Ballerina welcomes contributions from the community.
For more information, go to the contribution guidelines.
All the contributors are encouraged to read the Ballerina Code of Conduct.
- For more information go to the
alfresco
package. - For example demonstrations of the usage, go to Ballerina By Examples.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.