Projects API in AEM

 

AEM included a concept of ‘Project’ along with its Touch UI navigation. Projects allows you to have a collection of all the related resources for a project together. Resources includes Sites, workflows, Assets, Launches etc. Read AEM-Projects to know more on Projects.

projects

project-resources

With this console, you can access and take actions on your projects. You can create the project with the predefined project templates and associate the related resources. Similarly, you will also be able to delete a project or a resource respectively. Check here to know about managing projects.

templates

 

Projects API

There is a Projects API available to create the same programmatically

Package com.adobe.cq.projects.api

Project is an interface which holds all the properties of a project like title, description, member etc

ProjectManager is an interface which has the methods to create, delete projects

Example

Now, let us see how to use those API with the below example. I have tried to use both Projects and ProjectManager interfaces showing the basic functionality of how to

  • Create a Project
  • Retrieve a Project and
  • Delete a Project

Create

If you quickly want to check how it works, you can download the example project from github or

Create a new AEM maven multi module project. You can refer this blog to see how to create the same. Add the below two classes in the bundle

Service

ServiceImpl

Note: I have used a subService called ‘writeService’ to get the resource resolver. Make sure you create the same or use the existing subservice if you have already created. If like to know how to create the same, then refer this blog

Build and Install

Once you have a project created, build and install the bundle using the mvn command

Mvn clean install –PautoInstallBundle

Test

You can check the Projects console and see if the new project created.

new-project

project-modules

 

You can also check the logs. First time when you install the bundle it creates the project.

initial-log

When you install it again, it retrieves and deletes the existing project and create the project again.

recreate-log

 

Hope this examples helps you to know how to use the Projects APIs

3 thoughts on “Projects API in AEM

  1. Thanks for the example, was very helpful.

    Have you also tried to assign Users and Roles to the created project?

     

Leave a Reply

Your email address will not be published. Required fields are marked *