}
DotConnect dc = new DotConnect();
// Remove HTML Pages
HTMLPageAPI htmlPageAPI = APILocator.getHTMLPageAPI();
List<HTMLPage> pages = htmlPageAPI.findHtmlPages(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
for (HTMLPage page : pages) {
htmlPageAPI.delete(page, user, respectFrontendRoles);
}
// Remove Links
MenuLinkAPI linkAPI = APILocator.getMenuLinkAPI();
List<Link> links = linkAPI.findLinks(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
for (Link link : links) {
linkAPI.delete(link, user, respectFrontendRoles);
}
// Remove Contentlet
ContentletAPI contentAPI = APILocator.getContentletAPI();
List<Contentlet> contentlets = contentAPI.findContentletsByHost(host, user, respectFrontendRoles);
for (Contentlet contentlet : contentlets) {
contentAPI.delete(contentlet, user, respectFrontendRoles);
}
// Remove Folders
FolderAPI folderAPI = APILocator.getFolderAPI();
List<Folder> folders = folderAPI.findFoldersByHost(host, user, respectFrontendRoles);
for (Folder folder : folders) {
folderAPI.delete(folder, user, respectFrontendRoles);
}
// Remove Templates
TemplateAPI templateAPI = APILocator.getTemplateAPI();
List<Template> templates = templateAPI.findTemplates(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
for (Template template : templates) {
dc.setSQL("delete from template_containers where template_id = ?");
dc.addParam(template.getIdentifier());
dc.loadResult();
dc.setSQL("select inode, identifier from htmlpage where template_id = ?");
dc.addParam(template.getIdentifier());
List<HashMap<String, Object>> htmlpages = dc.loadResults();
for (HashMap<String, Object> folderMap : htmlpages) {
String identifier = (String) folderMap.get("identifier");
HTMLPage page = htmlPageAPI.loadWorkingPageById(identifier, user, respectFrontendRoles);
htmlPageAPI.delete(page, user, respectFrontendRoles);
}
templateAPI.delete(template, user, respectFrontendRoles);
}