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.lenya.cms.publication.SiteTreeNode; 26 import org.apache.tools.ant.BuildException; 27 28 33 public class DeleteLanguageNodeTask extends DeleteNodeTask { 34 private String language; 35 36 39 public DeleteLanguageNodeTask() { 40 super(); 41 } 42 43 54 public void deleteLanguageNode(String language, String documentid, String area) 55 throws SiteTreeException { 56 SiteTree tree = null; 57 58 try { 59 tree = getPublication().getTree(area); 60 SiteTreeNode node = tree.getNode(documentid); 61 node.removeLabel(node.getLabel(language)); 62 Label[] labels = node.getLabels(); 63 if (labels.length < 1 ){ 64 deleteNode(documentid,area); 65 } else { 66 tree.save(); 67 } 68 } catch (Exception e) { 69 throw new SiteTreeException(e); 70 } 71 } 72 75 public void execute() throws BuildException { 76 try { 77 log("document-id : " + getDocumentid()); 78 log("area: " + getArea()); 79 log("language : " + getLanguage()); 80 deleteLanguageNode(getLanguage(), getDocumentid(), getArea()); 81 } catch (Exception e) { 82 throw new BuildException(e); 83 } 84 } 85 86 91 public String getLanguage() { 92 return language; 93 } 94 95 100 public void setLanguage(String string) { 101 language = string; 102 } 103 104 } 105 | Popular Tags |