You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/09 22:17:39 UTC
[jspwiki] 29/32: JSPWIKI-120: move saveText from WikiEngine to
PageManager
This is an automated email from the ASF dual-hosted git repository.
juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 28c2dafcb3558dce5b38db81062a2aa55392446e
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 21:07:24 2020 +0100
JSPWIKI-120: move saveText from WikiEngine to PageManager
---
.../src/main/java/org/apache/wiki/WikiEngine.java | 63 +--------
.../org/apache/wiki/pages/DefaultPageManager.java | 58 +++++++-
.../java/org/apache/wiki/pages/PageManager.java | 20 +++
.../org/apache/wiki/plugin/BugReportHandler.java | 2 +-
.../org/apache/wiki/rpc/atom/AtomAPIServlet.java | 31 ++---
.../org/apache/wiki/xmlrpc/MetaWeblogHandler.java | 23 +---
.../src/test/java/org/apache/wiki/TestEngine.java | 4 +-
.../test/java/org/apache/wiki/WikiEngineTest.java | 4 +-
.../wiki/plugin/DefaultPluginManagerTest.java | 150 ++++++---------------
.../wiki/providers/VersioningFileProviderTest.java | 12 +-
.../org/apache/wiki/search/SearchManagerTest.java | 8 +-
jspwiki-war/src/main/webapp/Comment.jsp | 110 ++++++---------
jspwiki-war/src/main/webapp/Edit.jsp | 109 +++++----------
.../src/main/webapp/templates/default/Sidebar.jsp | 2 +-
14 files changed, 225 insertions(+), 371 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 2e0a0bf..0cae15a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -753,6 +753,7 @@ public class WikiEngine {
if( pageName == null ) {
pageName = getFrontPage();
}
+ //FIXME: final boolean absolute = getVariableManager().getVariable( this, WikiEngine.PROP_REFSTYLE );
return getURLConstructor().makeURL( WikiContext.VIEW, pageName, "absolute".equals( PROP_REFSTYLE ), null );
}
@@ -1172,68 +1173,6 @@ public class WikiEngine {
}
/**
- * Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
- * the property <code>jspwiki.approver.workflow.saveWikiPage</code> and its value resolves to a valid user,
- * {@link org.apache.wiki.auth.authorize.Group} or {@link org.apache.wiki.auth.authorize.Role}, this method will
- * place a {@link org.apache.wiki.workflow.Decision} in the approver's workflow inbox and throw a
- * {@link org.apache.wiki.workflow.DecisionRequiredException}. If the submitting user is authenticated and the
- * page save is rejected, a notification will be placed in the user's decision queue.
- *
- * @since 2.1.28
- * @param context The current WikiContext
- * @param text The Wiki markup for the page.
- * @throws WikiException if the save operation encounters an error during the save operation. If the page-save
- * operation requires approval, the exception will be of type {@link org.apache.wiki.workflow.DecisionRequiredException}.
- * Individual PageFilters, such as the {@link org.apache.wiki.filters.SpamFilter} may also throw a
- * {@link org.apache.wiki.api.exceptions.RedirectException}.
- */
- public void saveText( final WikiContext context, final String text ) throws WikiException {
- // Check if page data actually changed; bail if not
- final WikiPage page = context.getPage();
- final String oldText = getPageManager().getPureText( page );
- final String proposedText = TextUtil.normalizePostData( text );
- if ( oldText != null && oldText.equals( proposedText ) ) {
- return;
- }
-
- // Check if creation of empty pages is allowed; bail if not
- final boolean allowEmpty = TextUtil.getBooleanProperty( m_properties, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, false );
- if ( !allowEmpty && !m_pageManager.wikiPageExists( 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.
- final WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
- final Principal submitter = context.getCurrentUser();
- final Step prepTask = m_tasksManager.buildPreSaveWikiPageTask( context, proposedText );
- final Step completionTask = m_tasksManager.buildSaveWikiPageTask();
- final String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
- final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
- final Fact[] facts = new Fact[ 5 ];
- facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
- facts[ 1 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_DIFF_TEXT, diffText );
- facts[ 2 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, proposedText );
- facts[ 3 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_CURRENT_TEXT, oldText);
- facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, isAuthenticated );
- final String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
- final Workflow workflow = builder.buildApprovalWorkflow( submitter,
- WorkflowManager.WF_WP_SAVE_APPROVER,
- prepTask,
- WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
- facts,
- completionTask,
- rejectKey );
- m_workflowMgr.start( workflow );
-
- // Let callers know if the page-save requires approval
- if ( workflow.getCurrentStep() instanceof Decision ) {
- throw new DecisionRequiredException( "The page contents must be approved before they become active." );
- }
- }
-
- /**
* Returns this object's ReferenceManager.
* @return The current ReferenceManager instance.
*
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 1a7e4f7..c30113f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -21,6 +21,7 @@ package org.apache.wiki.pages;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiBackgroundThread;
+import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiProvider;
@@ -44,6 +45,13 @@ 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.workflow.Decision;
+import org.apache.wiki.workflow.DecisionRequiredException;
+import org.apache.wiki.workflow.Fact;
+import org.apache.wiki.workflow.Step;
+import org.apache.wiki.workflow.Workflow;
+import org.apache.wiki.workflow.WorkflowBuilder;
+import org.apache.wiki.workflow.WorkflowManager;
import java.io.IOException;
import java.security.Permission;
@@ -194,7 +202,6 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
*/
public String getPureText( final String page, final int version ) {
String result = null;
-
try {
result = getPageText( page, version );
} catch( final ProviderException e ) {
@@ -204,7 +211,6 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
result = "";
}
}
-
return result;
}
@@ -217,6 +223,54 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
return TextUtil.replaceEntities( result );
}
+ public void saveText( final WikiContext context, final String text ) throws WikiException {
+ // Check if page data actually changed; bail if not
+ final WikiPage page = context.getPage();
+ final String oldText = getPureText( page );
+ final String proposedText = TextUtil.normalizePostData( text );
+ if ( oldText != null && oldText.equals( proposedText ) ) {
+ return;
+ }
+
+ // Check if creation of empty pages is allowed; bail if not
+ final boolean allowEmpty = TextUtil.getBooleanProperty( m_engine.getWikiProperties(),
+ WikiEngine.PROP_ALLOW_CREATION_OF_EMPTY_PAGES,
+ false );
+ if ( !allowEmpty && !wikiPageExists( 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.
+ final WorkflowBuilder builder = WorkflowBuilder.getBuilder( m_engine );
+ final Principal submitter = context.getCurrentUser();
+ final Step prepTask = m_engine.getTasksManager().buildPreSaveWikiPageTask( context, proposedText );
+ final Step completionTask = m_engine.getTasksManager().buildSaveWikiPageTask();
+ final String diffText = m_engine.getDifferenceManager().makeDiff( context, oldText, proposedText );
+ final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
+ final Fact[] facts = new Fact[ 5 ];
+ facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
+ facts[ 1 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_DIFF_TEXT, diffText );
+ facts[ 2 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, proposedText );
+ facts[ 3 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_CURRENT_TEXT, oldText);
+ facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, isAuthenticated );
+ final String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
+ final Workflow workflow = builder.buildApprovalWorkflow( submitter,
+ WorkflowManager.WF_WP_SAVE_APPROVER,
+ prepTask,
+ WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
+ facts,
+ completionTask,
+ rejectKey );
+ m_engine.getWorkflowManager().start( workflow );
+
+ // Let callers know if the page-save requires approval
+ if ( workflow.getCurrentStep() instanceof Decision ) {
+ throw new DecisionRequiredException( "The page contents must be approved before they become active." );
+ }
+ }
+
/**
* Returns the WikiEngine to which this PageManager belongs to.
*
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 9173df8..80ddfc1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -18,8 +18,10 @@
*/
package org.apache.wiki.pages;
+import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiPage;
import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.exceptions.WikiException;
import org.apache.wiki.event.WikiEventListener;
import org.apache.wiki.providers.WikiPageProvider;
@@ -134,6 +136,24 @@ public interface PageManager extends WikiEventListener {
}
/**
+ * Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
+ * the property <code>jspwiki.approver.workflow.saveWikiPage</code> and its value resolves to a valid user,
+ * {@link org.apache.wiki.auth.authorize.Group} or {@link org.apache.wiki.auth.authorize.Role}, this method will
+ * place a {@link org.apache.wiki.workflow.Decision} in the approver's workflow inbox and throw a
+ * {@link org.apache.wiki.workflow.DecisionRequiredException}. If the submitting user is authenticated and the
+ * page save is rejected, a notification will be placed in the user's decision queue.
+ *
+ * @since 2.1.28, moved to PageManager on 2.11.0
+ * @param context The current WikiContext
+ * @param text The Wiki markup for the page.
+ * @throws WikiException if the save operation encounters an error during the save operation. If the page-save
+ * operation requires approval, the exception will be of type {@link org.apache.wiki.workflow.DecisionRequiredException}.
+ * Individual PageFilters, such as the {@link org.apache.wiki.filters.SpamFilter} may also throw a
+ * {@link org.apache.wiki.api.exceptions.RedirectException}.
+ */
+ void saveText( WikiContext context, String text ) throws WikiException;
+
+ /**
* Puts the page text into the repository. Note that this method does NOT update
* JSPWiki internal data structures, and therefore you should always use WikiEngine.saveText()
*
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
index 8ad5f9b..b725f7d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
@@ -141,7 +141,7 @@ public class BugReportHandler implements WikiPlugin {
final WikiPage newPage = new WikiPage( context.getEngine(), pageName );
final WikiContext newContext = (WikiContext)context.clone();
newContext.setPage( newPage );
- context.getEngine().saveText( newContext, str.toString() );
+ context.getEngine().getPageManager().saveText( newContext, str.toString() );
final MessageFormat formatter = new MessageFormat("");
formatter.applyPattern( rb.getString("bugreporthandler.new") );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index f568541..56dc601 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -156,21 +156,15 @@ public class AtomAPIServlet extends HttpServlet
log.debug("Writing entry: "+text);
- m_engine.saveText( context, text.toString() );
+ m_engine.getPageManager().saveText( context, text.toString() );
- }
- catch( FeedMarshallException e )
- {
+ } catch( final FeedMarshallException e ) {
log.error("Received faulty Atom entry",e);
throw new ServletException("Faulty Atom entry",e);
- }
- catch( IOException e )
- {
+ } catch( final IOException e ) {
log.error("I/O exception",e);
throw new ServletException("Could not get body of request",e);
- }
- catch( WikiException e )
- {
+ } catch( final WikiException e ) {
log.error("Provider exception while posting",e);
throw new ServletException("JSPWiki cannot save the entry",e);
}
@@ -220,9 +214,7 @@ public class AtomAPIServlet extends HttpServlet
}
- private Entry getBlogEntry( String entryid )
- throws ProviderException
- {
+ private Entry getBlogEntry( String entryid ) {
WikiPage page = m_engine.getPageManager().getPage( entryid );
WikiPage firstVersion = m_engine.getPageManager().getPage( entryid, 1 );
@@ -257,10 +249,7 @@ public class AtomAPIServlet extends HttpServlet
/**
* Creates and outputs a full list of all available blogs
*/
- private Feed listBlogs()
- throws ProviderException,
- IOException
- {
+ private Feed listBlogs() throws ProviderException {
Collection< WikiPage > pages = m_engine.getPageManager().getAllPages();
Feed feed = SyndicationFactory.newSyndicationFeed();
@@ -328,18 +317,14 @@ public class AtomAPIServlet extends HttpServlet
/**
* {@inheritDoc}
*/
- public void doDelete( HttpServletRequest request, HttpServletResponse response )
- throws ServletException
- {
+ public void doDelete( HttpServletRequest request, HttpServletResponse response ) {
log.debug("Received HTTP DELETE");
}
/**
* {@inheritDoc}
*/
- public void doPut( HttpServletRequest request, HttpServletResponse response )
- throws ServletException
- {
+ public void doPut( HttpServletRequest request, HttpServletResponse response ) {
log.debug("Received HTTP PUT");
}
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index 37f43a6..c726b83 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -205,8 +205,7 @@ public class MetaWeblogHandler
checkPermissions( page, username, password, "view" );
- try
- {
+ try {
WeblogPlugin plugin = new WeblogPlugin();
List<WikiPage> changed = plugin.findBlogEntries(m_context.getEngine(),
@@ -224,11 +223,8 @@ public class MetaWeblogHandler
result.put( "entry", makeEntry( p ) );
}
- }
- catch( ProviderException e )
- {
+ } catch( final ProviderException e ) {
log.error( "Failed to list recent posts", e );
-
throw new XmlRpcException( 0, e.getMessage() );
}
@@ -277,7 +273,7 @@ public class MetaWeblogHandler
log.debug("Writing entry: "+text);
- engine.saveText( context, text.toString() );
+ engine.getPageManager().saveText( context, text.toString() );
}
catch( Exception e )
{
@@ -320,16 +316,13 @@ public class MetaWeblogHandler
AttachmentManager attmgr = engine.getAttachmentManager();
- try
- {
+ try {
Attachment att = new Attachment( engine, blogid, name );
att.setAuthor( username );
attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
- }
- catch( Exception e )
- {
+ } catch( final Exception e ) {
log.error( "Failed to upload attachment", e );
throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
}
@@ -374,10 +367,8 @@ public class MetaWeblogHandler
log.debug("Updating entry: "+text);
- engine.saveText( context, text.toString() );
- }
- catch( Exception e )
- {
+ engine.getPageManager().saveText( context, text.toString() );
+ } catch( final Exception e ) {
log.error("Failed to create weblog entry",e);
throw new XmlRpcException( 0, "Failed to update weblog entry: "+e.getMessage() );
}
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index f012adb..9aaf8d2 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -368,7 +368,7 @@ public class TestEngine extends WikiEngine
// Create page and wiki context
final WikiPage page = new WikiPage( this, pageName );
final WikiContext context = new WikiContext( this, request, page );
- saveText( context, content );
+ getPageManager().saveText( context, content );
}
public void saveTextAsJanne( final String pageName, final String content ) throws WikiException {
@@ -381,7 +381,7 @@ public class TestEngine extends WikiEngine
final WikiPage page = new WikiPage( this, pageName );
page.setAuthor(Users.JANNE);
final WikiContext context = new WikiContext( this, request, page );
- saveText( context, content );
+ getPageManager().saveText( context, content );
}
/**
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
index d2718b0..779e7d7 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -365,13 +365,13 @@ public class WikiEngineTest {
final WikiPage p = new WikiPage( m_engine, NAME1 );
final WikiContext context = new WikiContext(m_engine,p);
context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
- m_engine.saveText( context, "test" );
+ m_engine.getPageManager().saveText( context, "test" );
for( int i = 0; i < 5; i++ ) {
final WikiPage p2 = ( WikiPage )m_engine.getPageManager().getPage( NAME1 ).clone();
p2.removeAttribute( WikiPage.CHANGENOTE );
context.setPage( p2 );
- m_engine.saveText( context, "test" + i );
+ m_engine.getPageManager().saveText( context, "test" + i );
}
final WikiPage p3 = m_engine.getPageManager().getPage( NAME1, -1 );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
index 9a0a14e..ca5aac5 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
@@ -45,173 +45,109 @@ public class DefaultPluginManagerTest {
}
@AfterEach
- public void tearDown() throws ProviderException
- {
+ public void tearDown() throws ProviderException {
engine.getPageManager().deletePage("Testpage");
}
@Test
- public void testSimpleInsert()
- throws Exception
- {
- String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text=foobar}");
-
+ public void testSimpleInsert() throws Exception {
+ final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text=foobar}");
Assertions.assertEquals( "foobar", res );
}
@Test
- public void testSimpleInsertNoPackage()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT SamplePlugin WHERE text=foobar}");
-
- Assertions.assertEquals( "foobar",
- res );
+ public void testSimpleInsertNoPackage() throws Exception {
+ final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text=foobar}");
+ Assertions.assertEquals( "foobar", res );
}
@Test
- public void testSimpleInsertNoPackage2()
- throws Exception
- {
+ public void testSimpleInsertNoPackage2() throws Exception {
props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo" );
- DefaultPluginManager m = new DefaultPluginManager( engine, props );
- String res = m.execute( context,
- "{INSERT SamplePlugin2 WHERE text=foobar}");
-
- Assertions.assertEquals( "foobar",
- res );
+ final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+ final String res = m.execute( context,"{INSERT SamplePlugin2 WHERE text=foobar}" );
+ Assertions.assertEquals( "foobar", res );
}
@Test
- public void testSimpleInsertNoPackage3()
- throws Exception
- {
+ public void testSimpleInsertNoPackage3() throws Exception {
props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo" );
- DefaultPluginManager m = new DefaultPluginManager( engine, props );
- String res = m.execute( context,
- "{INSERT SamplePlugin3 WHERE text=foobar}");
-
- Assertions.assertEquals( "foobar",
- res );
+ final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+ final String res = m.execute( context,"{INSERT SamplePlugin3 WHERE text=foobar}" );
+ Assertions.assertEquals( "foobar", res );
}
/** Check that in all cases org.apache.wiki.plugin is searched. */
@Test
- public void testSimpleInsertNoPackage4()
- throws Exception
- {
+ public void testSimpleInsertNoPackage4() throws Exception {
props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo,blat.blaa" );
- DefaultPluginManager m = new DefaultPluginManager( engine, props );
- String res = m.execute( context,
- "{INSERT SamplePlugin WHERE text=foobar}");
-
- Assertions.assertEquals( "foobar",
- res );
+ final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+ final String res = m.execute( context,"{INSERT SamplePlugin WHERE text=foobar}" );
+ Assertions.assertEquals( "foobar", res );
}
@Test
- public void testSimpleInsert2()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text = foobar2, moo=blat}");
-
- Assertions.assertEquals( "foobar2",
- res );
+ public void testSimpleInsert2() throws Exception {
+ final String res = manager.execute( context,"{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text = foobar2, moo=blat}");
+ Assertions.assertEquals( "foobar2", res );
}
/** Missing closing brace */
@Test
- public void testSimpleInsert3()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text = foobar2, moo=blat");
-
- Assertions.assertEquals( "foobar2",
- res );
+ public void testSimpleInsert3() throws Exception {
+ final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text = foobar2, moo=blat");
+ Assertions.assertEquals( "foobar2", res );
}
@Test
- public void testQuotedArgs()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT SamplePlugin WHERE text='this is a space'}");
-
- Assertions.assertEquals( "this is a space",
- res );
+ public void testQuotedArgs() throws Exception {
+ final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text='this is a space'}");
+ Assertions.assertEquals( "this is a space", res );
}
@Test
- public void testQuotedArgs2()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT SamplePlugin WHERE text='this \\'is a\\' space'}");
-
- Assertions.assertEquals( "this 'is a' space",
- res );
+ public void testQuotedArgs2() throws Exception {
+ final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text='this \\'is a\\' space'}" );
+ Assertions.assertEquals( "this 'is a' space", res );
}
@Test
- public void testNumberArgs()
- throws Exception
- {
- String res = manager.execute( context,
- "{INSERT SamplePlugin WHERE text=15}");
-
- Assertions.assertEquals( "15",
- res );
+ public void testNumberArgs() throws Exception {
+ final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text=15}" );
+ Assertions.assertEquals( "15", res );
}
@Test
- public void testNoInsert()
- throws Exception
- {
- String res = manager.execute( context,
- "{SamplePlugin WHERE text=15}");
-
- Assertions.assertEquals( "15",
- res );
+ public void testNoInsert() throws Exception {
+ final String res = manager.execute( context, "{SamplePlugin WHERE text=15}" );
+ Assertions.assertEquals( "15", res );
}
// This should be read from tests/etc/ini/jspwiki_module.xml
@Test
- public void testAlias()
- throws Exception
- {
- String res = manager.execute( context, "{samplealias text=15}");
-
+ public void testAlias() throws Exception {
+ final String res = manager.execute( context, "{samplealias text=15}");
Assertions.assertEquals( "15", res );
}
@Test
- public void testAlias2()
- throws Exception
- {
- String res = manager.execute( context, "{samplealias2 text=xyzzy}");
-
+ public void testAlias2() throws Exception {
+ final String res = manager.execute( context, "{samplealias2 text=xyzzy}");
Assertions.assertEquals( "xyzzy", res );
}
@Test
- public void testInitPlugin() throws Exception
- {
+ public void testInitPlugin() throws Exception {
manager.execute( context, "{JavaScriptPlugin}");
-
Assertions.assertTrue( JavaScriptPlugin.c_inited );
}
@Test
- public void testParserPlugin() throws Exception
- {
- engine.saveText(context, "[{SamplePlugin render=true}]");
+ public void testParserPlugin() throws Exception {
+ engine.getPageManager().saveText(context, "[{SamplePlugin render=true}]");
engine.getHTML( "Testpage" );
-
Assertions.assertTrue( SamplePlugin.c_rendered );
}
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
index cb17e9c..688ae5f 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
@@ -530,7 +530,7 @@ public class VersioningFileProviderTest
p.setAttribute(WikiPage.CHANGENOTE, "Test change" );
WikiContext context = new WikiContext(engine,p);
- engine.saveText( context, "test" );
+ engine.getPageManager().saveText( context, "test" );
WikiPage p2 = engine.getPageManager().getPage( NAME1 );
@@ -547,10 +547,10 @@ public class VersioningFileProviderTest
WikiContext context = new WikiContext(engine,p);
context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change" );
- engine.saveText( context, "test" );
+ engine.getPageManager().saveText( context, "test" );
context.getPage().setAttribute(WikiPage.CHANGENOTE, "Change 2" );
- engine.saveText( context, "test2" );
+ engine.getPageManager().saveText( context, "test2" );
WikiPage p2 = engine.getPageManager().getPage( NAME1, 1 );
@@ -570,7 +570,7 @@ public class VersioningFileProviderTest
context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
- engine.saveText( context, "test" );
+ engine.getPageManager().saveText( context, "test" );
for( int i = 0; i < 5; i++ )
{
@@ -579,12 +579,12 @@ public class VersioningFileProviderTest
context.setPage( p2 );
- engine.saveText( context, "test"+i );
+ engine.getPageManager().saveText( context, "test"+i );
}
WikiPage p3 = engine.getPageManager().getPage( NAME1, -1 );
- Assertions.assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
+ Assertions.assertEquals( null, (String)p3.getAttribute(WikiPage.CHANGENOTE) );
}
/*
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
index 1f7a935..9944ed4 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
@@ -122,8 +122,8 @@ public class SearchManagerTest {
final MockHttpServletRequest request = m_engine.newHttpRequest();
request.getParameterMap().put( "page", new String[]{ "TestPage" } );
final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
- m_engine.saveText( ctx, txt );
- m_engine.saveText( ctx, "The Babylon Project was a dream given form. Its goal: to prevent another war by creating a place where humans and aliens could work out their differences peacefully." );
+ m_engine.getPageManager().saveText( ctx, txt );
+ m_engine.getPageManager().saveText( ctx, "The Babylon Project was a dream given form. Its goal: to prevent another war by creating a place where humans and aliens could work out their differences peacefully." );
Collection< SearchResult > res = new ArrayList<>();
Awaitility.await( "testSimpleSearch3" ).until( findsResultsFor( res, "Babylon" ) );
@@ -144,14 +144,14 @@ public class SearchManagerTest {
final MockHttpServletRequest request = m_engine.newHttpRequest();
request.getParameterMap().put( "page", new String[]{ "TestPage" } );
final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
- m_engine.saveText( ctx, txt );
+ m_engine.getPageManager().saveText( ctx, txt );
Collection< SearchResult > res = new ArrayList<>();
Awaitility.await( "testSimpleSearch4" ).until( findsResultsFor( res, "mankind" ) );
Assertions.assertEquals( 1, res.size(), "result not found" );
- m_engine.saveText( ctx, "[{ALLOW view Authenticated}] It was the dawn of the third age of mankind... page is blocked" );
+ m_engine.getPageManager().saveText( ctx, "[{ALLOW view Authenticated}] It was the dawn of the third age of mankind... page is blocked" );
res = m_mgr.findPages( "mankind" , ctx );
Assertions.assertNotNull( res, "null result" );
diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index d1b90a1..5ef57e3 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -43,14 +43,12 @@
<%!
Logger log = Logger.getLogger("JSPWiki");
- String findParam( PageContext ctx, String key )
- {
+ String findParam( PageContext ctx, String key ) {
ServletRequest req = ctx.getRequest();
String val = req.getParameter( key );
- if( val == null )
- {
+ if( val == null ) {
val = (String)ctx.findAttribute( key );
}
@@ -73,8 +71,7 @@
WikiSession wikiSession = wikiContext.getWikiSession();
String storedUser = wikiSession.getUserPrincipal().getName();
- if( wikiSession.isAnonymous() )
- {
+ if( wikiSession.isAnonymous() ) {
storedUser = TextUtil.replaceEntities( request.getParameter( "author" ) );
}
@@ -91,8 +88,7 @@
session.removeAttribute( EditorManager.REQ_EDITEDTEXT );
- if( latestversion == null )
- {
+ if( latestversion == null ) {
latestversion = wikiContext.getPage();
}
@@ -101,8 +97,7 @@
// session.
//
- if( remember == null )
- {
+ if( remember == null ) {
remember = (String)session.getAttribute("remember");
}
@@ -114,16 +109,16 @@
session.setAttribute("remember",remember);
- if( author == null )
- {
+ if( author == null ) {
author = storedUser;
}
- if( author == null || author.length() == 0 ) author = "AnonymousCoward";
+ if( author == null || author.length() == 0 ) {
+ author = "AnonymousCoward";
+ }
session.setAttribute("author",author);
- if( link == null )
- {
+ if( link == null ) {
link = HttpUtil.retrieveCookieValue( request, "link" );
if( link == null ) link = "";
link = TextUtil.urlDecodeUTF8(link);
@@ -131,16 +126,16 @@
session.setAttribute( "link", link );
- if( changenote != null )
+ if( changenote != null ) {
session.setAttribute( "changenote", changenote );
+ }
//
// Branch
//
log.debug("preview="+preview+", ok="+ok);
- if( ok != null )
- {
+ if( ok != null ) {
log.info("Saving page "+pagereq+". User="+storedUser+", host="+HttpUtil.getRemoteAddress(request) );
// Modifications are written here before actual saving
@@ -153,14 +148,12 @@
String spamhash = request.getParameter( SpamFilter.getHashFieldName(request) );
- if( !SpamFilter.checkHash(wikiContext,pageContext) )
- {
+ if( !SpamFilter.checkHash(wikiContext,pageContext) ) {
return;
}
//
- // We expire ALL locks at this moment, simply because someone has
- // already broken it.
+ // We expire ALL locks at this moment, simply because someone has already broken it.
//
PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
wiki.getPageManager().unlockPage( lock );
@@ -169,18 +162,17 @@
//
// Set author and changenote information
//
-
modifiedPage.setAuthor( storedUser );
- if( changenote != null )
+ if( changenote != null ) {
modifiedPage.setAttribute( WikiPage.CHANGENOTE, changenote );
- else
+ } else {
modifiedPage.removeAttribute( WikiPage.CHANGENOTE );
+ }
//
// Build comment part
//
-
StringBuffer pageText = new StringBuffer(wiki.getPageManager().getPureText( wikipage ));
log.debug("Page initial contents are "+pageText.length()+" chars");
@@ -188,8 +180,7 @@
//
// Add a line on top only if we need to separate it from the content.
//
- if( pageText.length() > 0 )
- {
+ if( pageText.length() > 0 ) {
pageText.append( "\n\n----\n\n" );
}
@@ -200,22 +191,18 @@
// WYSIWYG editor sends us its greetings
//
String htmlText = findParam( pageContext, "htmlPageText" );
- if( htmlText != null && cancel == null )
- {
+ if( htmlText != null && cancel == null ) {
commentText = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
}
pageText.append( commentText );
log.debug("Author name ="+author);
- if( author != null && author.length() > 0 )
- {
+ if( author != null && author.length() > 0 ) {
String signature = author;
- if( link != null && link.length() > 0 )
- {
+ if( link != null && link.length() > 0 ) {
link = HttpUtil.guessValidURI( link );
-
signature = "["+author+"|"+link+"]";
}
@@ -226,57 +213,43 @@
}
- if( TextUtil.isPositive(remember) )
- {
- if( link != null )
- {
+ if( TextUtil.isPositive(remember) ) {
+ if( link != null ) {
Cookie linkcookie = new Cookie("link", TextUtil.urlEncodeUTF8(link) );
linkcookie.setMaxAge(1001*24*60*60);
response.addCookie( linkcookie );
}
CookieAssertionLoginModule.setUserCookie( response, author );
- }
- else
- {
+ } else {
session.removeAttribute("link");
session.removeAttribute("author");
}
- try
- {
+ try {
wikiContext.setPage( modifiedPage );
- wiki.saveText( wikiContext, pageText.toString() );
- }
- catch( DecisionRequiredException e )
- {
+ wiki.getPageManager().saveText( wikiContext, pageText.toString() );
+ } catch( DecisionRequiredException e ) {
String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
response.sendRedirect( redirect );
return;
- }
- catch( RedirectException e )
- {
+ } catch( RedirectException e ) {
session.setAttribute( VariableManager.VAR_MSG, e.getMessage() );
response.sendRedirect( e.getRedirect() );
return;
}
response.sendRedirect(wiki.getViewURL(pagereq));
return;
- }
- else if( preview != null )
- {
+ } else if( preview != null ) {
log.debug("Previewing "+pagereq);
session.setAttribute(EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext));
response.sendRedirect( TextUtil.replaceString( wiki.getURL(WikiContext.PREVIEW, pagereq, "action=comment", false),"&","&") );
return;
- }
- else if( cancel != null )
- {
+ } else if( cancel != null ) {
log.debug("Cancelled editing "+pagereq);
PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
- if( lock != null )
- {
+ if( lock != null ) {
wiki.getPageManager().unlockPage( lock );
session.removeAttribute( "lock-"+pagereq );
}
@@ -287,18 +260,15 @@
log.info("Commenting page "+pagereq+". User="+request.getRemoteUser()+", host="+HttpUtil.getRemoteAddress(request) );
//
- // Determine and store the date the latest version was changed. Since
- // the newest version is the one that is changed, we need to track
- // that instead of the edited version.
+ // Determine and store the date the latest version was changed. Since the newest version is the one that is changed,
+ // we need to track that instead of the edited version.
//
long lastchange = 0;
Date d = latestversion.getLastModified();
if( d != null ) lastchange = d.getTime();
- pageContext.setAttribute( "lastchange",
- Long.toString( lastchange ),
- PageContext.REQUEST_SCOPE );
+ pageContext.setAttribute( "lastchange", Long.toString( lastchange ), PageContext.REQUEST_SCOPE );
// This is a hack to get the preview to work.
// pageContext.setAttribute( "comment", Boolean.TRUE, PageContext.REQUEST_SCOPE );
@@ -306,11 +276,9 @@
//
// Attempt to lock the page.
//
- PageLock lock = wiki.getPageManager().lockPage( wikipage,
- storedUser );
+ PageLock lock = wiki.getPageManager().lockPage( wikipage, storedUser );
- if( lock != null )
- {
+ if( lock != null ) {
session.setAttribute( "lock-"+pagereq, lock );
}
@@ -319,8 +287,6 @@
response.setHeader( "Cache-control", "max-age=0" );
response.setDateHeader( "Expires", new Date().getTime() );
response.setDateHeader( "Last-Modified", new Date().getTime() );
- String contentPage = wiki.getTemplateManager().findJSP( pageContext,
- wikiContext.getTemplate(),
- "EditTemplate.jsp" );
+ String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
%><wiki:Include page="<%=contentPage%>" />
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index bcaf43e..b572cae 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -35,14 +35,10 @@
<%!
Logger log = Logger.getLogger("JSPWiki");
- String findParam( PageContext ctx, String key )
- {
+ String findParam( PageContext ctx, String key ) {
ServletRequest req = ctx.getRequest();
-
String val = req.getParameter( key );
-
- if( val == null )
- {
+ if( val == null ) {
val = (String)ctx.findAttribute( key );
}
@@ -54,7 +50,9 @@
WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
// Create wiki context and check for authorization
WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
- if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+ if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) {
+ return;
+ }
if( wikiContext.getCommand().getTarget() == null ) {
response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
return;
@@ -76,9 +74,7 @@
String spamhash = findParam( pageContext, SpamFilter.getHashFieldName(request) );
String captcha = (String)session.getAttribute("captcha");
- if ( !wikiSession.isAuthenticated() && wikiSession.isAnonymous()
- && author != null )
- {
+ if ( !wikiSession.isAuthenticated() && wikiSession.isAnonymous() && author != null ) {
user = TextUtil.replaceEntities( findParam( pageContext, "author" ) );
}
@@ -86,16 +82,14 @@
// WYSIWYG editor sends us its greetings
//
String htmlText = findParam( pageContext, "htmlPageText" );
- if( htmlText != null && cancel == null )
- {
+ if( htmlText != null && cancel == null ) {
text = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
}
WikiPage wikipage = wikiContext.getPage();
WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
- if( latestversion == null )
- {
+ if( latestversion == null ) {
latestversion = wikiContext.getPage();
}
@@ -112,16 +106,14 @@
//log.debug("Request content type+"+request.getContentType());
log.debug("preview="+preview+", ok="+ok);
- if( ok != null || captcha != null )
- {
+ if( ok != null || captcha != null ) {
log.info("Saving page "+pagereq+". User="+user+", host="+HttpUtil.getRemoteAddress(request) );
//
// Check for session expiry
//
- if( !SpamFilter.checkHash(wikiContext,pageContext) )
- {
+ if( !SpamFilter.checkHash(wikiContext,pageContext) ) {
return;
}
@@ -133,8 +125,7 @@
String h = SpamFilter.getSpamHash( latestversion, request );
- if( !h.equals(spamhash) )
- {
+ if( !h.equals(spamhash) ) {
//
// Someone changed the page while we were editing it!
//
@@ -147,8 +138,7 @@
}
//
- // We expire ALL locks at this moment, simply because someone has
- // already broken it.
+ // We expire ALL locks at this moment, simply because someone has already broken it.
//
PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
wiki.getPageManager().unlockPage( lock );
@@ -157,28 +147,24 @@
//
// Set author information and other metadata
//
-
modifiedPage.setAuthor( user );
- if( changenote == null ) changenote = (String) session.getAttribute("changenote");
+ if( changenote == null ) {
+ changenote = (String) session.getAttribute("changenote");
+ }
session.removeAttribute("changenote");
- if( changenote != null && changenote.length() > 0 )
- {
+ if( changenote != null && changenote.length() > 0 ) {
modifiedPage.setAttribute( WikiPage.CHANGENOTE, changenote );
- }
- else
- {
+ } else {
modifiedPage.removeAttribute( WikiPage.CHANGENOTE );
}
//
// Figure out the actual page text
//
-
- if( text == null )
- {
+ if( text == null ) {
throw new ServletException( "No parameter text set!" );
}
@@ -186,38 +172,26 @@
// If this is an append, then we just append it to the page.
// If it is a full edit, then we will replace the previous contents.
//
-
- try
- {
+ try {
wikiContext.setPage( modifiedPage );
- if( captcha != null )
- {
+ if( captcha != null ) {
wikiContext.setVariable( "captcha", Boolean.TRUE );
session.removeAttribute( "captcha" );
}
- if( append != null )
- {
+ if( append != null ) {
StringBuffer pageText = new StringBuffer(wiki.getPageManager().getText( pagereq ));
-
pageText.append( text );
-
- wiki.saveText( wikiContext, pageText.toString() );
- }
- else
- {
- wiki.saveText( wikiContext, text );
+ wiki.getPageManager().saveText( wikiContext, pageText.toString() );
+ } else {
+ wiki.getPageManager().saveText( wikiContext, text );
}
- }
- catch( DecisionRequiredException ex )
- {
+ } catch( DecisionRequiredException ex ) {
String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
response.sendRedirect( redirect );
return;
- }
- catch( RedirectException ex )
- {
+ } catch( RedirectException ex ) {
// FIXME: Cut-n-paste code.
wikiContext.getWikiSession().addMessage( ex.getMessage() ); // FIXME: should work, but doesn't
session.setAttribute( "message", ex.getMessage() );
@@ -234,27 +208,23 @@
response.sendRedirect(wiki.getViewURL(pagereq));
return;
- }
- else if( preview != null )
- {
+ } else if( preview != null ) {
log.debug("Previewing "+pagereq);
session.setAttribute(EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext));
session.setAttribute("author",user);
session.setAttribute("link",link != null ? link : "" );
- if( htmlText != null ) session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+ if( htmlText != null ) {
+ session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+ }
session.setAttribute("changenote", changenote != null ? changenote : "" );
response.sendRedirect( wiki.getURL(WikiContext.PREVIEW,pagereq,null,false) );
return;
- }
- else if( cancel != null )
- {
+ } else if( cancel != null ) {
log.debug("Cancelled editing "+pagereq);
PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
-
- if( lock != null )
- {
+ if( lock != null ) {
wiki.getPageManager().unlockPage( lock );
session.removeAttribute( "lock-"+pagereq );
}
@@ -274,23 +244,16 @@
//
String lastchange = SpamFilter.getSpamHash( latestversion, request );
- pageContext.setAttribute( "lastchange",
- lastchange,
- PageContext.REQUEST_SCOPE );
+ pageContext.setAttribute( "lastchange", lastchange, PageContext.REQUEST_SCOPE );
//
// Attempt to lock the page.
//
- PageLock lock = wiki.getPageManager().lockPage( wikipage,
- user );
-
- if( lock != null )
- {
+ PageLock lock = wiki.getPageManager().lockPage( wikipage, user );
+ if( lock != null ) {
session.setAttribute( "lock-"+pagereq, lock );
}
- String contentPage = wiki.getTemplateManager().findJSP( pageContext,
- wikiContext.getTemplate(),
- "EditTemplate.jsp" );
+ String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
%><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp b/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
index 369105c..12bcb73 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
@@ -27,7 +27,7 @@
<div class="sidebar">
- <c:set var="isweblog"><%= WikiContext.findContext( pageContext ).getPage().getAttribute( /*ATTR_ISWEBLOG*/ "weblogplugin.isweblog" ) %></c:set>
+ <c:set var="isweblog"><%= ( String )WikiContext.findContext( pageContext ).getPage().getAttribute( /*ATTR_ISWEBLOG*/ "weblogplugin.isweblog" ) %></c:set>
<c:if test="${isweblog}">
<wiki:Calendar pageformat="'${param.page}_blogentry_'ddMMyy'_1'"
urlformat="'Wiki.jsp?page=${param.page}&weblog.startDate='ddMMyy'&weblog.days=1'"/>