1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import org.apache.lenya.cms.publication.Document; 23 import org.apache.lenya.cms.publication.DocumentBuilder; 24 import org.apache.lenya.cms.publication.Publication; 25 import org.apache.lenya.cms.publication.util.LinkRewriter; 26 import org.apache.tools.ant.BuildException; 27 28 34 public class LinkRewriteTask extends PublicationTask { 35 36 private String area; 37 private String oldDocumentId; 38 private String newDocumentId; 39 40 44 public String getArea() { 45 return this.area; 46 } 47 48 52 public void setArea(String _area) { 53 this.area = _area; 54 } 55 56 60 public String getNewDocumentId() { 61 return this.newDocumentId; 62 } 63 64 68 public void setNewDocumentId(String _newDocumentId) { 69 this.newDocumentId = _newDocumentId; 70 } 71 72 76 public String getOldDocumentId() { 77 return this.oldDocumentId; 78 } 79 80 84 public void setOldDocumentId(String _oldDocumentId) { 85 this.oldDocumentId = _oldDocumentId; 86 } 87 88 92 public void setStylesheet(String _stylesheet) { 93 } 94 95 99 public void setBaseDir(String _baseDir) { 100 } 101 102 105 public void execute() throws BuildException { 106 try { 107 108 Publication pub = getPublication(); 109 DocumentBuilder builder = pub.getDocumentBuilder(); 110 111 String oldTargetUrl = builder.buildCanonicalUrl(pub, getArea(), getOldDocumentId()); 112 Document oldTargetDocument = builder.buildDocument(pub, oldTargetUrl); 113 114 String newTargetUrl = builder.buildCanonicalUrl(pub, getArea(), getNewDocumentId()); 115 Document newTargetDocument = builder.buildDocument(pub, newTargetUrl); 116 117 LinkRewriter rewriter = new LinkRewriter(); 118 rewriter.rewriteLinks(oldTargetDocument, newTargetDocument, getContextPrefix()); 119 120 } catch (Exception e) { 121 throw new BuildException(e); 122 } 123 124 } 125 126 } 127 | Popular Tags |