incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janne Jalkanen <Janne.Jalka...@ecyrd.com>
Subject JCR commit?
Date Tue, 03 Mar 2009 22:33:12 GMT
Folks,

I'd like to make the commit which removes the PageProviders from use  
and replaces them with the JCR backend (I'm scared to keep it in my  
hard drive for long).

However, this will break about 150 unit tests, and I haven't yet had  
time to see which ones became obsolete and which ones are really  
broken.  Also error handling is far from optimal (I don't want to  
tweak it too hard until we decide if we want to change the way we do  
errors).  But it should give you a chance to start hacking on it.

Any objections?  The patch is included, if you want to try it out  
before having an opinion. It's against the SVN trunk as of now.

/Janne

### Eclipse Workspace Patch 1.0
#P JSPWiki-trunk
Index: src/java/org/apache/wiki/WikiEngine.java
===================================================================
--- src/java/org/apache/wiki/WikiEngine.java	(revision 749743)
+++ src/java/org/apache/wiki/WikiEngine.java	(working copy)
@@ -1751,8 +1751,8 @@
          // If submitter is authenticated, any reject messages will  
appear in his/her workflow inbox.
          WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
          Principal submitter = context.getCurrentUser();
-        Task prepTask = new PageManager.PreSaveWikiPageTask( context,  
proposedText );
-        Task completionTask = new PageManager.SaveWikiPageTask();
+        Task prepTask = new  
ContentManager.PreSaveWikiPageTask( context, proposedText );
+        Task completionTask = new ContentManager.SaveWikiPageTask();
          String diffText = m_differenceManager.makeDiff( context,  
oldText, proposedText );
          boolean isAuthenticated =  
context.getWikiSession().isAuthenticated();
          Fact[] facts = new Fact[5];
Index: src/java/org/apache/wiki/PageManager.java
===================================================================
--- src/java/org/apache/wiki/PageManager.java	(revision 749743)
+++ src/java/org/apache/wiki/PageManager.java	(working copy)
@@ -20,35 +20,19 @@
   */
  package org.apache.wiki;

-import java.io.IOException;
-import java.security.Permission;
-import java.security.Principal;
-import java.util.*;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;

-import org.apache.commons.lang.ArrayUtils;
-import org.apache.wiki.api.FilterException;
  import org.apache.wiki.api.WikiException;
  import org.apache.wiki.api.WikiPage;
-import org.apache.wiki.auth.WikiPrincipal;
-import org.apache.wiki.auth.WikiSecurityException;
-import org.apache.wiki.auth.acl.Acl;
-import org.apache.wiki.auth.acl.AclEntry;
-import org.apache.wiki.auth.acl.AclEntryImpl;
-import org.apache.wiki.auth.user.UserProfile;
-import org.apache.wiki.event.*;
+import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.WikiName;
  import org.apache.wiki.log.Logger;
  import org.apache.wiki.log.LoggerFactory;
  import org.apache.wiki.modules.ModuleManager;
-import org.apache.wiki.providers.CachingProvider;
  import org.apache.wiki.providers.ProviderException;
-import org.apache.wiki.providers.RepositoryModifiedException;
  import org.apache.wiki.providers.WikiPageProvider;
