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.DocumentBuildException; 24 import org.apache.lenya.cms.publication.DocumentBuilder; 25 import org.apache.lenya.cms.publication.DocumentException; 26 import org.apache.lenya.cms.publication.DublinCore; 27 import org.apache.tools.ant.BuildException; 28 29 32 public class WriteDCParametersTask extends PublicationTask { 33 private String documentId = null; 34 private String area = null; 35 private String creator = null; 36 private String title = null; 37 private String description = null; 38 private String subject = null; 39 private String language = null; 40 private String publisher = null; 41 private String rights = null; 42 43 46 public WriteDCParametersTask() { 47 super(); 48 } 49 50 55 public String getCreator() { 56 return creator; 57 } 58 59 64 public String getDescription() { 65 return description; 66 } 67 68 73 public String getPublisher() { 74 return publisher; 75 } 76 77 82 public String getRights() { 83 return rights; 84 } 85 86 91 public String getSubject() { 92 return subject; 93 } 94 95 100 public String getTitle() { 101 return title; 102 } 103 104 109 public void setCreator(String string) { 110 creator = string; 111 } 112 113 118 public void setDescription(String string) { 119 description = string; 120 } 121 122 127 public void setPublisher(String string) { 128 publisher = string; 129 } 130 131 136 public void setRights(String string) { 137 rights = string; 138 } 139 140 145 public void setSubject(String string) { 146 subject = string; 147 } 148 149 154 public void setTitle(String string) { 155 title = string; 156 } 157 158 163 public String getArea() { 164 return area; 165 } 166 167 172 public void setArea(String string) { 173 area = string; 174 } 175 176 181 public String getDocumentId() { 182 return documentId; 183 } 184 185 190 public void setDocumentId(String string) { 191 documentId = string; 192 } 193 194 199 public String getLanguage() { 200 return language; 201 } 202 203 208 public void setLanguage(String string) { 209 language = string; 210 } 211 212 229 public void writeDublinCoreParameters( 230 String documentId, 231 String area, 232 String lang, 233 String creator, 234 String title, 235 String description, 236 String subject, 237 String publisher, 238 String rights) 239 throws BuildException, DocumentBuildException, DocumentException { 240 241 DocumentBuilder builder = getPublication().getDocumentBuilder(); 242 String url = builder.buildCanonicalUrl(getPublication(), area, documentId, lang); 243 Document doc = builder.buildDocument(getPublication(), url); 244 DublinCore dc = doc.getDublinCore(); 245 dc.setValue(DublinCore.ELEMENT_CREATOR, creator); 246 dc.setValue(DublinCore.ELEMENT_TITLE, title); 247 dc.setValue(DublinCore.ELEMENT_DESCRIPTION, description); 248 dc.setValue(DublinCore.ELEMENT_SUBJECT, subject); 249 dc.setValue(DublinCore.ELEMENT_PUBLISHER, publisher); 250 dc.setValue(DublinCore.ELEMENT_RIGHTS, rights); 251 dc.save(); 252 } 253 254 257 public void execute() throws BuildException { 258 try { 259 writeDublinCoreParameters( 260 getDocumentId(), 261 getArea(), 262 getLanguage(), 263 getCreator(), 264 getTitle(), 265 getDescription(), 266 getSubject(), 267 getPublisher(), 268 getRights()); 269 } catch ( 270 Exception e) { 271 throw new BuildException(e); 272 } 273 } 274 275 } 276 | Popular Tags |