[xwiki-devs] Modify page creation details without causing an update.. :S
Hi all Is there any way of modifying the creation details (or any other property) of a page/doc without really causing/trigerring an update? What I intend to do is modify the creator and the creation date as they were messed up during import but I need the author and the date to remain unchanged.. Any ideas? Thank you! Joanna D. ----- Joanna -- Please consider the environment -- -- View this message in context: http://xwiki.475771.n2.nabble.com/Modify-page-creation-details-without-causi... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On 06/22/2010 11:12 AM, JoannaD wrote:
Hi all
Is there any way of modifying the creation details (or any other property) of a page/doc without really causing/trigerring an update?
What I intend to do is modify the creator and the creation date as they were messed up during import but I need the author and the date to remain unchanged..
You can do that using programming rights. The author + date update is triggered by the contentDirty and metadataDirty flags of the XWikiDocument class. So, you need to: - make the changes you need -- setCreator - reset cd and md -- setContentDirty(false) - save the document -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi Sergiu Thank you very much for your response. I've tried what you suggested earlier but it is still updating the modified by and date. Here's the code if you can spot anything wrong: {{velocity}} #set($web = "Sandbox") #foreach($page in $xwiki.searchDocuments("doc.space = '$web' order by doc.space, doc.name")) #set($doc = $xwiki.getDocument("$page")) * [[$doc]] $doc.document.setCreator('XWiki.Admin') #set($milli = $xwiki.parseLong("1274823000000")) #set($tmpDate = $xwiki.getDate($milli)) $doc.document.setCreationDate($tmpDate) $doc.document.setAuthor($doc.document.getAuthor()) $doc.document.setDate($doc.document.getDate()) $doc.document.setContentDirty(false) $doc.save() #end {{/velocity}} Thank you! Joanna ----- Joanna -- Please consider the environment -- -- View this message in context: http://xwiki.475771.n2.nabble.com/Modify-page-creation-details-without-causi... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On 06/22/2010 05:38 PM, JoannaD wrote:
Hi Sergiu
Thank you very much for your response.
I've tried what you suggested earlier but it is still updating the modified by and date.
Here's the code if you can spot anything wrong:
{{velocity}} #set($web = "Sandbox")
#foreach($page in $xwiki.searchDocuments("doc.space = '$web' order by doc.space, doc.name")) #set($doc = $xwiki.getDocument("$page")) * [[$doc]] $doc.document.setCreator('XWiki.Admin') #set($milli = $xwiki.parseLong("1274823000000")) #set($tmpDate = $xwiki.getDate($milli)) $doc.document.setCreationDate($tmpDate) $doc.document.setAuthor($doc.document.getAuthor()) $doc.document.setDate($doc.document.getDate()) $doc.document.setContentDirty(false)
Try adding $doc.document.setMetaDataDirty(false) here
$doc.save()
You need to save it with $xwiki.getXWiki().saveDocument($doc.document, $context.context)
#end {{/velocity}}
Thank you!
Joanna
----- Joanna
-- Please consider the environment --
-- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (2)
-
JoannaD -
Sergiu Dumitriu