Author: juanpablo
Date: Wed May 21 16:02:06 2008
New Revision: 658923
URL: http://svn.apache.org/viewvc?rev=658923&view=rev
Log:
* 2.7.0-svn-28
* [JSPWIKI-25]. Creating empty pages should not be possible (default
behaviour). Can be changed by setting jspwiki.allowCreationOfEmptyPages
to true in jspwiki.properties.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/etc/jspwiki.properties.tmpl
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/WikiEngineTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=658923&r1=658922&r2=658923&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Wed May 21 16:02:06 2008
@@ -1,3 +1,14 @@
+2008-05-22 Juan Pablo Santos <[EMAIL PROTECTED]>
+
+ * 2.7.0-svn-28
+
+ * [JSPWIKI-25]. Creating empty pages should not be possible (default
+ behaviour). Can be changed by setting jspwiki.allowCreationOfEmptyPages
+ to true in jspwiki.properties.
+
+ * <i18n-create-template> target in build.xml was creating a wrong i18n
+ directory structure.
+
2008-05-11 Janne Jalkanen <[EMAIL PROTECTED]>
* 2.7.0-svn-27
Modified: incubator/jspwiki/trunk/etc/jspwiki.properties.tmpl
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/jspwiki.properties.tmpl?rev=658923&r1=658922&r2=658923&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/jspwiki.properties.tmpl (original)
+++ incubator/jspwiki/trunk/etc/jspwiki.properties.tmpl Wed May 21 16:02:06 2008
@@ -304,6 +304,11 @@
#
#jspwiki.frontPage = Main
+#
+# Allow creation of empty pages. Defaults to false.
+#
+#jspwiki.allowCreationOfEmptyPages = false
+
#
# If set to true, all outward links have a small icon attached. The icon
# can be found from images/out.png. Default is true.
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=658923&r1=658922&r2=658923&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Wed May 21
16:02:06 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "27";
+ public static final String BUILD = "28";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java?rev=658923&r1=658922&r2=658923&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java Wed May 21
16:02:06 2008
@@ -154,6 +154,9 @@
/** The name of the property containing the ACLManager implementing class.
* The value is [EMAIL PROTECTED] */
public static final String PROP_ACL_MANAGER_IMPL = "jspwiki.aclManager";
+
+ /** If this property is set to false, we don't allow the creation of empty
pages */
+ public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES =
"jspwiki.allowCreationOfEmptyPages";
/** Should the user info be saved with the page data as well? */
private boolean m_saveUserInfo = true;
@@ -1679,6 +1682,15 @@
return;
}
+ // Check if creation of empty pages is allowed; bail if not
+ boolean allowEmpty = TextUtil.getBooleanProperty( m_properties,
+
PROP_ALLOW_CREATION_OF_EMPTY_PAGES,
+ false );
+ if ( !allowEmpty && !pageExists( page ) && text.trim().equals( "" ) )
+ {
+ return;
+ }
+
// Create approval workflow for page save; add the diffed, proposed
// and old text versions as Facts for the approver (if approval is
required)
// If submitter is authenticated, any reject messages will appear in
his/her workflow inbox.
Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/WikiEngineTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/WikiEngineTest.java?rev=658923&r1=658922&r2=658923&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/WikiEngineTest.java
(original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/WikiEngineTest.java Wed May
21 16:02:06 2008
@@ -927,5 +927,61 @@
assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
}
+
+ public void testCreatePage() throws Exception
+ {
+ String text = "Foobar.\r\n";
+ String name = "mrmyxpltz";
+
+ assertEquals( "page should not exist right now",
+ false,
+ m_engine.pageExists( name ) );
+
+ m_engine.saveText( name, text );
+
+ assertEquals( "page does not exist",
+ true,
+ m_engine.pageExists( name ) );
+ }
+
+ public void testCreateEmptyPage() throws Exception
+ {
+ String text = "";
+ String name = "mrmxyzptlk";
+
+ assertEquals( "page should not exist right now",
+ false,
+ m_engine.pageExists( name ) );
+
+ m_engine.saveText( name, text );
+
+ assertEquals( "page should not exist right now neither",
+ false,
+ m_engine.pageExists( name ) );
+ }
+
+ public void testSaveExistingPageWithEmptyContent() throws Exception
+ {
+ String text = "Foobar.\r\n";
+ String name = NAME1;
+
+ m_engine.saveText( name, text );
+
+ assertEquals( "page does not exist",
+ true,
+ m_engine.pageExists( name ) );
+
+ // saveText uses normalizePostData to assure it conforms to certain
rules
+ assertEquals( "wrong content",
+ TextUtil.normalizePostData( text ),
+ m_engine.getText( name ) );
+
+ m_engine.saveText( name, "" );
+
+ assertEquals( "wrong content",
+ TextUtil.normalizePostData( "" ),
+ m_engine.getText( name ) );
+
+ }
}