jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1225831 - in /incubator/jspwiki/trunk: ./ src/WebContent/templates/default/admin/ src/java/org/apache/wiki/ src/java/org/apache/wiki/action/ src/java/org/apache/wiki/migration/ src/java/org/apache/wiki/util/ tests/etc/migration/ tests/etc/...
Date Fri, 30 Dec 2011 14:04:08 GMT
Author: juanpablo
Date: Fri Dec 30 14:04:07 2011
New Revision: 1225831

URL: http://svn.apache.org/viewvc?rev=1225831&view=rev
Log:
3.0.0-svn-234

JSPWIKI-690
 - InstallActionBean didn't have it's @UrlBinding
 - added org.apache.wiki.migration package. Initially, it contains the needed classes to load
a set of (initial) plain txt files, but could be improved/extended to perform a 2.8 migration
(see comments on JSPWIKI-454). Added some tests for this package.
 - added new i18n resource, "install.initialPageDir.description", in default.properties (line
512) to ask user where are located the initial pages to load.

Added:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/
    incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/DefaultJSPWikiPagesLoader.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationVO.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/package.html
    incubator/jspwiki/trunk/tests/etc/migration/
    incubator/jspwiki/trunk/tests/etc/migration/testrepo/
    incubator/jspwiki/trunk/tests/etc/migration/testrepo/About.txt
    incubator/jspwiki/trunk/tests/etc/migration/testrepo/LeftMenu.txt
    incubator/jspwiki/trunk/tests/etc/migration/testrepo/Main.txt
    incubator/jspwiki/trunk/tests/etc/migration/testrepo/TextFormattingRules.txt
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/MigrationManagerTest.java
Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/build.xml
    incubator/jspwiki/trunk/src/WebContent/templates/default/admin/Install.jsp
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/util/FileUtil.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Fri Dec 30 14:04:07 2011
@@ -1,3 +1,13 @@
+2011-12-30  Juan Pablo Santos (juanpablo AT apache DOT org)
+        
+        * 3.0.0-svn-234
+        
+        * fixed JSPWIKI-690: default set of pages for 3.0
+        
+        * fixed JSPWIKI-692: FCK.jsp uses TemplateManager.addResourceRequest, which does
not exist anymore
+        
+        * most of JSPWIKI-693 (style issues) fixed
+        
 2011-09-20  Florian Holeczek <florianh@apache.org>
 
         * no version bump

Modified: incubator/jspwiki/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/build.xml?rev=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/build.xml (original)
+++ incubator/jspwiki/trunk/build.xml Fri Dec 30 14:04:07 2011
@@ -718,6 +718,7 @@
       <fileset dir="${tests}/etc">
         <include name="CommentedPropertiesTest.properties" />
         <include name="log4j.properties" />
+      	<include name="migration/testrepo/**/*" />
       </fileset>
     </copy>
         

Modified: incubator/jspwiki/trunk/src/WebContent/templates/default/admin/Install.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/admin/Install.jsp?rev=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/templates/default/admin/Install.jsp (original)
+++ incubator/jspwiki/trunk/src/WebContent/templates/default/admin/Install.jsp Fri Dec 30
14:04:07 2011
@@ -69,6 +69,12 @@
           <s:errors field="properties.priha.priha_provider_defaultProvider_directory"
/>
           <div class="description"><fmt:message key="install.pageDir.description"
/></div>
         </div>
+        <div>
+          <s:label for="properties.jspwiki.default_set_of_pages_directory" />
+          <s:text name="properties.jspwiki.default_set_of_pages_directory" size="50" />
+          <s:errors field="properties.jspwiki.default_set_of_pages_directory" />
+          <div class="description"><fmt:message key="install.initialPageDir.description"
/></div>
+        </div>
         
         <!-- Advanced settings: security, logging/work directories -->
         <h3><fmt:message key="install.advanced" /></h3>

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=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Fri Dec 30 14:04:07 2011
@@ -77,7 +77,7 @@ public final class Release
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "233";
+    public static final String     BUILD         = "234";
 
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java?rev=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java Fri Dec
30 14:04:07 2011
@@ -60,6 +60,9 @@ import org.apache.wiki.auth.user.LdapUse
 import org.apache.wiki.auth.user.UserDatabase;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.auth.user.XMLUserDatabase;
