Author: jalkanen
Date: Mon Nov 23 23:20:41 2009
New Revision: 883542
URL: http://svn.apache.org/viewvc?rev=883542&view=rev
Log:
Fixed to output XML in lower case.
Fixed to deal with broken repositories (slashes in page names, name conflicts)
Modified:
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=883542&r1=883541&r2=883542&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Mon Nov 23 23:20:41
2009
@@ -1,4 +1,13 @@
-2008-04-04 Janne Jalkanen <[email protected]>
+2009-11-24 Janne Jalkanen <[email protected]>
+
+ * 2.8.4-svn-3
+
+ * Fixed export to deal better with broken repositories: automatic
renaming
+ of case-conflicts (on systems where they are possible).
+
+ * Export now properly exports in lower-case.
+
+2009-11-23 Janne Jalkanen <[email protected]>
* 2.8.4-svn-2
Modified:
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=883542&r1=883541&r2=883542&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
Mon Nov 23 23:20:41 2009
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "2";
+ public static final String BUILD = "3";
/**
* This is the generic version string you should use
Modified:
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java?rev=883542&r1=883541&r2=883542&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
Mon Nov 23 23:20:41 2009
@@ -59,6 +59,8 @@
private MimetypesFileTypeMap m_mimeTypes = new MimetypesFileTypeMap();
+ private TreeSet<String> m_exportedPageTitles = new TreeSet<String>();
+
private static final String NS_JSPWIKI = "http://www.jspwiki.org/ns#";
private static final String STRING = "String";
private static final String JSPWIKI_CONTENT_TYPE = "text/x-wiki.jspwiki";
@@ -171,16 +173,35 @@
protected void exportPage( WikiPage p ) throws IOException,
ProviderException
{
- if( p.getName().contains( "/" ) && !(p instanceof Attachment) )
+ String title = p.getName();
+
+ if( title.contains( "/" ) && !(p instanceof Attachment) )
{
- System.err.println("Unable to export '"+p.getName()+"', as it
contains an illegal character. With old repositories, this may sometimes
happen.");
- return;
+ title = title.replace( '/', '_' );
+ System.err.println("Page '"+p.getName()+"' will be renamed to
'"+title+"', as it contains an illegal character.");
}
+ title = title.toLowerCase();
+
+ String tryTitle = title;
+ int idx = 1;
+ while( m_exportedPageTitles.contains( tryTitle ) )
+ {
+ tryTitle = title + "-" + idx++;
+ }
+
+ if( !tryTitle.equals( title ) )
+ {
+ System.err.println( "New case independence rules state that page
'"+p.getName()+"' will be renamed to '"+tryTitle+"', as there is a conflict
already with a page with a similar title." );
+ title = tryTitle;
+ }
+
+ m_exportedPageTitles.add( title );
+
if( m_verbose )
- System.out.println("Exporting "+p.getName());
+ System.out.println("Exporting "+title);
- exportCommonHeader(p);
+ exportCommonHeader(title, p);
Map<String,Object> attrMap = p.getAttributes();
@@ -247,9 +268,9 @@
m_out.flush();
}
- private void exportCommonHeader( WikiPage p ) throws IOException
+ private void exportCommonHeader( String title, WikiPage p ) throws
IOException
{
- m_out.println(" <sv:node sv:name='"+StringEscapeUtils.escapeXml(
p.getName() )+"'>");
+ m_out.println(" <sv:node sv:name='"+StringEscapeUtils.escapeXml( title
)+"'>");
exportProperty( "jcr:primaryType", "nt:unstructured", NAME );
exportProperty( "jcr:mixinTypes",
@@ -261,11 +282,13 @@
exportProperty( "wiki:lastModified",
m_isoFormat.format(p.getLastModified()), DATE );
exportProperty( "wiki:contentType", guessMimeType( p ), STRING );
+
+ exportProperty( "wiki:title", p.getName(), STRING );
}
protected void exportPage( Attachment att ) throws IOException,
ProviderException
{
- exportCommonHeader(att);
+ exportCommonHeader(att.getName().toLowerCase(), att);
m_out.println(" <sv:property sv:name='"+att.getFileName()+"'
sv:type='"+BINARY+"'>");
@@ -322,7 +345,7 @@
out = new BufferedOutputStream( new FileOutputStream(outFile) );
WikiEngine engine = new WikiEngine(props);
- Exporter x = new Exporter(engine, out, false );
+ Exporter x = new Exporter(engine, out, true );
x.export();
}