1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import org.apache.lenya.cms.publication.SiteTree; 23 import org.apache.lenya.cms.publication.Label; 24 import org.apache.lenya.cms.publication.SiteTreeException; 25 import org.apache.tools.ant.BuildException; 26 27 30 public class InsertLabelTask extends PublicationTask { 31 private String documentid; 32 private String labelName; 33 private String area; 34 private String language; 35 36 39 public InsertLabelTask() { 40 super(); 41 } 42 43 48 protected String getArea() { 49 return area; 50 } 51 52 57 public void setArea(String area) { 58 this.area = area; 59 } 60 61 66 protected String getDocumentid() { 67 return documentid; 68 } 69 70 75 public void setDocumentid(String string) { 76 documentid = string; 77 } 78 79 84 public String getLabelName() { 85 return labelName; 86 } 87 88 93 public void setLabelName(String labelName) { 94 this.labelName = labelName; 95 } 96 97 102 public String getLanguage() { 103 return language; 104 } 105 106 111 public void setLanguage(String language) { 112 this.language = language; 113 } 114 115 125 public void insertLabel( 126 String documentid, 127 String labelName, 128 String language, 129 String area) 130 throws SiteTreeException { 131 132 SiteTree tree = null; 133 Label label = null; 134 try { 135 tree = getPublication().getTree(area); 136 label = new Label(labelName, language); 137 tree.addLabel(documentid, label); 138 tree.save(); 139 } catch (Exception e) { 140 throw new SiteTreeException( 141 "Cannot insert label " 142 + label 143 + " into tree " 144 + area, 145 e); 146 } 147 148 } 149 150 153 public void execute() throws BuildException { 154 try { 155 log("document-id corresponding to the node: " + getDocumentid()); 156 log("label name: " + getLabelName()); 157 log("language: " + getLanguage()); 158 log("area: " + getArea()); 159 insertLabel( 160 getDocumentid(), 161 getLabelName(), 162 getLanguage(), 163 getArea()); 164 } catch (Exception e) { 165 throw new BuildException(e); 166 } 167 } 168 } 169 | Popular Tags |