Expand my Community achievements bar.

SOLVED

Deleting Completed Project in aem 6.5 using Servlet

Avatar

Level 2

Hi, 

 

Can anyone please help me with the how to write servlet for deleting the completed project in aem 6.5

 

Thanks & Regards,

Madhu

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @madhuyadawad,

This is possible. You can use ProjectManager, Project, ProjectFilter java api, for this action:

Sample code, you could put inside servlet:

import com.adobe.cq.projects.api.ProjectManager;
import com.adobe.cq.projects.api.Project;
import java.util.Iterator;

ProjectManager projectManager = resourceResolver.adaptTo(ProjectManager.class);
Iterator<Project> iterator = projectManager.getProjects(null, 0, 100);
while(iterator.hasNext()) {
    Project project = iterator.next();
    if (project != null && !project.isActive()) {
        projectManager.deleteProject(project);
        resourceResolver.commit();
    }
}

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @madhuyadawad,

This is possible. You can use ProjectManager, Project, ProjectFilter java api, for this action:

Sample code, you could put inside servlet:

import com.adobe.cq.projects.api.ProjectManager;
import com.adobe.cq.projects.api.Project;
import java.util.Iterator;

ProjectManager projectManager = resourceResolver.adaptTo(ProjectManager.class);
Iterator<Project> iterator = projectManager.getProjects(null, 0, 100);
while(iterator.hasNext()) {
    Project project = iterator.next();
    if (project != null && !project.isActive()) {
        projectManager.deleteProject(project);
        resourceResolver.commit();
    }
}