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.Publication; 24 import org.apache.tools.ant.BuildException; 25 26 29 public class MoveSiteTreeNodeTask extends PublicationTask { 30 31 public static final String UP = "up"; 32 public static final String DOWN = "down"; 33 34 38 protected String getDocumentId() { 39 return documentId; 40 } 41 42 46 public void setDocumentId(String documentId) { 47 this.documentId = documentId; 48 } 49 50 54 protected String getDirection() { 55 return direction; 56 } 57 58 62 public void setDirection(String direction) { 63 this.direction = direction; 64 } 65 66 69 public void execute() throws BuildException { 70 71 log("Moving sitetree node:"); 72 log(" Document ID: [" + getDocumentId() + "]"); 73 log(" Direction: [" + getDirection() + "]"); 74 75 try { 76 SiteTree tree = getPublication().getTree(Publication.AUTHORING_AREA); 77 if (getDirection().equals(UP)) { 78 tree.moveUp(getDocumentId()); 79 } else if (getDirection().equals(DOWN)) { 80 tree.moveDown(getDocumentId()); 81 } else { 82 throw new BuildException( 83 "The direction in which the node should be moved isn't specified."); 84 } 85 tree.save(); 86 } catch (BuildException e) { 87 throw e; 88 } catch (Exception e) { 89 throw new BuildException(e); 90 } 91 } 92 93 private String direction; 94 private String documentId; 95 96 } 97 | Popular Tags |