-import org.apache.wiki.util.ClassUtil;
-import org.apache.wiki.util.TextUtil;
-import org.apache.wiki.util.WikiBackgroundThread;
-import org.apache.wiki.workflow.Outcome;
-import org.apache.wiki.workflow.Task;
-import org.apache.wiki.workflow.Workflow;


  /**
@@ -64,7 +48,7 @@
  // FIXME: This class currently only functions just as an extra layer  
over providers,
  //        complicating things.  We need to move more provider- 
specific functionality
  //        from WikiEngine (which is too big now) into this class.
-public class PageManager extends ModuleManager implements  
WikiEventListener
+public class PageManager extends ModuleManager
  {
      private static final long serialVersionUID = 1L;

@@ -117,14 +101,6 @@

      private WikiPageProvider m_provider;

-    protected HashMap<String,PageLock> m_pageLocks = new  
HashMap<String,PageLock>();
-
-    private WikiEngine m_engine;
-
-    private int m_expiryTime = 60;
-
-    private LockReaper m_reaper = null;
-
      /**
       *  Creates a new PageManager.
       *
@@ -136,66 +112,6 @@
          throws WikiException
      {
          super( engine );
-
-        String classname;
-
-        m_engine = engine;
-
-        boolean useCache =  
"true".equals(props.getProperty( PROP_USECACHE ));
-
-        m_expiryTime =  
TextUtil.parseIntParameter( props.getProperty( PROP_LOCKEXPIRY ), 60 );
-
-        //
-        //  If user wants to use a cache, then we'll use the  
CachingProvider.
-        //
-        if( useCache )
-        {
-            classname = "org.apache.wiki.providers.CachingProvider";
-        }
-        else
-        {
-            classname = WikiEngine.getRequiredProperty( props,  
PROP_PAGEPROVIDER );
-        }
-
-        try
-        {
-            log.debug("Page provider class: '"+classname+"'");
-
-            Class providerclass =  
ClassUtil.findClass( "org.apache.wiki.providers",
-                                                       classname );
-
-            m_provider = (WikiPageProvider)providerclass.newInstance();
-
-            log.debug("Initializing page provider class "+m_provider);
-            m_provider.initialize( m_engine, props );
-        }
-        catch( ClassNotFoundException e )
-        {
-            log.error("Unable to locate provider class '"+classname 
+"'",e);
-            throw new WikiException("no provider class");
-        }
-        catch( InstantiationException e )
-        {
-            log.error("Unable to create provider class '"+classname 
+"'",e);
-            throw new WikiException("faulty provider class");
-        }
-        catch( IllegalAccessException e )
-        {
-            log.error("Illegal access to provider class '"+classname 
+"'",e);
-            throw new WikiException("illegal provider class");
-        }
-        catch( NoRequiredPropertyException e )
-        {
-            log.error("Provider did not found a property it was  
looking for: "+e.getMessage(),
-                      e);
-            throw e;  // Same exception works.
-        }
-        catch( IOException e )
-        {
-            log.error("An I/O exception occurred while trying to  
create a new page provider: "+classname, e );
-            throw new WikiException("Unable to start page provider:  
"+e.getMessage());
-        }
-
      }


@@ -220,7 +136,7 @@
      public Collection getAllPages()
          throws ProviderException
      {
-        return m_provider.getAllPages();
+        return m_engine.getContentManager().getAllPages(null);
      }

      /**
@@ -236,49 +152,7 @@
      public String getPageText( String pageName, int version )
          throws ProviderException
      {
-        if( pageName == null || pageName.length() == 0 )
-        {
-            throw new ProviderException("Illegal page name");
-        }
-
-        String text = null;
-
-        try
-        {
-            text = m_provider.getPageText( pageName, version );
-        }
-        catch( RepositoryModifiedException e )
-        {
-            //
-            //  This only occurs with the latest version.
-            //
-            log.info("Repository has been modified externally while  
fetching page "+pageName );
-
-            //
-            //  Empty the references and yay, it shall be recalculated
-            //
-            //WikiPage p = new WikiPage( pageName );
-            WikiPage p = m_provider.getPageInfo( pageName, version );
-
-            m_engine.updateReferences( p );
-
-            if( p != null )
-            {
-                m_engine.getSearchManager().reindexPage( p );
-                text = m_provider.getPageText( pageName, version );
-            }
-            else
-            {
-                //
-                //  Make sure that it no longer exists in internal  
data structures either.
-                //
-                WikiPage dummy = m_engine.createPage(pageName);
-                m_engine.getSearchManager().pageRemoved(dummy);
-                m_engine.getReferenceManager().pageRemoved(dummy);
-            }
-        }
-
-        return text;
+        return  
m_engine.getContentManager().getPage( WikiName.valueOf( pageName ),  
version ).getContentAsString();
      }

      /**
@@ -302,12 +176,14 @@
      public void putPageText( WikiPage page, String content )
          throws ProviderException
      {
-        if( page == null || page.getName() == null ||  
page.getName().length() == 0 )
-        {
-            throw new ProviderException("Illegal page name");
-        }
-
-        m_provider.putPageText( page, content );
+        WikiPage p =  
m_engine.getContentManager().getPage( page.getQualifiedName() );
+
+        if( p == null )
+            p =  
m_engine.getContentManager().addPage( page.getQualifiedName(),  
ContentManager.JSPWIKI_CONTENT_TYPE );
+
+        p.setContent(content);
+
+        p.save();
      }

      /**
@@ -321,47 +197,7 @@
       */
      public PageLock lockPage( WikiPage page, String user )
      {
-        PageLock lock = null;
-
-        if( m_reaper == null )
-        {
-            //
-            //  Start the lock reaper lazily.  We don't want to start  
it in
-            //  the constructor, because starting threads in  
constructors
-            //  is a bad idea when it comes to inheritance.  Besides,
-            //  laziness is a virtue.
-            //
-            m_reaper = new LockReaper( m_engine );
-            m_reaper.start();
-        }
-
-        synchronized( m_pageLocks )
-        {
-            fireEvent( WikiPageEvent.PAGE_LOCK, page.getName() ); //  
prior to or after actual lock?
-
-            lock = m_pageLocks.get( page.getName() );
-
-            if( lock == null )
-            {
-                //
-                //  Lock is available, so make a lock.
-                //
-                Date d = new Date();
-                lock = new PageLock( page, user, d,
-                                     new Date( d.getTime() +  
m_expiryTime*60*1000L ) );
-
-                m_pageLocks.put( page.getName(), lock );
-
-                log.debug( "Locked page "+page.getName()+" for "+user);
-            }
-            else
-            {
-                log.debug( "Page "+page.getName()+" already locked by  
"+lock.getLocker() );
-                lock = null; // Nothing to return
-            }
-        }
-
-        return lock;
+        return m_engine.getContentManager().lockPage( page, user );
      }

      /**
@@ -372,16 +208,7 @@
       */
      public void unlockPage( PageLock lock )
      {
-        if( lock == null ) return;
-
-        synchronized( m_pageLocks )
-        {
-            m_pageLocks.remove( lock.getPage() );
-
-            log.debug( "Unlocked page "+lock.getPage() );
-        }
-
-        fireEvent( WikiPageEvent.PAGE_UNLOCK, lock.getPage() );
+        m_engine.getContentManager().unlockPage( lock );
      }

      /**
@@ -393,14 +220,7 @@
       */
      public PageLock getCurrentLock( WikiPage page )
      {
-        PageLock lock = null;
-
-        synchronized( m_pageLocks )
-        {
-            lock = m_pageLocks.get( page.getName() );
-        }
-
-        return lock;
+        return m_engine.getContentManager().getCurrentLock( page );
      }

      /**
@@ -413,17 +233,7 @@
       */
      public List getActiveLocks()
      {
-        ArrayList<PageLock> result = new ArrayList<PageLock>();
-
-        synchronized( m_pageLocks )
-        {
-            for( PageLock lock : m_pageLocks.values() )
-            {
-                result.add( lock );
-            }
-        }
-
-        return result;
+        return m_engine.getContentManager().getActiveLocks();
      }

      /**
@@ -438,47 +248,7 @@
      public WikiPage getPageInfo( String pageName, int version )
          throws ProviderException
      {
-        if( pageName == null || pageName.length() == 0 )
-        {
-            throw new ProviderException("Illegal page name '"+pageName 
+"'");
-        }
-
-        WikiPage page = null;
-
-        try
-        {
-            page = m_provider.getPageInfo( pageName, version );
-        }
-        catch( RepositoryModifiedException e )
-        {
-            //
-            //  This only occurs with the latest version.
-            //
-            log.info("Repository has been modified externally while  
fetching info for "+pageName );
-
-            page = m_provider.getPageInfo( pageName, version );
-
-            if( page != null )
-            {
-                m_engine.updateReferences( page );
-            }
-            else
-            {
-                 
m_engine 
.getReferenceManager().pageRemoved( m_engine.createPage(pageName) );
-            }
-        }
-
-        //
-        //  Should update the metadata.
-        //
-        /*
-        if( page != null && !page.hasMetadata() )
-        {
-            WikiContext ctx = new WikiContext(m_engine,page);
-            m_engine.textToHTML( ctx, getPageText(pageName,version) );
-        }
-        */
-        return page;
+        return  
m_engine.getContentManager().getPage( WikiName.valueOf( pageName ),  
version );
      }

      /**
@@ -493,12 +263,7 @@
      public List getVersionHistory( String pageName )
          throws ProviderException
      {
-        if( pageExists( pageName ) )
-        {
-            return m_provider.getVersionHistory( pageName );
-        }
-
-        return null;
+        return  
m_engine 
.getContentManager().getVersionHistory( WikiName.valueOf( pageName ) );
      }

      /**
@@ -508,7 +273,7 @@
       */
      public String getProviderDescription()
      {
-        return m_provider.getProviderInfo();
+        return m_engine.getContentManager().getProviderDescription();
      }

      /**
@@ -521,15 +286,7 @@
       */
      public int getTotalPageCount()
      {
-        try
-        {
-            return m_provider.getAllPages().size();
-        }
-        catch( ProviderException e )
-        {
-            log.error( "Unable to count pages: ",e );
-            return -1;
-        }
+        return m_engine.getContentManager().getTotalPageCount( null );
      }

      /**
@@ -542,12 +299,7 @@
      public boolean pageExists( String pageName )
          throws ProviderException
      {
-        if( pageName == null || pageName.length() == 0 )
-        {
-            throw new ProviderException("Illegal page name");
-        }
-
-        return m_provider.pageExists( pageName );
+        return  
m_engine.getContentManager().pageExists( WikiName.valueOf( pageName ) );
      }

      /**
@@ -562,20 +314,7 @@
      public boolean pageExists( String pageName, int version )
          throws ProviderException
      {
-        if( pageName == null || pageName.length() == 0 )
-        {
-            throw new ProviderException("Illegal page name");
-        }
-
-        if( version == WikiProvider.LATEST_VERSION )
-            return pageExists( pageName );
-
-        if( m_provider instanceof CachingProvider )
-        {
-            return  
((CachingProvider)m_provider).pageExists( pageName , version );
-        }
-
-        return m_provider.getPageInfo( pageName, version ) != null;
+        return  
m_engine.getContentManager().pageExists( WikiName.valueOf( pageName ),  
version );
      }

      /**
@@ -587,10 +326,7 @@
      public void deleteVersion( WikiPage page )
          throws ProviderException
      {
-        m_provider.deleteVersion( page.getName(), page.getVersion() );
-
-        // FIXME: If this was the latest, reindex Lucene
-        // FIXME: Update RefMgr
+        m_engine.getContentManager().deleteVersion( page );
      }

      /**
@@ -602,190 +338,10 @@
      public void deletePage( WikiPage page )
          throws ProviderException
      {
-        fireEvent( WikiPageEvent.PAGE_DELETE_REQUEST, page.getName() );
-
-        m_provider.deletePage( page.getName() );
-
-        fireEvent( WikiPageEvent.PAGE_DELETED, page.getName() );
+        m_engine.getContentManager().deletePage( page );
      }

-    /**
-     *  This is a simple reaper thread that runs roughly every minute
-     *  or so (it's not really that important, as long as it runs),
-     *  and removes all locks that have expired.
-     */
-    private class LockReaper extends WikiBackgroundThread
-    {
-        /**
-         *  Create a LockReaper for a given engine.
-         *
-         *  @param engine WikiEngine to own this thread.
-         */
-        public LockReaper( WikiEngine engine )
-        {
-            super( engine, 60 );
-            setName("JSPWiki Lock Reaper");
-        }
-
-        public void backgroundTask() throws Exception
-        {
-            synchronized( m_pageLocks )
-            {
-                Collection entries = m_pageLocks.values();
-
-                Date now = new Date();
-
-                for( Iterator i = entries.iterator(); i.hasNext(); )
-                {
-                    PageLock p = (PageLock) i.next();
-
-                    if( now.after( p.getExpiryTime() ) )
-                    {
-                        i.remove();
-
-                        log.debug( "Reaped lock: "+p.getPage()+
-                                   " by "+p.getLocker()+
-                                   ", acquired  
"+p.getAcquisitionTime()+
-                                   ", and expired  
"+p.getExpiryTime() );
-                    }
-                }
-            }
-        }
-    }
-
-    // workflow task inner  
classes....................................................
-
-    /**
-     * Inner class that handles the page pre-save actions. If the  
proposed page
-     * text is the same as the current version, the {@link  
#execute()} method
-     * returns {@link org.apache.wiki.workflow.Outcome#STEP_ABORT}. Any
-     * WikiExceptions thrown by page filters will be re-thrown, and  
the workflow
-     * will abort.
-     *
-     * @author Andrew Jaquith
-     */
-    public static class PreSaveWikiPageTask extends Task
-    {
-        private static final long serialVersionUID =  
6304715570092804615L;
-        private final WikiContext m_context;
-        private final String m_proposedText;
-
-        /**
-         *  Creates the task.
-         *
-         *  @param context The WikiContext
-         *  @param proposedText The text that was just saved.
-         */
-        public PreSaveWikiPageTask( WikiContext context, String  
proposedText )
-        {
-            super( PRESAVE_TASK_MESSAGE_KEY );
-            m_context = context;
-            m_proposedText = proposedText;
-        }
-
-        /**
-         *  {@inheritDoc}
-         */
-        @Override
-        public Outcome execute() throws WikiException
-        {
-            // Retrieve attributes
-            WikiEngine engine = m_context.getEngine();
-            Workflow workflow = getWorkflow();
-
-            // Get the wiki page
-            WikiPage page = m_context.getPage();
-
-            // Figure out who the author was. Prefer the author
-            // set programmatically; otherwise get from the
-            // current logged in user
-            if ( page.getAuthor() == null )
-            {
-                Principal wup = m_context.getCurrentUser();
-
-                if ( wup != null )
-                    page.setAuthor( wup.getName() );
-            }
-
-            // Run the pre-save filters. If any exceptions, add error  
to list, abort, and redirect
-            String saveText;
-            try
-            {
-                saveText =  
engine.getFilterManager().doPreSaveFiltering( m_context,  
m_proposedText );
-            }
-            catch ( FilterException e )
-            {
-                throw e;
-            }
-
-            // Stash the wiki context, old and new text as workflow  
attributes
-            workflow.setAttribute( PRESAVE_WIKI_CONTEXT, m_context );
-            workflow.setAttribute( FACT_PROPOSED_TEXT, saveText );
-            return Outcome.STEP_COMPLETE;
-        }
-    }
-
-    /**
-     * Inner class that handles the actual page save and post-save  
actions. Instances
-     * of this class are assumed to have been added to an approval  
workflow via
-     * {@link  
org 
.apache.wiki.workflow.WorkflowBuilder#buildApprovalWorkflow(Principal,  
String, Task, String, org.apache.wiki.workflow.Fact[], Task, String)};
-     * they will not function correctly otherwise.
-     *
-     * @author Andrew Jaquith
-     */
-    public static class SaveWikiPageTask extends Task
-    {
-        private static final long serialVersionUID =  
3190559953484411420L;
-
-        /**
-         *  Creates the Task.
-         */
-        public SaveWikiPageTask()
-        {
-            super( SAVE_TASK_MESSAGE_KEY );
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public Outcome execute() throws WikiException
-        {
-            // Retrieve attributes
-            WikiContext context = (WikiContext)  
getWorkflow().getAttribute( PRESAVE_WIKI_CONTEXT );
-            String proposedText = (String)  
getWorkflow().getAttribute( FACT_PROPOSED_TEXT );
-
-            WikiEngine engine = context.getEngine();
-            WikiPage page = context.getPage();
-
-            // Let the rest of the engine handle actual saving.
-            engine.getPageManager().putPageText( page, proposedText );
-
-            // Refresh the context for post save filtering.
-            engine.getPage( page.getName() );
-            engine.textToHTML( context, proposedText );
-            engine.getFilterManager().doPostSaveFiltering( context,  
proposedText );
-
-            return Outcome.STEP_COMPLETE;
-        }
-    }
-
-    // events  
processing .......................................................
-
-    /**
-     *  Fires a WikiPageEvent of the provided type and page name
-     *  to all registered listeners.
-     *
-     * @see org.apache.wiki.event.WikiPageEvent
-     * @param type       the event type to be fired
-     * @param pagename   the wiki page name as a String
-     */
-    protected final void fireEvent( int type, String pagename )
-    {
-        if ( WikiEventManager.isListening(this) )
-        {
-            WikiEventManager.fireEvent(this,new  
WikiPageEvent(m_engine,type,pagename));
-        }
-    }
-
+
      /**
       *  {@inheritDoc}
       */
@@ -796,117 +352,4 @@
          return null;
      }

-
-    /**
-     *  Listens for {@link  
org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
-     *  events. If a user profile's name changes, each page ACL is  
inspected. If an entry contains
-     *  a name that has changed, it is replaced with the new one. No  
events are emitted
-     *  as a consequence of this method, because the page contents  
are still the same; it is
-     *  only the representations of the names within the ACL that are  
changing.
-     *
-     *  @param event The event
-     */
-    public void actionPerformed(WikiEvent event)
-    {
-        if (! ( event instanceof WikiSecurityEvent ) )
-        {
-            return;
-        }
-
-        WikiSecurityEvent se = (WikiSecurityEvent)event;
-        if ( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED )
-        {
-            UserProfile[] profiles = (UserProfile[])se.getTarget();
-            Principal[] oldPrincipals = new Principal[]
-                { new WikiPrincipal( profiles[0].getLoginName() ),
-                  new WikiPrincipal( profiles[0].getFullname() ),
-                  new WikiPrincipal( profiles[0].getWikiName() ) };
-            Principal newPrincipal = new  
WikiPrincipal( profiles[1].getFullname() );
-
-            // Examine each page ACL
-            try
-            {
-                int pagesChanged = 0;
-                Collection pages = getAllPages();
-                for ( Iterator it = pages.iterator(); it.hasNext(); )
-                {
-                    WikiPage page = (WikiPage)it.next();
-                    boolean aclChanged = changeAcl( page,  
oldPrincipals, newPrincipal );
-                    if ( aclChanged )
-                    {
-                        // If the Acl needed changing, change it now
-                        try
-                        {
-                             
m_engine.getAclManager().setPermissions( page, page.getAcl() );
-                        }
-                        catch ( WikiSecurityException e )
-                        {
-                            log.error( "Could not change page ACL for  
page " + page.getName() + ": " + e.getMessage() );
-                        }
-                        pagesChanged++;
-                    }
-                }
-                log.info( "Profile name change for '" +  
newPrincipal.toString() +
-                          "' caused " + pagesChanged + " page ACLs to  
change also." );
-            }
-            catch ( ProviderException e )
-            {
-                // Oooo! This is really bad...
-                log.error( "Could not change user name in Page ACLs  
because of Provider error:" + e.getMessage() );
-            }
-        }
-    }
-
-    /**
-     *  For a single wiki page, replaces all Acl entries matching a  
supplied array of Principals
-     *  with a new Principal.
-     *
-     *  @param page the wiki page whose Acl is to be modified
-     *  @param oldPrincipals an array of Principals to replace; all  
AclEntry objects whose
-     *   {@link AclEntry#getPrincipal()} method returns one of these  
Principals will be replaced
-     *  @param newPrincipal the Principal that should receive the old  
Principals' permissions
-     *  @return <code>true</code> if the Acl was actually changed;  
<code>false</code> otherwise
-     */
-    protected boolean changeAcl( WikiPage page, Principal[]  
oldPrincipals, Principal newPrincipal )
-    {
-        Acl acl = page.getAcl();
-        boolean pageChanged = false;
-        if ( acl != null )
-        {
-            Enumeration entries = acl.entries();
-            Collection<AclEntry> entriesToAdd    = new  
ArrayList<AclEntry>();
-            Collection<AclEntry> entriesToRemove = new  
ArrayList<AclEntry>();
-            while ( entries.hasMoreElements() )
-            {
-                AclEntry entry = (AclEntry)entries.nextElement();
-                if ( ArrayUtils.contains( oldPrincipals,  
entry.getPrincipal() ) )
-                {
-                    // Create new entry
-                    AclEntry newEntry = new AclEntryImpl();
-                    newEntry.setPrincipal( newPrincipal );
-                    Enumeration permissions = entry.permissions();
-                    while ( permissions.hasMoreElements() )
-                    {
-                        Permission permission =  
(Permission)permissions.nextElement();
-                        newEntry.addPermission(permission);
-                    }
-                    pageChanged = true;
-                    entriesToRemove.add( entry );
-                    entriesToAdd.add( newEntry );
-                }
-            }
-            for ( Iterator ix = entriesToRemove.iterator();  
ix.hasNext(); )
-            {
-                AclEntry entry = (AclEntry)ix.next();
-                acl.removeEntry( entry );
-            }
-            for ( Iterator ix = entriesToAdd.iterator();  
ix.hasNext(); )
-            {
-                AclEntry entry = (AclEntry)ix.next();
-                acl.addEntry( entry );
-            }
-        }
-        return pageChanged;
-    }
-
  }
Index: src/java/org/apache/wiki/JCRWikiPage.java
===================================================================
--- src/java/org/apache/wiki/JCRWikiPage.java	(revision 749743)
+++ src/java/org/apache/wiki/JCRWikiPage.java	(working copy)
@@ -20,13 +20,14 @@
   */
  package org.apache.wiki;

-import java.io.InputStream;
+import java.io.*;
  import java.util.*;

-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
+import javax.jcr.*;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;

  import org.apache.wiki.api.WikiException;
  import org.apache.wiki.api.WikiPage;
@@ -35,12 +36,12 @@
  import org.apache.wiki.auth.acl.AclImpl;
  import org.apache.wiki.content.ContentManager;
  import org.apache.wiki.content.WikiName;
+import org.apache.wiki.providers.ProviderException;
  import org.apache.wiki.providers.WikiPageProvider;


  /**
- *  Simple wrapper class for the Wiki page attributes.  The Wiki page
- *  content is moved around in Strings, though.
+ *  JCR-backed implementation of the WikiPage.
   *
   *  @since 3.0
   */
@@ -55,16 +56,15 @@
  {
      private static final long serialVersionUID = 1L;

+    private static final String LASTMODIFIED = "wiki:lastModified";
+
+    private static final String AUTHOR       = "wiki:author";
+
+    private static final String ACL = "wiki:acl";
+
      private       WikiName   m_name;
      private       WikiEngine m_engine;
-    private Date             m_lastModified;
-    private long             m_fileSize = -1;
-    private int              m_version =  
WikiPageProvider.LATEST_VERSION;
-    private String           m_author = null;
-    private final HashMap<String,Object> m_attributes = new  
HashMap<String,Object>();
-    private Node             m_node;
-
-    private Acl m_accessList = null;
+    private String           m_jcrPath = null;

      /**
       *  Use {@link WikiEngine#createPage(String)} instead.
@@ -72,8 +72,7 @@
       */
      public JCRWikiPage( WikiEngine engine, String path )
      {
-        m_engine = engine;
-        m_name   = WikiName.valueOf( path );
+        this( engine, WikiName.valueOf( path ) );
      }

      /**
@@ -82,22 +81,22 @@
       */
      public JCRWikiPage( WikiEngine engine, WikiName name )
      {
-        m_engine = engine;
-        m_name   = name;
+        m_engine  = engine;
+        m_name    = name;
+        m_jcrPath = ContentManager.getJCRPath( name );
      }

      public JCRWikiPage(WikiEngine engine, Node node)
-        throws RepositoryException, WikiException
+        throws RepositoryException, ProviderException
      {
-        m_engine = engine;
-        m_node   = node;
-        m_name   = ContentManager.getWikiPath( node.getPath() );
+        m_engine  = engine;
+        m_jcrPath = node.getPath();
+        m_name    = ContentManager.getWikiPath( node.getPath() );
      }
-
-
-    public Node getJCRNode()
+
+    public Node getJCRNode() throws RepositoryException
      {
-        return m_node;
+        return m_engine.getContentManager().getJCRNode(m_jcrPath);
      }

      /* (non-Javadoc)
@@ -111,9 +110,9 @@
      /* (non-Javadoc)
       * @see org.apache.wiki.WikiPage#getQualifiedName()
       */
-    public String getQualifiedName()
+    public WikiName getQualifiedName()
      {
-        return m_name.toString();
+        return m_name;
      }

      /* (non-Javadoc)
@@ -121,23 +120,58 @@
       */
      public Object getAttribute( String key )
      {
-        return m_attributes.get( key );
+        try
+        {
+            Property property = getJCRNode().getProperty( key );
+
+            return getValue( property );
+        }
+        catch( ItemNotFoundException e ) {}
+        catch( RepositoryException e ) {} // FIXME: Should log this  
at least.
+
+        return null;
+    }
+
+    private Object getValue( Property property ) throws  
RepositoryException, ValueFormatException
+    {
+        switch( property.getType() )
+        {
+            case PropertyType.STRING:
+                return property.getString();
+        }
+
+        return property.getString();
      }

      /* (non-Javadoc)
       * @see org.apache.wiki.WikiPage#setAttribute(java.lang.String,  
java.lang.Object)
       */
-    public void setAttribute( String key, Object attribute )
+    public void setAttribute( String key, String attribute )
      {
-        m_attributes.put( key, attribute );
+        try
+        {
+            getJCRNode().setProperty( key, attribute );
+        }
+        catch(RepositoryException e) {} // FIXME: Should log
      }

+    public void setAttribute( String key, Date attribute )
+    {
+        try
+        {
+            Calendar c = Calendar.getInstance();
+            c.setTime( attribute );
+            getJCRNode().setProperty( key, c );
+        }
+        catch(RepositoryException e) {} // FIXME: Should log
+    }
+
      /* (non-Javadoc)
       * @see org.apache.wiki.WikiPage#getAttributes()
       */
      public Map getAttributes()
      {
-        return m_attributes;
+        return null; // FIXME: m_attributes;
      }

      /* (non-Javadoc)
@@ -145,7 +179,18 @@
       */
      public Object removeAttribute( String key )
      {
-        return m_attributes.remove( key );
+        try
+        {
+            Property p = getJCRNode().getProperty( key );
+
+            Object value = getValue(p);
+            p.remove();
+
+            return value;
+        }
+        catch(RepositoryException e) {}
+
+        return null;
      }

      /* (non-Javadoc)
@@ -153,7 +198,15 @@
       */
      public Date getLastModified()
      {
-        return m_lastModified;
+        try
+        {
+            return  
getJCRNode().getProperty( LASTMODIFIED ).getDate().getTime();
+        }
+        catch( RepositoryException e )
+        {
+            // FIXME: Should rethrow
+        }
+        return null;
      }

      /* (non-Javadoc)
@@ -161,15 +214,7 @@
       */
      public void setLastModified( Date date )
      {
-        m_lastModified = date;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#setVersion(int)
-     */
-    public void setVersion( int version )
-    {
-        m_version = version;
+        setAttribute( LASTMODIFIED, date );
      }

      /* (non-Javadoc)
@@ -177,7 +222,8 @@
       */
      public int getVersion()
      {
-        return m_version;
+        return -1;
+        //return getJCRNode().getBaseVersion().
      }

      /* (non-Javadoc)
@@ -185,15 +231,13 @@
       */
      public long getSize()
      {
-        return m_fileSize;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#setSize(long)
-     */
-    public void setSize( long size )
-    {
-        m_fileSize = size;
+        try
+        {
+            return  
getJCRNode().getProperty( ATTR_CONTENT ).getLength();
+        }
+        catch(RepositoryException e){}
+
+        return -1;
      }

      /* (non-Javadoc)
@@ -201,7 +245,50 @@
       */
      public Acl getAcl()
      {
-        return m_accessList;
+        ObjectInputStream in = null;
+
+        try
+        {
+            Property acl = getJCRNode().getProperty( ACL );
+
+            in = new ObjectInputStream( acl.getStream() );
+
+            Acl a = (Acl) in.readObject();
+
+            return a;
+        }
+        catch( PathNotFoundException e )
+        {
+            // No ACL, so this is ok.
+        }
+        catch( RepositoryException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( IOException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( ClassNotFoundException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        finally
+        {
+            if( in != null )
+                try
+                {
+                    in.close();
+                }
+                catch( IOException e )
+                {
+                }
+        }
+
+        return null;
      }

      /* (non-Javadoc)
@@ -209,7 +296,49 @@
       */
      public void setAcl( Acl acl )
      {
-        m_accessList = acl;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        ObjectOutputStream oout;
+        try
+        {
+            oout = new ObjectOutputStream(out);
+            oout.writeObject( acl );
+
+            oout.close();
+
+            getJCRNode().setProperty( ACL, new  
ByteArrayInputStream(out.toByteArray()) );
+        }
+        catch( IOException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( ValueFormatException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( VersionException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( LockException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( ConstraintViolationException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch( RepositoryException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
      }

      /* (non-Javadoc)
@@ -217,7 +346,7 @@
       */
      public void setAuthor( String author )
      {
-        m_author = author;
+        setAttribute( AUTHOR, author );
      }

      /* (non-Javadoc)
@@ -225,7 +354,7 @@
       */
      public String getAuthor()
      {
-        return m_author;
+        return (String)getAttribute( AUTHOR );
      }

      /* (non-Javadoc)
@@ -238,39 +367,11 @@
      }

      /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#invalidateMetadata()
-     */
-    public void invalidateMetadata()
-    {
-        m_hasMetadata = false;
-        setAcl( null );
-        m_attributes.clear();
-    }
-
-    private boolean m_hasMetadata = false;
-
-    /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#hasMetadata()
-     */
-    public boolean hasMetadata()
-    {
-        return m_hasMetadata;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#setHasMetadata()
-     */
-    public void setHasMetadata()
-    {
-        m_hasMetadata = true;
-    }
-
-    /* (non-Javadoc)
       * @see org.apache.wiki.WikiPage#toString()
       */
      public String toString()
      {
-        return "WikiPage ["+m_name+",ver="+m_version 
+",mod="+m_lastModified+"]";
+        return "WikiPage ["+m_name+",ver="+getVersion() 
+",mod="+getLastModified()+"]";
      }

      /* (non-Javadoc)
@@ -280,30 +381,6 @@
      {
          JCRWikiPage p = new JCRWikiPage( m_engine, m_name );

-        p.m_author       = m_author;
-        p.m_version      = m_version;
-        p.m_lastModified = m_lastModified != null ?  
(Date)m_lastModified.clone() : null;
-
-        p.m_fileSize     = m_fileSize;
-
-        for( Map.Entry<String,Object> entry : m_attributes.entrySet() )
-        {
-            p.m_attributes.put( entry.getKey(),
-                                entry.getValue() );
-        }
-
-        if( m_accessList != null )
-        {
-            p.m_accessList = new AclImpl();
-
-            for( Enumeration entries = m_accessList.entries();  
entries.hasMoreElements(); )
-            {
-                AclEntry e = (AclEntry)entries.nextElement();
-
-                p.m_accessList.addEntry( e );
-            }
-        }
-
          return p;
      }

@@ -356,7 +433,7 @@
       */
      public int hashCode()
      {
-        return m_name.hashCode() * m_version;
+        return m_name.hashCode() * getVersion();
      }

      public InputStream getContentAsStream()
@@ -381,7 +458,7 @@
      {
          try
          {
-            m_node.setProperty( ATTR_CONTENT, in );
+            getJCRNode().setProperty( ATTR_CONTENT, in );
          }
          catch( RepositoryException e )
          {
@@ -395,28 +472,29 @@

      }

-    public void save() throws WikiException
+    public void save() throws ProviderException
      {
          try
          {
-            if( m_node.isNew() )
-                m_node.getParent().save();
+            Node nd = getJCRNode();
+            if( nd.isNew() )
+                nd.getParent().save();
              else
-                m_node.save();
+                nd.save();
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Save failed",e);
+            throw new ProviderException("Save failed",e);
          }
      }

      private static final String ATTR_CONTENT = "wiki:content";

-    public String getContentAsString() throws WikiException
+    public String getContentAsString() throws ProviderException
      {
          try
          {
-            Property p = m_node.getProperty( ATTR_CONTENT );
+            Property p = getJCRNode().getProperty( ATTR_CONTENT );

              return p.getString();
          }
@@ -425,22 +503,59 @@
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Unable to get property",e);
+            throw new ProviderException("Unable to get property",e);
          }

          return null;
      }

-    public void setContent( String content ) throws WikiException
+    public void setContent( String content ) throws ProviderException
      {
          try
          {
-            m_node.setProperty( ATTR_CONTENT, content );
+            getJCRNode().setProperty( ATTR_CONTENT, content );
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Unable to set content",e);
+            throw new ProviderException("Unable to set content",e);
          }
      }

+    // FIXME: The following are obsolete and must go.
+    public boolean hasMetadata()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void invalidateMetadata()
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setAttribute( String key, Object attribute )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setHasMetadata()
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setSize( long size )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setVersion( int version )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
  }
Index: src/java/org/apache/wiki/auth/UserManager.java
===================================================================
--- src/java/org/apache/wiki/auth/UserManager.java	(revision 749743)
+++ src/java/org/apache/wiki/auth/UserManager.java	(working copy)
@@ -117,7 +117,7 @@

          // Attach the PageManager as a listener
          // TODO: it would be better if we did this in PageManager  
directly
-        addWikiEventListener( engine.getPageManager() );
+        addWikiEventListener( engine.getContentManager() );

          JSONRPCManager.registerGlobalObject( "users", new  
JSONUserModule(this), new AllPermission(null) );
      }
Index: tests/java/org/apache/wiki/content/ContentManagerTest.java
===================================================================
--- tests/java/org/apache/wiki/content/ContentManagerTest.java	 
(revision 749743)
+++ tests/java/org/apache/wiki/content/ContentManagerTest.java	 
(working copy)
@@ -17,7 +17,6 @@
  {
      ContentManager m_mgr;
      TestEngine     m_engine;
-    Object         m_owner;

      @Override
      protected void setUp() throws Exception
@@ -30,7 +29,6 @@
          m_engine = new TestEngine(props);

          m_mgr = m_engine.getContentManager();
-        m_owner = m_mgr.acquire();
      }

      @Override
@@ -40,7 +38,6 @@

          if( p != null ) m_mgr.deletePage( p );

-        m_mgr.release( m_owner );
          super.tearDown();
      }


Property changes on: etc
___________________________________________________________________
Modified: svn:ignore
    - jspwiki.properties
jspwiki.jks
classes

    + jspwiki.properties
jspwiki.jks
classes
i18n


Index: src/java/org/apache/wiki/content/ContentManager.java
===================================================================
--- src/java/org/apache/wiki/content/ContentManager.java	(revision  
749743)
+++ src/java/org/apache/wiki/content/ContentManager.java	(working copy)
@@ -46,10 +46,7 @@
  import org.apache.wiki.auth.acl.AclEntry;
  import org.apache.wiki.auth.acl.AclEntryImpl;
  import org.apache.wiki.auth.user.UserProfile;
-import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventManager;
-import org.apache.wiki.event.WikiPageEvent;
-import org.apache.wiki.event.WikiSecurityEvent;
+import org.apache.wiki.event.*;
  import org.apache.wiki.log.Logger;
  import org.apache.wiki.log.LoggerFactory;
  import org.apache.wiki.providers.ProviderException;
@@ -85,7 +82,7 @@
   *  @since 3.0
   */

-public class ContentManager
+public class ContentManager implements WikiEventListener
  {
      /**
       *  The name of the default WikiSpace.
@@ -166,6 +163,7 @@
       *  @param engine WikiEngine instance
       *  @throws WikiException If anything goes wrong, you get this.
       */
+    @SuppressWarnings("unchecked")
      public ContentManager( WikiEngine engine )
          throws WikiException
      {
@@ -238,14 +236,14 @@

          try
          {
-            Object foo = acquire();
              initialize();
-            release(foo);
          }
          catch( RepositoryException e )
          {
              throw new WikiException("Failed to initialize the  
repository content",e);
          }
+
+        log.info("ContentManager initialized!");
      }

      /**
@@ -286,6 +284,17 @@

      }

+    /**
+     *  Discards all unsaved modifications made to this repository.
+     *
+     *  @throws RepositoryException
+     */
+    public void discardModifications() throws RepositoryException
+    {
+        m_sessionManager.getSession().refresh( false );
+    }
+
+    /*
      public Object acquire() throws ProviderException
      {
          try
@@ -302,6 +311,7 @@
      {
          m_sessionManager.destroySession( id );
      }
+    */

      /**
       *  Returns all pages in some random order.  If you need just  
the page names,
@@ -549,10 +559,10 @@
          List<WikiPage> result = new ArrayList<WikiPage>();
          JCRWikiPage base = getPage(path);

-        Node baseNode = base.getJCRNode();
-
          try
          {
+            Node baseNode = base.getJCRNode();
+
              VersionHistory vh = baseNode.getVersionHistory();

              for( VersionIterator vi = vh.getAllVersions();  
vi.hasNext(); )
@@ -648,11 +658,11 @@
       *  @throws WikiException If the backend fails or the wikiPath  
is illegal.
       */
      public boolean pageExists( WikiName wikiPath, int version )
-        throws WikiException
+        throws ProviderException
      {
          if( wikiPath == null )
          {
-            throw new WikiException("Illegal page name");
+            throw new ProviderException("Illegal page name");
          }

          try
@@ -663,7 +673,7 @@
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Unable to check for page  
existence",e);
+            throw new ProviderException("Unable to check for page  
existence",e);
          }
      }

@@ -674,7 +684,7 @@
       *  @throws WikiException if the page fails
       */
      public void deleteVersion( WikiPage page )
-        throws WikiException
+        throws ProviderException
      {
          fireEvent( WikiPageEvent.PAGE_DELETE_REQUEST,  
page.getName() );

@@ -688,7 +698,7 @@
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Unable to delete a page",e);
+            throw new ProviderException("Unable to delete a page",e);
          }
      }

@@ -700,7 +710,7 @@
       */

      public void deletePage( WikiPage page )
-        throws WikiException
+        throws ProviderException
      {
          fireEvent( WikiPageEvent.PAGE_DELETE_REQUEST,  
page.getName() );

@@ -733,7 +743,7 @@
          }
          catch( RepositoryException e )
          {
-            throw new WikiException("Deletion of pages failed.",e);
+            throw new ProviderException("Deletion of pages failed.",e);
          }
      }

@@ -921,7 +931,7 @@
       *  @param wikiName The WikiName.
       *  @return A full JCR path
       */
-    protected static String getJCRPath( WikiName wikiName )
+    public static String getJCRPath( WikiName wikiName )
      {
          String spaceName;
          String spacePath;
@@ -940,7 +950,7 @@
       *  @throws WikiException If the backend fails.
       */
      // FIXME: Should be protected - fix once WikiPage moves to  
content-package
-    public static WikiName getWikiPath( String jcrpath ) throws  
WikiException
+    public static WikiName getWikiPath( String jcrpath ) throws  
ProviderException
      {
          if( jcrpath.startsWith("/"+JCR_PAGES_NODE+"/") )
          {
@@ -955,7 +965,7 @@
              }
          }

-        throw new WikiException("This is not a valid JSPWiki JCR  
path: "+jcrpath);
+        throw new ProviderException("This is not a valid JSPWiki JCR  
path: "+jcrpath);
      }

      /**
@@ -967,7 +977,7 @@
       *  @return the {@link JCRWikiPage}
       *  @throws WikiException If the backend fails.
       */
-    public JCRWikiPage addPage( WikiName path, String contentType )  
throws WikiException
+    public JCRWikiPage addPage( WikiName path, String contentType )  
throws ProviderException
      {
          try
          {
@@ -981,7 +991,7 @@
          }
          catch( RepositoryException e )
          {
-            throw new WikiException( "Unable to add a page", e );
+            throw new ProviderException( "Unable to add a page", e );
          }
      }

@@ -1017,25 +1027,36 @@
          }
      }

-    public JCRWikiPage getPage( WikiName path, int version ) throws  
WikiException
+    public JCRWikiPage getPage( WikiName path, int version ) throws  
ProviderException
      {
          try
          {
+            JCRWikiPage page = null;
              Session session = m_sessionManager.getSession();

              Node nd =  
session.getRootNode().getNode( getJCRPath(path) );

-            VersionHistory vh = nd.getVersionHistory();
+            try
+            {
+                VersionHistory vh = nd.getVersionHistory();

-            Version v = vh.getVersion( Integer.toString( version ) );
+                Version v =  
vh.getVersion( Integer.toString( version ) );

-            JCRWikiPage page = new JCRWikiPage(m_engine, v);
+                page = new JCRWikiPage(m_engine, v);
+            }
+            catch( UnsupportedRepositoryOperationException e )
+            {
+                // No version history yet
+
+                if( version == WikiProvider.LATEST_VERSION || version  
== 1)
+                    page = new JCRWikiPage( m_engine, nd );
+            }

              return page;
          }
          catch( RepositoryException e )
          {
-            throw new WikiException( "Unable to get a page", e );
+            throw new ProviderException( "Unable to get a page", e );
          }
      }

@@ -1221,12 +1242,18 @@
           *
           *  @return A valid Session object, if called between  
createSession and destroySession().
           *  @throws IllegalStateException If the object has not been  
acquired with createSession()
+         * @throws RepositoryException
+         * @throws LoginException
           */
-        public Session getSession() throws IllegalStateException
+        public Session getSession() throws LoginException,  
RepositoryException
          {
              Session s = m_currentSession.get();

-            if( s == null ) throw new IllegalStateException("You have  
not yet opened a Session");
+            if( s == null )
+            {
+                createSession();
+                s = m_currentSession.get();
+            }

              return s;
          }
@@ -1245,4 +1272,9 @@
          }
          boolean m_identity = false;
      }
+
+    public Node getJCRNode( String path ) throws RepositoryException
+    {
+        return (Node)m_sessionManager.getSession().getItem( path );
+    }
  }
Index: src/java/org/apache/wiki/api/WikiPage.java
===================================================================
--- src/java/org/apache/wiki/api/WikiPage.java	(revision 749743)
+++ src/java/org/apache/wiki/api/WikiPage.java	(working copy)
@@ -24,6 +24,8 @@
  import java.util.Map;

  import org.apache.wiki.auth.acl.Acl;
+import org.apache.wiki.content.WikiName;
+import org.apache.wiki.providers.ProviderException;


  /**
@@ -65,7 +67,7 @@
       * {@link org.apache.wiki.ui.stripes.HandlerPermission}  
annotations.
       * @return the qualified page name, for example  
<code>mywiki:Main</code>
       */
-    public String getQualifiedName();
+    public WikiName getQualifiedName();

      /**
       *  A WikiPage may have a number of attributes, which might or  
might not be
@@ -233,9 +235,9 @@
       */
      public int compareTo( Object o );

-    public String getContentAsString() throws WikiException;
+    public String getContentAsString() throws ProviderException;

-    public void save() throws WikiException;
+    public void save() throws ProviderException;

-    public void setContent(String content) throws WikiException;
+    public void setContent(String content) throws ProviderException;
  }
Index: src/java/org/apache/wiki/ReferenceManager.java
===================================================================
--- src/java/org/apache/wiki/ReferenceManager.java	(revision 749743)
+++ src/java/org/apache/wiki/ReferenceManager.java	(working copy)
@@ -412,157 +412,21 @@
      /**
       *  Reads the serialized data from the disk back to memory.
       *  Returns the date when the data was last written on disk
+     *  @deprecated to be removed
       */
      private synchronized long unserializeAttrsFromDisk(WikiPage p)
          throws IOException,
                 ClassNotFoundException
      {
-        ObjectInputStream in = null;
-        long saved = 0L;
-
-        try
-        {
-            StopWatch sw = new StopWatch();
-            sw.start();
-
-            //
-            //  Find attribute cache, and check if it exists
-            //
-            File f = new File( m_engine.getWorkDir(),  
SERIALIZATION_DIR );
-
-            f = new File( f, getHashFileName(p.getName()) );
-
-            if( !f.exists() )
-            {
-                return 0L;
-            }
-
-            log.debug("Deserializing attributes for "+p.getName());
-
-            in = new ObjectInputStream( new BufferedInputStream(new  
FileInputStream(f)) );
-
-            long ver     = in.readLong();
-
-            if( ver != serialVersionUID )
-            {
-                log.debug("File format has changed; cannot  
deserialize.");
-                return 0L;
-            }
-
-            saved        = in.readLong();
-
-            String name  = in.readUTF();
-
-            if( !name.equals(p.getName()) )
-            {
-                log.debug("File name does not match ("+name+"),  
skipping...");
-                return 0L; // Not here
-            }
-
-            long entries = in.readLong();
-
-            for( int i = 0; i < entries; i++ )
-            {
-                String key   = in.readUTF();
-                Object value = in.readObject();
-
-                p.setAttribute( key, value );
-
-                log.debug("   attr: "+key+"="+value);
-            }
-
-            in.close();
-
-            sw.stop();
-            log.debug("Read serialized data for "+name+" successfully  
in "+sw);
-            p.setHasMetadata();
-        }
-        catch( NoSuchAlgorithmException e )
-        {
-            log.error("No MD5!?!");
-        }
-        finally
-        {
-            if( in != null ) in.close();
-        }
-
-        return saved;
+        return 0L;
      }

      /**
       *  Serializes hashmaps to disk.  The format is private, don't  
touch it.
+     *  @deprecated To be removed
       */
      private synchronized void serializeAttrsToDisk( WikiPage p )
      {
-        ObjectOutputStream out = null;
-        StopWatch sw = new StopWatch();
-        sw.start();
-
-        try
-        {
-            File f = new File( m_engine.getWorkDir(),  
SERIALIZATION_DIR );
-
-            if( !f.exists() ) f.mkdirs();
-
-            //
-            //  Create a digest for the name
-            //
-            f = new File( f, getHashFileName(p.getName()) );
-
-            // FIXME: There is a concurrency issue here...
-            Set entries = p.getAttributes().entrySet();
-
-            if( entries.size() == 0 )
-            {
-                //  Nothing to serialize, therefore we will just  
simply remove the
-                //  serialization file so that the next time we boot,  
we don't
-                //  deserialize old data.
-                f.delete();
-                return;
-            }
-
-            out = new ObjectOutputStream( new  
BufferedOutputStream(new FileOutputStream(f)) );
-
-            out.writeLong( serialVersionUID );
-            out.writeLong( System.currentTimeMillis() ); // Timestamp
-
-            out.writeUTF( p.getName() );
-            out.writeLong( entries.size() );
-
-            for( Iterator i = entries.iterator(); i.hasNext(); )
-            {
-                Map.Entry e = (Map.Entry) i.next();
-
-                if( e.getValue() instanceof Serializable )
-                {
-                    out.writeUTF( (String)e.getKey() );
-                    out.writeObject( e.getValue() );
-                }
-            }
-
-            out.close();
-
-        }
-        catch( IOException e )
-        {
-            log.error("Unable to serialize!");
-
-            try
-            {
-                if( out != null ) out.close();
-            }
-            catch( IOException ex ) {}
-        }
-        catch( NoSuchAlgorithmException e )
-        {
-            log.error("No MD5 algorithm!?!");
-        }
-        finally
-        {
-            sw.stop();
-
-            log.debug("serialization for "+p.getName()+" done - took  
"+sw);
-        }
      }

      /**


Mime
View raw message