[opencms-dev] How to publish deleted resource with the API
Olli Aro
olli_aro at yahoo.co.uk
Tue Oct 12 21:21:09 CEST 2004
Hi,
I case someone has this problem in future, this is what you need to do :)
Regards,
Olli
//Throws an exception if the file is not in undelete state but we don't
really care about that.
int id=cms.getRequestContext().currentProject().getId();
try
{
//Deleted resource in "undelete" state can be only
published in the same project as the resource was when deleted.
CmsResource res=cms.readFileHeader(fileUri,true);
cms.getRequestContext().setCurrentProject(res.getProjectId());
cms.publishResource(fileUri,false);
//And let's set the project back as it was.
cms.getRequestContext().setCurrentProject(id);
}catch(Exception e){//If something went wrong let's put the
user back to his project.
cms.getRequestContext().setCurrentProject(id);
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.776 / Virus Database: 523 - Release Date: 12/10/2004
More information about the opencms-dev
mailing list