[opencms-dev] setContents() and writeFile() not enough to save?

jill jwetzler_cmu at hotmail.com
Mon Nov 13 21:25:05 CET 2006


In case anyone is interested in the solution, it was punting in an exception
somewhere down the line for not locking the resource before I saved it.  I
was hoping that I could implement the bare bones of WebDAV first and
introduce locking later, but OpenCms was at least expecting me to lock
before writing the file.  Fair enough.


jill wrote:
> 
> I'm currently writing a WebDAV hook into OpenCms, and I'm stumped on one
> last major function.
> 
> Jakarta's SLIDE project has a setResourceContent() method that is called
> when you attempt to save a file.  I have verified that my method is
> grabbing the right file with the newly-altered content and that I'm
> attempting to store to the correct project (Offline).
> 
> After getting my byte array with the edited content in it, I call
> CmsFile's setContents() function and then call CmsObject's writeFile()
> function.  
> 
> An oversimplified glance at what I'm doing, with CmsObject obj and byte[]
> content:
> CmsFile file = new CmsFile(obj.readFile(resourceUri));
> file.setContents(content);
> obj.writeFile(file);
> 
> It does save my changes through WebDAV because I can close the file and
> reopen it through WebDAV and see the changes I saved.  However, when I
> look at the file in OpenCms, it hasn't picked up any of the changes. 
> What's more, after looking at it in OpenCms, it reverts the file that's
> served through my WebDAV server (which is probably a good sign--at least
> I'm pulling the file directly from the database instead of caching it
> somewhere on my machine).
> 
> I'm able to edit and save in OpenCms and see the changes reflected through
> my WebDAV client, but not vice versa.  I've stepped through
> CmsSimpleEditor's actionSave() method and can't figure out what my code is
> doing differently.  Is there something I need to do to broadcast to
> OpenCms that I've changed the file?  What purpose does the
> setAction(ACTION_SAVE) call at the end of the actionSave() method serve?
> 
> I've tried restarting Tomcat immediately after saving through WebDAV to
> see if it would pick up the change through a total refresh, but no luck. 
> Somehow the changes are not sticking in the database (or even getting into
> the database?).  I'm missing an important call to OpenCms somewhere and
> I'm just not seeing what it is.
> 
> Any suggestions would be appreciated.
> 
> Thanks,
> Jill
> 

-- 
View this message in context: http://www.nabble.com/setContents%28%29-and-writeFile%28%29-not-enough-to-save--tf2610875.html#a7324916
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.




More information about the opencms-dev mailing list