+import org.apache.wiki.migration.MigrationManager;
+import org.apache.wiki.migration.DefaultJSPWikiPagesLoader;
+import org.apache.wiki.migration.MigrationVO;
 import org.apache.wiki.ui.stripes.*;
 import org.apache.wiki.util.CommentedProperties;
 import org.apache.wiki.util.CryptoUtil;
@@ -69,6 +72,7 @@ import org.freshcookies.security.Keychai
 
 
 @HttpCache( allow = false )
+@UrlBinding( "/Install.jsp" )
 public class InstallActionBean extends AbstractActionBean
 {
     /**
@@ -328,6 +332,8 @@ public class InstallActionBean extends A
 
     private static final String CONFIG_PAGE_DIR = "priha_provider_defaultProvider_directory";
 
+    private static final String CONFIG_INITIAL_PAGES_DIR = "default_set_of_pages_directory";
+
     private static final String CONFIG_USERDATABASE = "jspwiki_userdatabase";
 
     private static final String CONFIG_AUTHORIZER = "jspwiki_authorizer";
@@ -498,6 +504,11 @@ public class InstallActionBean extends A
             String pageDir = sanitizeDir( System.getProperty( "java.io.tmpdir" ) ) + "priha/fileprovider";
             priha.put( CONFIG_PAGE_DIR, pageDir );
         }
+        if ( !jspwiki.containsKey( CONFIG_INITIAL_PAGES_DIR ) )
+        {
+            String pageDir = sanitizeDir( System.getProperty( "java.io.tmpdir" ) ) + "corepages";
+            jspwiki.put( CONFIG_INITIAL_PAGES_DIR, pageDir );
+        }
 
         return null;
     }
@@ -532,11 +543,14 @@ public class InstallActionBean extends A
         PropertiesMap<String, String> jspwiki = m_properties.get( "jspwiki" );
         jspwiki.put( CONFIG_BASE_URL, sanitizeURL( jspwiki.get( CONFIG_BASE_URL ) ) );
         jspwiki.put( CONFIG_WORK_DIR, sanitizeDir( jspwiki.get( CONFIG_WORK_DIR ) ) );
+        String defaultDirOfWikiPages = sanitizeDir( jspwiki.get( CONFIG_INITIAL_PAGES_DIR
) );
+        jspwiki.remove( CONFIG_INITIAL_PAGES_DIR ); // we don't want it in the final jspwiki.properties
file
+        
         PropertiesMap<String, String> log4j = m_properties.get( "log4j" );
         log4j.put( CONFIG_LOG_FILE, sanitizeDir( m_logDirectory ) + "jspwiki.log" );
         PropertiesMap<String, String> priha = m_properties.get( "priha" );
         priha.put( CONFIG_PAGE_DIR, sanitizeDir( priha.get( CONFIG_PAGE_DIR ) ) );
-
+        
         // Set the correct userdatabase and authorizer
         String userdatabase = jspwiki.get( CONFIG_USERDATABASE );
         if( LdapUserDatabase.class.getName().equals( userdatabase ) )
@@ -564,11 +578,15 @@ public class InstallActionBean extends A
         log4j.store();
         priha.store();
 
+        // Load default set of wiki pages
+        WikiEngine engine = getContext().getEngine();
+        MigrationManager m = new DefaultJSPWikiPagesLoader();
+        m.migrate( engine, new MigrationVO().setRepoDir( defaultDirOfWikiPages ) );
+        
         // Flush the WikiSession
         getContext().getWikiSession().invalidate();
 
         // Restart the WikiEngine
-        WikiEngine engine = getContext().getEngine();
         engine.restart();
 
         return new TemplateResolution( "admin/InstallSuccess.jsp" );

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/DefaultJSPWikiPagesLoader.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/DefaultJSPWikiPagesLoader.java?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/DefaultJSPWikiPagesLoader.java
(added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/DefaultJSPWikiPagesLoader.java
Fri Dec 30 14:04:07 2011
@@ -0,0 +1,179 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+package org.apache.wiki.migration;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.WikiException;
+import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageAlreadyExistsException;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.content.WikiPath;
+import org.apache.wiki.log.Logger;
+import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.providers.ProviderException;
+import org.apache.wiki.util.FileUtil;
+
+
+/**
+ * Migration Manager to load an initial set of 2.8 JSPWiki pages.
+ * 
+ * Could be expanded to import a 2.8 JSPWiki repository.
+ */
+public class DefaultJSPWikiPagesLoader implements MigrationManager
+{
+    
+    /** class logger */
+    private static final Logger LOG = LoggerFactory.getLogger( DefaultJSPWikiPagesLoader.class
);
+    
+    /** 2.8 file wiki pages */
+    private static final String TXT_SUFFIX = ".txt";
+    
+    /** filter for 2.8 wiki pages */
+    private FilenameFilter filter = new FilenameFilter() 
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public boolean accept( File dir, String name ) 
+        {
+            return name.toLowerCase().endsWith( TXT_SUFFIX );
+        }
+    };
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void migrate( WikiEngine engine, MigrationVO vo ) 
+    {
+        if( vo != null && vo.getRepoDir() != null ) 
+        {
+            File repo = new File( vo.getRepoDir().trim() );
+            if( repo.isDirectory() ) 
+            {
+                LOG.info( "migrating from " + vo );
+                List< File > wikiPageFiles = Arrays.asList( repo.listFiles( filter
) );
+                for( File wpf : wikiPageFiles ) 
+                {
+                    LOG.info( "migrating " + wpf.getName() );
+                    migrateOlderVersionsFor( engine, repo, wpf.getName() );
+                    migratePage( engine, wpf );
+                }
+            }
+        }
+    }
+    
+    /**
+     * Migrates all the older versions of a given 2.8 WikiPage.
+     * 
+     * @param engine {@link WikiEngine} performing the migration.
+     * @param repo directory holding the 2.8 repository.
+     * @param page 2.8 WikiPage to be migrated.
+     */
+    void migrateOlderVersionsFor( WikiEngine engine, File repo, String page ) 
+    {
+        /* TODO
+        List< File > wpVersioned = obtainOlderVersionsFor( page );
+        for( File version : wpVersioned ) 
+        {
+            File oldVersion = obtainOldVersion( engine, repo, page );
+            migratePage( engine, oldVersion );
+        } 
+        */
+    }
+    
+    /**
+     * Performs the migration of a simple 2.8 WikiPage.
+     * 
+     * @param engine {@link WikiEngine} performing the migration.
+     * @param page Page to be loaded.
+     */
+    void migratePage( WikiEngine engine, File page ) 
+    {
+        WikiPage wp = getWikiPage( engine, page.getName().replaceAll( TXT_SUFFIX, "" ) );
+        
+        // TODO: add metadata held in the correponding page.properties file
+        // TODO: add attachments
+        WikiContext context = engine.getWikiContextFactory().newViewContext( null, null,
wp );
+        try
+        {
+            engine.saveText( context, FileUtil.getContentFrom( page.getAbsolutePath() ) );
+        }
+        catch( WikiException we )
+        {
+            LOG.error( "problems migrating " + page.getName(), we );
+        }
+    }
+    
+    /**
+     * Retrieves a WikiPage or, if it doesn't exist, creates a new one with the given name.
+     * 
+     * @param engine {@link WikiEngine} responsible of grabbing the WikiPage. 
+     * @param pageName Name of the WikiPage.
+     * @return the asked WikiPage or a new one with the given name if it doesn't exist.
+     */
+    WikiPage getWikiPage( WikiEngine engine, String pageName ) 
+    {
+        WikiPage wpage = null;
+        try
+        {
+            wpage = engine.getPage( pageName );
+        }
+        catch ( PageNotFoundException pnfe )
+        { 
+            LOG.info( "page " + pageName + " not found, will proceed to create a new one"
);
+        }
+        catch( ProviderException pe )
+        {
+            LOG.error( pe.getMessage(), pe );
+        }
+        catch( IllegalArgumentException iae )
+        {
+            LOG.error( iae.getMessage(), iae );
+        }
+        if( wpage == null ) 
+        {
+             try
+            {
+                wpage = engine.createPage( WikiPath.valueOf( pageName ) );
+            }
+            catch( ProviderException pe )
+            {
+                LOG.error( pe.getMessage(), pe );
+            }
+            catch( IllegalArgumentException iae )
+            {
+                LOG.error( iae.getMessage(), iae );
+            }
+            catch( PageAlreadyExistsException paee )
+            {
+                LOG.error( paee.getMessage(), paee );
+            }
+        }
+        return wpage;
+    }
+    
+}
\ No newline at end of file

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationManager.java?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationManager.java (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationManager.java Fri Dec
30 14:04:07 2011
@@ -0,0 +1,40 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+package org.apache.wiki.migration;
+
+import org.apache.wiki.WikiEngine;
+
+
+/**
+ * Defines the common operations of a migration task. 
+ */
+public interface MigrationManager
+{
+    
+    /**
+     * Reads all wiki pages from <code>repoDir</code> and saves them through
the given <code>engine</code>. 
+     * 
+     * @param engine current <code>WikiEngine</code>.
+     * @param repoDir location of a <code>WikiPage</code>s repository.
+     */
+    void migrate( WikiEngine engine, MigrationVO repoDir );
+    
+}

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationVO.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationVO.java?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationVO.java (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/MigrationVO.java Fri Dec 30
14:04:07 2011
@@ -0,0 +1,79 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+package org.apache.wiki.migration;
+
+
+/**
+ * Simple Value Object to hold all necessary information to perform a migration.  
+ */
+public class MigrationVO
+{
+    /** directory holding the repository */
+    private String repoDir;
+    
+    /** encoding of wiki pages; not actually used, but could be useful when developing a
custom MigrationManager impl. */
+    private String encoding;
+
+    /**
+     * getter for {@link #repoDir}.
+     * 
+     * @return {@link #repoDir}.
+     */
+    public String getRepoDir()
+    {
+        return repoDir;
+    }
+
+    /**
+     * setter for {@link #repoDir}.
+     * 
+     * @param repoDir the {@link #repoDir} to set.
+     * @return the current instance, with it's {@link #repoDir} updated.
+     */
+    public MigrationVO setRepoDir( String repoDir )
+    {
+        this.repoDir = repoDir;
+        return this;
+    }
+
+    /**
+     * getter for {@link #encoding}.
+     * 
+     * @return {@link #encoding}.
+     */
+    public String getEncoding()
+    {
+        return encoding;
+    }
+
+    /**
+     * setter for {@link #encoding}.
+     * 
+     * @param repoDir the {@link #encoding} to set.
+     * @return the current instance, with it's {@link #encoding} updated.
+     */
+    public MigrationVO setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+        return this;
+    }
+    
+}

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/package.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/package.html?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/package.html (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/migration/package.html Fri Dec 30 14:04:07
2011
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>JSPWiki Java API Documentation</title>
+<!--
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.   
+-->
+</head>
+<body>
+
+<p>Contains all of JSPWiki's migration code from older (2.8, file-based access) to
newer (3.0, JCR-based) repositories.</p>
+
+<h3>Package Specification</h3>
+
+<p>This package contains all of JSPWiki's migration code from older (2.8, file-based
access) to newer (3.0, JCR-based) repositories.</p>
+
+</body>
+</html>
\ No newline at end of file

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/util/FileUtil.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/util/FileUtil.java?rev=1225831&r1=1225830&r2=1225831&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/util/FileUtil.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/util/FileUtil.java Fri Dec 30 14:04:07
2011
@@ -40,6 +40,9 @@ public final class FileUtil
 {
     /** Size of the buffer used when copying large chunks of data. */
     private static final int      BUFFER_SIZE = 4096;
+    
+    /** class logger. */
+    private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
 
     /**
      *  Private constructor prevents instantiation.
@@ -117,8 +120,6 @@ public final class FileUtil
                InterruptedException
     {
         StringBuilder result = new StringBuilder();
-
-        Logger log = LoggerFactory.getLogger(FileUtil.class);
         log.info("Running simple command "+command+" in "+directory);
 
         Process process = Runtime.getRuntime().exec( command, null, new File(directory) );
@@ -299,6 +300,43 @@ public final class FileUtil
             }
         }
     }
+    
+    /**
+     * Retrieves the contents of a text file.
+     * 
+     * @param fileName file (path) name
+     * @return the contents of the text file or a blank String if there is any kind of error.
+     */
+    public static String getContentFrom( String fileName ) 
+    {
+        String str = "";
+        BufferedReader in = null;
+        try 
+        {
+            in = new BufferedReader( new FileReader( fileName ) );
+            str = readContents( in );
+        } 
+        catch ( IOException ioe ) 
+        {
+            log.error( ioe.getMessage(), ioe );
+            str = "";
+        } 
+        finally 
+        {
+            try
+            {
+                if( in != null ) 
+                {
+                    in.close();
+                }
+            }
+            catch( IOException ioe )
+            {
+                log.error( ioe.getMessage(), ioe );
+            }
+        }
+        return str;
+    }
 
     /**
      *  Returns the class and method name (+a line number) in which the

Added: incubator/jspwiki/trunk/tests/etc/migration/testrepo/About.txt
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/migration/testrepo/About.txt?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/migration/testrepo/About.txt (added)
+++ incubator/jspwiki/trunk/tests/etc/migration/testrepo/About.txt Fri Dec 30 14:04:07 2011
@@ -0,0 +1,15 @@
+This Wiki is done using [JSP|http://java.sun.com/products/jsp] technology, 
+which hopefully makes it very easy to keep up to date and looking better than most of the
Wikis based on the [original one|http://c2.com/cgi/wiki].  A custom bean handles the translation
of text into HTML.
+
+Most of the [editing markers|TextFormattingRules] have been styled according to the [Sensei's
Library|http://senseis.xmp.net], the best Go sites in the Internet.  I find their markup very
easy, yet clear.
+
+This wiki is authored by [Janne Jalkanen|http://www.ecyrd.com/ButtUgly/], and is available
under the [GNU Lesser General Public License|http://www.gnu.org/copyleft/lesser.html].
+
+If you are interested in the JSPWiki development, the home page for JSPWiki is at [http://www.jspwiki.org].
 Some quick links:
+
+* [Bug Reports|JSPWiki:SubmitBugReport] - or [look at the list of open bugs|JSPWiki:OpenBugs].
+* [Contribute new ideas|JSPWiki:SubmitNewIdea].
+* Take a look at the most up-to-date [JSPWiki FAQ|JSPWiki:JSPWikiFAQ]
+* Look for additional [plugins|JSPWiki:ContributedPlugins], [templates|JSPWiki:ContributedTemplates],
[filters|JSPWiki:ContributedFilters], [providers|JSPWiki:ContributedProviders], or [other
cool stuff|JSPWiki:ContributedCode].
+
+Happy hacking, and thanks for choosing JSPWiki!

Added: incubator/jspwiki/trunk/tests/etc/migration/testrepo/LeftMenu.txt
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/migration/testrepo/LeftMenu.txt?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/migration/testrepo/LeftMenu.txt (added)
+++ incubator/jspwiki/trunk/tests/etc/migration/testrepo/LeftMenu.txt Fri Dec 30 14:04:07
2011
@@ -0,0 +1,11 @@
+* [Main page|Main]
+* [About]
+* [News]
+* [Recent Changes]
+* [WikiEtiquette]
+
+* [Find pages|FindPage]
+* [Unused pages|UnusedPages]
+* [Undefined pages|UndefinedPages]
+* [Page Index]
+

Added: incubator/jspwiki/trunk/tests/etc/migration/testrepo/Main.txt
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/migration/testrepo/Main.txt?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/migration/testrepo/Main.txt (added)
+++ incubator/jspwiki/trunk/tests/etc/migration/testrepo/Main.txt Fri Dec 30 14:04:07 2011
@@ -0,0 +1,34 @@
+!!!Congratulations!
+
+You have successfully installed [JSPWiki|About].
+
+You have some pages set up for you:
+
+!Quick start
+
+* For testing things, try the [SandBox].
+* For a quick look on what Wiki is, check out [OneMinuteWiki].
+* For a guideline on good working habits with wiki, see [WikiEtiquette].
+
+!Installation issues
+
+* If you run Microsoft Windows, or you are having trouble with UTF-8 then you probably want
to take a look
+  at [InstallationTips] for further information.
+!Documentation
+
+* For all of the Wiki markup features, see [TextFormattingRules].
+* Entry point for full [JSPWikiDocumentation|http://www.jspwiki.org/wiki/JSPWikiDocumentation]
+** [JSPWiki 2.6 New Features|http://www.jspwiki.org/wiki/NewIn2.6].
+** [JSPWiki 2.4.x|http://doc.jspwiki.org/2.4]. ([Security|http://doc.jspwiki.org/2.4/wiki/Security])
+** [Security2.3Howto|http://www.jspwiki.org/wiki/Security2.3Howto]
+** [JSPWiki 2.2.x|http://doc.jspwiki.org/2.2].
+
+!Miscellaneous
+
+* There are several ways you can get in touch with JSPWiki [Community]. Check them out!
+* To see what this particular wiki is about, click on the Wiki name
+  on the top left corner of the browser window, or [click here|SystemInfo].
+
+Good luck, and thanks for choosing JSPWiki!
+
+--[Janne Jalkanen|mailto:jalkanen+jspwiki@ecyrd.com].

Added: incubator/jspwiki/trunk/tests/etc/migration/testrepo/TextFormattingRules.txt
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/migration/testrepo/TextFormattingRules.txt?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/migration/testrepo/TextFormattingRules.txt (added)
+++ incubator/jspwiki/trunk/tests/etc/migration/testrepo/TextFormattingRules.txt Fri Dec 30
14:04:07 2011
@@ -0,0 +1,168 @@
+This page describes the wiki syntax used by JSPWiki. For details about how this differs from
the syntax used by Wikipedia, please see [MigratingFromMediaWiki|http://www.jspwiki.org/wiki/MigratingFromMediaWiki].
+
+[{TableOfContents }]
+\\
+When you've figured out how the editor works, then you should read [WikiEtiquette] so that
you would know how to use your newly acquired skills. The [SandBox|http://sandbox.jspwiki.org]
is a great place to try them out.
+!Quick Reference
+{{{
+----       = make a horizontal ruler. Extra '-' is ignored.
+\\         = force a line break
+
+[link]     = create a hyperlink to an internal WikiPage called 'Link'.
+[this is also a link] = create a hyperlink to an internal WikiPage called
+             'ThisIsAlsoALink' but show the link as typed with spaces.
+[a sample|link] = create a hyperlink to an internal WikiPage called
+             'Link', but display the text 'a sample' to the
+             user instead of 'Link'.
+~NoLink    = disable link creation for the word in CamelCase.
+[1]        = make a reference to a footnote numbered 1.
+[#1]       = mark the footnote number 1.
+[link]     = create text '[link]'.
+
+!heading   = small heading with text 'heading'
+!!heading  = medium heading with text 'heading'
+!!!heading = large heading with text 'heading'
+
+''text''   = print 'text' in italic.
+__text__   = print 'text' in bold.
+{{text}}   = print 'text' in monospaced font.
+[text|]    = print 'text' underscored (dummy hyperlink)
+* text     = make a bulleted list item with 'text'
+# text     = make a numbered list item with 'text'
+;term:ex   = make a definition for 'term' with the explanation 'ex'
+}}}
+!Writing text
+You don't need to know anything about the Wiki text formatting rules to use Wiki. Just write
normal text, and then use an empty line to mark a paragraph.
+It's just like writing an email.
+You can always Edit this page (look at the left sidebar) to see how the different
+effects on this page are used.
+!Hyperlinks
+The link can also be a direct URL starting with {{http:}}, {{ftp:}}, {{mailto:}}, {{https:}},
or {{news:}}, in which case the link points to an external entity. For example, to point at
the java.sun.com home page, use {{[[http://java.sun.com]}}, which becomes [http://java.sun.com/]
or {{[[Java home page|http://java.sun.com]}}, which becomes [Java home page|http://java.sun.com].
+If you do not start the link with one of the above "protocols", the wiki assumes a normal
link to another page in the wiki space, you need to use a letter as the first character of
the page, purely numeric page names are not allowed. If you want to use square brackets ({{[[]}})
in the page without creating a hyperlink, use two opening square brackets. So the text {{[[[Example
Non-Link]}}, will appear as {{[[Example Non-Link]}}[[Murali].
+To add a new page you just create a link to it from somewhere else. After all, there isn't
much point in having a page if you can't access it! You'll then see a small question mark
after the page name when you return to that page. Then click on it and you have created a
new page!
+It's allowed to use almost any kind of characters inside a [WikiName|http://www.jspwiki.org/wiki/WikiName],
as long
+as they are letters or numbers.
+Note also that this Wiki can be configured to support standard [CamelCase|http://www.jspwiki.org/wiki/CamelCase]
linking (if it's supported, the word CamelCase should be a link, if it doesn't start with
'~~'). It's off by default, but if your friendly administrator has turned it on, then well,
CamelCase all you want =).
+!Footnotes
+These are a special kind of hyperlink. By using nothing but a number inside
+a hyperlink you create a reference to a footnote, like this {{[[1]}}, which
+creates a footnote[1]. To make the actual footnote, you just put a {{[[#1]}}
+where you want that footnote to point at. Look below to find the footnote.
+You can also make a named footnote, just as if you were doing a normal hyperlink, such as
{{[[Footnote name|1]}} as another way of referring to the first footnote[Footnote name|1].
Or you can put the custom name at the footnote itself[2].
+![InterWiki|http://www.jspwiki.org/wiki/InterWiki] links
+You can also do links between different Wikis without knowing the URL. Just use a link in
the form {{[[Wiki:WikiPage]}} and JSPWiki will create a link for you. For example, this link
points to the [JSPWiki TextFormatting rules|JSPWiki:TextFormattingRules]. Check the [SystemInfo]
page for more information on which Wiki links are available.
+If an [InterWiki|http://www.jspwiki.org/wiki/InterWiki link is not supported, you'll get
a notification of it on the page when
+you save your page.
+!Adding pictures
+You can embed
+any image in the wiki code by putting the image available somewhere on the web in one of
the allowed formats, and then just linking to it.
+If you specify a link text ({{[[this one here|http://example.com/example.png]}}) it becomes
+the ALT text for those who either can't or don't want to view images.
+The list of accepted image types depends on the Wiki. See the [SystemInfo]
+page for a list of the different image types.
+It is also possible to use the [Image plugin|http://www.jspwiki.org/wiki/Image] to gain more
control over the image placement and attributes.
+To force a flush after an image, use \ \ \ (that is, three consecutive backslashes instead
of two).
+!Bulleted lists
+Use an asterisk (*) in the first column to make bulleted lists. Use more asterisks for deeper
indentation. For example:
+{{{
+* One \\ one and a half
+* Two
+* Three
+** Three.One}}}
+creates
+* One \\ one and a half
+* Two
+* Three
+** Three.One
+!Numbered lists
+Just like with bulleted lists, but use a hash (#) instead of the asterisk. Like this:
+{{{
+# One \\ one and a half
+# Two
+# Three
+## Three.One
+}}}
+creates
+# One \\ one and a half
+# Two
+# Three
+## Three.One
+If you want to write the list item on multiple lines, just add one or more spaces on the
next line and the line will be automatically added to the
+previous item. For example:
+{{{
+* This is a single-line item.
+* This is actually a multi-line item.
+  We continue the second sentence on a line on a line of its own.
+  We might as well do a third line while we're at it...
+  Notice, however, as all these sentences get put inside a single item!
+* The third line is again a single-line item for your convenience.
+}}}
+produces:
+* This is a single-line item.
+* This is actually a multi-line item.
+  We continue the second sentence on a line on a line of its own.
+  We might as well do a third line while we're at it...
+  Notice, however, as all these sentences get put inside a single item!
+* The third line is again a single-line item for your convenience.
+!Definition lists and comments
+A simple way to make definition lists is to use the ';:' -construct:
+{{{
+;__Construct__:''Something you use to do something with''
+}}}
+is rendered as:
+;__Construct__:''Something you use to do something with''
+Another nice use for the ';:' is that you can use it to comment shortly on other people's
text, by having an empty 'term' in the definition, like this:
+{{{
+;:''Comment here.''
+}}}
+Which would be seen as
+;:''Comment here.''
+!Text effects
+You may use __bold__ text or ''italic'' text, by using two underscores (_) and two single
quotes ('), respectively. If you're on a Windows computer, make sure that you are using the
correct quote sign, as there is one that looks the same, but really isn't.
+A [underscore|] effect can be produced by using a hyperlink to nowhere, [[like this|]
+!Preformatted text
+If you want to add preformatted text (like code) just use three consecutive braces ({) to
open a block, and three consecutive braces (}) to close a block. Edit this page for an example.
+({)java.package.pseudocode.class(})
+!Tables
+You can do simple tables by using pipe signs ('|'). Use double pipe
+signs to start the heading of a table, and single pipe signs to then
+write the rows of the table. End with a line that is not a table.
+For example:
+{{{
+|| Heading 1 || Heading 2
+| ''Gobble'' | Bar \\ foo
+| [Main] | [SandBox]
+}}}
+gives you the following table. Note how you can use links also inside tables.
+|| Heading 1 || Heading 2
+| ''Gobble'' | Bar \\ foo
+| [Main] | [SandBox]
+!CSS styles
+While not in line with the keep it simple principle, CSS styles [can be used inline|http://www.jspwiki.org/wiki/CSSInWikipages]
for those special occasions when you really need to emphasize part of a page.
+!Conflicts
+If someone happens to edit the same page as you at the same time, JSPWiki will prevent you
from doing changes and show a conflict page instead. Sorry to say, but the first one to make
changes wins...
+__A word of warning:__ If you use the Back button of your browser to go into the Edit page,
you will almost certainly get a conflict. This is because the browser thinks it's still editing
an earlier copy of the page.
+!Deleting pages
+This is not possible. You can, of course, remove all the links to that page, which makes
it inaccessible. Or you can email the administrator, and I'll remove the page. You may also
add a [DELETEME|JSPWiki:DELETEME] link.
+!Adding new pages
+Create a link that points to a new (not existing) page using its [WikiName|http://www.jspwiki.org/wiki/WikiName].
+Click that new link, which should now have a question mark (?) suffix and
+you will get an editor for the new page. -- [Asser|http://www.jspwiki.org/wiki/Asser]
+!Aliasing a Page
+Sometimes you want any link to a wiki page to immediately traverse to a different page. This
can be done using a PageAlias.
+!Inserting variables
+There are many possible variables you can insert on a page. The basic form is:
+{{ [[{$variablename}], }}
+where ''variablename'' is the name of the variable you want to insert. Note that variable
names are case-insensitive - that is, "pagename" is the same as "paGeNamE" and "PageName".
+You can see the list of available of variables at [WikiVariables|http://www.jspwiki.org/wiki/WikiVariables].
+
+!Inserting plugins
+The basic incantation to insert a plugin looks like this:
+[[{INSERT <plugin class> WHERE param1=value, param2=value, ...}]
+There is more information in [JSPWikiPlugins | http://www.jspwiki.org/wiki/JSPWikiPlugins].
+----
+[#1] Here's the footnote I mentioned.
+[2-The other footnote|#2] The other footnote. Note how its name is different?
+----
+Any [ideas | http://www.jspwiki.org/wiki/IdeasTextFormattingRules]?
+Any [questions | http://www.jspwiki.org/wiki/TextFormattingRulesDiscussion]?
\ No newline at end of file

Added: incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/MigrationManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/MigrationManagerTest.java?rev=1225831&view=auto
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/MigrationManagerTest.java
(added)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/migration/MigrationManagerTest.java
Fri Dec 30 14:04:07 2011
@@ -0,0 +1,103 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+package org.apache.wiki.migration;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.providers.ProviderException;
+
+
+/**
+ * Unit tests associated to {@link MigrationManager}.
+ */
+public class MigrationManagerTest extends TestCase
+{
+    
+    Properties props = new Properties();
+
+    private TestEngine m_engine = null;
+
+    public MigrationManagerTest( String s )
+    {
+        super( s );
+    }
+
+    public void setUp()
+        throws Exception
+    {
+        props.load( TestEngine.findTestProperties() );
+        m_engine = new TestEngine( props );
+    }
+
+    public void tearDown()
+    {
+        m_engine.shutdown();
+    }
+    
+    public void testMigration() 
+    {
+        MigrationManager m = new DefaultJSPWikiPagesLoader();
+        m.migrate( m_engine, new MigrationVO().setRepoDir( "build/tests/migration/testrepo"
) );
+        WikiPage page = null;
+        
+        try
+        {
+            page = m_engine.getPage( "Main" );
+            assertNotNull( page );
+            assertEquals( 1, page.getVersion() );
+        }
+        catch( ProviderException pe )
+        {
+            fail( pe.getMessage() );
+        }
+        catch( PageNotFoundException pnfe )
+        {
+            fail( pnfe.getMessage() );
+        }
+        try
+        {
+            page = m_engine.getPage( "Blurb" );
+            fail( "should not get here" );
+        }
+        catch( ProviderException pe )
+        {
+            fail( pe.getMessage() );
+        }
+        catch( PageNotFoundException pnfe )
+        {
+            // Blurb does not exist
+            assertEquals( "Main", page.getName() );
+        }
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( MigrationManagerTest.class );
+    }
+    
+}



Mime
View raw message