1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 25 import org.apache.lenya.cms.publication.Document; 26 import org.apache.lenya.cms.publication.DocumentBuilder; 27 import org.apache.lenya.cms.publication.Label; 28 import org.apache.lenya.cms.publication.Publication; 29 import org.apache.lenya.cms.publication.SiteTreeNode; 30 import org.apache.lenya.cms.rc.RevisionController; 31 import org.apache.tools.ant.BuildException; 32 33 38 public class InitRCTask extends TwoDocumentsOperationTask { 39 private String rcmlDir = ""; 40 private String rcbakDir = ""; 41 private String userId = ""; 42 private RevisionController rc = null; 43 46 public InitRCTask() { 47 super(); 48 } 49 50 53 public String getRcbakDir() { 54 return rcbakDir; 55 } 56 57 60 public String getRcmlDir() { 61 return rcmlDir; 62 } 63 64 67 public void setRcbakDir(String string) { 68 rcbakDir = string; 69 } 70 71 74 public void setRcmlDir(String string) { 75 rcmlDir = string; 76 } 77 78 81 public void visitSiteTreeNode(SiteTreeNode node) { 82 try { 83 Publication publication = getPublication(); 84 String publicationPath = 85 this.getPublicationDirectory().getCanonicalPath(); 86 DocumentBuilder builder = publication.getDocumentBuilder(); 87 88 String srcDocumentid = node.getAbsoluteId(); 89 String destDocumentid = 90 srcDocumentid.replaceFirst( 91 getFirstdocumentid(), 92 getSecdocumentid()); 93 94 Label[] labels = node.getLabels(); 95 for (int i = 0; i < labels.length; i++) { 96 String language = labels[i].getLanguage(); 97 String destUrl = 98 builder.buildCanonicalUrl( 99 publication, 100 getSecarea(), 101 destDocumentid, 102 language); 103 Document destDoc; 104 destDoc = builder.buildDocument(publication, destUrl); 105 String filename = destDoc.getFile().getCanonicalPath(); 106 filename = filename.substring(publicationPath.length()); 107 rc.reservedCheckIn(filename, getUserId(), true); 108 } 109 } catch (Exception e) { 110 throw new BuildException(e); 111 } 112 } 113 114 117 118 public void execute() throws BuildException { 119 try { 120 log("rcml dir" + this.getRcmlDir()); 121 log("rcbak dir" + this.getRcbakDir()); 122 log("user" + this.getUserId()); 123 String publicationPath = 124 this.getPublicationDirectory().getCanonicalPath(); 125 String rcmlDirectory = new File (publicationPath, this.getRcmlDir()).getCanonicalPath(); 126 String rcbakDirectory = new File (publicationPath, this.getRcbakDir()).getCanonicalPath(); 127 this.rc = 128 new RevisionController( 129 rcmlDirectory, 130 rcbakDirectory, 131 publicationPath); 132 } catch (IOException e) { 133 throw new BuildException(e); 134 } 135 super.execute(); 136 } 137 138 141 public String getUserId() { 142 return userId; 143 } 144 145 148 public void setUserId(String string) { 149 userId = string; 150 } 151 152 } 153 | Popular Tags |