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 33 public class DocumentIdToFile extends PublicationTask { 34 private String area; 35 private String documentId; 36 private String language; 37 private String propertyname; 38 39 42 public DocumentIdToFile() { 43 super(); 44 } 45 46 51 public String getArea() { 52 return area; 53 } 54 55 60 protected String getDocumentid() { 61 return documentId; 62 } 63 64 69 public String getPropertyname() { 70 return propertyname; 71 } 72 73 78 public void setArea(String area) { 79 this.area = area; 80 } 81 82 87 public void setPropertyname(String string) { 88 propertyname = string; 89 } 90 91 96 public void setDocumentid(String documentId) { 97 this.documentId = documentId; 98 } 99 100 105 public String getLanguage() { 106 return language; 107 } 108 109 114 public void setLanguage(String language) { 115 this.language = language; 116 } 117 118 127 public void compute( 128 String area, 129 String documentid, 130 String language, 131 String propertyname) { 132 133 Publication publication = getPublication(); 134 DocumentIdToPathMapper pathMapper = publication.getPathMapper(); 135 String fileName = 136 pathMapper 137 .getFile(publication, area, documentid, language) 138 .getAbsolutePath(); 139 140 Target target = getOwningTarget(); 141 Project project = target.getProject(); 142 project.setProperty(propertyname, fileName); 143 } 144 145 148 public void execute() throws BuildException { 149 try { 150 log("document-id " + getDocumentid()); 151 log("area " + getArea()); 152 log("language " + getLanguage()); 153 log("property: " + getPropertyname()); 154 compute( 155 getArea(), 156 getDocumentid(), 157 getLanguage(), 158 getPropertyname()); 159 } catch (Exception e) { 160 throw new BuildException(e); 161 } 162 } 163 } 164 | Popular Tags |