1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import java.io.File ; 23 24 import org.apache.lenya.cms.publication.Document; 25 import org.apache.lenya.cms.publication.DocumentBuilder; 26 import org.apache.lenya.cms.publication.DocumentException; 27 import org.apache.lenya.cms.publication.Label; 28 import org.apache.lenya.cms.publication.Publication; 29 import org.apache.lenya.cms.publication.SiteTree; 30 import org.apache.lenya.cms.publication.SiteTreeNode; 31 import org.apache.lenya.cms.publication.SiteTreeNodeVisitor; 32 import org.apache.lenya.cms.scheduler.LoadQuartzServlet; 33 import org.apache.tools.ant.BuildException; 34 35 38 public class DeleteSchedulerEntryTask extends PublicationTask implements SiteTreeNodeVisitor { 39 40 43 public void execute() throws BuildException { 44 try { 45 log("Document ID: [" + documentId + "]"); 46 log("Area: [" + area + "]"); 47 48 Publication publication = getPublication(); 49 SiteTree tree = publication.getTree(area); 50 SiteTreeNode node = tree.getNode(documentId); 51 52 node.acceptSubtree(this); 53 } catch (Exception e) { 54 throw new BuildException(e); 55 } 56 } 57 58 private String area, documentId, servletContextPath; 59 60 63 public void setArea(String string) { 64 area = string; 65 } 66 67 70 public void setDocumentId(String string) { 71 documentId = string; 72 } 73 74 78 public void setServletContextPath(String servletContextPath) { 79 this.servletContextPath = servletContextPath; 80 } 81 82 85 public void visitSiteTreeNode(SiteTreeNode node) throws DocumentException { 86 Publication publication = getPublication(); 87 88 Label[] labels = node.getLabels(); 89 for (int i = 0; i < labels.length; i++) { 90 91 String language = labels[i].getLanguage(); 92 DocumentBuilder builder = publication.getDocumentBuilder(); 93 94 try { 95 String url = builder.buildCanonicalUrl(publication, area, documentId, language); 96 Document document = builder.buildDocument(publication, url); 97 98 String servletContext = new File (servletContextPath).getCanonicalPath(); 99 log("Deleting scheduler entry for document [" + document + "]"); 100 log("Resolving servlet [" + servletContext + "]"); 101 102 LoadQuartzServlet servlet = LoadQuartzServlet.getServlet(servletContext); 103 servlet.deleteDocumentJobs(document); 104 105 } catch (Exception e) { 106 throw new DocumentException(e); 107 } 108 109 } 110 } 111 112 } 113 | Popular Tags |