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.Publication; 26 import org.apache.lenya.cms.publication.PublicationException; 27 import org.apache.lenya.cms.publication.PublicationFactory; 28 import org.apache.lenya.cms.task.AntTask; 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.Task; 31 32 36 public abstract class PublicationTask extends Task { 37 38 public PublicationTask() {} 39 40 45 protected File getPublicationDirectory() { 46 return new File ( 47 getProject().getProperty(AntTask.PUBLICATION_DIRECTORY)); 48 } 49 50 55 protected String getContextPrefix() { 56 return getProject().getProperty(AntTask.CONTEXT_PREFIX); 57 } 58 59 64 protected String getPublicationId() { 65 return getProject().getProperty(AntTask.PUBLICATION_ID); 66 } 67 68 73 protected File getServletContext() { 74 return new File (getProject().getProperty(AntTask.SERVLET_CONTEXT_PATH)); 75 } 76 77 84 protected Publication getPublication() throws BuildException { 85 try { 86 return PublicationFactory.getPublication( 87 getPublicationId(), 88 getServletContext().getCanonicalPath()); 89 } catch (IOException e) { 90 throw new BuildException(e); 91 } catch (PublicationException e) { 92 throw new BuildException(e); 93 } 94 } 95 96 101 protected void assertString(String string) { 102 assert(string != null) && !string.equals(""); 103 } 104 } 105 | Popular Tags |