Bug 50722

Summary: Exception when trying to empty trash
Product: Lenya Reporter: Rainer Schöpf <rainer.schoepf>
Component: Site ManagementAssignee: Lenya Developers <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.0.4   
Target Milestone: 2.0.4   
Hardware: All   
OS: All   

Description Rainer Schöpf 2011-02-05 15:52:40 UTC
On a fresh lenya 2.0.4 install, trying to empty the trash leads to (after clicking on the delete button in the confirmation dialog):

java.lang.RuntimeException: The document [test:trash:b005a910-315f-11e0-806c-93e5409e06ee:de] is not referenced in the site structure.

        at org.apache.lenya.cms.publication.DocumentImpl.getLocator(DocumentImpl.java:508)
        at org.apache.lenya.cms.publication.DocumentManagerImpl.deleteAllLanguageVersions(DocumentManagerImpl.java:763)
        at org.apache.lenya.cms.publication.DocumentManagerImpl$DeleteVisitor.visitDocument(DocumentManagerImpl.java:791)
        at org.apache.lenya.cms.publication.DocumentImpl.accept(DocumentImpl.java:404)
        at org.apache.lenya.cms.publication.util.DocumentSet.visit(DocumentSet.java:131)
        at org.apache.lenya.cms.publication.DocumentManagerImpl.delete(DocumentManagerImpl.java:817)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.apache.avalon.excalibur.component.ComponentProxyGenerator$ComponentInvocationHandler.invoke(ComponentProxyGenerator.java:143)
        at $Proxy56.delete(Unknown Source)
        at org.apache.lenya.cms.site.usecases.EmptyTrash.doExecute(EmptyTrash.java:116)
        at org.apache.lenya.cms.usecase.AbstractUsecase.execute(AbstractUsecase.java:319)
Comment 1 Rainer Schöpf 2011-02-07 15:08:20 UTC
Analysis of the bug:

The exception happens if you try to delete more than one language version of a document. EmptyTrash.doExecute passes a list of documents to DocumentManager.delete. Different language versions are passed as separate documents.

However, the method DeleteVisitor.visitDocument (in DocumentManagerImpl) calls deleteAllLanguageVersions on each of the documents, hence on each of the language versions, ie. tries to delete the same thing several times.

Replacing the call of deleteAllLanguageVersions by delete seems to do the trick.
Comment 2 Rainer Schöpf 2011-02-15 01:59:18 UTC
Fixed in r1068192 (2.0.4), added test case in r1070690.

Needs to be merged to 2.1.X
Comment 3 Rainer Schöpf 2011-02-20 09:24:56 UTC
(In reply to comment #2)
> Fixed in r1068192 (2.0.4), added test case in r1070690.
> 
> Needs to be merged to 2.1.X

Done in r1072602.
Comment 4 Rainer Schöpf 2011-02-20 09:25:34 UTC
Fixed for Release 2.0.4.