[ 
https://issues.apache.org/jira/browse/JSPWIKI-807?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

KP Hemsteter reopened JSPWIKI-807:
----------------------------------


Harry,

Sorry for the poor quality original post and the delay - I'm very much the 
amateur. The correction made is nearly right. If _pageExists_ is called with 
the actual value of the last version, the method returns false. The correct 
test is:

        if( version == WikiPageProvider.LATEST_VERSION || version == 
findLatestVersion( pageName ) )

However, _findLatestVersion_ is declared with _throws ProviderException_. It 
does not throw it, so it can be safely removed. _case-1.patch-sortof_ provides 
what is needed once the header is modified.

Now regarding the very poor comments I added to the original post. It seems 
that the normal method for calling _pageExists_ is to call the method in the 
_WikiEngine_ object. This calls the method in the _PageManager_ object. Things 
get complicated here. The _PageManager_

1)      Checks that the name is not _null_ or blank.
2)      If the version is _WikiProvider.LATEST_VERSION_ call _pageExists( 
String pageName )_
3)      For _CachingProvider_ calls its _pageExists( String pageName, int 
version )_
4)      Else call the provider's _getPageInfo( pageName, version )_ and check 
is a null pointer is returned.

Interestingly, if _VersionFileProvider_ is used with out a cache, its 
_pageExists_ method is not called.

It is also interesting that the base interface _WikiPageProvider_ has several 
methods that are called with the version number. So there is no clear reason 
for not include _pageExist_ with version in the interface.

So the fixes are:
1)      Elimate the interface _VersioningProvider_. 
2)      Add the method _pageExists_ to _AbstractFileProvider_ to simply call 
_pageExists_ without a version.
        The two test providers _CounterProvider_ and _VerySimpleProvider_ need 
the some modification.

3)      Clean up _PageManger's pageExist_ method to check if the page name is 
black/null then to call the provider's _pageExists_ method

4)      Do a simile cleanup in _CachingProvider_.

The patches (including the one for _VersionFileProvinder_) are include in 
case-2.patch-sortof

Sorry for the delay.

Kevin

> VersioningFileProvider pageExist failure to properly handle latest version
> --------------------------------------------------------------------------
>
>                 Key: JSPWIKI-807
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-807
>             Project: JSPWiki
>          Issue Type: Bug
>          Components: Core & storage
>    Affects Versions: 2.9.1
>         Environment: All
>            Reporter: KP Hemsteter
>            Assignee: Harry Metske
>            Priority: Trivial
>              Labels: patch
>             Fix For: 2.10.1
>
>         Attachments: JSPWIKI-807.patch, case-1.patch-sortof, 
> case-2.patch-sortof
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In VersioningFileProvider, the function "pageExists" for versions search for 
> the versions of  wiki page in the "OLD" directory for that page. The latest 
> version is in the main storage directory. The problem is masked because the 
> PageProvider class handles the case - which it should not. Adding the 
> following code to pageExists and removing the code for PageProvider will 
> resolve this issue:
>     if( version == WikiPageProvider.LATEST_VERSION || version == latest)
>     {
>         return pageExists( pageName );
>     }
>     else
>     {



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to