Author: ajaquith
Date: Sat May  2 14:08:16 2009
New Revision: 770957

URL: http://svn.apache.org/viewvc?rev=770957&view=rev
Log:
Fixed subtle bug in JCRWikiPage that was causing isAttachment() to incorrectly 
report its status. Also, JCRWikiPage no longer manages its own references (now 
handled by ReferenceManager) or saves itself to the JCR (it delegates to 
ContentManager, so that ContentEvent creation can be guaranteed).

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

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java?rev=770957&r1=770956&r2=770957&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java Sat May  
2 14:08:16 2009
@@ -64,9 +64,6 @@
     public  static final String CONTENTTYPE  = "wiki:contentType";
     
 
-    public static final String REFERSTO = "wiki:refersTo";
-    
-
     private       WikiPath   m_name;
     private       WikiEngine m_engine;
     private String           m_jcrPath = null;
@@ -472,31 +469,14 @@
         return (String)getAttribute( CONTENTTYPE );
     }
 
-    public Set<String> getReferrers()
+    public List<WikiPath> getReferrers() throws ProviderException
     {
-        // TODO Auto-generated method stub
-        return null;
+        return m_engine.getReferenceManager().getReferredBy( m_name );
     }
     
-    public Collection<WikiPath> getRefersTo() throws ProviderException
+    public List<WikiPath> getRefersTo() throws ProviderException
     {
-        Collection<WikiPath> refs = new ArrayList<WikiPath>();
-        
-        try
-        {
-            Property p = getProperty( REFERSTO );
-            
-            Value[] values = p.getValues();
-            
-            for( Value v : values )
-                refs.add( WikiPath.valueOf( v.getString() ) );
-        }
-        catch( PathNotFoundException e ) {}
-        catch( RepositoryException e )
-        {
-            throw new ProviderException("Unable to get the referrals",e);
-        }
-        return refs;
+        return m_engine.getReferenceManager().getRefersTo( m_name );
     }
     
 
@@ -517,15 +497,14 @@
         setAttribute( CONTENTTYPE, contentType );
     }
     
+    /**
+     * {...@inheritdoc}. This implementation delegates to {...@link 
ContentManager#save(WikiPage)}.
+     */
     public void save() throws ProviderException
     {
         try
         {
-            Node nd = getJCRNode();
-            if( nd.isNew() )
-                nd.getParent().save();
-            else
-                nd.save();
+            m_engine.getContentManager().save( this );
         }
         catch( RepositoryException e )
         {
@@ -601,7 +580,7 @@
     {
         String contentType = getContentType();
         boolean exists = m_engine.getContentManager().pageExists( getPath() );
-        if( !exists || ContentManager.JSPWIKI_CONTENT_TYPE.equals( contentType 
) ) return false;
+        if( !exists || contentType == null || 
ContentManager.JSPWIKI_CONTENT_TYPE.equals( contentType ) ) return false;
         
         return true;
     }


Reply via email to