1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import org.apache.lenya.cms.publication.Document; 23 import org.apache.lenya.cms.publication.DocumentBuildException; 24 import org.apache.lenya.cms.publication.DocumentBuilder; 25 import org.apache.lenya.cms.publication.DocumentType; 26 import org.apache.lenya.cms.publication.DocumentTypeBuilder; 27 import org.apache.lenya.cms.publication.Publication; 28 import org.apache.lenya.cms.workflow.WorkflowFactory; 29 import org.apache.lenya.workflow.Situation; 30 import org.apache.tools.ant.BuildException; 31 32 public class InitWorkflowHistoryTask extends PublicationTask { 33 private String documentId; 34 private String documentType; 35 private String language; 36 37 41 public String getMachineIp() { 42 return machineIp; 43 } 44 45 49 public void setMachineIp(String machineIp) { 50 this.machineIp = machineIp; 51 } 52 53 57 public String getUserId() { 58 return userId; 59 } 60 61 65 public void setUserId(String userId) { 66 this.userId = userId; 67 } 68 69 72 public void execute() throws BuildException { 73 String language = getLanguage(); 74 75 if (language == null) { 76 language = getPublication().getDefaultLanguage(); 77 } 78 DocumentBuilder builder = getPublication().getDocumentBuilder(); 79 String url = builder.buildCanonicalUrl(getPublication(), Publication.AUTHORING_AREA, getDocumentId(), language); 80 Document document; 81 try { 82 document = builder.buildDocument(getPublication(), url); 83 log(".execute(): " + document.getLanguage()); 84 } catch (DocumentBuildException e) { 85 throw new BuildException(e); 86 } 87 88 try { 89 String [] roles = new String [0]; 90 Situation situation = 91 WorkflowFactory.newInstance().buildSituation(roles, getUserId(), getMachineIp()); 92 DocumentType type = 93 DocumentTypeBuilder.buildDocumentType(getDocumentType(), getPublication()); 94 WorkflowFactory.initHistory(document, type.getWorkflowFileName(), situation); 95 } catch (Exception e) { 96 throw new BuildException(e); 97 } 98 } 99 100 105 public String getDocumentId() { 106 assertString(documentId); 107 108 return documentId; 109 } 110 111 116 public void setDocumentId(String aDocumentId) { 117 assertString(aDocumentId); 118 documentId = aDocumentId; 119 } 120 121 126 public String getDocumentType() { 127 assertString(documentType); 128 129 return documentType; 130 } 131 132 137 public void setDocumentType(String aDocumentType) { 138 assertString(aDocumentType); 139 documentType = aDocumentType; 140 } 141 142 147 public String getLanguage() { 148 return language; 149 } 150 151 156 public void setLanguage(String string) { 157 language = string; 158 } 159 160 private String userId = ""; 161 private String machineIp = ""; 162 163 } 164 | Popular Tags |