OK, it seems there's enough consensus on this... So I'll modify ContentManager accordingly.

(This commit was just to fix that one bug :-)

/Janne

On Mar 12, 2009, at 20:57 , Harry Metske wrote:

maybe I misunderstood, but my +1 was intended for your second suggestion :

*(A general question, should we start throwing something like
PageNotFoundExceptions as opposed to returning nulls? That would encourage a bit safer coding and would eliminate a number of if(getPage() == null) tests
across the codebase.)*

/Harry


2009/3/12 <[email protected]>

Author: jalkanen
Date: Thu Mar 12 18:34:27 2009
New Revision: 752963

URL: http://svn.apache.org/viewvc?rev=752963&view=rev
Log:
getPage(WikiName,int) was not catching exceptions properly.

Modified:
  incubator/jspwiki/trunk/ChangeLog
  incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java

incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ ContentManager.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=752963&r1=752962&r2=752963&view=diff

= = = = = = = = = =====================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Thu Mar 12 18:34:27 2009
@@ -1,3 +1,10 @@
+2009-03-12  Janne Jalkanen <[email protected]>
+
+        * 3.0.0-svn-82
+
+        * Fixed issue in ContentManager.getPage() not properly
+        catching exceptions.
+
2009-02-22  Andrew Jaquith <ajaquith AT apache DOT org>

       * 3.0.0-svn-81

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=752963&r1=752962&r2=752963&view=diff

= = = = = = = = = =====================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Thu Mar
12 18:34:27 2009
@@ -77,7 +77,7 @@
    *  <p>
    *  If the build identifier is empty, it is not added.
    */
-    public static final String     BUILD         = "80";
+    public static final String     BUILD         = "81";

   /**
    *  This is the generic version string you should use

Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ ContentManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java?rev=752963&r1=752962&r2=752963&view=diff

= = = = = = = = = =====================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ ContentManager.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ ContentManager.java
Thu Mar 12 18:34:27 2009
@@ -655,7 +655,7 @@
    *  @param wikiPath  the {...@link WikiName} to check for
    *  @param version The version to check
* @return <code>true</code> if the page exists, <code>false</ code>
otherwise
- * @throws WikiException If the backend fails or the wikiPath is
illegal.
+ * @throws ProviderException If the backend fails or the wikiPath is
illegal.
    */
   public boolean pageExists( WikiName wikiPath, int version )
       throws ProviderException
@@ -681,7 +681,7 @@
    *  Deletes only a specific version of a WikiPage.
    *
    *  @param page The page to delete.
-     *  @throws WikiException if the page fails
+     *  @throws ProviderException if the page fails
    */
   public void deleteVersion( WikiPage page )
       throws ProviderException
@@ -706,7 +706,7 @@
    *  Deletes an entire page, all versions, all traces.
    *
    *  @param page The WikiPage to delete
- * @throws WikiException If the backend fails or the page is illegal. + * @throws ProviderException If the backend fails or the page is
illegal.
    */

   public void deletePage( WikiPage page )
@@ -947,7 +947,7 @@
    *
    *  @param jcrpath The JCR Path used to get the {...@link WikiName}
    *  @return The {...@link WikiName} for the requested jcr path
-     *  @throws WikiException If the backend fails.
+     *  @throws ProviderException If the backend fails.
    */
   // FIXME: Should be protected - fix once WikiPage moves to
content-package
   public static WikiName getWikiPath( String jcrpath ) throws
ProviderException
@@ -975,7 +975,7 @@
    *  @param path the WikiName
    *  @param contentType the type of content
    *  @return the {...@link JCRWikiPage}
-     *  @throws WikiException If the backend fails.
+     *  @throws ProviderException If the backend fails.
    */
public JCRWikiPage addPage( WikiName path, String contentType ) throws
ProviderException
   {
@@ -1054,6 +1054,11 @@

           return page;
       }
+        catch( PathNotFoundException e )
+        {
+            // Page was not found at all.
+            return null;
+        }
       catch( RepositoryException e )
       {
           throw new ProviderException( "Unable to get a page", e );




Reply via email to