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/17 18:13:49 UTC
[jspwiki] branch master updated (63da657 -> cf23ad6)
This is an automated email from the ASF dual-hosted git repository.
juanpablo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git.
from 63da657 fixed russian translation
new 959f9d1 remove direct reference to WikiEngine on WikiEngineEvent, in order to break package cycle between o.a.wiki and o.a.w.event. To obtain the WikiEngine reference from the event just use getSrc()
new 214c1a9 small refactor to AttachmentManagerTest
new d4827ab remove unused imports
new 6985a59 extract new PluginElement interface from PluginContent in order to break a package/class cycle between PluginContent and ParserStagePlugin
new dc44642 make WeblogPlugin use new PluginElement on ParserStage#executeParser
new 0d178df JSPWIKI-120: finally, extract Engine interface from WikiEngine
new 42d8c74 apply format & fixes suggested by intellij
new 4ace95f apply format suggested by intellij
new db287dc make SamplePlugin use new PluginElement on ParserStage#executeParser
new ba49292 update dependencies: tomcat to 8.5.51, selenide to 5.7.0 and flexmark to 0.50.50
new cf23ad6 2.11.0-M7-git-08
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
ChangeLog.md | 19 +
.../src/main/java/org/apache/wiki/Release.java | 2 +-
.../src/main/java/org/apache/wiki/WikiEngine.java | 393 +++++++--------------
.../main/java/org/apache/wiki/api/core/Engine.java | 312 ++++++++++++++++
.../apache/wiki/api/{engine => core}/package.html | 4 +-
.../apache/wiki/api/plugin/ParserStagePlugin.java | 12 +-
.../org/apache/wiki/api/plugin/PluginElement.java | 86 +++++
.../org/apache/wiki/attachment/Attachment.java | 51 +--
.../java/org/apache/wiki/auth/SessionMonitor.java | 25 +-
.../org/apache/wiki/event/WikiEngineEvent.java | 15 -
.../java/org/apache/wiki/parser/PluginContent.java | 69 ++--
.../java/org/apache/wiki/plugin/WeblogPlugin.java | 8 +-
.../org/apache/wiki/ajax/WikiAjaxServletTest.java | 3 -
.../wiki/attachment/AttachmentManagerTest.java | 39 +-
.../java/org/apache/wiki/plugin/SamplePlugin.java | 8 +-
pom.xml | 6 +-
16 files changed, 637 insertions(+), 415 deletions(-)
create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
copy jspwiki-main/src/main/java/org/apache/wiki/api/{engine => core}/package.html (89%)
create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/api/plugin/PluginElement.java
[jspwiki] 06/11: JSPWIKI-120: finally,
extract Engine interface from WikiEngine
Posted by ju...@apache.org.
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 0d178df16c4cfae7030d1d884d9b943e06f07520
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 23:51:39 2020 +0100
JSPWIKI-120: finally, extract Engine interface from WikiEngine
also first step towards public api - JSPWIKI-303
---
.../src/main/java/org/apache/wiki/WikiEngine.java | 393 +++++++--------------
.../main/java/org/apache/wiki/api/core/Engine.java | 312 ++++++++++++++++
.../java/org/apache/wiki/api/core/package.html | 36 ++
3 files changed, 481 insertions(+), 260 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 29079b6..5b9d1c5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -21,6 +21,7 @@ package org.apache.wiki;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
+import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.engine.AdminBeanManager;
import org.apache.wiki.api.engine.FilterManager;
import org.apache.wiki.api.engine.PluginManager;
@@ -91,7 +92,7 @@ import java.util.concurrent.ConcurrentHashMap;
* <p>
* There's basically only a single WikiEngine for each web application, and you should always get it using the WikiEngine.getInstance() method.
*/
-public class WikiEngine {
+public class WikiEngine implements Engine {
private static final String ATTR_WIKIENGINE = "org.apache.wiki.WikiEngine";
private static final Logger log = Logger.getLogger( WikiEngine.class );
@@ -103,59 +104,9 @@ public class WikiEngine {
/** Stores properties. */
private Properties m_properties;
- /** The default inlining pattern. Currently "*.png" */
- public static final String DEFAULT_INLINEPATTERN = "*.png";
-
- /** The name used for the default template. The value is {@value}. */
- public static final String DEFAULT_TEMPLATE_NAME = "default";
-
- /** Property for application name */
- public static final String PROP_APPNAME = "jspwiki.applicationName";
-
- /** This property defines the inline image pattern. It's current value is {@value} */
- public static final String PROP_INLINEIMAGEPTRN = "jspwiki.translatorReader.inlinePattern";
-
- /** Property start for any interwiki reference. */
- public static final String PROP_INTERWIKIREF = "jspwiki.interWikiRef.";
-
- /** If true, then the user name will be stored with the page data.*/
- public static final String PROP_STOREUSERNAME= "jspwiki.storeUserName";
-
- /** Define the used encoding. Currently supported are ISO-8859-1 and UTF-8 */
- public static final String PROP_ENCODING = "jspwiki.encoding";
-
- /** Do not use encoding in WikiJSPFilter, default is false for most servers.
- Double negative, cause for most servers you don't need the property */
- public static final String PROP_NO_FILTER_ENCODING = "jspwiki.nofilterencoding";
-
- /** Property name for where the jspwiki work directory should be.
- If not specified, reverts to ${java.tmpdir}. */
- public static final String PROP_WORKDIR = "jspwiki.workDir";
-
- /** The name of the cookie that gets stored to the user browser. */
- public static final String PREFS_COOKIE_NAME = "JSPWikiUserProfile";
-
- /** Property name for the "match english plurals" -hack. */
- public static final String PROP_MATCHPLURALS = "jspwiki.translatorReader.matchEnglishPlurals";
-
- /** Property name for the template that is used. */
- public static final String PROP_TEMPLATEDIR = "jspwiki.templateDir";
-
- /** Property name for the default front page. */
- public static final String PROP_FRONTPAGE = "jspwiki.frontPage";
-
- /** Property name for setting the url generator instance */
- public static final String PROP_URLCONSTRUCTOR = "jspwiki.urlConstructor";
-
/** Does the work in renaming pages. */
private PageRenamer m_pageRenamer = null;
- /** The name of the property containing the ACLManager implementing class. The value is {@value}. */
- public static final String PROP_ACL_MANAGER_IMPL = "jspwiki.aclManager";
-
- /** If this property is set to false, we don't allow the creation of empty pages */
- public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES = "jspwiki.allowCreationOfEmptyPages";
-
/** Should the user info be saved with the page data as well? */
private boolean m_saveUserInfo = true;
@@ -254,7 +205,10 @@ public class WikiEngine {
private AdminBeanManager m_adminBeanManager;
/** Stores wikiengine attributes. */
- private Map<String,Object> m_attributes = new ConcurrentHashMap<>();
+ private Map< String, Object > m_attributes = new ConcurrentHashMap<>();
+
+ /** Stores WikiEngine's associated managers. */
+ protected Map< Class< ? >, Object > managers = new ConcurrentHashMap<>();
/**
* Gets a WikiEngine related to this servlet. Since this method is only called from JSP pages (and JspInit()) to be specific,
@@ -316,13 +270,10 @@ public class WikiEngine {
log.error( "ERROR: Failed to create a Wiki engine, stacktrace follows " , e);
throw new InternalWikiException( "No wiki engine, check logs." , e);
}
-
}
-
return engine;
}
-
/**
* Instantiate the WikiEngine using a given set of properties. Use this constructor for testing purposes only.
*
@@ -475,6 +426,20 @@ public class WikiEngine {
// Initialize the authentication, authorization, user and acl managers
m_authenticationManager.initialize( this, props );
m_authorizationManager.initialize( this, props );
+
+ managers.put( CommandResolver.class, m_commandResolver );
+ managers.put( URLConstructor.class, m_urlConstructor );
+ managers.put( PageManager.class, m_pageManager );
+ managers.put( PluginManager.class, m_pluginManager );
+ managers.put( DifferenceManager.class, m_differenceManager );
+ managers.put( AttachmentManager.class, m_attachmentManager );
+ managers.put( VariableManager.class, m_variableManager );
+ managers.put( RenderingManager.class, m_renderingManager );
+ managers.put( SearchManager.class, m_searchManager );
+ managers.put( AuthenticationManager.class, m_authenticationManager );
+ managers.put( AuthorizationManager.class, m_authorizationManager );
+ managers.put( UserManager.class, m_userManager );
+
m_userManager.initialize( this, props );
m_groupManager.initialize( this, props );
m_aclManager = getAclManager();
@@ -491,6 +456,16 @@ public class WikiEngine {
// listeners, it must be called lastly, so that all object references in the engine are availabe to the initialize() method
m_filterManager = ClassUtil.getMappedObject(FilterManager.class.getName(), this, props );
+ managers.put( GroupManager.class, m_groupManager );
+ managers.put( EditorManager.class, m_editorManager );
+ managers.put( ProgressManager.class, m_progressManager );
+ managers.put( AclManager.class, m_aclManager );
+ managers.put( WorkflowManager.class, m_workflowMgr );
+ managers.put( TasksManager.class, m_tasksManager );
+ managers.put( InternationalizationManager.class, m_internationalizationManager );
+ managers.put( TemplateManager.class, m_templateManager );
+ managers.put( FilterManager.class, m_filterManager );
+
m_adminBeanManager = ClassUtil.getMappedObject(AdminBeanManager.class.getName(),this);
// RenderingManager depends on FilterManager events.
@@ -501,8 +476,14 @@ public class WikiEngine {
initReferenceManager();
// Hook the different manager routines into the system.
- m_filterManager.addPageFilter(m_referenceManager, -1001 );
- m_filterManager.addPageFilter(m_searchManager, -1002 );
+ m_filterManager.addPageFilter( m_referenceManager, -1001 );
+ m_filterManager.addPageFilter( m_searchManager, -1002 );
+
+ m_pageRenamer = ClassUtil.getMappedObject( PageRenamer.class.getName(), this, props );
+
+ managers.put( ReferenceManager.class, m_referenceManager );
+ managers.put( AdminBeanManager.class, m_adminBeanManager );
+ managers.put( PageRenamer.class, m_pageRenamer );
} catch( final RuntimeException e ) {
// RuntimeExceptions may occur here, even if they shouldn't.
log.fatal( "Failed to start managers.", e );
@@ -522,21 +503,18 @@ public class WikiEngine {
throw new WikiException( "Failed to start. Caused by: " + e.getMessage() + "; please check log files for better information.", e );
}
- //
// Initialize the good-to-have-but-not-fatal modules.
- //
try {
if( TextUtil.getBooleanProperty( props, RSSGenerator.PROP_GENERATE_RSS,false ) ) {
m_rssGenerator = ClassUtil.getMappedObject( RSSGenerator.class.getName(), this, props );
}
-
- m_pageRenamer = ClassUtil.getMappedObject( PageRenamer.class.getName(), this, props );
} catch( final Exception e ) {
log.error( "Unable to start RSS generator - JSPWiki will still work, but there will be no RSS feed.", e );
}
// Start the RSS generator & generator thread
if( m_rssGenerator != null ) {
+ managers.put( RSSGenerator.class, m_rssGenerator );
m_rssFile = TextUtil.getStringProperty( props, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
final File rssFile;
if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames:
@@ -555,11 +533,14 @@ public class WikiEngine {
m_isConfigured = true;
}
- /**
- * check if the WikiEngine has been configured.
- *
- * @return {@code true} if it has, {@code false} otherwise.
- */
+ /** {@inheritDoc} */
+ @Override
+ public < T > T getManager( final Class< T > manager ) {
+ return ( T )managers.get( manager );
+ }
+
+ /** {@inheritDoc} */
+ @Override
public boolean isConfigured() {
return m_isConfigured;
}
@@ -600,7 +581,7 @@ public class WikiEngine {
*/
public void initReferenceManager() throws WikiException {
try {
- final ArrayList<WikiPage> pages = new ArrayList<>();
+ final ArrayList< WikiPage > pages = new ArrayList<>();
pages.addAll( m_pageManager.getAllPages() );
pages.addAll( m_attachmentManager.getAllAttachments() );
@@ -617,32 +598,20 @@ public class WikiEngine {
}
}
- /**
- * Returns the set of properties that the WikiEngine was initialized with. Note that this method returns a direct reference, so it's
- * possible to manipulate the properties. However, this is not advised unless you really know what you're doing.
- *
- * @return The wiki properties
- */
+ /** {@inheritDoc} */
+ @Override
public Properties getWikiProperties() {
return m_properties;
}
- /**
- * Returns the JSPWiki working directory set with "jspwiki.workDir".
- *
- * @since 2.1.100
- * @return The working directory.
- */
+ /** {@inheritDoc} */
+ @Override
public String getWorkDir() {
return m_workDir;
}
- /**
- * Returns the current template directory.
- *
- * @since 1.9.20
- * @return The template directory as initialized by the engine.
- */
+ /** {@inheritDoc} */
+ @Override
public String getTemplateDir() {
return m_templateDir;
}
@@ -653,35 +622,23 @@ public class WikiEngine {
* @return A TemplateManager instance.
*/
public TemplateManager getTemplateManager() {
- return m_templateManager;
+ return getManager( TemplateManager.class );
}
- /**
- * Returns the moment when this engine was started.
- *
- * @since 2.0.15.
- * @return The start time of this wiki.
- */
+ /** {@inheritDoc} */
+ @Override
public Date getStartTime() {
return ( Date )m_startTime.clone();
}
- /**
- * Returns the base URL, telling where this Wiki actually lives.
- *
- * @since 1.6.1
- * @return The Base URL.
- */
+ /** {@inheritDoc} */
+ @Override
public String getBaseURL() {
return m_servletContext.getContextPath();
}
- /**
- * Returns the URL of the global RSS file. May be null, if the RSS file generation is not operational.
- *
- * @since 1.7.10
- * @return The global RSS url
- */
+ /** {@inheritDoc} */
+ @Override
public String getGlobalRSSURL() {
if( m_rssGenerator != null && m_rssGenerator.isEnabled() ) {
return getBaseURL() + "/" + m_rssFile;
@@ -690,24 +647,14 @@ public class WikiEngine {
return null;
}
- /**
- * Returns an URL to some other Wiki that we know.
- *
- * @param wikiName The name of the other wiki.
- * @return null, if no such reference was found.
- */
+ /** {@inheritDoc} */
+ @Override
public String getInterWikiURL( final String wikiName ) {
return TextUtil.getStringProperty( m_properties,PROP_INTERWIKIREF + wikiName,null );
}
- /**
- * Returns an URL if a WikiContext is not available.
- *
- * @param context The WikiContext (VIEW, EDIT, etc...)
- * @param pageName Name of the page, as usual
- * @param params List of parameters. May be null, if no parameters.
- * @return An URL (absolute or relative).
- */
+ /** {@inheritDoc} */
+ @Override
public String getURL( final String context, String pageName, final String params ) {
if( pageName == null ) {
pageName = getFrontPage();
@@ -715,34 +662,22 @@ public class WikiEngine {
return m_urlConstructor.makeURL( context, pageName, params );
}
- /**
- * Returns the default front page, if no page is used.
- *
- * @return The front page name.
- */
+ /** {@inheritDoc} */
+ @Override
public String getFrontPage() {
return m_frontPage;
}
- /**
- * Returns the ServletContext that this particular WikiEngine was
- * initialized with. <B>It may return null</B>, if the WikiEngine is not
- * running inside a servlet container!
- *
- * @since 1.7.10
- * @return ServletContext of the WikiEngine, or null.
- */
+ /** {@inheritDoc} */
+ @Override
public ServletContext getServletContext() {
return m_servletContext;
}
- /**
- * Returns a collection of all supported InterWiki links.
- *
- * @return A Collection of Strings.
- */
+ /** {@inheritDoc} */
+ @Override
public Collection< String > getAllInterWikiLinks() {
- final ArrayList< String > list = new ArrayList< >();
+ final ArrayList< String > list = new ArrayList<>();
for( final Enumeration< ? > i = m_properties.propertyNames(); i.hasMoreElements(); ) {
final String prop = ( String )i.nextElement();
if( prop.startsWith( PROP_INTERWIKIREF ) ) {
@@ -753,11 +688,8 @@ public class WikiEngine {
return list;
}
- /**
- * Returns a collection of all image types that get inlined.
- *
- * @return A Collection of Strings with a regexp pattern.
- */
+ /** {@inheritDoc} */
+ @Override
public Collection< String > getAllInlinedImagePatterns() {
final ArrayList< String > ptrnlist = new ArrayList<>();
for( final Enumeration< ? > e = m_properties.propertyNames(); e.hasMoreElements(); ) {
@@ -774,54 +706,28 @@ public class WikiEngine {
return ptrnlist;
}
- /**
- * <p>If the page is a special page, then returns a direct URL to that page. Otherwise returns <code>null</code>.
- * This method delegates requests to {@link org.apache.wiki.ui.CommandResolver#getSpecialPageReference(String)}.
- * </p>
- * <p>
- * Special pages are defined in jspwiki.properties using the jspwiki.specialPage setting. They're typically used to give Wiki page
- * names to e.g. custom JSP pages.
- * </p>
- *
- * @param original The page to check
- * @return A reference to the page, or null, if there's no special page.
- */
- public String getSpecialPageReference( final String original )
- {
+ /** {@inheritDoc} */
+ @Override
+ public String getSpecialPageReference( final String original ) {
return m_commandResolver.getSpecialPageReference( original );
}
- /**
- * Returns the name of the application.
- *
- * @return A string describing the name of this application.
- */
+ /** {@inheritDoc} */
+ @Override
// FIXME: Should use servlet context as a default instead of a constant.
public String getApplicationName() {
final String appName = TextUtil.getStringProperty( m_properties, PROP_APPNAME, Release.APPNAME );
return TextUtil.cleanString( appName, TextUtil.PUNCTUATION_CHARS_ALLOWED );
}
- /**
- * Returns the correct page name, or null, if no such page can be found. Aliases are considered. This method simply delegates to
- * {@link org.apache.wiki.ui.CommandResolver#getFinalPageName(String)}.
- * @since 2.0
- * @param page Page name.
- * @return The rewritten page name, or null, if the page does not exist.
- * @throws ProviderException If something goes wrong in the backend.
- */
+ /** {@inheritDoc} */
+ @Override
public String getFinalPageName( final String page ) throws ProviderException {
return m_commandResolver.getFinalPageName( page );
}
- /**
- * Turns a WikiName into something that can be called through using an URL.
- *
- * @since 1.4.1
- * @param pagename A name. Can be actually any string.
- * @return A properly encoded name.
- * @see #decodeName(String)
- */
+ /** {@inheritDoc} */
+ @Override
public String encodeName( final String pagename ) {
try {
return URLEncoder.encode( pagename, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
@@ -830,13 +736,8 @@ public class WikiEngine {
}
}
- /**
- * Decodes a URL-encoded request back to regular life. This properly heeds the encoding as defined in the settings file.
- *
- * @param pagerequest The URL-encoded string to decode
- * @return A decoded string.
- * @see #encodeName(String)
- */
+ /** {@inheritDoc} */
+ @Override
public String decodeName( final String pagerequest ) {
try {
return URLDecoder.decode( pagerequest, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
@@ -845,12 +746,8 @@ public class WikiEngine {
}
}
- /**
- * Returns the IANA name of the character set encoding we're supposed to be using right now.
- *
- * @since 1.5.3
- * @return The content encoding (either UTF-8 or ISO-8859-1).
- */
+ /** {@inheritDoc} */
+ @Override
public Charset getContentEncoding() {
if( m_useUTF8 ) {
return StandardCharsets.UTF_8;
@@ -865,16 +762,18 @@ public class WikiEngine {
* @return the task queue
*/
public WorkflowManager getWorkflowManager() {
- return m_workflowMgr;
+ return getManager( WorkflowManager.class );
}
/**
- * Protected method that signals that the WikiEngine will be shut down by the servlet container. It is called by
- * {@link WikiServlet#destroy()}. When this method is called, it fires a "shutdown" WikiEngineEvent to all registered listeners.
+ * {@inheritDoc}
+ * <p>It is called by {@link WikiServlet#destroy()}. When this method is called, it fires a "shutdown" WikiEngineEvent to
+ * all registered listeners.
*/
- protected void shutdown() {
+ @Override
+ public void shutdown() {
fireEvent( WikiEngineEvent.SHUTDOWN );
- m_filterManager.destroy();
+ getManager( FilterManager.class ).destroy();
}
/**
@@ -884,7 +783,7 @@ public class WikiEngine {
* @since 1.6.1
*/
public ReferenceManager getReferenceManager() {
- return m_referenceManager;
+ return getManager( ReferenceManager.class );
}
/**
@@ -894,7 +793,7 @@ public class WikiEngine {
* @return A RenderingManager object.
*/
public RenderingManager getRenderingManager() {
- return m_renderingManager;
+ return getManager( RenderingManager.class );
}
/**
@@ -904,7 +803,7 @@ public class WikiEngine {
* @return The current PluginManager instance
*/
public PluginManager getPluginManager() {
- return m_pluginManager;
+ return getManager( PluginManager.class );
}
/**
@@ -913,7 +812,7 @@ public class WikiEngine {
* @return The current VariableManager.
*/
public VariableManager getVariableManager() {
- return m_variableManager;
+ return getManager( VariableManager.class );
}
/**
@@ -922,7 +821,7 @@ public class WikiEngine {
* @return The current PageManager instance.
*/
public PageManager getPageManager() {
- return m_pageManager;
+ return getManager( PageManager.class );
}
/**
@@ -931,7 +830,7 @@ public class WikiEngine {
* @return the resolver
*/
public CommandResolver getCommandResolver() {
- return m_commandResolver;
+ return getManager( CommandResolver.class );
}
/**
@@ -941,7 +840,7 @@ public class WikiEngine {
* @return The current AttachmentManager instance
*/
public AttachmentManager getAttachmentManager() {
- return m_attachmentManager;
+ return getManager( AttachmentManager.class );
}
/**
@@ -950,7 +849,7 @@ public class WikiEngine {
* @return The current AuthorizationManager instance
*/
public AuthorizationManager getAuthorizationManager() {
- return m_authorizationManager;
+ return getManager( AuthorizationManager.class );
}
/**
@@ -959,7 +858,7 @@ public class WikiEngine {
* @return The current AuthenticationManager instance.
*/
public AuthenticationManager getAuthenticationManager() {
- return m_authenticationManager;
+ return getManager( AuthenticationManager.class );
}
/**
@@ -969,7 +868,7 @@ public class WikiEngine {
* @return The current FilterManager instance
*/
public FilterManager getFilterManager() {
- return m_filterManager;
+ return getManager( FilterManager.class );
}
/**
@@ -979,7 +878,7 @@ public class WikiEngine {
* @return The current SearchManager instance
*/
public SearchManager getSearchManager() {
- return m_searchManager;
+ return getManager( SearchManager.class );
}
/**
@@ -989,15 +888,11 @@ public class WikiEngine {
* @since 2.6
*/
public ProgressManager getProgressManager() {
- return m_progressManager;
+ return getManager( ProgressManager.class );
}
- /**
- * Returns the root path. The root path is where the WikiEngine is located in the file system.
- *
- * @since 2.2
- * @return A path to where the Wiki is installed in the local filesystem.
- */
+ /** {@inheritDoc} */
+ @Override
public String getRootPath() {
return m_rootPath;
}
@@ -1007,7 +902,7 @@ public class WikiEngine {
* @return the URL constructor
*/
public URLConstructor getURLConstructor() {
- return m_urlConstructor;
+ return getManager( URLConstructor.class );
}
/**
@@ -1018,7 +913,7 @@ public class WikiEngine {
* @return the RSS generator
*/
public RSSGenerator getRSSGenerator() {
- return m_rssGenerator;
+ return getManager( RSSGenerator.class );
}
/**
@@ -1028,7 +923,7 @@ public class WikiEngine {
* @return The current PageRenamer instance.
*/
public PageRenamer getPageRenamer() {
- return m_pageRenamer;
+ return getManager( PageRenamer.class );
}
/**
@@ -1038,7 +933,7 @@ public class WikiEngine {
* @return The current UserManager instance.
*/
public UserManager getUserManager() {
- return m_userManager;
+ return getManager( UserManager.class );
}
/**
@@ -1047,7 +942,7 @@ public class WikiEngine {
* @return The current TasksManager instance.
*/
public TasksManager getTasksManager() {
- return m_tasksManager;
+ return getManager( TasksManager.class );
}
/**
@@ -1057,7 +952,7 @@ public class WikiEngine {
* @return The current GroupManager instance
*/
public GroupManager getGroupManager() {
- return m_groupManager;
+ return getManager( GroupManager.class );
}
/**
@@ -1067,7 +962,7 @@ public class WikiEngine {
* @since 2.6
*/
public AdminBeanManager getAdminBeanManager() {
- return m_adminBeanManager;
+ return getManager( AdminBeanManager.class );
}
/**
@@ -1099,7 +994,7 @@ public class WikiEngine {
* @return the difference manager
*/
public DifferenceManager getDifferenceManager() {
- return m_differenceManager;
+ return getManager( DifferenceManager.class );
}
/**
@@ -1108,7 +1003,7 @@ public class WikiEngine {
* @return The current EditorManager.
*/
public EditorManager getEditorManager() {
- return m_editorManager;
+ return getManager( EditorManager.class );
}
/**
@@ -1117,23 +1012,17 @@ public class WikiEngine {
* @return The current Intertan... Interante... Internatatializ... Whatever.
*/
public InternationalizationManager getInternationalizationManager() {
- return m_internationalizationManager;
+ return getManager( InternationalizationManager.class );
}
- /**
- * Registers a WikiEventListener with this instance.
- *
- * @param listener the event listener
- */
+ /** {@inheritDoc} */
+ @Override
public final synchronized void addWikiEventListener( final WikiEventListener listener ) {
WikiEventManager.addWikiEventListener( this, listener );
}
- /**
- * Un-registers a WikiEventListener with this instance.
- *
- * @param listener the event listener
- */
+ /** {@inheritDoc} */
+ @Override
public final synchronized void removeWikiEventListener( final WikiEventListener listener ) {
WikiEventManager.removeWikiEventListener( this, listener );
}
@@ -1159,44 +1048,28 @@ public class WikiEngine {
}
}
- /**
- * Adds an attribute to the engine for the duration of this engine. The value is not persisted.
- *
- * @since 2.4.91
- * @param key the attribute name
- * @param value the value
- */
+ /** {@inheritDoc} */
+ @Override
public void setAttribute( final String key, final Object value ) {
m_attributes.put( key, value );
}
- /**
- * Gets an attribute from the engine.
- *
- * @param key the attribute name
- * @return the value
- */
+ /** {@inheritDoc} */
+ @Override
@SuppressWarnings( "unchecked" )
public < T > T getAttribute( final String key ) {
return ( T )m_attributes.get( key );
}
- /**
- * Removes an attribute.
- *
- * @param key The key of the attribute to remove.
- * @return The previous attribute, if it existed.
- */
- public Object removeAttribute( final String key ) {
- return m_attributes.remove( key );
+ /** {@inheritDoc} */
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public < T > T removeAttribute( final String key ) {
+ return ( T )m_attributes.remove( key );
}
- /**
- * Returns a WatchDog for current thread.
- *
- * @return The current thread WatchDog.
- * @since 2.4.92
- */
+ /** {@inheritDoc} */
+ @Override
public WatchDog getCurrentWatchDog() {
return WatchDog.getCurrentWatchDog( this );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
new file mode 100644
index 0000000..7cb1bf6
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
@@ -0,0 +1,312 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.api.core;
+
+import org.apache.wiki.WatchDog;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.event.WikiEventListener;
+
+import javax.servlet.ServletContext;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Properties;
+
+
+public interface Engine {
+
+ /** The default inlining pattern. Currently "*.png" */
+ String DEFAULT_INLINEPATTERN = "*.png";
+
+ /** The name used for the default template. The value is {@value}. */
+ String DEFAULT_TEMPLATE_NAME = "default";
+
+ /** Property for application name */
+ String PROP_APPNAME = "jspwiki.applicationName";
+
+ /** This property defines the inline image pattern. It's current value is {@value} */
+ String PROP_INLINEIMAGEPTRN = "jspwiki.translatorReader.inlinePattern";
+
+ /** Property start for any interwiki reference. */
+ String PROP_INTERWIKIREF = "jspwiki.interWikiRef.";
+
+ /** If true, then the user name will be stored with the page data.*/
+ String PROP_STOREUSERNAME= "jspwiki.storeUserName";
+
+ /** Define the used encoding. Currently supported are ISO-8859-1 and UTF-8 */
+ String PROP_ENCODING = "jspwiki.encoding";
+
+ /** Do not use encoding in WikiJSPFilter, default is false for most servers.
+ Double negative, cause for most servers you don't need the property */
+ String PROP_NO_FILTER_ENCODING = "jspwiki.nofilterencoding";
+
+ /** Property name for where the jspwiki work directory should be.
+ If not specified, reverts to ${java.tmpdir}. */
+ String PROP_WORKDIR = "jspwiki.workDir";
+
+ /** The name of the cookie that gets stored to the user browser. */
+ String PREFS_COOKIE_NAME = "JSPWikiUserProfile";
+
+ /** Property name for the "match english plurals" -hack. */
+ String PROP_MATCHPLURALS = "jspwiki.translatorReader.matchEnglishPlurals";
+
+ /** Property name for the template that is used. */
+ String PROP_TEMPLATEDIR = "jspwiki.templateDir";
+
+ /** Property name for the default front page. */
+ String PROP_FRONTPAGE = "jspwiki.frontPage";
+
+ /** Property name for setting the url generator instance */
+ String PROP_URLCONSTRUCTOR = "jspwiki.urlConstructor";
+
+ /** The name of the property containing the ACLManager implementing class. The value is {@value}. */
+ String PROP_ACL_MANAGER_IMPL = "jspwiki.aclManager";
+
+ /** If this property is set to false, we don't allow the creation of empty pages */
+ String PROP_ALLOW_CREATION_OF_EMPTY_PAGES = "jspwiki.allowCreationOfEmptyPages";
+
+ /**
+ * Retrieves the requested object instantiated by the Engine.
+ *
+ * @param manager requested object instantiated by the Engine.
+ * @param <T> type of the requested object.
+ * @return requested object instantiated by the Engine, {@code null} if not available.
+ */
+ < T > T getManager( Class< T > manager );
+
+ /**
+ * check if the WikiEngine has been configured.
+ *
+ * @return {@code true} if it has, {@code false} otherwise.
+ */
+ boolean isConfigured();
+
+ /**
+ * Returns the set of properties that the WikiEngine was initialized with. Note that this method returns a direct reference, so it's
+ * possible to manipulate the properties. However, this is not advised unless you really know what you're doing.
+ *
+ * @return The wiki properties
+ */
+ Properties getWikiProperties();
+
+ /**
+ * Returns the JSPWiki working directory set with "jspwiki.workDir".
+ *
+ * @since 2.1.100
+ * @return The working directory.
+ */
+ String getWorkDir();
+
+ /**
+ * Returns the current template directory.
+ *
+ * @since 1.9.20
+ * @return The template directory as initialized by the engine.
+ */
+ String getTemplateDir();
+
+ /**
+ * Returns the moment when this engine was started.
+ *
+ * @since 2.0.15.
+ * @return The start time of this wiki.
+ */
+ Date getStartTime();
+
+ /**
+ * Returns the base URL, telling where this Wiki actually lives.
+ *
+ * @since 1.6.1
+ * @return The Base URL.
+ */
+ String getBaseURL();
+
+ /**
+ * Returns the URL of the global RSS file. May be null, if the RSS file generation is not operational.
+ *
+ * @since 1.7.10
+ * @return The global RSS url
+ */
+ String getGlobalRSSURL();
+
+ /**
+ * Returns an URL to some other Wiki that we know.
+ *
+ * @param wikiName The name of the other wiki.
+ * @return null, if no such reference was found.
+ */
+ String getInterWikiURL( String wikiName );
+
+ /**
+ * Returns an URL if a WikiContext is not available.
+ *
+ * @param context The WikiContext (VIEW, EDIT, etc...)
+ * @param pageName Name of the page, as usual
+ * @param params List of parameters. May be null, if no parameters.
+ * @return An URL (absolute or relative).
+ */
+ String getURL( String context, String pageName, String params );
+
+ /**
+ * Returns the default front page, if no page is used.
+ *
+ * @return The front page name.
+ */
+ String getFrontPage();
+
+ /**
+ * Returns the ServletContext that this particular WikiEngine was initialized with. <strong>It may return {@code null}</strong>,
+ * if the Engine is not running inside a servlet container!
+ *
+ * @since 1.7.10
+ * @return ServletContext of the Engine, or {@code null}.
+ */
+ ServletContext getServletContext();
+
+ /**
+ * Returns a collection of all supported InterWiki links.
+ *
+ * @return A Collection of Strings.
+ */
+ Collection< String > getAllInterWikiLinks();
+
+ /**
+ * Returns a collection of all image types that get inlined.
+ *
+ * @return A Collection of Strings with a regexp pattern.
+ */
+ Collection< String > getAllInlinedImagePatterns();
+
+ /**
+ * <p>If the page is a special page, then returns a direct URL to that page. Otherwise returns <code>null</code>.
+ * This method delegates requests to {@link org.apache.wiki.ui.CommandResolver#getSpecialPageReference(String)}.</p>
+ * <p>Special pages are defined in jspwiki.properties using the jspwiki.specialPage setting. They're typically used to give Wiki page
+ * names to e.g. custom JSP pages.</p>
+ *
+ * @param original The page to check
+ * @return A reference to the page, or null, if there's no special page.
+ */
+ String getSpecialPageReference( String original );
+
+ /**
+ * Returns the name of the application.
+ *
+ * @return A string describing the name of this application.
+ */
+ String getApplicationName();
+
+ /**
+ * Returns the root path. The root path is where the WikiEngine is located in the file system.
+ *
+ * @since 2.2
+ * @return A path to where the Wiki is installed in the local filesystem.
+ */
+ String getRootPath();
+
+ /**
+ * Returns the correct page name, or null, if no such page can be found. Aliases are considered. This method simply delegates to
+ * {@link org.apache.wiki.ui.CommandResolver#getFinalPageName(String)}.
+ *
+ * @since 2.0
+ * @param page Page name.
+ * @return The rewritten page name, or null, if the page does not exist.
+ * @throws ProviderException If something goes wrong in the backend.
+ */
+ String getFinalPageName( String page ) throws ProviderException;
+
+ /**
+ * Turns a WikiName into something that can be called through using an URL.
+ *
+ * @since 1.4.1
+ * @param pagename A name. Can be actually any string.
+ * @return A properly encoded name.
+ * @see #decodeName(String)
+ */
+ String encodeName( String pagename );
+
+ /**
+ * Decodes a URL-encoded request back to regular life. This properly heeds the encoding as defined in the settings file.
+ *
+ * @param pagerequest The URL-encoded string to decode
+ * @return A decoded string.
+ * @see #encodeName(String)
+ */
+ String decodeName( String pagerequest );
+
+ /**
+ * Returns the IANA name of the character set encoding we're supposed to be using right now.
+ *
+ * @since 1.5.3
+ * @return The content encoding (either UTF-8 or ISO-8859-1).
+ */
+ Charset getContentEncoding();
+
+ /**
+ * Registers a WikiEventListener with this instance.
+ *
+ * @param listener the event listener
+ */
+ void addWikiEventListener( WikiEventListener listener );
+
+ /**
+ * Un-registers a WikiEventListener with this instance.
+ *
+ * @param listener the event listener
+ */
+ void removeWikiEventListener( WikiEventListener listener );
+
+ /**
+ * Adds an attribute to the engine for the duration of this engine. The value is not persisted.
+ *
+ * @since 2.4.91
+ * @param key the attribute name
+ * @param value the value
+ */
+ void setAttribute( String key, Object value );
+
+ /**
+ * Gets an attribute from the engine.
+ *
+ * @param key the attribute name
+ * @return the value
+ */
+ < T > T getAttribute( String key );
+
+ /**
+ * Removes an attribute.
+ *
+ * @param key The key of the attribute to remove.
+ * @return The previous attribute, if it existed.
+ */
+ < T > T removeAttribute( String key );
+
+ /**
+ * Returns a WatchDog for current thread.
+ *
+ * @return The current thread WatchDog.
+ * @since 2.4.92
+ */
+ WatchDog getCurrentWatchDog();
+
+ /**
+ * Signals that the Engine will be shut down by the servlet container.
+ */
+ void shutdown();
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/package.html b/jspwiki-main/src/main/java/org/apache/wiki/api/core/package.html
new file mode 100644
index 0000000..67dd3e3
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/package.html
@@ -0,0 +1,36 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>WikiEngine Managers</title>
+</head>
+<body>
+JSPWiki's central API.
+
+This package holds the central API classes: Engine, Context, Page, etc.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file
[jspwiki] 07/11: apply format & fixes suggested by intellij
Posted by ju...@apache.org.
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 42d8c74019b59fc24d7bc3cbd23fd32432aa9fb1
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 23:53:36 2020 +0100
apply format & fixes suggested by intellij
---
.../org/apache/wiki/attachment/Attachment.java | 51 ++++++++--------------
1 file changed, 19 insertions(+), 32 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
index a7b81d2..6b608b0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
@@ -22,13 +22,10 @@ import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;
/**
- * Describes an attachment. Attachments are actually derivatives of
- * a WikiPage, since they do actually have a WikiName as well.
- *
+ * Describes an attachment. Attachments are actually derivatives of a WikiPage, since they do actually have a WikiName as well.
*/
-public class Attachment
- extends WikiPage
-{
+public class Attachment extends WikiPage {
+
private String m_fileName;
private String m_parentName;
private boolean m_cacheable = true;
@@ -41,9 +38,8 @@ public class Attachment
* @param parentPage The page which will contain this attachment.
* @param fileName The file name for the attachment.
*/
- public Attachment( WikiEngine engine, String parentPage, String fileName )
- {
- super( engine, parentPage+"/"+fileName );
+ public Attachment( final WikiEngine engine, final String parentPage, final String fileName ) {
+ super( engine, parentPage + "/" + fileName );
m_parentName = parentPage;
m_fileName = fileName;
@@ -54,9 +50,8 @@ public class Attachment
*
* @return A debugging string
*/
- public String toString()
- {
- return "Attachment ["+getName()+";mod="+getLastModified()+"]";
+ public String toString() {
+ return "Attachment [" + getName() + ";mod=" + getLastModified() + "]";
}
/**
@@ -64,56 +59,48 @@ public class Attachment
*
* @return A String with the file name.
*/
- public String getFileName()
- {
+ public String getFileName() {
return m_fileName;
}
/**
* Sets the file name of this attachment.
*
- * @param name The name of the attachment. Must be a legal file name without
- * the path.
+ * @param name The name of the attachment. Must be a legal file name without the path.
*/
- public void setFileName( String name )
+ public void setFileName( final String name )
{
m_fileName = name;
}
/**
- * Returns the name of the parent of this Attachment, i.e. the page
- * which contains this attachment.
+ * Returns the name of the parent of this Attachment, i.e. the page which contains this attachment.
*
* @return String depicting the parent of the attachment.
*/
- public String getParentName()
- {
+ public String getParentName() {
return m_parentName;
}
/**
- * Returns true, if this attachment can be cached by the user agent. By default
- * attachments are cacheable.
+ * Returns true, if this attachment can be cached by the user agent. By default attachments are cacheable.
*
* @return False, if the attachment should not be cached by the user agent.
* @since 2.5.34
*/
- public boolean isCacheable()
- {
+ public boolean isCacheable() {
return m_cacheable;
}
/**
- * Sets this attachment to be cacheable or not. This mostly concerns things
- * like DynamicAttachments, but it may be useful for certain AttachmentProviders
- * as well.
+ * Sets this attachment to be cacheable or not. This mostly concerns things like DynamicAttachments, but it may be useful for
+ * certain AttachmentProviders as well.
*
- * @param value True or false, depending on whether you want this attachment
- * to be cacheable or not.
+ * @param value True or false, depending on whether you want this attachment to be cacheable or not.
* @since 2.5.34
*/
- public void setCacheable(boolean value)
- {
+ public void setCacheable( final boolean value ) {
m_cacheable = value;
}
+
}
[jspwiki] 04/11: extract new PluginElement interface from
PluginContent in order to break a package/class cycle between PluginContent
and ParserStagePlugin
Posted by ju...@apache.org.
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 6985a5913f2816dee3442d8903ec637b8ebafb7a
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 21:34:16 2020 +0100
extract new PluginElement interface from PluginContent in order to break a package/class cycle between PluginContent and ParserStagePlugin
---
.../apache/wiki/api/plugin/ParserStagePlugin.java | 12 ++-
.../org/apache/wiki/api/plugin/PluginElement.java | 86 ++++++++++++++++++++++
.../java/org/apache/wiki/parser/PluginContent.java | 69 ++++++-----------
3 files changed, 112 insertions(+), 55 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
index 666b1b1..1e38c5c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
@@ -18,17 +18,15 @@
*/
package org.apache.wiki.api.plugin;
-import java.util.Map;
-
import org.apache.wiki.WikiContext;
-import org.apache.wiki.parser.PluginContent;
+
+import java.util.Map;
/**
- * Implements a Plugin interface for the parser stage. Please see org.apache.wiki.api.PluginManager
+ * Implements a Plugin interface for the parser stage. Please see {@link org.apache.wiki.api.engine.PluginManager}
* for further documentation.
*/
-public interface ParserStagePlugin
-{
+public interface ParserStagePlugin {
/**
* Method which is executed during parsing.
@@ -37,6 +35,6 @@ public interface ParserStagePlugin
* @param context WikiContext, as usual.
* @param params Parsed parameters for the plugin.
*/
- void executeParser( PluginContent element, WikiContext context, Map< String, String > params );
+ void executeParser( PluginElement element, WikiContext context, Map< String, String > params );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/PluginElement.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/PluginElement.java
new file mode 100644
index 0000000..ee7e33b
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/PluginElement.java
@@ -0,0 +1,86 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.apache.wiki.api.plugin;
+
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.exceptions.PluginException;
+
+import java.util.Map;
+
+
+/**
+ * Exposes the contents of a plugin in a WikiDocument DOM tree.
+ */
+public interface PluginElement {
+
+ /**
+ * Returns the name of the plugin invoked by the DOM element.
+ *
+ * @return Name of the plugin
+ * @since 2.5.7
+ */
+ String getPluginName();
+
+ /**
+ * Returns a parameter value from the parameter map.
+ *
+ * @param name the name of the parameter.
+ * @return The value from the map, or null, if no such parameter exists.
+ */
+ String getParameter( String name);
+
+ /**
+ * Returns the parameter map given in the constructor.
+ *
+ * @return The parameter map.
+ */
+ Map< String, String > getParameters();
+
+ /**
+ * Returns the rendered plugin. Only calls getText().
+ *
+ * @return HTML
+ */
+ String getValue();
+
+ /**
+ * The main invocation for the plugin. When the getText() is called, it invokes the plugin and returns its contents. If there is
+ * no Document yet, only returns the plugin name itself.
+ *
+ * @return The plugin rendered according to the options set in the WikiContext.
+ */
+ String getText();
+
+ /**
+ * Performs plugin invocation and return its contents.
+ *
+ * @param context WikiContext in which the plugin is executed. Must NOT be null.
+ * @return plugin contents.
+ */
+ String invoke( WikiContext context );
+
+ /**
+ * Executes the executeParse() method.
+ *
+ * @param context The WikiContext
+ * @throws PluginException If something goes wrong.
+ */
+ void executeParse( WikiContext context ) throws PluginException;
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
index 1fa4947..a7f6f1c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
@@ -27,6 +27,7 @@ import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.api.engine.PluginManager;
import org.apache.wiki.api.exceptions.PluginException;
+import org.apache.wiki.api.plugin.PluginElement;
import org.apache.wiki.api.plugin.ParserStagePlugin;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.preferences.Preferences;
@@ -50,7 +51,7 @@ import java.util.ResourceBundle;
*
* @since 2.4
*/
-public class PluginContent extends Text {
+public class PluginContent extends Text implements PluginElement {
private static final String BLANK = "";
private static final String CMDLINE = "_cmdline";
@@ -62,11 +63,10 @@ public class PluginContent extends Text {
private static final String SPACE = " ";
private static final long serialVersionUID = 1L;
-
- private static Logger log = Logger.getLogger(PluginContent.class);
+ private static final Logger log = Logger.getLogger(PluginContent.class);
private String m_pluginName;
- private Map<String, String> m_params;
+ private Map< String, String > m_params;
/**
* Creates a new DOM element with the given plugin name and a map of parameters.
@@ -79,51 +79,32 @@ public class PluginContent extends Text {
m_params = parameters;
}
- /**
- * Returns the name of the plugin invoked by the DOM element.
- *
- * @return Name of the plugin
- * @since 2.5.7
- */
+ /**{@inheritDoc}*/
+ @Override
public String getPluginName() {
return m_pluginName;
}
- /**
- * Returns a parameter value from the parameter map.
- *
- * @param name the name of the parameter.
- * @return The value from the map, or null, if no such parameter exists.
- */
+ /**{@inheritDoc}*/
+ @Override
public String getParameter( final String name) {
- return m_params.get(name);
+ return m_params.get( name );
}
- /**
- * Returns the parameter map given in the constructor.
- *
- * @return The parameter map.
- */
+ /**{@inheritDoc}*/
+ @Override
public Map< String, String > getParameters() {
return m_params;
}
- /**
- * Returns the rendered plugin. Only calls getText().
- *
- * @return HTML
- */
+ /**{@inheritDoc}*/
+ @Override
public String getValue() {
return getText();
}
- /**
- * The main invocation for the plugin. When the getText() is called, it
- * invokes the plugin and returns its contents. If there is no Document
- * yet, only returns the plugin name itself.
- *
- * @return The plugin rendered according to the options set in the WikiContext.
- */
+ /**{@inheritDoc}*/
+ @Override
public String getText() {
final WikiDocument doc = ( WikiDocument )getDocument();
if( doc == null ) {
@@ -144,13 +125,9 @@ public class PluginContent extends Text {
return invoke( context );
}
- /**
- * Performs plugin invocation and return its contents.
- *
- * @param context WikiContext in which the plugin is executed. Must NOT be null.
- * @return plugin contents.
- */
- public String invoke( final WikiContext context ) {
+ /**{@inheritDoc}*/
+ @Override
+ public String invoke( final WikiContext context ) {
String result;
final Boolean wysiwygVariable = ( Boolean )context.getVariable( WikiContext.VAR_WYSIWYG_EDITOR_MODE );
boolean wysiwygEditorMode = false;
@@ -165,7 +142,7 @@ public class PluginContent extends Text {
// since they can be edited visually.
//
// FIXME: The plugin name matching should not be done here, but in a per-editor resource
- if (wysiwygEditorMode && !m_pluginName.matches(EMITTABLE_PLUGINS)) {
+ if( wysiwygEditorMode && !m_pluginName.matches( EMITTABLE_PLUGINS ) ) {
result = PLUGIN_START + m_pluginName + SPACE;
// convert newlines to <br> in case the plugin has a body.
@@ -205,12 +182,8 @@ public class PluginContent extends Text {
return result;
}
- /**
- * Executes the executeParse() method.
- *
- * @param context The WikiContext
- * @throws PluginException If something goes wrong.
- */
+ /**{@inheritDoc}*/
+ @Override
public void executeParse( final WikiContext context ) throws PluginException {
final PluginManager pm = context.getEngine().getPluginManager();
if( pm.pluginsEnabled() ) {
[jspwiki] 01/11: remove direct reference to WikiEngine on
WikiEngineEvent,
in order to break package cycle between o.a.wiki and o.a.w.event. To obtain
the WikiEngine reference from the event just use getSrc()
Posted by ju...@apache.org.
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 959f9d1e525ee2962247f54e0191469e9cb19491
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 20:49:52 2020 +0100
remove direct reference to WikiEngine on WikiEngineEvent, in order to break package cycle between o.a.wiki and o.a.w.event. To obtain the WikiEngine reference from the event just use getSrc()
---
.../main/java/org/apache/wiki/event/WikiEngineEvent.java | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
index 7cb6758..65d1ef7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
@@ -16,11 +16,8 @@
specific language governing permissions and limitations
under the License.
*/
-
package org.apache.wiki.event;
-import org.apache.wiki.WikiEngine;
-
/**
* WikiEngineEvent indicates a change in the state of the WikiEngine.
*
@@ -46,8 +43,6 @@ public class WikiEngineEvent extends WikiEvent {
*/
public static final int STOPPED = 2;
- private WikiEngine m_engine;
-
/**
* Constructs an instance of this event.
*
@@ -57,7 +52,6 @@ public class WikiEngineEvent extends WikiEvent {
*/
public WikiEngineEvent( final Object eventSource, final int type ) {
super( eventSource, type );
- m_engine = ( WikiEngine )eventSource;
}
/**
@@ -74,15 +68,6 @@ public class WikiEngineEvent extends WikiEvent {
}
/**
- * Returns the WikiEngine that spawned this event.
- *
- * @return the WikiEngine that spawned this event.
- */
- public WikiEngine getEngine() {
- return m_engine;
- }
-
- /**
* Returns <code>true</code> if the int value is a WikiPageEvent type.
*
* @param type the event type
[jspwiki] 11/11: 2.11.0-M7-git-08
Posted by ju...@apache.org.
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 cf23ad692ab731ea7fc6cb7ce0c24f67ff6c74a4
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Feb 17 17:56:12 2020 +0100
2.11.0-M7-git-08
---
ChangeLog.md | 19 +++++++++++++++++++
.../src/main/java/org/apache/wiki/Release.java | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 7bde688..aecb3ad 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,25 @@ specific language governing permissions and limitations
under the License.
-->
+**2020-02-20 Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-08_
+
+* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): finally, extracted `Engine` interface from
+`WikiEngine`. It will be part of JSPWiki public API later on.
+ * removed direct reference to `WikiEngine` on `WikiEngineEvent`, in order to break package cycle between
+ `o.a.wiki` and `o.a.w.event`. To obtain the `WikiEngine` reference from the event just use `getSrc()`
+ * extract new `PluginElement` interface from `PluginContent` in order to break a package/class cycle between
+ `PluginContent` and `ParserStagePlugin`
+
+* Merged [PR #13](https://github.com/apache/jspwiki/pull/13) from [Kideath](https://github.com/kideath) in order
+to fix russian translation. Thanks!
+
+* Dependency updates
+ * Flexmark to 0.50.50
+ * Selenide to 5.7.0
+ * Tomcat to 8.5.51
+
**2002-02-14 Dirk Frederickx (brushed AT apache DOT org)**
* _2.11.0-M7-git-07_
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index 19026cc..a06d3ab 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -69,7 +69,7 @@ public final class Release {
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "git-07";
+ public static final String BUILD = "git-08";
/**
* This is the generic version string you should use when printing out the version. It is of
[jspwiki] 02/11: small refactor to AttachmentManagerTest
Posted by ju...@apache.org.
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 214c1a958bdce935cbb1d1651652eebba88c7dda
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 20:51:28 2020 +0100
small refactor to AttachmentManagerTest
---
.../wiki/attachment/AttachmentManagerTest.java | 39 ++++++++--------------
1 file changed, 14 insertions(+), 25 deletions(-)
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
index b4cd203..a231cb9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
@@ -31,53 +31,38 @@ import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
-import java.util.Properties;
-public class AttachmentManagerTest
-{
+public class AttachmentManagerTest {
+
public static final String NAME1 = "TestPage";
public static final String NAMEU = "TestPage\u00e6";
- Properties props = TestEngine.getTestProperties();
-
TestEngine m_engine;
AttachmentManager m_manager;
static String c_fileContents = "ABCDEFGHIJKLMNOPQRSTUVWxyz";
@BeforeEach
- public void setUp()
- throws Exception
- {
- CacheManager m_cacheManager = CacheManager.getInstance();
- m_cacheManager.clearAll();
- m_cacheManager.removeAllCaches();
-
- m_engine = new TestEngine(props);
+ public void setUp() throws Exception {
+ m_engine = TestEngine.build();
m_manager = m_engine.getAttachmentManager();
m_engine.saveText( NAME1, "Foobar" );
m_engine.saveText( NAMEU, "Foobar" );
}
- private File makeAttachmentFile()
- throws Exception
- {
- File tmpFile = File.createTempFile("test","txt");
+ private File makeAttachmentFile() throws Exception {
+ final File tmpFile = File.createTempFile("test","txt");
tmpFile.deleteOnExit();
-
- FileWriter out = new FileWriter( tmpFile );
-
- FileUtil.copyContents( new StringReader( c_fileContents ), out );
-
- out.close();
+ try( final FileWriter out = new FileWriter( tmpFile ) ) {
+ FileUtil.copyContents( new StringReader( c_fileContents ), out );
+ }
return tmpFile;
}
@AfterEach
- public void tearDown()
- {
+ public void tearDown() {
m_engine.deleteTestPage( NAME1 );
m_engine.deleteTestPage( NAMEU );
@@ -85,6 +70,10 @@ public class AttachmentManagerTest
TestEngine.deleteAttachments(NAMEU);
TestEngine.emptyWorkDir();
+
+ final CacheManager m_cacheManager = CacheManager.getInstance();
+ m_cacheManager.clearAll();
+ m_cacheManager.removeAllCaches();
}
@Test
[jspwiki] 08/11: apply format suggested by intellij
Posted by ju...@apache.org.
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 4ace95fcc7e7cb46e4cd64d42c94ad127abec0ab
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 23:54:10 2020 +0100
apply format suggested by intellij
---
.../java/org/apache/wiki/auth/SessionMonitor.java | 25 +++++++++++-----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index d7439ea..c326a7b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -18,6 +18,16 @@
*/
package org.apache.wiki.auth;
+import org.apache.log4j.Logger;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiSession;
+import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.event.WikiEventManager;
+import org.apache.wiki.event.WikiSecurityEvent;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
@@ -27,17 +37,6 @@ import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-
-import org.apache.log4j.Logger;
-import org.apache.wiki.WikiEngine;
-import org.apache.wiki.WikiSession;
-import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.event.WikiEventManager;
-import org.apache.wiki.event.WikiSecurityEvent;
-
/**
* <p>Manages WikiSession's for different WikiEngine's.</p>
* <p>The WikiSession's are stored both in the remote user
@@ -46,8 +45,8 @@ import org.apache.wiki.event.WikiSecurityEvent;
* web.xml for the wiki web application.
* </p>
*/
-public class SessionMonitor implements HttpSessionListener
-{
+public class SessionMonitor implements HttpSessionListener {
+
private static Logger log = Logger.getLogger( SessionMonitor.class );
/** Map with WikiEngines as keys, and SessionMonitors as values. */
[jspwiki] 03/11: remove unused imports
Posted by ju...@apache.org.
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 d4827abf5fffe4b0f695861e645bf9c5ad0f8b63
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 21:32:35 2020 +0100
remove unused imports
---
.../src/test/java/org/apache/wiki/ajax/WikiAjaxServletTest.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ajax/WikiAjaxServletTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ajax/WikiAjaxServletTest.java
index 445a272..29f6ad8 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ajax/WikiAjaxServletTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ajax/WikiAjaxServletTest.java
@@ -19,11 +19,8 @@
package org.apache.wiki.ajax;
import org.junit.jupiter.api.Test;
-
import org.junit.jupiter.api.Assertions;
-import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
-import org.apache.wiki.ajax.WikiAjaxServlet;
import org.apache.wiki.plugin.SampleAjaxPlugin;
/**
[jspwiki] 05/11: make WeblogPlugin use new PluginElement on
ParserStage#executeParser
Posted by ju...@apache.org.
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 dc44642e847e9f8d3ca01db10bf08d5dae438ab1
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Feb 2 21:54:54 2020 +0100
make WeblogPlugin use new PluginElement on ParserStage#executeParser
---
.../src/main/java/org/apache/wiki/plugin/WeblogPlugin.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index 418aa9e..5247c4f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -26,11 +26,11 @@ import org.apache.wiki.WikiProvider;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.exceptions.ProviderException;
import org.apache.wiki.api.plugin.ParserStagePlugin;
+import org.apache.wiki.api.plugin.PluginElement;
import org.apache.wiki.api.plugin.WikiPlugin;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.permissions.PagePermission;
import org.apache.wiki.pages.PageManager;
-import org.apache.wiki.parser.PluginContent;
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.preferences.Preferences.TimeFormat;
import org.apache.wiki.util.TextUtil;
@@ -426,6 +426,8 @@ public class WeblogPlugin implements WikiPlugin, ParserStagePlugin {
*/
private static class PageDateComparator implements Comparator< WikiPage > {
+ /**{@inheritDoc}*/
+ @Override
public int compare( final WikiPage page1, final WikiPage page2 ) {
if( page1 == null || page2 == null ) {
return 0;
@@ -437,9 +439,11 @@ public class WeblogPlugin implements WikiPlugin, ParserStagePlugin {
/**
* Mark us as being a real weblog.
+ *
* {@inheritDoc}
*/
- public void executeParser( final PluginContent element, final WikiContext context, final Map< String, String > params ) {
+ public void executeParser( final PluginElement element, final WikiContext context, final Map< String, String > params ) {
context.getPage().setAttribute( ATTR_ISWEBLOG, "true" );
}
+
}
[jspwiki] 10/11: update dependencies: tomcat to 8.5.51,
selenide to 5.7.0 and flexmark to 0.50.50
Posted by ju...@apache.org.
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 ba49292bf5a65ff8b7a7ce5ca79584e8d6e61e56
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Feb 17 17:53:56 2020 +0100
update dependencies: tomcat to 8.5.51, selenide to 5.7.0 and flexmark to 0.50.50
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 869d711..c7c6a65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
<commons-lang.version>3.9</commons-lang.version>
<commons-text.version>1.8</commons-text.version>
<ehcache.version>2.10.6</ehcache.version>
- <flexmark.version>0.50.48</flexmark.version>
+ <flexmark.version>0.50.50</flexmark.version>
<freshcookies-security.version>0.60</freshcookies-security.version>
<gson.version>2.8.5</gson.version>
<hsqldb.version>2.5.0</hsqldb.version>
@@ -70,11 +70,11 @@
<nekohtml.version>1.9.22</nekohtml.version>
<oro.version>2.0.8</oro.version>
<sandler.version>0.5</sandler.version>
- <selenide.version>5.6.0</selenide.version>
+ <selenide.version>5.7.0</selenide.version>
<slf4j.version>1.7.30</slf4j.version>
<stripes.version>1.7.0-async-beta</stripes.version>
<tika.version>1.23</tika.version>
- <tomcat.version>8.5.50</tomcat.version>
+ <tomcat.version>8.5.51</tomcat.version>
<wro4j.version>1.8.0</wro4j.version>
<xmlrpc.version>2.0.1</xmlrpc.version>
[jspwiki] 09/11: make SamplePlugin use new PluginElement on
ParserStage#executeParser
Posted by ju...@apache.org.
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 db287dc9be158e3687c8b9904a32409ee8c43871
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Feb 17 17:16:52 2020 +0100
make SamplePlugin use new PluginElement on ParserStage#executeParser
---
.../src/test/java/org/apache/wiki/plugin/SamplePlugin.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/SamplePlugin.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/SamplePlugin.java
index d35e75e..d68a896 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/SamplePlugin.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/SamplePlugin.java
@@ -18,13 +18,13 @@
*/
package org.apache.wiki.plugin;
-import java.util.Map;
-
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.plugin.ParserStagePlugin;
+import org.apache.wiki.api.plugin.PluginElement;
import org.apache.wiki.api.plugin.WikiPlugin;
-import org.apache.wiki.parser.PluginContent;
+
+import java.util.Map;
/**
* Implements a simple plugin that just returns its text.
@@ -54,7 +54,7 @@ public class SamplePlugin implements WikiPlugin, ParserStagePlugin {
return sb.toString();
}
- public void executeParser(PluginContent element, WikiContext context, Map< String, String > params) {
+ public void executeParser( PluginElement element, WikiContext context, Map< String, String > params) {
if( element.getParameter("render") != null ) c_rendered = true;
}