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/02/24 16:53:16 UTC
[jspwiki] 34/38: JSPWIKI-120: propagate WikiContext#getEngine() now
returns Engine instead of WikiEngine (11)
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 de7c7705375ae346c61c4fa0e7c5c9c39e3225f1
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Feb 24 17:18:13 2020 +0100
JSPWIKI-120: propagate WikiContext#getEngine() now returns Engine instead of WikiEngine (11)
---
.../main/java/org/apache/wiki/auth/Authorizer.java | 44 ++--
.../apache/wiki/auth/acl/DefaultAclManager.java | 14 +-
.../login/CookieAuthenticationLoginModule.java | 292 +++++++++------------
.../wiki/variables/DefaultVariableManager.java | 17 +-
.../org/apache/wiki/xmlrpc/AbstractRPCHandler.java | 13 +-
.../org/apache/wiki/xmlrpc/MetaWeblogHandler.java | 37 +--
.../java/org/apache/wiki/xmlrpc/RPCHandler.java | 34 +--
.../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java | 34 +--
8 files changed, 219 insertions(+), 266 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
index 13f82c2..efdc60e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
@@ -26,41 +26,30 @@ import java.util.Properties;
/**
- * Interface for service providers of authorization information. After a user
- * successfully logs in, the
- * {@link org.apache.wiki.auth.AuthenticationManager} consults the configured
- * Authorizer to determine which additional
- * {@link org.apache.wiki.auth.authorize.Role} principals should be added to
- * the user's WikiSession. To determine which roles should be injected, the
- * Authorizer is queried for the roles it knows about by calling
- * {@link org.apache.wiki.auth.Authorizer#getRoles()}. Then, each role
- * returned by the Authorizer is tested by calling
- * {@link org.apache.wiki.auth.Authorizer#isUserInRole(WikiSession, Principal)}.
- * If this check fails, and the Authorizer is of type WebAuthorizer,
- * AuthenticationManager checks the role again by calling
+ * Interface for service providers of authorization information. After a user successfully logs in, the
+ * {@link org.apache.wiki.auth.AuthenticationManager} consults the configured Authorizer to determine which additional
+ * {@link org.apache.wiki.auth.authorize.Role} principals should be added to the user's WikiSession. To determine which roles should be
+ * injected, the Authorizer is queried for the roles it knows about by calling {@link org.apache.wiki.auth.Authorizer#getRoles()}. Then,
+ * each role returned by the Authorizer is tested by calling {@link org.apache.wiki.auth.Authorizer#isUserInRole(WikiSession, Principal)}.
+ * If this check fails, and the Authorizer is of type WebAuthorizer, AuthenticationManager checks the role again by calling
* {@link org.apache.wiki.auth.authorize.WebAuthorizer#isUserInRole(javax.servlet.http.HttpServletRequest, Principal)}).
- * Any roles that pass the test are injected into the Subject by firing
- * appropriate authentication events.
+ * Any roles that pass the test are injected into the Subject by firing appropriate authentication events.
*
* @since 2.3
*/
public interface Authorizer {
/**
- * Returns an array of role Principals this Authorizer knows about. This
- * method will always return an array; an implementing class may choose to
- * return an zero-length array if it has no ability to identify the roles
- * under its control.
+ * Returns an array of role Principals this Authorizer knows about. This method will always return an array; an implementing class may
+ * choose to return an zero-length array if it has no ability to identify the roles under its control.
*
* @return an array of Principals representing the roles
*/
Principal[] getRoles();
/**
- * Looks up and returns a role Principal matching a given String. If a
- * matching role cannot be found, this method returns <code>null</code>.
- * Note that it may not always be feasible for an Authorizer implementation
- * to return a role Principal.
+ * Looks up and returns a role Principal matching a given String. If a matching role cannot be found, this method returns
+ * <code>null</code>. Note that it may not always be feasible for an Authorizer implementation to return a role Principal.
*
* @param role the name of the role to retrieve
* @return the role Principal
@@ -77,16 +66,13 @@ public interface Authorizer {
void initialize( Engine engine, Properties props ) throws WikiSecurityException;
/**
- * Determines whether the Subject associated with a WikiSession is in a
- * particular role. This method takes two parameters: the WikiSession
- * containing the subject and the desired role ( which may be a Role or a
- * Group). If either parameter is <code>null</code>, this method must
- * return <code>false</code>.
+ * Determines whether the Subject associated with a WikiSession is in a particular role. This method takes two parameters: the
+ * WikiSession containing the subject and the desired role ( which may be a Role or a Group). If either parameter is <code>null</code>,
+ * this method must return <code>false</code>.
*
* @param session the current WikiSession
* @param role the role to check
- * @return <code>true</code> if the user is considered to be in the role,
- * <code>false</code> otherwise
+ * @return <code>true</code> if the user is considered to be in the role, <code>false</code> otherwise
*/
boolean isUserInRole( WikiSession session, Principal role );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
index 7b0ca22..29b593f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
@@ -80,7 +80,7 @@ public class DefaultAclManager implements AclManager {
* @param props the initialization properties
* @see org.apache.wiki.auth.acl.AclManager#initialize(org.apache.wiki.WikiEngine, java.util.Properties)
*/
- public void initialize( final WikiEngine engine, final Properties props ) {
+ @Override public void initialize( final WikiEngine engine, final Properties props ) {
m_auth = engine.getAuthorizationManager();
m_engine = engine;
}
@@ -96,7 +96,7 @@ public class DefaultAclManager implements AclManager {
* @throws WikiSecurityException if the ruleLine was faulty somehow.
* @since 2.1.121
*/
- public Acl parseAcl( final WikiPage page, final String ruleLine ) throws WikiSecurityException {
+ @Override public Acl parseAcl( final WikiPage page, final String ruleLine ) throws WikiSecurityException {
Acl acl = page.getAcl();
if (acl == null) {
acl = new AclImpl();
@@ -150,7 +150,7 @@ public class DefaultAclManager implements AclManager {
* @return the Acl representing permissions for the page
* @since 2.2.121
*/
- public Acl getPermissions( final WikiPage page ) {
+ @Override public Acl getPermissions( final WikiPage page ) {
// Does the page already have cached ACLs?
Acl acl = page.getAcl();
log.debug( "page=" + page.getName() + "\n" + acl );
@@ -158,7 +158,7 @@ public class DefaultAclManager implements AclManager {
if( acl == null ) {
// If null, try the parent.
if( page instanceof Attachment ) {
- final WikiPage parent = m_engine.getPageManager().getPage( ( ( Attachment ) page ).getParentName() );
+ final WikiPage parent = m_engine.getManager( PageManager.class ).getPage( ( ( Attachment ) page ).getParentName() );
acl = getPermissions(parent);
} else {
// Or, try parsing the page
@@ -188,8 +188,8 @@ public class DefaultAclManager implements AclManager {
* @throws WikiSecurityException of the Acl cannot be set
* @since 2.5
*/
- public void setPermissions( final WikiPage page, final Acl acl ) throws WikiSecurityException {
- final PageManager pageManager = m_engine.getPageManager();
+ @Override public void setPermissions( final WikiPage page, final Acl acl ) throws WikiSecurityException {
+ final PageManager pageManager = m_engine.getManager( PageManager.class );
// Forcibly expire any page locks
final PageLock lock = pageManager.getCurrentLock( page );
@@ -198,7 +198,7 @@ public class DefaultAclManager implements AclManager {
}
// Remove all of the existing ACLs.
- final String pageText = m_engine.getPageManager().getPureText( page );
+ final String pageText = m_engine.getManager( PageManager.class ).getPureText( page );
final Matcher matcher = DefaultAclManager.ACL_PATTERN.matcher( pageText );
final String cleansedText = matcher.replaceAll("" );
final String newText = DefaultAclManager.printAcl( page.getAcl() ) + cleansedText;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
index f4615a0..c5facb7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
@@ -20,6 +20,7 @@ package org.apache.wiki.auth.login;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
import org.apache.wiki.auth.WikiPrincipal;
import org.apache.wiki.util.FileUtil;
import org.apache.wiki.util.HttpUtil;
@@ -45,125 +46,109 @@ import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
+
/**
- * Logs in an user based on a cookie stored in the user's computer. The cookie
- * information is stored in the <code>jspwiki.workDir</code>, under the directory
- * {@value #COOKIE_DIR}. For security purposes it is a very, very good idea
- * to prevent access to this directory by everyone except the web server process;
- * otherwise people having read access to this directory may be able to spoof
- * other users.
- * <p>
- * The cookie directory is scrubbed of old entries at regular intervals.
- * <p>
- * This module must be used with a CallbackHandler (such as
- * {@link WebContainerCallbackHandler}) that supports the following Callback
- * types:
- * </p>
- * <ol>
- * <li>{@link HttpRequestCallback}- supplies the cookie, which should contain
- * an unique id for fetching the UID.</li>
- * <li>{@link WikiEngineCallback} - allows access to the WikiEngine itself.
- * </ol>
- * <p>
- * After authentication, a generic WikiPrincipal based on the username will be
- * created and associated with the Subject.
- * </p>
- * @see javax.security.auth.spi.LoginModule#commit()
- * @see CookieAssertionLoginModule
- * @since 2.5.62
+ * Logs in an user based on a cookie stored in the user's computer. The cookie
+ * information is stored in the <code>jspwiki.workDir</code>, under the directory
+ * {@value #COOKIE_DIR}. For security purposes it is a very, very good idea
+ * to prevent access to this directory by everyone except the web server process;
+ * otherwise people having read access to this directory may be able to spoof
+ * other users.
+ * <p>
+ * The cookie directory is scrubbed of old entries at regular intervals.
+ * <p>
+ * This module must be used with a CallbackHandler (such as
+ * {@link WebContainerCallbackHandler}) that supports the following Callback
+ * types:
+ * </p>
+ * <ol>
+ * <li>{@link HttpRequestCallback}- supplies the cookie, which should contain
+ * an unique id for fetching the UID.</li>
+ * <li>{@link WikiEngineCallback} - allows access to the WikiEngine itself.
+ * </ol>
+ * <p>
+ * After authentication, a generic WikiPrincipal based on the username will be
+ * created and associated with the Subject.
+ * </p>
+ * @see javax.security.auth.spi.LoginModule#commit()
+ * @see CookieAssertionLoginModule
+ * @since 2.5.62
*/
-public class CookieAuthenticationLoginModule extends AbstractLoginModule
-{
+public class CookieAuthenticationLoginModule extends AbstractLoginModule {
private static final Logger log = Logger.getLogger( CookieAuthenticationLoginModule.class );
private static final String LOGIN_COOKIE_NAME = "JSPWikiUID";
/** The directory name under which the cookies are stored. The value is {@value}. */
- protected static final String COOKIE_DIR = "logincookies";
+ protected static final String COOKIE_DIR = "logincookies";
/**
- * User property for setting how long the cookie is stored on the user's computer.
- * The value is {@value}. The default expiry time is 14 days.
+ * User property for setting how long the cookie is stored on the user's computer.
+ * The value is {@value}. The default expiry time is 14 days.
*/
- public static final String PROP_LOGIN_EXPIRY_DAYS = "jspwiki.cookieAuthentication.expiry";
+ public static final String PROP_LOGIN_EXPIRY_DAYS = "jspwiki.cookieAuthentication.expiry";
/**
- * Built-in value for storing the cookie.
+ * Built-in value for storing the cookie.
*/
- private static final int DEFAULT_EXPIRY_DAYS = 14;
+ private static final int DEFAULT_EXPIRY_DAYS = 14;
- private static long c_lastScrubTime = 0L;
+ private static long c_lastScrubTime = 0L;
- /** Describes how often we scrub the cookieDir directory.
+ /**
+ * Describes how often we scrub the cookieDir directory.
*/
- private static final long SCRUB_PERIOD = 60*60*1000L; // In milliseconds
+ private static final long SCRUB_PERIOD = 60 * 60 * 1000L; // In milliseconds
/**
* @see javax.security.auth.spi.LoginModule#login()
- *
* {@inheritDoc}
*/
- public boolean login() throws LoginException
- {
+ @Override public boolean login() throws LoginException {
// Otherwise, let's go and look for the cookie!
- HttpRequestCallback hcb = new HttpRequestCallback();
- WikiEngineCallback wcb = new WikiEngineCallback();
+ final HttpRequestCallback hcb = new HttpRequestCallback();
+ final WikiEngineCallback wcb = new WikiEngineCallback();
- Callback[] callbacks = new Callback[]
- { hcb, wcb };
+ final Callback[] callbacks = new Callback[] { hcb, wcb };
- try
- {
+ try {
m_handler.handle( callbacks );
- HttpServletRequest request = hcb.getRequest();
- String uid = getLoginCookie( request );
+ final HttpServletRequest request = hcb.getRequest();
+ final String uid = getLoginCookie( request );
- if( uid != null )
- {
- WikiEngine engine = wcb.getEngine();
- File cookieFile = getCookieFile(engine, uid);
+ if( uid != null ) {
+ final Engine engine = wcb.getEngine();
+ final File cookieFile = getCookieFile( engine, uid );
- if( cookieFile != null && cookieFile.exists() && cookieFile.canRead() )
- {
+ if( cookieFile != null && cookieFile.exists() && cookieFile.canRead() ) {
- try
- (
- Reader in = new BufferedReader( new InputStreamReader( new FileInputStream( cookieFile ), "UTF-8" ) );
- )
- {
- String username = FileUtil.readContents( in );
+ try( final Reader in = new BufferedReader( new InputStreamReader( new FileInputStream( cookieFile ), "UTF-8" ) ) ) {
+ final String username = FileUtil.readContents( in );
- if ( log.isDebugEnabled() )
- {
+ if( log.isDebugEnabled() ) {
log.debug( "Logged in cookie authenticated name=" + username );
}
// If login succeeds, commit these principals/roles
- m_principals.add( new WikiPrincipal( username, WikiPrincipal.LOGIN_NAME ) );
+ m_principals.add( new WikiPrincipal( username, WikiPrincipal.LOGIN_NAME ) );
//
// Tag the file so that we know that it has been accessed recently.
//
return cookieFile.setLastModified( System.currentTimeMillis() );
- }
- catch( IOException e )
- {
+ } catch( final IOException e ) {
return false;
}
}
}
- }
- catch( IOException e )
- {
- String message = "IO exception; disallowing login.";
+ } catch( final IOException e ) {
+ final String message = "IO exception; disallowing login.";
log.error( message, e );
throw new LoginException( message );
- }
- catch( UnsupportedCallbackException e )
- {
- String message = "Unable to handle callback; disallowing login.";
+ } catch( final UnsupportedCallbackException e ) {
+ final String message = "Unable to handle callback; disallowing login.";
log.error( message, e );
throw new LoginException( message );
}
@@ -172,43 +157,36 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule
}
/**
- * Attempts to locate the cookie file.
- * @param engine WikiEngine
- * @param uid An unique ID fetched from the user cookie
- * @return A File handle, or null, if there was a problem.
+ * Attempts to locate the cookie file.
+ *
+ * @param engine WikiEngine
+ * @param uid An unique ID fetched from the user cookie
+ * @return A File handle, or null, if there was a problem.
*/
- private static File getCookieFile(WikiEngine engine, String uid)
- {
- File cookieDir = new File( engine.getWorkDir(), COOKIE_DIR );
+ private static File getCookieFile( final Engine engine, final String uid ) {
+ final File cookieDir = new File( engine.getWorkDir(), COOKIE_DIR );
- if( !cookieDir.exists() )
- {
+ if( !cookieDir.exists() ) {
cookieDir.mkdirs();
}
- if( !cookieDir.canRead() )
- {
- log.error("Cannot read from cookie directory!"+cookieDir.getAbsolutePath());
+ if( !cookieDir.canRead() ) {
+ log.error( "Cannot read from cookie directory!" + cookieDir.getAbsolutePath() );
return null;
}
- if( !cookieDir.canWrite() )
- {
- log.error("Cannot write to cookie directory!"+cookieDir.getAbsolutePath());
+ if( !cookieDir.canWrite() ) {
+ log.error( "Cannot write to cookie directory!" + cookieDir.getAbsolutePath() );
return null;
}
//
// Scrub away old files
//
- long now = System.currentTimeMillis();
-
- if( now > (c_lastScrubTime+SCRUB_PERIOD ) )
- {
- scrub( TextUtil.getIntegerProperty( engine.getWikiProperties(),
- PROP_LOGIN_EXPIRY_DAYS,
- DEFAULT_EXPIRY_DAYS ),
- cookieDir );
+ final long now = System.currentTimeMillis();
+
+ if( now > ( c_lastScrubTime + SCRUB_PERIOD ) ) {
+ scrub( TextUtil.getIntegerProperty( engine.getWikiProperties(), PROP_LOGIN_EXPIRY_DAYS, DEFAULT_EXPIRY_DAYS ), cookieDir );
c_lastScrubTime = now;
}
@@ -219,23 +197,22 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule
}
/**
- * Extracts the login cookie UID from the servlet request.
+ * Extracts the login cookie UID from the servlet request.
*
- * @param request The HttpServletRequest
- * @return The UID value from the cookie, or null, if no such cookie exists.
+ * @param request The HttpServletRequest
+ * @return The UID value from the cookie, or null, if no such cookie exists.
*/
- private static String getLoginCookie(HttpServletRequest request)
- {
+ private static String getLoginCookie( final HttpServletRequest request ) {
return HttpUtil.retrieveCookieValue( request, LOGIN_COOKIE_NAME );
}
/**
- * Sets a login cookie based on properties set by the user. This method also
- * creates the cookie uid-username mapping in the work directory.
+ * Sets a login cookie based on properties set by the user. This method also
+ * creates the cookie uid-username mapping in the work directory.
*
- * @param engine The WikiEngine
- * @param response The HttpServletResponse
- * @param username The username for whom to create the cookie.
+ * @param engine The WikiEngine
+ * @param response The HttpServletResponse
+ * @param username The username for whom to create the cookie.
*/
public static void setLoginCookie( final WikiEngine engine, final HttpServletResponse response, final String username ) {
final UUID uid = UUID.randomUUID();
@@ -247,14 +224,11 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule
final File cf = getCookieFile( engine, uid.toString() );
if( cf != null ) {
// Write the cookie content to the cookie store file.
- try(
- final Writer out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(cf), StandardCharsets.UTF_8 ) )
- )
- {
- FileUtil.copyContents( new StringReader(username), out );
+ try( final Writer out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( cf ), StandardCharsets.UTF_8 ) ) ) {
+ FileUtil.copyContents( new StringReader( username ), out );
if( log.isDebugEnabled() ) {
- log.debug( "Created login cookie for user "+username+" for "+days+" days" );
+ log.debug( "Created login cookie for user " + username + " for " + days + " days" );
}
} catch( final IOException ex ) {
@@ -264,86 +238,70 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule
}
/**
- * Clears away the login cookie, and removes the uid-username mapping file as well.
+ * Clears away the login cookie, and removes the uid-username mapping file as well.
*
- * @param engine WikiEngine
- * @param request Servlet request
- * @param response Servlet response
+ * @param engine WikiEngine
+ * @param request Servlet request
+ * @param response Servlet response
*/
- public static void clearLoginCookie( WikiEngine engine, HttpServletRequest request, HttpServletResponse response )
- {
- Cookie userId = getLoginCookie( "" );
+ public static void clearLoginCookie( final WikiEngine engine, final HttpServletRequest request, final HttpServletResponse response ) {
+ final Cookie userId = getLoginCookie( "" );
userId.setMaxAge( 0 );
response.addCookie( userId );
- String uid = getLoginCookie( request );
+ final String uid = getLoginCookie( request );
- if( uid != null )
- {
- File cf = getCookieFile( engine, uid );
+ if( uid != null ) {
+ final File cf = getCookieFile( engine, uid );
- if( cf != null )
- {
- if( !cf.delete() )
- {
- log.debug("Error deleting cookie login "+uid);
+ if( cf != null ) {
+ if( !cf.delete() ) {
+ log.debug( "Error deleting cookie login " + uid );
}
}
}
}
/**
- * Helper function to get secure LOGIN cookie
+ * Helper function to get secure LOGIN cookie
*
- * @param: value of the cookie
+ * @param: value of the cookie
*/
- private static Cookie getLoginCookie( String value )
- {
- Cookie c = new Cookie( LOGIN_COOKIE_NAME, value );
- c.setHttpOnly(true); //no browser access
- c.setSecure(true); //only access via encrypted https allowed
+ private static Cookie getLoginCookie( final String value ) {
+ final Cookie c = new Cookie( LOGIN_COOKIE_NAME, value );
+ c.setHttpOnly( true ); //no browser access
+ c.setSecure( true ); //only access via encrypted https allowed
return c;
}
-
/**
- * Goes through the cookie directory and removes any obsolete files.
- * The scrubbing takes place one day after the cookie was supposed to expire.
- * However, if the user has logged in during the expiry period, the expiry is
- * reset, and the cookie file left here.
+ * Goes through the cookie directory and removes any obsolete files.
+ * The scrubbing takes place one day after the cookie was supposed to expire.
+ * However, if the user has logged in during the expiry period, the expiry is
+ * reset, and the cookie file left here.
*
- * @param days
- * @param cookieDir
+ * @param days
+ * @param cookieDir
*/
- private static synchronized void scrub( int days, File cookieDir )
- {
- log.debug("Scrubbing cookieDir...");
-
- File[] files = cookieDir.listFiles();
-
- long obsoleteDateLimit = System.currentTimeMillis() - ((long)days+1) * 24 * 60 * 60 * 1000L;
-
- int deleteCount = 0;
-
- for( int i = 0; i < files.length; i++ )
- {
- File f = files[i];
-
- long lastModified = f.lastModified();
-
- if( lastModified < obsoleteDateLimit )
- {
- if( f.delete() )
- {
+ private static synchronized void scrub( final int days, final File cookieDir ) {
+ log.debug( "Scrubbing cookieDir..." );
+ final File[] files = cookieDir.listFiles();
+ final long obsoleteDateLimit = System.currentTimeMillis() - ( ( long )days + 1 ) * 24 * 60 * 60 * 1000L;
+ int deleteCount = 0;
+
+ for( int i = 0; i < files.length; i++ ) {
+ final File f = files[ i ];
+ final long lastModified = f.lastModified();
+ if( lastModified < obsoleteDateLimit ) {
+ if( f.delete() ) {
deleteCount++;
- }
- else
- {
- log.debug("Error deleting cookie login with index "+i);
+ } else {
+ log.debug( "Error deleting cookie login with index " + i );
}
}
}
- log.debug("Removed "+deleteCount+" obsolete cookie logins");
+ log.debug( "Removed " + deleteCount + " obsolete cookie logins" );
}
+
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index c998d1d..7525759 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -25,10 +25,13 @@ import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiProvider;
import org.apache.wiki.WikiSession;
import org.apache.wiki.api.engine.FilterManager;
+import org.apache.wiki.api.engine.PluginManager;
import org.apache.wiki.api.exceptions.NoSuchVariableException;
import org.apache.wiki.api.filters.PageFilter;
+import org.apache.wiki.attachment.AttachmentManager;
import org.apache.wiki.i18n.InternationalizationManager;
import org.apache.wiki.modules.InternalModule;
+import org.apache.wiki.pages.PageManager;
import org.apache.wiki.preferences.Preferences;
import javax.servlet.http.HttpServletRequest;
@@ -298,24 +301,24 @@ public class DefaultVariableManager implements VariableManager {
}
public String getTotalpages() {
- return Integer.toString( m_context.getEngine().getPageManager().getTotalPageCount() );
+ return Integer.toString( m_context.getEngine().getManager( PageManager.class ).getTotalPageCount() );
}
public String getPageprovider() {
- return m_context.getEngine().getPageManager().getCurrentProvider();
+ return m_context.getEngine().getManager( PageManager.class ).getCurrentProvider();
}
public String getPageproviderdescription() {
- return m_context.getEngine().getPageManager().getProviderDescription();
+ return m_context.getEngine().getManager( PageManager.class ).getProviderDescription();
}
public String getAttachmentprovider() {
- final WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
+ final WikiProvider p = m_context.getEngine().getManager( AttachmentManager.class ).getCurrentProvider();
return (p != null) ? p.getClass().getName() : "-";
}
public String getAttachmentproviderdescription() {
- final WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
+ final WikiProvider p = m_context.getEngine().getManager( AttachmentManager.class ).getCurrentProvider();
return (p != null) ? p.getProviderInfo() : "-";
}
@@ -347,7 +350,7 @@ public class DefaultVariableManager implements VariableManager {
}
public String getPluginpath() {
- final String s = m_context.getEngine().getPluginManager().getPluginSearchPath();
+ final String s = m_context.getEngine().getManager( PluginManager.class ).getPluginSearchPath();
return ( s == null ) ? "-" : s;
}
@@ -386,7 +389,7 @@ public class DefaultVariableManager implements VariableManager {
}
public String getPagefilters() {
- final FilterManager fm = m_context.getEngine().getFilterManager();
+ final FilterManager fm = m_context.getEngine().getManager( FilterManager.class );
final List< PageFilter > filters = fm.getFilterList();
final StringBuilder sb = new StringBuilder();
for( final PageFilter pf : filters ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
index 3b1406b..bd7cbc1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
@@ -19,11 +19,12 @@
package org.apache.wiki.xmlrpc;
import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.permissions.PagePermission;
import org.apache.wiki.auth.permissions.WikiPermission;
+import org.apache.wiki.pages.PageManager;
import org.apache.xmlrpc.AuthenticationFailed;
import java.security.Permission;
@@ -54,13 +55,13 @@ public abstract class AbstractRPCHandler implements WikiRPCHandler {
/** This is an inlined image. */
public static final String LINK_INLINE = "inline";
- protected WikiEngine m_engine;
+ protected Engine m_engine;
protected WikiContext m_context;
/** This is the currently implemented JSPWiki XML-RPC code revision. */
public static final int RPC_VERSION = 1;
- public void initialize( final WikiContext context ) {
+ @Override public void initialize( final WikiContext context ) {
m_context = context;
m_engine = context.getEngine();
}
@@ -69,7 +70,7 @@ public abstract class AbstractRPCHandler implements WikiRPCHandler {
public Vector getRecentChanges( final Date since ) {
checkPermission( PagePermission.VIEW );
- final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+ final Set< WikiPage > pages = m_engine.getManager( PageManager.class ).getRecentChanges();
final Vector< Hashtable< ?, ? > > result = new Vector<>();
// Transform UTC into local time.
@@ -78,7 +79,7 @@ public abstract class AbstractRPCHandler implements WikiRPCHandler {
cal.add( Calendar.MILLISECOND, cal.get( Calendar.ZONE_OFFSET ) +
(cal.getTimeZone().inDaylightTime( since ) ? cal.get( Calendar.DST_OFFSET ) : 0 ) );
- for( WikiPage page : pages ) {
+ for( final WikiPage page : pages ) {
if( page.getLastModified().after( cal.getTime() ) ) {
result.add( encodeWikiPage( page ) );
}
@@ -94,7 +95,7 @@ public abstract class AbstractRPCHandler implements WikiRPCHandler {
* @param perm the Permission to check
*/
protected void checkPermission( final Permission perm ) {
- final AuthorizationManager mgr = m_engine.getAuthorizationManager();
+ final AuthorizationManager mgr = m_engine.getManager( AuthorizationManager.class );
if( mgr.checkPermission( m_context.getWikiSession(), perm ) ) {
return;
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 c40db82..6145a94 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
@@ -20,14 +20,15 @@ package org.apache.wiki.xmlrpc;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
import org.apache.wiki.attachment.Attachment;
import org.apache.wiki.attachment.AttachmentManager;
import org.apache.wiki.auth.AuthenticationManager;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.WikiSecurityException;
import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.pages.PageManager;
import org.apache.wiki.pages.PageTimeComparator;
import org.apache.wiki.plugin.WeblogEntryPlugin;
import org.apache.wiki.plugin.WeblogPlugin;
@@ -60,7 +61,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
/**
* {@inheritDoc}
*/
- public void initialize( final WikiContext context )
+ @Override public void initialize( final WikiContext context )
{
m_context = context;
}
@@ -79,8 +80,8 @@ public class MetaWeblogHandler implements WikiRPCHandler {
final String password,
final String permission ) throws XmlRpcException {
try {
- final AuthenticationManager amm = m_context.getEngine().getAuthenticationManager();
- final AuthorizationManager mgr = m_context.getEngine().getAuthorizationManager();
+ final AuthenticationManager amm = m_context.getEngine().getManager( AuthenticationManager.class );
+ final AuthorizationManager mgr = m_context.getEngine().getManager( AuthorizationManager.class );
if( amm.login( m_context.getWikiSession(), m_context.getHttpRequest(), username, password ) ) {
if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ) ) {
@@ -104,7 +105,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
* @return An empty hashtable.
*/
public Hashtable< Object, Object > getCategories( final String blogid, final String username, final String password ) throws XmlRpcException {
- final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
+ final WikiPage page = m_context.getEngine().getManager( PageManager.class ).getPage( blogid );
checkPermissions( page, username, password, "view" );
return new Hashtable<>();
}
@@ -120,7 +121,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
* @return A metaWeblog entry struct.
*/
private Hashtable< String,Object > makeEntry( final WikiPage page ) {
- final WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
+ final WikiPage firstVersion = m_context.getEngine().getManager( PageManager.class ).getPage( page.getName(), 1 );
final Hashtable< String, Object > ht = new Hashtable<>();
ht.put( "dateCreated", firstVersion.getLastModified() );
ht.put( "link", getURL(page.getName() ) );
@@ -128,7 +129,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
ht.put( "postid", page.getName() );
ht.put( "userid", page.getAuthor() );
- final String pageText = m_context.getEngine().getPageManager().getText(page.getName());
+ final String pageText = m_context.getEngine().getManager( PageManager.class ).getText(page.getName());
final int firstLine = pageText.indexOf('\n');
String title = "";
@@ -165,7 +166,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
public Hashtable getRecentPosts( final String blogid, final String username, final String password, final int numberOfPosts ) throws XmlRpcException {
final Hashtable<String, Hashtable<String, Object>> result = new Hashtable<>();
log.info( "metaWeblog.getRecentPosts() called");
- final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
+ final WikiPage page = m_context.getEngine().getManager( PageManager.class ).getPage( blogid );
checkPermissions( page, username, password, "view" );
final WeblogPlugin plugin = new WeblogPlugin();
@@ -198,8 +199,8 @@ public class MetaWeblogHandler implements WikiRPCHandler {
final Hashtable< String, Object > content,
final boolean publish ) throws XmlRpcException {
log.info("metaWeblog.newPost() called");
- final WikiEngine engine = m_context.getEngine();
- final WikiPage page = engine.getPageManager().getPage( blogid );
+ final Engine engine = m_context.getEngine();
+ final WikiPage page = engine.getManager( PageManager.class ).getPage( blogid );
checkPermissions( page, username, password, "createPages" );
try {
@@ -216,7 +217,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
log.debug("Writing entry: "+text);
- engine.getPageManager().saveText( context, text.toString() );
+ engine.getManager( PageManager.class ).saveText( context, text.toString() );
} catch( final Exception e ) {
log.error("Failed to create weblog entry",e);
throw new XmlRpcException( 0, "Failed to create weblog entry: "+e.getMessage() );
@@ -241,18 +242,18 @@ public class MetaWeblogHandler implements WikiRPCHandler {
final String username,
final String password,
final Hashtable< String, Object > content ) throws XmlRpcException {
- final WikiEngine engine = m_context.getEngine();
+ final Engine engine = m_context.getEngine();
final String url;
log.info( "metaWeblog.newMediaObject() called" );
- final WikiPage page = engine.getPageManager().getPage( blogid );
+ final WikiPage page = engine.getManager( PageManager.class ).getPage( blogid );
checkPermissions( page, username, password, "upload" );
final String name = (String) content.get( "name" );
final byte[] data = (byte[]) content.get( "bits" );
- final AttachmentManager attmgr = engine.getAttachmentManager();
+ final AttachmentManager attmgr = engine.getManager( AttachmentManager.class );
try {
final Attachment att = new Attachment( engine, blogid, name );
@@ -280,11 +281,11 @@ public class MetaWeblogHandler implements WikiRPCHandler {
final String password,
final Hashtable< String,Object > content,
final boolean publish ) throws XmlRpcException {
- final WikiEngine engine = m_context.getEngine();
+ final Engine engine = m_context.getEngine();
log.info("metaWeblog.editPost("+postid+") called");
// FIXME: Is postid correct? Should we determine it from the page name?
- final WikiPage page = engine.getPageManager().getPage( postid );
+ final WikiPage page = engine.getManager( PageManager.class ).getPage( postid );
checkPermissions( page, username, password, "edit" );
try {
@@ -300,7 +301,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
log.debug("Updating entry: "+text);
- engine.getPageManager().saveText( context, text.toString() );
+ engine.getManager( PageManager.class ).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() );
@@ -315,7 +316,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
*/
Hashtable< String, Object > getPost( final String postid, final String username, final String password ) throws XmlRpcException {
final String wikiname = "FIXME";
- final WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
+ final WikiPage page = m_context.getEngine().getManager( PageManager.class ).getPage( wikiname );
checkPermissions( page, username, password, "view" );
return makeEntry( page );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
index e2a8f40..7bf5423 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
@@ -25,6 +25,8 @@ import org.apache.wiki.WikiPage;
import org.apache.wiki.attachment.Attachment;
import org.apache.wiki.auth.permissions.PagePermission;
import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
import org.apache.wiki.util.TextUtil;
import org.apache.xmlrpc.XmlRpcException;
@@ -77,7 +79,7 @@ public class RPCHandler extends AbstractRPCHandler {
public Vector< String > getAllPages() {
checkPermission( PagePermission.VIEW );
- final Collection< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+ final Collection< WikiPage > pages = m_engine.getManager( PageManager.class ).getRecentChanges();
final Vector< String > result = new Vector<>();
for( final WikiPage p : pages ) {
@@ -128,7 +130,7 @@ public class RPCHandler extends AbstractRPCHandler {
@Override
public Vector< Hashtable< String, Object > > getRecentChanges( Date since ) {
checkPermission( PagePermission.VIEW );
- final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+ final Set< WikiPage > pages = m_engine.getManager( PageManager.class ).getRecentChanges();
final Vector< Hashtable< String, Object > > result = new Vector<>();
final Calendar cal = Calendar.getInstance();
@@ -162,11 +164,11 @@ public class RPCHandler extends AbstractRPCHandler {
private String parsePageCheckCondition( String pagename ) throws XmlRpcException {
pagename = fromRPCString( pagename );
- if( !m_engine.getPageManager().wikiPageExists(pagename) ) {
+ if( !m_engine.getManager( PageManager.class ).wikiPageExists(pagename) ) {
throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
}
- final WikiPage p = m_engine.getPageManager().getPage( pagename );
+ final WikiPage p = m_engine.getManager( PageManager.class ).getPage( pagename );
checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
@@ -175,50 +177,50 @@ public class RPCHandler extends AbstractRPCHandler {
public Hashtable getPageInfo( String pagename ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return encodeWikiPage( m_engine.getPageManager().getPage(pagename) );
+ return encodeWikiPage( m_engine.getManager( PageManager.class ).getPage(pagename) );
}
- public Hashtable getPageInfoVersion( String pagename, int version ) throws XmlRpcException {
+ public Hashtable getPageInfoVersion( String pagename, final int version ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
+ return encodeWikiPage( m_engine.getManager( PageManager.class ).getPage( pagename, version ) );
}
public byte[] getPage( final String pagename ) throws XmlRpcException {
- final String text = m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), -1 );
+ final String text = m_engine.getManager( PageManager.class ).getPureText( parsePageCheckCondition( pagename ), -1 );
return toRPCBase64( text );
}
public byte[] getPageVersion( String pagename, final int version ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return toRPCBase64( m_engine.getPageManager().getPureText( pagename, version ) );
+ return toRPCBase64( m_engine.getManager( PageManager.class ).getPureText( pagename, version ) );
}
public byte[] getPageHTML( String pagename ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return toRPCBase64( m_engine.getRenderingManager().getHTML( pagename ) );
+ return toRPCBase64( m_engine.getManager( RenderingManager.class ).getHTML( pagename ) );
}
- public byte[] getPageHTMLVersion( String pagename, int version ) throws XmlRpcException {
+ public byte[] getPageHTMLVersion( String pagename, final int version ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return toRPCBase64( m_engine.getRenderingManager().getHTML( pagename, version ) );
+ return toRPCBase64( m_engine.getManager( RenderingManager.class ).getHTML( pagename, version ) );
}
public Vector< Hashtable< String, String > > listLinks( String pagename ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- final WikiPage page = m_engine.getPageManager().getPage( pagename );
- final String pagedata = m_engine.getPageManager().getPureText( page );
+ final WikiPage page = m_engine.getManager( PageManager.class ).getPage( pagename );
+ final String pagedata = m_engine.getManager( PageManager.class ).getPureText( page );
final LinkCollector localCollector = new LinkCollector();
final LinkCollector extCollector = new LinkCollector();
final LinkCollector attCollector = new LinkCollector();
final WikiContext context = new WikiContext( m_engine, page );
- m_engine.getRenderingManager().textToHTML( context, pagedata, localCollector, extCollector, attCollector );
+ m_engine.getManager( RenderingManager.class ).textToHTML( context, pagedata, localCollector, extCollector, attCollector );
final Vector< Hashtable< String, String > > result = new Vector<>();
@@ -240,7 +242,7 @@ public class RPCHandler extends AbstractRPCHandler {
// FIXME: The current link collector interface is not very good, since it causes this.
//
- if( m_engine.getPageManager().wikiPageExists( link ) ) {
+ if( m_engine.getManager( PageManager.class ).wikiPageExists( link ) ) {
ht.put( "href", context.getURL( WikiContext.VIEW, link ) );
} else {
ht.put( "href", context.getURL( WikiContext.EDIT, link ) );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
index 40f143f..a184ec2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
@@ -24,6 +24,8 @@ import org.apache.wiki.WikiPage;
import org.apache.wiki.attachment.Attachment;
import org.apache.wiki.auth.permissions.PagePermission;
import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
import org.apache.xmlrpc.XmlRpcException;
import java.util.Calendar;
@@ -49,7 +51,7 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
public Vector< String > getAllPages() {
checkPermission( PagePermission.VIEW );
- final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+ final Set< WikiPage > pages = m_engine.getManager( PageManager.class ).getRecentChanges();
final Vector< String > result = new Vector<>();
for( final WikiPage p : pages ) {
@@ -64,7 +66,7 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
/**
* Encodes a single wiki page info into a Hashtable.
*/
- protected Hashtable<String, Object> encodeWikiPage( final WikiPage page ) {
+ @Override protected Hashtable<String, Object> encodeWikiPage( final WikiPage page ) {
final Hashtable<String, Object> ht = new Hashtable<>();
ht.put( "name", page.getName() );
@@ -90,10 +92,10 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
return ht;
}
- public Vector< Hashtable< String, Object > > getRecentChanges( Date since ) {
+ @Override public Vector< Hashtable< String, Object > > getRecentChanges( Date since ) {
checkPermission( PagePermission.VIEW );
- final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+ final Set< WikiPage > pages = m_engine.getManager( PageManager.class ).getRecentChanges();
final Vector< Hashtable< String, Object > > result = new Vector<>();
final Calendar cal = Calendar.getInstance();
@@ -125,54 +127,54 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
* @throws XmlRpcException, if there is something wrong with the page.
*/
private String parsePageCheckCondition( final String pagename ) throws XmlRpcException {
- if( !m_engine.getPageManager().wikiPageExists(pagename) ) {
+ if( !m_engine.getManager( PageManager.class ).wikiPageExists(pagename) ) {
throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
}
- final WikiPage p = m_engine.getPageManager().getPage( pagename );
+ final WikiPage p = m_engine.getManager( PageManager.class ).getPage( pagename );
checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
return pagename;
}
public Hashtable<String, Object> getPageInfo( final String pagename ) throws XmlRpcException {
- return encodeWikiPage( m_engine.getPageManager().getPage( parsePageCheckCondition( pagename ) ) );
+ return encodeWikiPage( m_engine.getManager( PageManager.class ).getPage( parsePageCheckCondition( pagename ) ) );
}
public Hashtable<String, Object> getPageInfoVersion( String pagename, final int version ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
+ return encodeWikiPage( m_engine.getManager( PageManager.class ).getPage( pagename, version ) );
}
public String getPage( final String pagename ) throws XmlRpcException {
- return m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), -1 );
+ return m_engine.getManager( PageManager.class ).getPureText( parsePageCheckCondition( pagename ), -1 );
}
public String getPageVersion( final String pagename, final int version ) throws XmlRpcException {
- return m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), version );
+ return m_engine.getManager( PageManager.class ).getPureText( parsePageCheckCondition( pagename ), version );
}
public String getPageHTML( final String pagename ) throws XmlRpcException {
- return m_engine.getRenderingManager().getHTML( parsePageCheckCondition( pagename ) );
+ return m_engine.getManager( RenderingManager.class ).getHTML( parsePageCheckCondition( pagename ) );
}
public String getPageHTMLVersion( final String pagename, final int version ) throws XmlRpcException {
- return m_engine.getRenderingManager().getHTML( parsePageCheckCondition( pagename ), version );
+ return m_engine.getManager( RenderingManager.class ).getHTML( parsePageCheckCondition( pagename ), version );
}
public Vector< Hashtable< String, String > > listLinks( String pagename ) throws XmlRpcException {
pagename = parsePageCheckCondition( pagename );
- final WikiPage page = m_engine.getPageManager().getPage( pagename );
- final String pagedata = m_engine.getPageManager().getPureText( page );
+ final WikiPage page = m_engine.getManager( PageManager.class ).getPage( pagename );
+ final String pagedata = m_engine.getManager( PageManager.class ).getPureText( page );
final LinkCollector localCollector = new LinkCollector();
final LinkCollector extCollector = new LinkCollector();
final LinkCollector attCollector = new LinkCollector();
final WikiContext context = new WikiContext( m_engine, page );
- m_engine.getRenderingManager().textToHTML( context, pagedata, localCollector, extCollector, attCollector );
+ m_engine.getManager( RenderingManager.class ).textToHTML( context, pagedata, localCollector, extCollector, attCollector );
final Vector< Hashtable< String, String > > result = new Vector<>();
@@ -186,7 +188,7 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
ht.put( "page", link );
ht.put( "type", LINK_LOCAL );
- if( m_engine.getPageManager().wikiPageExists( link ) ) {
+ if( m_engine.getManager( PageManager.class ).wikiPageExists( link ) ) {
ht.put( "href", context.getViewURL( link ) );
} else {
ht.put( "href", context.getURL( WikiContext.EDIT, link ) );