<html>
<body>
Hi. <br><br>
I think you must write C_VFS_PATH_BODIES constant ( /system/bodies/
directory by default ). Here a example: <br><br>
<font face="Courier New, Courier">CmsFile bodyFile =
cms.readFile(C_VFS_PATH_BODIES +
<x-tab> </x-tab>currentFilelist.substring(1,currentFilelist.length()),newFile);<br>
bodyFile.setContents(bodyBytes);<br>
cms.writeFile(bodyFile);<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
</font>Regards.<br>
J. Montero<br><br>
At 12:53 03/11/2003, you wrote:<br>
<blockquote type=cite class=cite cite>Hi to all.<br>
I'm trying to write a java class to retrieve the content of an HTML
page<br>
stored in the VFS using che opencms java API.<br><br>
I wrote a class that get the CmsFile content, but the CmsFile
object<br>
contains an XML descriptor and not the HTML source code.<br><br>
Someone can help me?<br><br>
Thank you in advance and sorry for my poor english.<br><br>
Massimiliano.<br><br>
-----<br>
This is the java code I wrote.<br><br>
OpenCms m_openCms;<br>
CmsObject m_cms;<br>
//A_OpenCms.initVersion(this);<br>
try {<br>
<x-tab> </x-tab>CmsBase.setBasePath("c:\\Program
Files\\Apache Group\\Tomcat<br>
4.1\\webapps\\opencms\\WEB-INF");<br>
<x-tab> </x-tab>String
propsPath = CmsBase.getPropertiesPath(true);<br>
<x-tab> </x-tab>System.out.println("%%%
props: " + propsPath);<br>
<x-tab> </x-tab>Configurations
conf = new Configurations(new<br>
ExtendedProperties(propsPath));<br>
<x-tab> </x-tab>m_openCms
= new OpenCms(conf);<br>
<x-tab> </x-tab>m_cms =
new CmsObject();<br><br>
<x-tab> </x-tab>//log in
default user.<br>
<x-tab> </x-tab>m_openCms.initUser(m_cms,
null, null, C_USER_GUEST, C_GROUP_GUEST,<br>
C_PROJECT_ONLINE_ID, null);<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
<x-tab> </x-tab>CmsFile
file = m_cms.readFile("/MyFirstProject/Index.html");<br>
<x-tab> </x-tab>if ( file
!= null )<br>
<x-tab> </x-tab>{<br>
<x-tab> </x-tab><x-tab> </x-tab>System.out.println(file);<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
<x-tab> </x-tab><x-tab> </x-tab>byte
[] fileContent = file.getContents();<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
<x-tab> </x-tab><x-tab> </x-tab>ByteArrayOutputStream
bA = new ByteArrayOutputStream();<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab>bA.write(fileContent);<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab>System.out.println
(bA.toString());<br>
<x-tab> </x-tab>}<br>
<x-tab> </x-tab>else<br>
<x-tab> </x-tab><x-tab> </x-tab>throw
new NullPointerException ("Oggetto file nullo");<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><br>
}<br>
catch(Exception exc) {<br>
<x-tab> </x-tab>exc.printStackTrace();<br>
}<br><br>
This is the output:<br><br>
[Resource]:/default/vfs/MyFirstProject/Index.html ID: 913 ParentID:
911<br>
, Project=1 , User=2 , Group=2 : Access=rwvrwvr-v- : Resource-type=1
:<br>
Locked=-1 : length=379 : state=0<br><br>
<?xml version="1.0"
encoding="ISO-8859-1"?><br>
<PAGE><br>
<class>com.opencms.template.CmsXmlTemplate</class><br><br>
<masterTemplate>/system/modules/org.opencms.default/templates/empty</masterTemplate><br>
<ELEMENTDEF name="body"><br>
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS><br>
<TEMPLATE>/system/bodies/MyFirstProject/index.html</TEMPLATE><br>
</ELEMENTDEF><br>
</PAGE><br><br>
_______________________________________________<br>
This mail is send to you from the opencms-dev mailing list<br>
To change your list options, or to unsubscribe from the list, please
visit<br>
<a href="http://mail.opencms.org/mailman/listinfo/opencms-dev" eudora="autourl">http://mail.opencms.org/mailman/listinfo/opencms-dev</a>
</blockquote></body>
</html>