1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import org.apache.lenya.cms.publication.DocumentIdToPathMapper; 23 import org.apache.lenya.cms.publication.Publication; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.Project; 26 import org.apache.tools.ant.Target; 27 28 32 public class DocumentIdToPath extends PublicationTask { 33 private String area; 34 private String documentid; 35 private String propertyname; 36 37 40 public DocumentIdToPath() { 41 super(); 42 } 43 44 47 public String getArea() { 48 return area; 49 } 50 51 54 protected String getDocumentid() { 55 return documentid; 56 } 57 58 61 public String getPropertyname() { 62 return propertyname; 63 } 64 65 68 public void setArea(String string) { 69 area = string; 70 } 71 72 75 public void setPropertyname(String string) { 76 propertyname = string; 77 } 78 79 84 public void setDocumentid(String string) { 85 documentid = string; 86 } 87 88 96 public void compute(String area, String documentid, String propertyname) { 97 98 Publication publication = getPublication(); 99 DocumentIdToPathMapper pathMapper = publication.getPathMapper(); 100 String path = pathMapper.getPath(documentid, ""); 101 log("path " + path); 102 103 int index = path.lastIndexOf("/"); 104 String dir = path.substring(0, index); 105 log("dir " + dir); 106 107 Target target = getOwningTarget(); 108 Project project = target.getProject(); 109 project.setProperty(propertyname, dir); 110 } 111 112 115 public void execute() throws BuildException { 116 log("document-id " + getDocumentid()); 117 log("area " + getArea()); 118 log("property: " + getPropertyname()); 119 compute(getArea(), getDocumentid(), getPropertyname()); 120 } 121 122 } 123 | Popular Tags |