1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import org.apache.lenya.cms.publication.Publication; 23 import org.apache.lenya.cms.publication.UniqueDocumentId; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.Project; 26 import org.apache.tools.ant.Target; 27 28 29 38 public class ComputeNewDocumentId extends PublicationTask{ 39 private String area; 40 private String firstdocumentid; 41 private String secdocumentid; 42 43 46 public ComputeNewDocumentId() { 47 super(); 48 } 49 50 53 public String getArea() { 54 return area; 55 } 56 57 61 public void setArea(String string) { 62 area = string; 63 } 64 65 68 protected String getFirstdocumentid() { 69 return firstdocumentid; 70 } 71 72 76 public void setFirstdocumentid(String string) { 77 firstdocumentid = string; 78 } 79 80 84 protected String getSecdocumentid() { 85 return secdocumentid; 86 } 87 88 92 public void setSecdocumentid(String string) { 93 secdocumentid = string; 94 } 95 96 103 protected String compute(String firstdocumentid, String secdocumentid) { 104 return secdocumentid; 105 } 106 107 114 protected String computeUniqueId(String documentid, String area) { 115 116 Publication publication = getPublication(); 117 118 UniqueDocumentId uniqueDocumentId = new UniqueDocumentId(); 119 String newdocumentid = uniqueDocumentId.computeUniqueDocumentId(publication, area, documentid); 120 return newdocumentid; 121 122 } 123 124 128 protected void setNewProperty(String documentid) { 129 Target target = getOwningTarget(); 130 Project project = target.getProject(); 131 project.setProperty("node.newdocumentid", documentid); 132 } 133 134 137 public void execute() throws BuildException { 138 try { 139 log("document id of the source" + getFirstdocumentid()); 140 log("document id of the destination" + getSecdocumentid()); 141 log("area: " + getArea()); 142 String documentId = compute(getFirstdocumentid(), getSecdocumentid()); 143 String uniqueId = computeUniqueId(documentId, getArea()); 144 setNewProperty(uniqueId); 145 } catch (Exception e) { 146 throw new BuildException(e); 147 } 148 } 149 } 150 | Popular Tags |