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/03/16 21:58:33 UTC
[jspwiki] 43/47: use Context instead of WikiContext
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 b8b6ded3e9abb0030bfbfeb589164432222f666f
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Mar 16 21:32:32 2020 +0100
use Context instead of WikiContext
---
.../main/java/org/apache/wiki/rss/AtomFeed.java | 3 +-
.../src/main/java/org/apache/wiki/rss/Entry.java | 101 ++++++++++-----------
.../src/main/java/org/apache/wiki/rss/Feed.java | 8 +-
.../main/java/org/apache/wiki/rss/RSS10Feed.java | 3 +-
.../main/java/org/apache/wiki/rss/RSS20Feed.java | 9 +-
.../java/org/apache/wiki/rss/RSSGenerator.java | 11 ++-
.../main/java/org/apache/wiki/rss/RSSThread.java | 1 -
7 files changed, 64 insertions(+), 72 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
index 86c5ad3..7639d11 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
@@ -22,6 +22,7 @@ import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.Release;
import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.core.Page;
import org.apache.wiki.api.exceptions.ProviderException;
@@ -55,7 +56,7 @@ public class AtomFeed extends Feed {
*
* @param c A WikiContext.
*/
- public AtomFeed( final WikiContext c )
+ public AtomFeed( final Context c )
{
super(c);
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/Entry.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/Entry.java
index a27fda2..0e15954 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/Entry.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/Entry.java
@@ -22,112 +22,105 @@ import org.apache.wiki.api.core.Page;
/**
- * Represents an entry, that is, an unit of change, in a Feed.
+ * Represents an entry, that is, an unit of change, in a Feed.
*/
-public class Entry
-{
+public class Entry {
+
private String m_content;
private String m_url;
private String m_title;
- private Page m_page;
+ private Page m_page;
private String m_author;
- /**
- * Set the author of this entry.
- *
- * @param author Name of the author.
+
+ /**
+ * Set the author of this entry.
+ *
+ * @param author Name of the author.
*/
- public void setAuthor( final String author )
- {
+ public void setAuthor( final String author ) {
m_author = author;
}
/**
- * Return the author set by setAuthor().
- *
- * @return A String representing the author.
+ * Return the author set by setAuthor().
+ *
+ * @return A String representing the author.
*/
- public String getAuthor()
- {
+ public String getAuthor() {
return m_author;
}
/**
- * Returns the page set by {@link #setPage(Page)}.
- *
- * @return The WikiPage to which this Entry refers to.
+ * Returns the page set by {@link #setPage(Page)}.
+ *
+ * @return The WikiPage to which this Entry refers to.
*/
- public Page getPage()
- {
+ public Page getPage() {
return m_page;
}
/**
- * Sets the WikiPage to which this Entry refers to.
- *
- * @param p A valid WikiPage.
+ * Sets the WikiPage to which this Entry refers to.
+ *
+ * @param p A valid WikiPage.
*/
public void setPage( final Page p ) {
m_page = p;
}
/**
- * Sets a title for the change. For example, a WebLog entry might use the
- * post title, or a Wiki change could use something like "XXX changed page YYY".
- *
- * @param title A String description of the change.
+ * Sets a title for the change. For example, a WebLog entry might use the
+ * post title, or a Wiki change could use something like "XXX changed page YYY".
+ *
+ * @param title A String description of the change.
*/
- public void setTitle( final String title )
- {
+ public void setTitle( final String title ) {
m_title = title;
}
/**
- * Returns the title.
- *
- * @return The title set in setTitle.
+ * Returns the title.
+ *
+ * @return The title set in setTitle.
*/
- public String getTitle()
- {
+ public String getTitle() {
return m_title;
}
/**
- * Set the URL - the permalink - of the Entry.
- *
- * @param url An absolute URL to the entry.
+ * Set the URL - the permalink - of the Entry.
+ *
+ * @param url An absolute URL to the entry.
*/
- public void setURL( final String url )
- {
+ public void setURL( final String url ) {
m_url = url;
}
/**
- * Return the URL set by setURL().
- *
- * @return The URL.
+ * Return the URL set by setURL().
+ *
+ * @return The URL.
*/
- public String getURL()
- {
+ public String getURL() {
return m_url;
}
/**
- * Set the content of this entry.
- *
- * @param content A String of the content.
+ * Set the content of this entry.
+ *
+ * @param content A String of the content.
*/
- public void setContent( final String content )
- {
+ public void setContent( final String content ) {
m_content = content;
}
/**
- * Return the content set by {@link #setContent(String)}.
- *
- * @return Whatever was set by setContent().
+ * Return the content set by {@link #setContent(String)}.
+ *
+ * @return Whatever was set by setContent().
*/
- public String getContent()
- {
+ public String getContent() {
return m_content;
}
+
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/Feed.java
index 92af083..c9a7d7a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/Feed.java
@@ -19,7 +19,7 @@
package org.apache.wiki.rss;
import org.apache.commons.text.StringEscapeUtils;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.exceptions.NoSuchVariableException;
import org.apache.wiki.variables.VariableManager;
@@ -39,7 +39,7 @@ public abstract class Feed {
protected String m_channelDescription;
protected String m_channelLanguage;
- protected WikiContext m_wikiContext;
+ protected Context m_wikiContext;
protected String m_mode = RSSGenerator.MODE_WIKI;
@@ -54,7 +54,7 @@ public abstract class Feed {
* @param context the wiki context
* @return the site name
*/
- public static String getSiteName( final WikiContext context ) {
+ public static String getSiteName( final Context context ) {
final Engine engine = context.getEngine();
String blogname = null;
@@ -76,7 +76,7 @@ public abstract class Feed {
*
* @param context The WikiContext.
*/
- public Feed( final WikiContext context) {
+ public Feed( final Context context) {
m_wikiContext = context;
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
index bf85987..227aaa0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
@@ -19,6 +19,7 @@
package org.apache.wiki.rss;
import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.core.Page;
import org.apache.wiki.util.XhtmlUtil;
@@ -46,7 +47,7 @@ public class RSS10Feed extends Feed {
*
* @param context The WikiContext.
*/
- public RSS10Feed( final WikiContext context ) {
+ public RSS10Feed( final Context context ) {
super( context );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
index 31e9a4d..e2fa6f8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
@@ -21,6 +21,7 @@ package org.apache.wiki.rss;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.Release;
import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.core.Page;
import org.apache.wiki.api.exceptions.ProviderException;
@@ -36,7 +37,6 @@ import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Iterator;
import java.util.List;
/**
@@ -52,7 +52,7 @@ public class RSS20Feed extends Feed
*
* @param context The WikiContext.
*/
- public RSS20Feed( final WikiContext context )
+ public RSS20Feed( final Context context )
{
super( context );
}
@@ -82,10 +82,7 @@ public class RSS20Feed extends Feed
if( engine.getManager( AttachmentManager.class ).hasAttachments( p ) && servletContext != null ) {
try {
final List< Attachment > c = engine.getManager( AttachmentManager.class ).listAttachments( p );
-
- for( final Iterator< Attachment > a = c.iterator(); a.hasNext(); ) {
- final Attachment att = a.next();
-
+ for( final Attachment att : c ) {
final Element attEl = new Element( "enclosure" );
attEl.setAttribute( "url", engine.getURL( WikiContext.ATTACH, att.getName(), null ) );
attEl.setAttribute( "length", Long.toString( att.getSize() ) );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index 59ac8c1..827c99e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.core.Engine;
import org.apache.wiki.api.core.Page;
import org.apache.wiki.api.core.Session;
@@ -257,7 +258,7 @@ public class RSSGenerator {
* @return Fully formed XML.
* @throws IllegalArgumentException If an illegal mode is given.
*/
- public String generateFeed( final WikiContext wikiContext, final List< Page > changed, final String mode, final String type ) throws IllegalArgumentException {
+ public String generateFeed( final Context wikiContext, final List< Page > changed, final String mode, final String type ) throws IllegalArgumentException {
final Feed feed;
final String res;
@@ -296,7 +297,7 @@ public class RSSGenerator {
/**
* Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not
- * actually affect whether the {@link #generate()} or {@link #generateFeed(WikiContext, List, String, String)} methods output anything.
+ * actually affect whether the {@link #generate()} or {@link #generateFeed(Context, List, String, String)} methods output anything.
*
* @param enabled whether RSS generation is considered enabled.
*/
@@ -312,7 +313,7 @@ public class RSSGenerator {
* @param feed A Feed to generate the feed to.
* @return feed.getString().
*/
- protected String generateFullWikiRSS( final WikiContext wikiContext, final Feed feed ) {
+ protected String generateFullWikiRSS( final Context wikiContext, final Feed feed ) {
feed.setChannelTitle( m_engine.getApplicationName() );
feed.setFeedURL( m_engine.getBaseURL() );
feed.setChannelLanguage( m_channelLanguage );
@@ -359,7 +360,7 @@ public class RSSGenerator {
* @param feed A Feed object to fill.
* @return the RSS representation of the wiki context
*/
- protected String generateWikiPageRSS( final WikiContext wikiContext, final List< Page > changed, final Feed feed ) {
+ protected String generateWikiPageRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
final String language = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
@@ -412,7 +413,7 @@ public class RSSGenerator {
* @param feed A valid Feed object. The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.
* @return A String of valid RSS or Atom.
*/
- protected String generateBlogRSS( final WikiContext wikiContext, final List< Page > changed, final Feed feed ) {
+ protected String generateBlogRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
if( log.isDebugEnabled() ) {
log.debug( "Generating RSS for blog, size=" + changed.size() );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
index 1168f84..e13abc8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
@@ -95,7 +95,6 @@ public class RSSThread extends WikiBackgroundThread {
} finally {
m_watchdog.exitState();
}
-
}
}