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.DocumentException; 24 import org.apache.lenya.cms.publication.SiteTreeException; 25 import org.apache.lenya.cms.publication.SiteTreeNode; 26 import org.apache.lenya.cms.publication.SiteTreeNodeImpl; 27 import org.apache.tools.ant.BuildException; 28 29 32 public class ChangeVisibilityTask extends PublicationTask { 33 private String documentid; 34 private String area; 35 36 39 public ChangeVisibilityTask() { 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 87 public void changeVisibility( 88 String documentid, 89 String area) 90 throws SiteTreeException, DocumentException { 91 92 SiteTree tree = null; 93 tree = getPublication().getTree(area); 94 SiteTreeNode node = tree.getNode(documentid); 95 96 if (node == null) { 97 throw new DocumentException( 98 "Document-id " + documentid + " not found."); 99 } 100 101 String visibility = "false"; 103 if (!node.visibleInNav()) visibility = "true"; 104 node.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, visibility); 105 106 tree.save(); 107 } 108 109 112 public void execute() throws BuildException { 113 try { 114 log("document-id corresponding to the node: " + getDocumentid()); 115 log("area: " + getArea()); 116 changeVisibility( 117 getDocumentid(), 118 getArea()); 119 } catch (Exception e) { 120 throw new BuildException(e); 121 } 122 } 123 } 124 | Popular Tags |