[opencms-dev] how to modify and write to a CmsFile during a Publish Project sequence

frankg fg_salesforce at hotmail.com
Fri May 30 01:22:05 CEST 2008


Hello everyone,
 
I'm trying to toggle a switch within a file after I've published a file (during publication would also be okay) .  The file is an xml file, so I've figured that it would be basically be updating the xml value and then writing to the file.  So far, writing to the file has been troublesome, because I've tried doing it during the publish and I've tried immediately after the publish (using EVENT_PUBLISH_PROJECT).  btw, this is actually a follow up to the suggestion that Nacho provided about updating xml values (Thanks Nacho!).
 
Given the below code snippet, I've been having trouble when trying to lock the resource in preparation for the write command because during a "Publish Project" code sequence, the project is "Online"  (temporarily?) .  Locking a resource while the project is online throws an exception.  
 
CmsFile file = xmlDocument.getFile()
String filePath = cms.getSitePath(file);
cms.lockResource(filePath, CmsLock.TEMPORARY);     (PROBLEM!!)
file.setContents(xmlDocument.marshal());
cms.writeFile(file);
 
 
Anyway, if anyone has any advice, it'd be greatly appreciated.  Thanks so much!
 
Frank
_________________________________________________________________
E-mail for the greater good. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ GreaterGood
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080529/11f49dd2/attachment.htm>


More information about the opencms-dev mailing list