[opencms-dev] Trouble modifying a file

M Butcher mbutcher at grcomputing.net
Sat Apr 3 04:51:01 CEST 2004


I'm having trouble updating the contents of a file from a cron script.

The script is running as Admin/Administrators. Here's the part of the 
code that is causing problems:

this.cms.lockResource( modFilePath, true );
try {
   modFile.setContents( contents );

   this.cms.writeFile( modFile ); // <- this appears to be the problem
   this.cms.writeProperty( modFilePath, "Title", title );
   this.cms.writeProperty( modFilePath, "Description", desc );

} catch ( CmsException cmse ) {
   throw new CmsException( "Error trying to update file.", cmse );
} finally {
   this.cms.unlockResource( modFilePath );
}

Where modFilePath is the absolute path to the file, modFile is a 
CmsFile, and cms is a CmsObject.

Every time I run it, it throws the CmsException with the message I 
specified:


com.opencms.core.CmsException: 0 Unknown exception. Detailed error: 
Error trying to update file.. root cause was 
com.opencms.core.CmsException: 1 Access denied. Detailed error: 
[com.opencms.file.mySql.CmsResourceBroker] /html/myfile.html.

Note that I _am_ running against the offline project and Admin is the 
owner of the file. Permissions are rwvrwvr-v.

As far as I can tell, the exception gets thrown when writeFile() is 
executed.

Matt




More information about the opencms-dev mailing list