<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-2022-jp">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="MS UI Gothic" color=#008080 size=2>hi there,</FONT></DIV>
<DIV><FONT face="MS UI Gothic" color=#008080 size=2></FONT> </DIV>
<DIV><FONT face="MS UI Gothic" color=#008080 size=2>i've been tried to
use the Scheduled Tasks these days. but it wasn't working at
all.</FONT></DIV>
<DIV><FONT face="MS UI Gothic" color=#008080 size=2>i opened the "Scheduled
tasks" from Administration view, and enterd a line like this:</FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><FONT face="MS UI Gothic" color=#008080 size=2>30 21 15 5 * Admin Users
Publish 4</FONT></DIV></BLOCKQUOTE>
<DIV> <FONT face="MS UI Gothic" color=#008080 size=2>then i wrote
a file "Publish.java" like this:</FONT></DIV>
<DIV><FONT face="MS UI Gothic" color=#008080 size=2></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><FONT face="MS UI Gothic" color=#008080 size=2>import
java.io.File;<BR>import java.io.FileWriter;<BR>import
java.io.IOException;<BR>import java.io.StringWriter;<BR>import
javax.servlet.ServletContext;<BR>import
javax.servlet.http.HttpServlet;<BR>import
javax.xml.parsers.DocumentBuilder;<BR>import
javax.xml.parsers.DocumentBuilderFactory;<BR>import
javax.xml.transform.Transformer;<BR>import
javax.xml.transform.TransformerFactory;<BR>import
javax.xml.transform.dom.DOMSource;<BR>import
javax.xml.transform.stream.StreamResult;<BR>import
org.w3c.dom.Document;<BR>import org.w3c.dom.Element;<BR>import
org.w3c.dom.Node;<BR>import com.opencms.core.CmsException;<BR>import
com.opencms.core.I_CmsCronJob;<BR>import
com.opencms.file.CmsObject;<BR><BR>public class Publish extends HttpServlet
implements I_CmsCronJob<BR>{<BR> ServletContext application =
getServletConfig().getServletContext();<BR><BR> public String
launch(CmsObject arg0, String arg1)<BR> throws IOException,
CmsException<BR> {<BR> Document document =
null;<BR> try<BR> {<BR> DocumentBuilder
builder
=<BR> DocumentBuilderFactory.newInstance().newDocumentBuilder();<BR> document
=<BR> builder.parse(<BR> new
File(<BR> application.getRealPath("export/Sample/addbook.xml")));<BR> Element
element =
document.createElement("new");<BR> element.appendChild(<BR> document.createTextNode("this
is the new element"));<BR> Node member =
document.getElementsByTagName("member").item(0);<BR> member.insertBefore(<BR> element,<BR> document.getElementsByTagName("address").item(0));<BR> StringWriter
sw = new StringWriter();<BR> Transformer t =
TransformerFactory.newInstance().newTransformer();<BR> t.transform(new
DOMSource(document), new StreamResult(sw));<BR> String out =
sw.toString().replaceFirst("UTF-8", "Shift_Jis");<BR> //out
print all the document to temp.xml<BR> FileWriter fw
=<BR> new
FileWriter(<BR> new
File(<BR> application.getRealPath("export/Sample/addbook.xml")));<BR> try<BR> {<BR> fw.write(out);<BR> fw.close();<BR> }<BR> catch
(IOException
e)<BR> {<BR> e.printStackTrace();<BR> }<BR> }<BR> catch
(Exception
e)<BR> {<BR> e.printStackTrace();<BR> }<BR> int
project_id =
Integer.parseInt(arg1);<BR> arg0.publishProject(project_id);<BR> return
"Scheduler launched successfully!";<BR> }<BR> public static void
main(String[] args)<BR> {<BR> CmsObject cms = new
CmsObject();<BR> Publish publish = new
Publish();<BR> String string =
"";<BR> try<BR> {<BR> string =
publish.launch(cms, "4");<BR> }<BR> catch (IOException
e)<BR> {<BR> e.printStackTrace();<BR> }<BR> catch
(CmsException e)<BR> {
<BR> e.printStackTrace();<BR> }<BR> System.out.println(string);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="MS UI Gothic" color=#008080
size=2> }<BR>}</FONT></DIV></BLOCKQUOTE><FONT face="MS UI Gothic"
color=#008080 size=2>
<DIV>the class simplely add a node to an xml file.</DIV>
<DIV>the problem is that i don't know how to define a CmsObject in main method
which is needed to call the launch mothod.</DIV>
<DIV>i complied it and put the class into C:\Program Files\Apache
Tomcat 4.0\webapps\opencms\WEB-INF\classes\, but it didn't work.</DIV>
<DIV>could someone with experence of Scheduled tasks give me a simple
example java source?</DIV>
<DIV>and is there a API documentation of Opencms somethere? </DIV>
<DIV> </DIV>
<DIV>thank you in advance!</DIV>
<DIV> </DIV>
<DIV>With regards </DIV></FONT>
<DIV><FONT face="MS UI Gothic" color=#008080
size=2><BR>---------------------------------<BR>fangzhu
from japan</FONT></DIV></BODY></HTML>