You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Ichiro Furusato <ic...@gmail.com> on 2014/10/28 11:25:28 UTC
movePage() overwrites existing page?
Hi,
Just coming up for air, thought I'd throw what might seem a random question
into
the group, as I'm working on a WikiPageProvider implementation.
It appears that the movePage() method makes absolutely no checks prior to
moving (renaming) a wiki page. In other words, moving/renaming a page to
the
name of an already-existing page will clobber that existing page. There's in
the existing code no check, nor even any feedback, as the method returns
void.
Here's the code from the FileSystemProvider:
public void movePage( String from, String to )
throws ProviderException
{
File fromPage = findPage( from );
File toPage = findPage( to );
fromPage.renameTo( toPage );
}
I thought I might throw a ProviderException if the page existed but that
seems
contrary to existing practice. Am I missing something here? Should we
consider
changing the API and/or the documentation (and therefore the
implementations)?
Ichiro
PS. And don't get me started on the deletePage() and deleteVersion()
methods...
And attachments? Yuck.
Re: movePage() overwrites existing page?
Posted by David Vittor <dv...@gmail.com>.
Hi Ichiro,
Interesting, I was just writing a JDBCPageProvider, and noticed the same
thing. In the FileSystemProvider class we potentially clobber an existing
page. Although throwing an exception seems dramatic, I think it might be
the best approach for now.
Cheers,
David V
On Tue, Oct 28, 2014 at 9:25 PM, Ichiro Furusato <ic...@gmail.com>
wrote:
> Hi,
>
> Just coming up for air, thought I'd throw what might seem a random question
> into
> the group, as I'm working on a WikiPageProvider implementation.
>
> It appears that the movePage() method makes absolutely no checks prior to
> moving (renaming) a wiki page. In other words, moving/renaming a page to
> the
> name of an already-existing page will clobber that existing page. There's
> in
> the existing code no check, nor even any feedback, as the method returns
> void.
>
> Here's the code from the FileSystemProvider:
>
> public void movePage( String from, String to )
> throws ProviderException
> {
> File fromPage = findPage( from );
> File toPage = findPage( to );
>
> fromPage.renameTo( toPage );
> }
>
> I thought I might throw a ProviderException if the page existed but that
> seems
> contrary to existing practice. Am I missing something here? Should we
> consider
> changing the API and/or the documentation (and therefore the
> implementations)?
>
> Ichiro
>
> PS. And don't get me started on the deletePage() and deleteVersion()
> methods...
> And attachments? Yuck.
>