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 7377ff98dc36d32cfd7b8820c7a1cefb72801391
Author: juanpablo <[email protected]>
AuthorDate: Sat Mar 21 15:44:28 2020 +0100

    use Context and Page instead of WikiContext and WikiPage
---
 .../org/apache/wiki/attachment/AttachmentManager.java   |  5 ++---
 .../wiki/attachment/DefaultAttachmentManager.java       |  5 ++---
 .../wiki/attachment/DynamicAttachmentProvider.java      |  4 ++--
 .../java/org/apache/wiki/auth/AuthorizationManager.java | 10 +++++-----
 .../apache/wiki/auth/DefaultAuthorizationManager.java   |  2 +-
 .../org/apache/wiki/auth/authorize/GroupManager.java    |  8 ++++----
 .../org/apache/wiki/content/DefaultPageRenamer.java     | 17 ++++++++---------
 .../main/java/org/apache/wiki/content/PageRenamer.java  |  4 ++--
 .../src/main/java/org/apache/wiki/ui/PageCommand.java   | 12 ++++++------
 9 files changed, 32 insertions(+), 35 deletions(-)

diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
index 0b91e5b..c22b695 100644
--- 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
+++ 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
@@ -20,7 +20,6 @@ package org.apache.wiki.attachment;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Page;
@@ -191,7 +190,7 @@ public interface AttachmentManager {
      *  @throws ProviderException If the backend fails due to some reason
      *  @throws IOException If the stream cannot be opened
      */
-    InputStream getAttachmentStream( WikiContext ctx, Attachment att ) throws 
ProviderException, IOException;
+    InputStream getAttachmentStream( Context ctx, Attachment att ) throws 
ProviderException, IOException;
 
     /**
      *  Stores a dynamic attachment.  Unlike storeAttachment(), this just 
stores the attachment in the memory.
@@ -199,7 +198,7 @@ public interface AttachmentManager {
      *  @param ctx A WikiContext
      *  @param att An attachment to store
      */
-    void storeDynamicAttachment( WikiContext ctx, DynamicAttachment att );
+    void storeDynamicAttachment( Context ctx, DynamicAttachment att );
 
     /**
      *  Finds a DynamicAttachment.  Normally, you should just use {@link 
#getAttachmentInfo(String)} , since that will find also
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
index 6642227..654adc8 100644
--- 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
+++ 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
@@ -22,7 +22,6 @@ import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Context;
@@ -242,7 +241,7 @@ public class DefaultAttachmentManager implements 
AttachmentManager {
 
     /** {@inheritDoc} */
     @Override
-    public InputStream getAttachmentStream( final WikiContext ctx, final 
Attachment att ) throws ProviderException, IOException {
+    public InputStream getAttachmentStream( final Context ctx, final 
Attachment att ) throws ProviderException, IOException {
         if( m_provider == null ) {
             return null;
         }
@@ -256,7 +255,7 @@ public class DefaultAttachmentManager implements 
AttachmentManager {
 
     /** {@inheritDoc} */
     @Override
-    public void storeDynamicAttachment( final WikiContext ctx, final 
DynamicAttachment att ) {
+    public void storeDynamicAttachment( final Context ctx, final 
DynamicAttachment att ) {
         m_dynamicAttachments.put( new Element( att.getName(), att ) );
     }
 
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
index e891bb6..e555f24 100644
--- 
a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
+++ 
b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.attachment;
 
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.exceptions.ProviderException;
 
 import java.io.IOException;
@@ -45,6 +45,6 @@ public interface DynamicAttachmentProvider {
      *  @throws ProviderException If something goes wrong internally
      *  @throws IOException If something goes wrong when reading the data
      */
-    InputStream getAttachmentData( WikiContext context, Attachment att ) 
throws ProviderException, IOException;
+    InputStream getAttachmentData( Context context, Attachment att ) throws 
ProviderException, IOException;
 
 }
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index 40cb14f..a0c1e80 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -166,7 +166,7 @@ public interface AuthorizationManager {
     boolean hasRoleOrPrincipal( Session session, Principal principal );
 
     /**
-     * Checks whether the current user has access to the wiki context, by 
obtaining the required Permission ({@link WikiContext#requiredPermission()})
+     * Checks whether the current user has access to the wiki context, by 
obtaining the required Permission ({@link Context#requiredPermission()})
      * and delegating the access check to {@link #checkPermission(Session, 
Permission)}. If the user is allowed, this method returns
      * <code>true</code>; <code>false</code> otherwise. If access is allowed, 
the wiki context will be added to the request as an attribute
      * with the key name {@link 
org.apache.wiki.api.core.Context#ATTR_CONTEXT}. Note that this method will 
automatically redirect the user to
@@ -177,13 +177,13 @@ public interface AuthorizationManager {
      * @return the result of the access check
      * @throws IOException In case something goes wrong
      */
-    default boolean hasAccess( final WikiContext context, final 
HttpServletResponse response ) throws IOException {
+    default boolean hasAccess( final Context context, final 
HttpServletResponse response ) throws IOException {
         return hasAccess( context, response, true );
     }
 
     /**
      * Checks whether the current user has access to the wiki context (and
-     * optionally redirects if not), by obtaining the required Permission 
({@link WikiContext#requiredPermission()})
+     * optionally redirects if not), by obtaining the required Permission 
({@link Context#requiredPermission()})
      * and delegating the access check to {@link #checkPermission(Session, 
Permission)}.
      * If the user is allowed, this method returns <code>true</code>;
      * <code>false</code> otherwise. Also, the wiki context will be added to 
the request as attribute
@@ -195,7 +195,7 @@ public interface AuthorizationManager {
      * @return the result of the access check
      * @throws IOException If something goes wrong
      */
-    boolean hasAccess( final WikiContext context, final HttpServletResponse 
response, final boolean redirect ) throws IOException;
+    boolean hasAccess( final Context context, final HttpServletResponse 
response, final boolean redirect ) throws IOException;
 
     /**
      * Initializes AuthorizationManager with an engine and set of properties. 
Expects to find property 'jspwiki.authorizer' with a valid
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
index edb6a5a..5ca590a 100644
--- 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
+++ 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
@@ -199,7 +199,7 @@ public class DefaultAuthorizationManager implements 
AuthorizationManager {
 
     /** {@inheritDoc} */
     @Override
-    public boolean hasAccess( final WikiContext context, final 
HttpServletResponse response, final boolean redirect ) throws IOException {
+    public boolean hasAccess( final Context context, final HttpServletResponse 
response, final boolean redirect ) throws IOException {
         final boolean allowed = checkPermission( context.getWikiSession(), 
context.requiredPermission() );
         final ResourceBundle rb = Preferences.getBundle( context, 
InternationalizationManager.CORE_BUNDLE );
 
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index ce8b856..f6986b3 100644
--- 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.auth.authorize;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.Authorizer;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -115,7 +115,7 @@ public interface GroupManager extends Authorizer, 
WikiEventListener {
      * @throws WikiSecurityException if the group name isn't allowed, or if 
<code>create</code> is <code>false</code>
      *                               and the Group does not exist
      */
-    default Group parseGroup( final WikiContext context, final boolean create 
) throws WikiSecurityException {
+    default Group parseGroup( final Context context, final boolean create ) 
throws WikiSecurityException {
         // Extract parameters
         final HttpServletRequest request = context.getHttpRequest();
         final String name = request.getParameter( "group" );
@@ -185,7 +185,7 @@ public interface GroupManager extends Authorizer, 
WikiEventListener {
      * @param context the current wiki context
      * @param group the supplied Group
      */
-    default void validateGroup( final WikiContext context, final Group group ) 
{
+    default void validateGroup( final Context context, final Group group ) {
         final InputValidator validator = new InputValidator( MESSAGES_KEY, 
context );
 
         // Name cannot be null or one of the restricted names
@@ -210,7 +210,7 @@ public interface GroupManager extends Authorizer, 
WikiEventListener {
      * @throws WikiSecurityException if <code>session</code> is 
<code>null</code> or the Group name is illegal
      * @see Group#RESTRICTED_GROUPNAMES
      */
-    default void checkGroupName( final WikiContext context, final String name 
) throws WikiSecurityException {
+    default void checkGroupName( final Context context, final String name ) 
throws WikiSecurityException {
         // TODO: groups cannot have the same name as a user
 
         // Name cannot be null
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java 
b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index 04db620..9d64ecc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -20,9 +20,8 @@ package org.apache.wiki.content;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.exceptions.ProviderException;
@@ -67,7 +66,7 @@ public class DefaultPageRenamer implements PageRenamer {
      *  @throws WikiException If the page cannot be renamed.
      */
     @Override
-    public String renamePage( final WikiContext context, final String 
renameFrom, final String renameTo, final boolean changeReferrers ) throws 
WikiException {
+    public String renamePage( final Context context, final String renameFrom, 
final String renameTo, final boolean changeReferrers ) throws WikiException {
         //  Sanity checks first
         if( renameFrom == null || renameFrom.length() == 0 ) {
             throw new WikiException( "From name may not be null or empty" );
@@ -113,7 +112,7 @@ public class DefaultPageRenamer implements PageRenamer {
         if( toPage == null ) {
             throw new InternalWikiException( "Rename seems to have failed for 
some strange reason - please check logs!" );
         }
-        toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " 
+ toPage.getName() );
+        toPage.setAttribute( Page.CHANGENOTE, fromPage.getName() + " ==> " + 
toPage.getName() );
         toPage.setAuthor( context.getCurrentUser().getName() );
         engine.getManager( PageManager.class ).putPageText( toPage, 
engine.getManager( PageManager.class ).getPureText( toPage ) );
 
@@ -165,7 +164,7 @@ public class DefaultPageRenamer implements PageRenamer {
      *  @param fromPage The old page
      *  @param toPage The new page
      */
-    private void updateReferrers( final WikiContext context, final Page 
fromPage, final Page toPage, final Set< String > referrers ) {
+    private void updateReferrers( final Context context, final Page fromPage, 
final Page toPage, final Set< String > referrers ) {
         if( referrers.isEmpty() ) { // No referrers
             return;
         }
@@ -188,7 +187,7 @@ public class DefaultPageRenamer implements PageRenamer {
             }
             
             if( !sourceText.equals( newText ) ) {
-                p.setAttribute( WikiPage.CHANGENOTE, fromPage.getName()+" ==> 
"+toPage.getName() );
+                p.setAttribute( Page.CHANGENOTE, fromPage.getName()+" ==> 
"+toPage.getName() );
                 p.setAuthor( context.getCurrentUser().getName() );
          
                 try {
@@ -227,7 +226,7 @@ public class DefaultPageRenamer implements PageRenamer {
     /**
      *  Replaces camelcase links.
      */
-    private String replaceCCReferrerString( final WikiContext context, final 
String sourceText, final String from, final String to ) {
+    private String replaceCCReferrerString( final Context context, final 
String sourceText, final String from, final String to ) {
         final StringBuilder sb = new StringBuilder( sourceText.length()+32 );
         final Pattern linkPattern = Pattern.compile( 
"\\p{Lu}+\\p{Ll}+\\p{Lu}+[\\p{L}\\p{Digit}]*" );
         final Matcher matcher = linkPattern.matcher( sourceText );
@@ -253,7 +252,7 @@ public class DefaultPageRenamer implements PageRenamer {
         return sb.toString();
     }
 
-    private String replaceReferrerString( final WikiContext context, final 
String sourceText, final String from, final String to ) {
+    private String replaceReferrerString( final Context context, final String 
sourceText, final String from, final String to ) {
         final StringBuilder sb = new StringBuilder( sourceText.length()+32 );
         
         // This monstrosity just looks for a JSPWiki link pattern.  But it is 
pretty cool for a regexp, isn't it?  If you can
@@ -313,7 +312,7 @@ public class DefaultPageRenamer implements PageRenamer {
     /**
      *  This method does a correct replacement of a single link, taking into 
account anchors and attachments.
      */
-    private String replaceSingleLink( final WikiContext context, final String 
original, final String from, final String newlink ) {
+    private String replaceSingleLink( final Context context, final String 
original, final String from, final String newlink ) {
         final int hash = original.indexOf( '#' );
         final int slash = original.indexOf( '/' );
         String realLink = original;
diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java 
b/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
index c62b478..3f2c006 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.content;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.exceptions.WikiException;
 
 /**
@@ -39,7 +39,7 @@ public interface PageRenamer {
      *  @return The final new name (in case it had to be modified)
      *  @throws WikiException If the page cannot be renamed.
      */
-    String renamePage( WikiContext context, String renameFrom, String 
renameTo, boolean changeReferrers ) throws WikiException;
+    String renamePage( Context context, String renameFrom, String renameTo, 
boolean changeReferrers ) throws WikiException;
 
     /**
      * Fires a WikiPageRenameEvent to all registered listeners. Currently not 
used internally by JSPWiki itself, but you can use it for
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java 
b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
index b8fcca7..11ce763 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Command;
+import org.apache.wiki.api.core.Page;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 
@@ -92,7 +92,7 @@ public final class PageCommand extends AbstractCommand {
     private PageCommand( final String requestContext,
                          final String urlPattern,
                          final String contentTemplate,
-                         final WikiPage target,
+                         final Page target,
                          final String action ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = action;
@@ -112,10 +112,10 @@ public final class PageCommand extends AbstractCommand {
      * @throws IllegalArgumentException if the target is not of the correct 
type
      */
     public Command targetedCommand( final Object target ) {
-        if( !( target instanceof WikiPage ) ) {
-            throw new IllegalArgumentException( "Target must non-null and of 
type WikiPage." );
+        if( !( target instanceof Page ) ) {
+            throw new IllegalArgumentException( "Target must non-null and of 
type Page." );
         }
-        return new PageCommand( getRequestContext(), getURLPattern(), 
getContentTemplate(), ( WikiPage )target, m_action );
+        return new PageCommand( getRequestContext(), getURLPattern(), 
getContentTemplate(), ( Page )target, m_action );
     }
 
     /**
@@ -126,7 +126,7 @@ public final class PageCommand extends AbstractCommand {
         if( target == null ) {
             return getJSPFriendlyName();
         }
-        return ( ( WikiPage )target ).getName();
+        return ( ( Page )target ).getName();
     }
 
     /**

Reply via email to