[opencms-dev] deleting a file

bart vandendriessche bart at nascom.be
Thu Dec 23 15:01:04 CET 2004


I still haven't resolved this issue, I dug into the openCMS source code 
to figure out what is going wrong and apparently (i'm using opencms 
5.01) the error is thrown when the publisResource method calls the 
readFileHeader method.
Apparently, readFileHeader(String file) can't read headers from files 
that are marked as deleted (in the offline project). Can someone then 
tell me what the proper way to delete a resource from the online project 
is ?
Using java code offcourse.

Here's my rundown of things:
try {
           cmso.lockResource(file, true);
           cmso.deleteResource(file);
           cmso.unlockResource(file);      //this crashes since we can't 
unlock deleted resources
           cmso.publishResource(file);
       } catch ( CmsException cmse ) {
                     return false;
       }

so I leave out the unlockResource(file); line and we get the following

try {
           cmso.lockResource(file, true);
           cmso.deleteResource(file);
           cmso.publishResource(file);       //this crashes since we 
can't publish deleted resources
       } catch ( CmsException cmse ) {
                     return false;
       }

Is there anybody that has successfully done this before, and could they 
please tell me what I'm doing wrong ? I really need to be able to delete 
stuff, since this code is supposed to handle structured content which 
the site's admins will manage through an administration point.

- bart

bart vandendriessche wrote:

> hmm, i'm shooting from the hip again, i meant unlocking is not the 
> solution, typo :)
>
> I currently have the following code:
>
> try {
>            cmso.lockResource(file, true);
>            cmso.deleteResource(file);
>            cmso.unlockResource(file);
>            cmso.publishResource(file);
>        } catch ( CmsException cmse ) {                     return false;
>        }
>
> which is returning false.
>
> Thanks for the answer, sorry i didn't phrase the problem properly.
>
> -bart
>
> Thomas Maerz wrote:
>
>> bart vandendriessche <bart at nascom.be> writes:
>>
>>  
>>
>>> One more thing, locking the resource before publishing it is not the
>>> solution, just tried that again as well.
>>>   
>>
>>
>> Unlock the resource before publishing.
>>
>> Regards,
>> Thomas
>>
>>
>>
>> _______________________________________________
>> This mail is send to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list, please 
>> visit
>> http://mail.opencms.org/mailman/listinfo/opencms-dev
>>
>>  
>>
>
>
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please 
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>




More information about the opencms-dev mailing list