1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 25 import org.apache.avalon.excalibur.io.FileUtil; 26 import org.apache.lenya.cms.publication.Publication; 27 import org.apache.lenya.cms.publication.SiteTree; 28 import org.apache.lenya.cms.publication.SiteTreeNode; 29 import org.apache.tools.ant.BuildException; 30 31 35 public class DeleteRCTask extends TwoDocumentsOperationTask { 36 private String rcmldir = ""; 37 private String rcbakdir = ""; 38 private String srcareadir = ""; 39 40 43 public DeleteRCTask() { 44 super(); 45 } 46 47 50 public void visitSiteTreeNode(SiteTreeNode node) { 51 String publicationPath; 52 String rcmlDirectory; 53 String rcbakDirectory; 54 try { 55 publicationPath = this.getPublicationDirectory().getCanonicalPath(); 56 rcmlDirectory = 57 new File (publicationPath, this.getRcmldir()).getCanonicalPath(); 58 rcbakDirectory = 59 new File (publicationPath, this.getRcbakdir()) 60 .getCanonicalPath(); 61 } catch (IOException e) { 62 throw new BuildException(e); 63 } 64 65 String destDocumentid = node.getAbsoluteId(); 66 String srcDocumentid = 67 destDocumentid.replaceFirst( 68 getSecdocumentid(), 69 getFirstdocumentid()); 70 71 File srcRcmlDir = 72 new File ( 73 rcmlDirectory, 74 this.getSrcareadir() + File.separator + srcDocumentid); 75 76 if (srcRcmlDir.exists()) { 77 try { 78 FileUtil.forceDelete(srcRcmlDir); 79 } catch (IOException e) { 80 log("exception " + e); 82 } 83 } 84 85 File srcRcbakDir = 86 new File ( 87 rcbakDirectory, 88 this.getSrcareadir() + File.separator + srcDocumentid); 89 90 if (srcRcbakDir.exists()) { 91 try { 92 FileUtil.forceDelete(srcRcbakDir); 93 } catch (IOException e) { 94 log("exception " + e); 96 } 97 log("delete rcbak directory " + srcRcbakDir.getAbsolutePath()); 98 } 99 100 } 101 102 105 public void execute() throws BuildException { 106 try { 107 log("document-id for the source :" + this.getFirstdocumentid()); 108 log("document-id for the destination :" + this.getSecdocumentid()); 109 log("area for the destination :" + this.getSecarea()); 110 log("rcml dir" + this.getRcmldir()); 111 log("rcbak dir" + this.getRcbakdir()); 112 log("src area dir" + this.getSrcareadir()); 113 114 Publication publication = getPublication(); 116 SiteTree tree = publication.getTree(this.getSecarea()); 117 SiteTreeNode node = tree.getNode(this.getSecdocumentid()); 118 node.acceptReverseSubtree(this); 119 120 } catch (Exception e) { 121 throw new BuildException(e); 122 } 123 } 124 127 public String getRcbakdir() { 128 return rcbakdir; 129 } 130 131 134 public String getRcmldir() { 135 return rcmldir; 136 } 137 138 141 public String getSrcareadir() { 142 return srcareadir; 143 } 144 145 148 public void setRcbakdir(String string) { 149 rcbakdir = string; 150 } 151 152 155 public void setRcmldir(String string) { 156 rcmldir = string; 157 } 158 159 162 public void setSrcareadir(String string) { 163 srcareadir = string; 164 } 165 166 } 167 | Popular Tags |