You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/08/03 14:22:18 UTC
svn commit: r682148 [3/8] - in
/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki:
parser/ plugin/ preferences/ providers/ render/ rpc/ rpc/atom/ rpc/json/
rss/ search/ tags/ ui/ ui/admin/ ui/admin/beans/ ui/progress/
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WeblogPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WeblogPlugin.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WeblogPlugin.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WeblogPlugin.java Sun Aug 3 05:22:13 2008
@@ -1,28 +1,37 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.plugin;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -31,9 +40,9 @@
import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.auth.AuthorizationManager;
import com.ecyrd.jspwiki.auth.permissions.PagePermission;
-import com.ecyrd.jspwiki.action.CommentActionBean;
-import com.ecyrd.jspwiki.action.ViewActionBean;
import com.ecyrd.jspwiki.parser.PluginContent;
+import com.ecyrd.jspwiki.preferences.Preferences;
+import com.ecyrd.jspwiki.preferences.Preferences.TimeFormat;
import com.ecyrd.jspwiki.providers.ProviderException;
/**
@@ -69,15 +78,14 @@
implements WikiPlugin, ParserStagePlugin
{
private static Logger log = Logger.getLogger(WeblogPlugin.class);
- private static final DateFormat DEFAULT_ENTRYFORMAT
- = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);
- private static final Pattern headingPattern;
+ private static final Pattern HEADINGPATTERN;
/** How many days are considered by default. Default value is {@value} */
- public static final int DEFAULT_DAYS = 7;
- public static final String DEFAULT_PAGEFORMAT = "%p_blogentry_";
+ private static final int DEFAULT_DAYS = 7;
+ private static final String DEFAULT_PAGEFORMAT = "%p_blogentry_";
- public static final String DEFAULT_DATEFORMAT = "ddMMyy";
+ /** The default date format used in the blog entry page names. */
+ public static final String DEFAULT_DATEFORMAT = "ddMMyy";
public static final String PARAM_STARTDATE = "startDate";
public static final String PARAM_ENTRYFORMAT = "entryFormat";
@@ -86,14 +94,25 @@
public static final String PARAM_MAXENTRIES = "maxEntries";
public static final String PARAM_PAGE = "page";
+ /** The attribute which is stashed to the WikiPage attributes to check if a page
+ * is a weblog or not. You may check for its presence.
+ */
public static final String ATTR_ISWEBLOG = "weblogplugin.isweblog";
static
{
// This is a pretty ugly, brute-force regex. But it will do for now...
- headingPattern = Pattern.compile("(<h[1-4].*>)(.*)(</h[1-4]>)", Pattern.CASE_INSENSITIVE);
+ HEADINGPATTERN = Pattern.compile("(<h[1-4].*>)(.*)(</h[1-4]>)", Pattern.CASE_INSENSITIVE);
}
+ /**
+ * Create an entry name based on the blogname, a date, and an entry number.
+ *
+ * @param pageName Name of the blog
+ * @param date The date (in ddMMyy format)
+ * @param entryNum The entry number.
+ * @return A formatted page name.
+ */
public static String makeEntryPage( String pageName,
String date,
String entryNum )
@@ -101,16 +120,33 @@
return TextUtil.replaceString(DEFAULT_PAGEFORMAT,"%p",pageName)+date+"_"+entryNum;
}
+ /**
+ * Return just the basename for entires without date and entry numebr.
+ *
+ * @param pageName The name of the blog.
+ * @return A formatted name.
+ */
public static String makeEntryPage( String pageName )
{
return TextUtil.replaceString(DEFAULT_PAGEFORMAT,"%p",pageName);
}
+ /**
+ * Returns the entry page without the entry number.
+ *
+ * @param pageName Blog name.
+ * @param date The date.
+ * @return A base name for the blog entries.
+ */
public static String makeEntryPage( String pageName, String date )
{
return TextUtil.replaceString(DEFAULT_PAGEFORMAT,"%p",pageName)+date;
}
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
public String execute( WikiContext context, Map params )
throws PluginException
{
@@ -142,7 +178,7 @@
if( ( params.get(PARAM_ENTRYFORMAT)) == null )
{
- entryFormat = DEFAULT_ENTRYFORMAT;
+ entryFormat = Preferences.getDateFormat( context, TimeFormat.DATETIME );
}
else
{
@@ -220,9 +256,9 @@
try
{
List<WikiPage> blogEntries = findBlogEntries( engine.getPageManager(),
- weblogName,
- startTime.getTime(),
- stopTime.getTime() );
+ weblogName,
+ startTime.getTime(),
+ stopTime.getTime() );
Collections.sort( blogEntries, new PageDateComparator() );
@@ -288,7 +324,7 @@
// Extract the first h1/h2/h3 as title, and replace with null
buffer.append("<div class=\"weblogentrytitle\">\n");
- Matcher matcher = headingPattern.matcher( html );
+ Matcher matcher = HEADINGPATTERN.matcher( html );
if ( matcher.find() )
{
String title = matcher.group(2);
@@ -316,7 +352,7 @@
{
if( engine.pageExists(author) )
{
- author = "<a href=\""+entryCtx.getContext().getURL( ViewActionBean.class, author )+"\">"+engine.beautifyTitle(author)+"</a>";
+ author = "<a href=\""+entryCtx.getURL( WikiContext.VIEW, author )+"\">"+engine.beautifyTitle(author)+"</a>";
}
}
else
@@ -325,7 +361,7 @@
}
buffer.append("By "+author+" ");
- buffer.append( "<a href=\""+entryCtx.getContext().getURL( ViewActionBean.class, entry.getName())+"\">Permalink</a>" );
+ buffer.append( "<a href=\""+entryCtx.getURL(WikiContext.VIEW, entry.getName())+"\">Permalink</a>" );
String commentPageName = TextUtil.replaceString( entry.getName(),
"blogentry",
"comments" );
@@ -340,10 +376,10 @@
// has changed.
//
buffer.append( " " );
- Map<String,String> urlParams = new HashMap<String,String>();
- urlParams.put("nc",String.valueOf(numComments));
buffer.append( "<a target=\"_blank\" href=\""+
- entryCtx.getContext().getURL(CommentActionBean.class, commentPageName, urlParams) +
+ entryCtx.getURL(WikiContext.COMMENT,
+ commentPageName,
+ "nc="+numComments)+
"\">Comments? ("+
numComments+
")</a>" );
@@ -381,18 +417,20 @@
* @return a list of pages with their FIRST revisions.
* @throws ProviderException If something goes wrong
*/
- public List<WikiPage> findBlogEntries( PageManager mgr,
+ public List findBlogEntries( PageManager mgr,
String baseName, Date start, Date end )
throws ProviderException
{
- Collection<WikiPage> everyone = mgr.getAllPages();
- List<WikiPage> result = new ArrayList<WikiPage>();
+ Collection everyone = mgr.getAllPages();
+ ArrayList<WikiPage> result = new ArrayList<WikiPage>();
baseName = makeEntryPage( baseName );
SimpleDateFormat fmt = new SimpleDateFormat(DEFAULT_DATEFORMAT);
- for( WikiPage p : everyone )
+ for( Iterator i = everyone.iterator(); i.hasNext(); )
{
+ WikiPage p = (WikiPage)i.next();
+
String pageName = p.getName();
if( pageName.startsWith( baseName ) )
@@ -445,14 +483,14 @@
*/
private static class PageDateComparator implements Comparator<WikiPage>
{
- public int compare( WikiPage o1, WikiPage o2 )
+ public int compare( WikiPage page1, WikiPage page2 )
{
- if( o1 == null || o2 == null )
+ if( page1 == null || page2 == null )
{
return 0;
}
- return o2.getLastModified().compareTo( o1.getLastModified() );
+ return page2.getLastModified().compareTo( page1.getLastModified() );
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WikiPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WikiPlugin.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WikiPlugin.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/plugin/WikiPlugin.java Sun Aug 3 05:22:13 2008
@@ -31,7 +31,10 @@
*/
public interface WikiPlugin
{
- static final String CORE_PLUGINS_RESOURCEBUNDLE = "com.ecyrd.jspwiki.plugin.PluginResources";
+ /**
+ * Name of the default plugin resource bundle.
+ */
+ static final String CORE_PLUGINS_RESOURCEBUNDLE = "plugin.PluginResources";
/**
* This is the main entry point for any plugin. The parameters are parsed,
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/Preferences.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/Preferences.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/Preferences.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/Preferences.java Sun Aug 3 05:22:13 2008
@@ -1,28 +1,51 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ 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 com.ecyrd.jspwiki.preferences;
+import java.text.DateFormat;
import java.text.ParseException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
+import java.text.SimpleDateFormat;
+import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.PageContext;
+import org.apache.log4j.Logger;
import org.json.JSONObject;
+import com.ecyrd.jspwiki.InternalWikiException;
import com.ecyrd.jspwiki.PropertyReader;
import com.ecyrd.jspwiki.TextUtil;
import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.action.WikiActionBean;
+import com.ecyrd.jspwiki.i18n.InternationalizationManager;
import com.ecyrd.jspwiki.util.HttpUtil;
/**
* Represents an object which is used to store user preferences.
*
- * @author jalkanen
*/
public class Preferences
- extends HashMap
+ extends HashMap<String,String>
{
private static final long serialVersionUID = 1L;
@@ -32,6 +55,8 @@
*/
public static final String SESSIONPREFS = "prefs";
+ private static Logger log = Logger.getLogger( Preferences.class );
+
/**
* This is an utility method which is called to make sure that the
* JSP pages do have proper access to any user preferences. It should be
@@ -56,20 +81,42 @@
}
}
+ /**
+ * Reloads the preferences from the PageContext into the WikiContext.
+ *
+ * @param pageContext The page context.
+ */
+ // FIXME: The way that date preferences are chosen is currently a bit wacky: it all
+ // gets saved to the cookie based on the browser state with which the user
+ // happened to first arrive to the site with. This, unfortunately, means that
+ // even if the user changes e.g. language preferences (like in a web cafe),
+ // the old preferences still remain in a site cookie.
public static void reloadPreferences( PageContext pageContext )
{
Preferences prefs = new Preferences();
Properties props = PropertyReader.loadWebAppProps( pageContext.getServletContext() );
+ WikiContext ctx = WikiContext.findContext( pageContext );
prefs.put("SkinName", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.skinname", "PlainVanilla" ) );
- prefs.put("DateFormat", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.dateformat", "dd-MMM-yyyy HH:mm" ) );
+ prefs.put("DateFormat",
+ TextUtil.getStringProperty( props,
+ "jspwiki.defaultprefs.template.dateformat",
+ ctx.getEngine().getInternationalizationManager().get( InternationalizationManager.CORE_BUNDLE,
+ getLocale( ctx ),
+ "common.datetimeformat" ) ) );
+
prefs.put("TimeZone", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.timezone",
java.util.TimeZone.getDefault().getID() ) );
- prefs.put("orientation", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.orientation", "fav-left" ) );
+ /*
+ prefs.put("TimeZone", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.timezone",
+ Integer.toString( java.util.TimeZone.getDefault().getRawOffset() )
+ ) );
+ */
+ prefs.put("Orientation", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.orientation", "fav-left" ) );
// FIXME: "editor" property does not get registered, may be related with http://bugs.jspwiki.org/show_bug.cgi?id=117
// disabling it until knowing why it's happening
- // FIXME: editomanager reads jspwiki.editor -- which of both properties should continue
+ // FIXME: editormanager reads jspwiki.editor -- which of both properties should continue
prefs.put("editor", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.editor", "plain" ) );
parseJSONPreferences( (HttpServletRequest) pageContext.getRequest(), prefs );
@@ -115,14 +162,17 @@
*
* @param wikiContext
* @param name
- * @return
+ * @return the preference value
*/
- public static String getPreference( WikiContext wikiContext, String name )
+ public static String getPreference( WikiActionBean wikiContext, String name )
{
- Preferences prefs = (Preferences)wikiContext.getHttpRequest().getSession().getAttribute( SESSIONPREFS );
+ HttpServletRequest request = wikiContext.getHttpRequest();
+ if ( request == null ) return null;
+
+ Preferences prefs = (Preferences)request.getSession().getAttribute( SESSIONPREFS );
if( prefs != null )
- return (String)prefs.get( name );
+ return prefs.get( name );
return null;
}
@@ -132,15 +182,146 @@
*
* @param pageContext
* @param name
- * @return
+ * @return the preference value
*/
public static String getPreference( PageContext pageContext, String name )
{
Preferences prefs = (Preferences)pageContext.getSession().getAttribute( SESSIONPREFS );
if( prefs != null )
- return (String)prefs.get( name );
+ return prefs.get( name );
return null;
}
+
+
+ /**
+ * Get Locale according to user-preference settings or the user browser locale
+ *
+ * @param context The context to examine.
+ * @return a Locale object.
+ * @since 2.8
+ */
+ public static Locale getLocale(WikiActionBean context)
+ {
+ Locale loc = null;
+
+ String language = Preferences.getPreference( context, "Language" );
+
+ if( language != null)
+ loc = new Locale(language);
+
+ if( loc == null)
+ {
+ HttpServletRequest request = context.getHttpRequest();
+ loc = ( request != null ) ? request.getLocale() : Locale.getDefault();
+ }
+
+ return loc;
+ }
+
+ /**
+ * Get SimpleTimeFormat according to user browser locale and preferred time
+ * formats. If not found, it will revert to whichever format is set for the
+ * default
+ *
+ * @param context WikiContext to use for rendering.
+ * @param tf Which version of the dateformat you are looking for?
+ * @return A SimpleTimeFormat object which you can use to render
+ * @since 2.8
+ */
+ public static SimpleDateFormat getDateFormat( WikiContext context, TimeFormat tf )
+ {
+ InternationalizationManager imgr = context.getEngine().getInternationalizationManager();
+ Locale clientLocale = Preferences.getLocale( context );
+ String prefTimeZone = Preferences.getPreference( context, "TimeZone" );
+ String prefDateFormat;
+
+ log.debug("Checking for preferences...");
+
+ switch( tf )
+ {
+ case DATETIME:
+ prefDateFormat = Preferences.getPreference( context, "DateFormat" );
+ log.debug("Preferences fmt = "+prefDateFormat);
+ if( prefDateFormat == null )
+ {
+ prefDateFormat = imgr.get( InternationalizationManager.CORE_BUNDLE,
+ clientLocale,
+ "common.datetimeformat" );
+ log.debug("Using locale-format = "+prefDateFormat);
+ }
+ break;
+
+ case TIME:
+ prefDateFormat = imgr.get( "common.timeformat" );
+ break;
+
+ case DATE:
+ prefDateFormat = imgr.get( "common.dateformat" );
+ break;
+
+ default:
+ throw new InternalWikiException( "Got a TimeFormat for which we have no value!" );
+ }
+
+ try
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( prefDateFormat, clientLocale );
+
+ if( prefTimeZone != null )
+ {
+ TimeZone tz = TimeZone.getTimeZone( prefTimeZone );
+ // TimeZone tz = TimeZone.getDefault();
+ // tz.setRawOffset(Integer.parseInt(prefTimeZone));
+
+ fmt.setTimeZone( tz );
+ }
+
+ return fmt;
+ }
+ catch( Exception e )
+ {
+ return null;
+ }
+ }
+
+ /**
+ * A simple helper function to render a date based on the user preferences.
+ * This is useful for example for all plugins.
+ *
+ * @param context The context which is used to get the preferences
+ * @param date The date to render.
+ * @param tf In which format the date should be rendered.
+ * @return A ready-rendered date.
+ * @since 2.8
+ */
+ public static String renderDate( WikiContext context, Date date, TimeFormat tf )
+ {
+ DateFormat df = getDateFormat( context, tf );
+
+ return df.format( date );
+ }
+
+ /**
+ * Is used to choose between the different date formats that JSPWiki supports.
+ * <ul>
+ * <li>TIME: A time format, without date</li>
+ * <li>DATE: A date format, without a time</li>
+ * <li>DATETIME: A date format, with a time</li>
+ * </ul>
+ *
+ * @since 2.8
+ */
+ public enum TimeFormat
+ {
+ /** A time format, no date. */
+ TIME,
+
+ /** A date format, no time. */
+ DATE,
+
+ /** A date+time format. */
+ DATETIME
+ }
}
Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/package.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/package.html?rev=682148&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/package.html (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/preferences/package.html Sun Aug 3 05:22:13 2008
@@ -0,0 +1,14 @@
+<body>
+
+Preferences storage.
+
+<h2>Package Specification</h2>
+
+Provides storage for the user preferences that JSPWiki uses.
+
+<h2>Related Documentation</h2>
+
+TBD.
+
+<hr>
+</body>
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/AbstractFileProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/AbstractFileProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/AbstractFileProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -41,7 +42,6 @@
*
* @since 2.1.21.
*
- * @author Janne Jalkanen
*/
public abstract class AbstractFileProvider
implements WikiPageProvider
@@ -65,17 +65,19 @@
*/
public static final String FILE_EXT = ".txt";
+ /** The default encoding. */
public static final String DEFAULT_ENCODING = "ISO-8859-1";
private boolean m_windowsHackNeeded = false;
/**
+ * {@inheritDoc}
* @throws FileNotFoundException If the specified page directory does not exist.
* @throws IOException In case the specified page directory is a file, not a directory.
*/
public void initialize( WikiEngine engine, Properties properties )
throws NoRequiredPropertyException,
- IOException
+ IOException, FileNotFoundException
{
log.debug("Initing FileSystemProvider");
m_pageDirectory = WikiEngine.getRequiredProperty( properties, PROP_PAGEDIR );
@@ -84,11 +86,22 @@
if( !f.exists() )
{
- f.mkdirs();
+ if( !f.mkdirs() )
+ {
+ throw new IOException( "Failed to create page directory " + f.getAbsolutePath() + " , please check property "
+ + PROP_PAGEDIR );
+ }
}
- else if( !f.isDirectory() )
+ else
{
- throw new IOException("Page directory is not a directory: "+m_pageDirectory);
+ if( !f.isDirectory() )
+ {
+ throw new IOException( "Page directory is not a directory: " + f.getAbsolutePath() );
+ }
+ if( !f.canWrite() )
+ {
+ throw new IOException( "Page directory is not writable: " + f.getAbsolutePath() );
+ }
}
m_engine = engine;
@@ -120,7 +133,11 @@
/**
* This makes sure that the queried page name
- * is still readable by the file system.
+ * is still readable by the file system. For example, all XML entities
+ * and slashes are encoded with the percent notation.
+ *
+ * @param pagename The name to mangle
+ * @return The mangled name.
*/
protected String mangleName( String pagename )
{
@@ -128,6 +145,15 @@
pagename = TextUtil.replaceString( pagename, "/", "%2F" );
+ //
+ // Names which start with a dot must be escaped to prevent problems.
+ // Since we use URL encoding, this is invisible in our unescaping.
+ //
+ if( pagename.startsWith( "." ) )
+ {
+ pagename = "%2E" + pagename.substring( 1 );
+ }
+
if( m_windowsHackNeeded )
{
String pn = pagename.toLowerCase();
@@ -145,6 +171,9 @@
/**
* This makes the reverse of mangleName.
+ *
+ * @param filename The filename to unmangle
+ * @return The unmangled name.
*/
protected String unmangleName( String filename )
{
@@ -166,13 +195,18 @@
/**
* Finds a Wiki page from the page repository.
+ *
+ * @param page The name of the page.
+ * @return A File to the page. May be null.
*/
protected File findPage( String page )
{
return new File( m_pageDirectory, mangleName(page)+FILE_EXT );
}
-
+ /**
+ * {@inheritDoc}
+ */
public boolean pageExists( String page )
{
File pagefile = findPage( page );
@@ -183,6 +217,10 @@
/**
* This implementation just returns the current version, as filesystem
* does not provide versioning information for now.
+ *
+ * @param page {@inheritDoc}
+ * @param version {@inheritDoc}
+ * @throws {@inheritDoc}
*/
public String getPageText( String page, int version )
throws ProviderException
@@ -239,6 +277,9 @@
return result;
}
+ /**
+ * {@inheritDoc}
+ */
public void putPageText( WikiPage page, String text )
throws ProviderException
{
@@ -262,12 +303,15 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Collection getAllPages()
throws ProviderException
{
log.debug("Getting all pages...");
- ArrayList set = new ArrayList();
+ ArrayList<WikiPage> set = new ArrayList<WikiPage>();
File wikipagedir = new File( m_pageDirectory );
@@ -300,11 +344,20 @@
return set;
}
+ /**
+ * Does not work.
+ *
+ * @param date {@inheritDoc}
+ * @return {@inheritDoc}
+ */
public Collection getAllChangedSince( Date date )
{
return new ArrayList(); // FIXME
}
+ /**
+ * {@inheritDoc}
+ */
public int getPageCount()
{
File wikipagedir = new File( m_pageDirectory );
@@ -317,11 +370,14 @@
/**
* Iterates through all WikiPages, matches them against the given query,
* and returns a Collection of SearchResult objects.
+ *
+ * @param query {@inheritDoc}
+ * @return {@inheritDoc}
*/
public Collection findPages( QueryItem[] query )
{
File wikipagedir = new File( m_pageDirectory );
- TreeSet res = new TreeSet( new SearchResultComparator() );
+ TreeSet<SearchResult> res = new TreeSet<SearchResult>( new SearchResultComparator() );
SearchMatcher matcher = new SearchMatcher( m_engine, query );
File[] wikipages = wikipagedir.listFiles( new WikiFileFilter() );
@@ -368,6 +424,11 @@
/**
* Always returns the latest version, since FileSystemProvider
* does not support versioning.
+ *
+ * @param page {@inheritDoc}
+ * @param version {@inheritDoc}
+ * @return {@inheritDoc}
+ * @throws {@inheritDoc}
*/
public WikiPage getPageInfo( String page, int version )
throws ProviderException
@@ -387,22 +448,32 @@
/**
* The FileSystemProvider provides only one version.
+ *
+ * @param page {@inheritDoc}
+ * @throws {@inheritDoc}
+ * @return {@inheritDoc}
*/
public List getVersionHistory( String page )
throws ProviderException
{
- ArrayList list = new ArrayList();
+ ArrayList<WikiPage> list = new ArrayList<WikiPage>();
list.add( getPageInfo( page, WikiPageProvider.LATEST_VERSION ) );
return list;
}
+ /**
+ * {@inheritDoc}
+ */
public String getProviderInfo()
{
return "";
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteVersion( String pageName, int version )
throws ProviderException
{
@@ -414,6 +485,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public void deletePage( String pageName )
throws ProviderException
{
@@ -422,9 +496,16 @@
f.delete();
}
+ /**
+ * A simple filter which filters only those filenames which correspond to the
+ * file extension used.
+ */
public static class WikiFileFilter
implements FilenameFilter
{
+ /**
+ * {@inheritDoc}
+ */
public boolean accept( File dir, String name )
{
return name.endsWith( FILE_EXT );
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/BasicAttachmentProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/BasicAttachmentProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/BasicAttachmentProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/BasicAttachmentProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -78,6 +79,8 @@
{
private WikiEngine m_engine;
private String m_storageDir;
+
+ /** The property name for where the attachments should be stored. Value is <tt>{@value}</tt>. */
public static final String PROP_STORAGEDIR = "jspwiki.basicAttachmentProvider.storageDir";
/*
@@ -85,15 +88,24 @@
* since 2.5.96
*/
private Pattern m_disableCache = null;
+
+ /** The property name for specifying which attachments are not cached. Value is <tt>{@value}</tt>. */
public static final String PROP_DISABLECACHE = "jspwiki.basicAttachmentProvider.disableCache";
+ /** The name of the property file. */
public static final String PROPERTY_FILE = "attachment.properties";
+ /** The default extension for the page attachment directory name. */
public static final String DIR_EXTENSION = "-att";
+
+ /** The default extension for the attachment directory. */
public static final String ATTDIR_EXTENSION = "-dir";
static final Logger log = Logger.getLogger( BasicAttachmentProvider.class );
+ /**
+ * {@inheritDoc}
+ */
public void initialize( WikiEngine engine, Properties properties )
throws NoRequiredPropertyException,
IOException
@@ -248,6 +260,9 @@
* Returns the file extension. For example "test.png" returns "png".
* <p>
* If file has no extension, will return "bin"
+ *
+ * @param filename The file name to check
+ * @return The extension. If no extension is found, returns "bin".
*/
protected static String getFileExtension( String filename )
{
@@ -306,6 +321,9 @@
return props;
}
+ /**
+ * {@inheritDoc}
+ */
public void putAttachmentData( Attachment att, InputStream data )
throws ProviderException,
IOException
@@ -343,7 +361,7 @@
if( author == null )
{
- author = "unknown";
+ author = "unknown"; // FIXME: Should be localized, but cannot due to missing WikiContext
}
props.setProperty( versionNumber+".author", author );
@@ -367,6 +385,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public String getProviderInfo()
{
return "";
@@ -403,6 +424,9 @@
return f;
}
+ /**
+ * {@inheritDoc}
+ */
public InputStream getAttachmentData( Attachment att )
throws IOException,
ProviderException
@@ -422,10 +446,13 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Collection listAttachments( WikiPage page )
throws ProviderException
{
- Collection result = new ArrayList();
+ Collection<Attachment> result = new ArrayList<Attachment>();
File dir = findPageDir( page.getName() );
@@ -495,11 +522,17 @@
return result;
}
+ /**
+ * {@inheritDoc}
+ */
public Collection findAttachments( QueryItem[] query )
{
return null;
}
+ /**
+ * {@inheritDoc}
+ */
// FIXME: Very unoptimized.
public List listAllChanged( Date timestamp )
throws ProviderException
@@ -511,7 +544,7 @@
throw new ProviderException("Specified attachment directory "+m_storageDir+" does not exist!");
}
- ArrayList list = new ArrayList();
+ ArrayList<Attachment> list = new ArrayList<Attachment>();
String[] pagesWithAttachments = attDir.list( new AttachmentFilter() );
@@ -538,6 +571,9 @@
return list;
}
+ /**
+ * {@inheritDoc}
+ */
public Attachment getAttachmentInfo( WikiPage page, String name, int version )
throws ProviderException
{
@@ -600,9 +636,12 @@
return att;
}
+ /**
+ * {@inheritDoc}
+ */
public List getVersionHistory( Attachment att )
{
- ArrayList list = new ArrayList();
+ ArrayList<Attachment> list = new ArrayList<Attachment>();
try
{
@@ -628,13 +667,18 @@
return list;
}
-
+ /**
+ * {@inheritDoc}
+ */
public void deleteVersion( Attachment att )
throws ProviderException
{
// FIXME: Does nothing yet.
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteAttachment( Attachment att )
throws ProviderException
{
@@ -656,6 +700,9 @@
public static class AttachmentFilter
implements FilenameFilter
{
+ /**
+ * {@inheritDoc}
+ */
public boolean accept( File dir, String name )
{
return name.endsWith( DIR_EXTENSION );
@@ -668,12 +715,19 @@
public static class AttachmentVersionFilter
implements FilenameFilter
{
+ /**
+ * {@inheritDoc}
+ */
public boolean accept( File dir, String name )
{
return !name.equals( PROPERTY_FILE );
}
}
+ /**
+ * {@inheritDoc}
+ */
+
public void moveAttachmentsForPage( String oldParent, String newParent )
throws ProviderException
{
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -30,7 +31,9 @@
import com.ecyrd.jspwiki.attachment.AttachmentManager;
import com.ecyrd.jspwiki.util.ClassUtil;
import com.opensymphony.oscache.base.Cache;
+import com.opensymphony.oscache.base.CacheEntry;
import com.opensymphony.oscache.base.NeedsRefreshException;
+import com.opensymphony.oscache.base.events.*;
/**
* Provides a caching attachment provider. This class rests on top of a
@@ -38,7 +41,6 @@
* Attachment objects are cached; the actual attachment contents are
* fetched always from the provider.
*
- * @author Janne Jalkanen
* @since 2.1.64.
*/
@@ -61,16 +63,25 @@
private Cache m_cache;
private long m_cacheMisses = 0;
- private long m_cacheHits = 0;
+ private long m_cacheHits = 0;
+
+ /**
+ * This cache contains Attachment objects and is keyed by attachment name.
+ * This provides for quickly giving recently changed attachments (for the RecentChanges plugin)
+ */
+ private Cache m_attCache;
/** The extension to append to directory names to denote an attachment directory. */
public static final String DIR_EXTENSION = "-att";
-
+
/** Property that supplies the directory used to store attachments. */
public static final String PROP_STORAGEDIR = "jspwiki.basicAttachmentProvider.storageDir";
// FIXME: Make settable.
private int m_refreshPeriod = 60*10; // 10 minutes at the moment
+
+ private boolean m_gotall = false;
+ private CachedAttachmentCollector m_allCollector = new CachedAttachmentCollector();
/**
* {@inheritDoc}
@@ -79,14 +90,21 @@
throws NoRequiredPropertyException,
IOException
{
- log.debug("Initing CachingAttachmentProvider");
+ log.info("Initing CachingAttachmentProvider");
//
- // Construct an unlimited cache.
+ // Construct an unlimited cache of Collection objects
//
m_cache = new Cache( true, false, true );
//
+ // Construct an unlimited cache for the individual Attachment objects.
+ // Attachment name is key, the Attachment object is the cached object
+ //
+ m_attCache = new Cache(true, false, true);
+ m_attCache.addCacheEventListener(m_allCollector,CacheEntryEventListener.class);
+
+ //
// Find and initialize real provider.
//
String classname = WikiEngine.getRequiredProperty( properties,
@@ -130,6 +148,8 @@
m_provider.putAttachmentData( att, data );
m_cache.flushEntry( att.getParentName() );
+ att.setLastModified(new Date());
+ m_attCache.putInCache(att.getName(), att);
}
/**
@@ -145,13 +165,14 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
public Collection listAttachments( WikiPage page )
throws ProviderException
{
log.debug("Listing attachments for "+page);
try
{
- Collection c = (Collection)m_cache.getFromCache( page.getName(), m_refreshPeriod );
+ Collection<Attachment> c = (Collection<Attachment>)m_cache.getFromCache( page.getName(), m_refreshPeriod );
if( c != null )
{
@@ -168,7 +189,7 @@
{
try
{
- Collection c = refresh( page );
+ Collection<Attachment> c = refresh( page );
return cloneCollection(c);
}
@@ -187,9 +208,9 @@
return new ArrayList();
}
- private Collection cloneCollection( Collection c )
+ private <T> Collection<T> cloneCollection( Collection<T> c )
{
- ArrayList list = new ArrayList();
+ ArrayList<T> list = new ArrayList<T>();
list.addAll( c );
@@ -210,8 +231,31 @@
public List listAllChanged( Date timestamp )
throws ProviderException
{
- // FIXME: Should cache
- return m_provider.listAllChanged( timestamp );
+ List all = null;
+ //
+ // we do a one-time build up of the cache, after this the cache is updated for every attachment add/delete
+ if (m_gotall == false)
+ {
+ all = m_provider.listAllChanged(timestamp);
+
+ // Put all pages in the cache :
+
+ synchronized (this)
+ {
+ for (Iterator i = all.iterator(); i.hasNext();)
+ {
+ Attachment att = (Attachment) i.next();
+ m_attCache.putInCache(att.getName(), att);
+ }
+ m_gotall = true;
+ }
+ }
+ else
+ {
+ all = m_allCollector.getAllItems();
+ }
+
+ return all;
}
/**
@@ -240,11 +284,12 @@
*
* @return The newly fetched object from the provider.
*/
- private final Collection refresh( WikiPage page )
+ @SuppressWarnings("unchecked")
+ private final Collection<Attachment> refresh( WikiPage page )
throws ProviderException
{
m_cacheMisses++;
- Collection c = m_provider.listAttachments( page );
+ Collection<Attachment> c = m_provider.listAttachments( page );
m_cache.putInCache( page.getName(), c );
return c;
@@ -331,7 +376,7 @@
throws ProviderException
{
// This isn't strictly speaking correct, but it does not really matter
- m_cache.putInCache( att.getParentName(), null );
+ m_cache.removeEntry( att.getParentName() );
m_provider.deleteVersion( att );
}
@@ -341,7 +386,8 @@
public void deleteAttachment( Attachment att )
throws ProviderException
{
- m_cache.putInCache( att.getParentName(), null );
+ m_cache.removeEntry( att.getParentName() );
+ m_attCache.removeEntry( att.getName() );
m_provider.deleteAttachment( att );
}
@@ -356,7 +402,9 @@
}
/**
- * {@inheritDoc}
+ * Returns the WikiAttachmentProvider that this caching provider delegates to.
+ *
+ * @return The real provider underneath this one.
*/
public WikiAttachmentProvider getRealProvider()
{
@@ -370,7 +418,119 @@
throws ProviderException
{
m_provider.moveAttachmentsForPage(oldParent, newParent);
- m_cache.putInCache( newParent, null ); // FIXME
- m_cache.putInCache( oldParent, null );
+ m_cache.removeEntry( newParent );
+ m_cache.removeEntry( oldParent );
+
+ //
+ // This is a kludge to make sure that the pages are removed
+ // from the other cache as well.
+ //
+ String checkName = oldParent + "/";
+
+ Collection<String> names = cloneCollection( m_allCollector.m_allItems.keySet() );
+ for( String name : names )
+ {
+ if( name.startsWith( checkName ) )
+ {
+ m_attCache.removeEntry( name );
+ }
+ }
+ }
+
+ /**
+ * Keep a list of all Attachments in the OSCache (OSCache does not provide
+ * something like that) Idea copied from CacheItemCollector The cache is used to
+ * speed up the getRecentChanges function
+ *
+ * @author Harry Metske
+ * @since 2.5
+ */
+ private static class CachedAttachmentCollector implements CacheEntryEventListener
+ {
+ private static final Logger log = Logger.getLogger( CachedAttachmentCollector.class );
+
+ private Map<String, Attachment> m_allItems = new HashMap<String, Attachment>();
+
+ /**
+ * Returns a clone of the set - you cannot manipulate this.
+ *
+ * @return A list of all items.
+ */
+ public List<Attachment> getAllItems()
+ {
+ List<Attachment> ret = new LinkedList<Attachment>();
+ ret.addAll( m_allItems.values() );
+ log.info( "returning " + ret.size() + " attachments" );
+ return ret;
+ }
+
+ public void cacheEntryRemoved( CacheEntryEvent aEvent )
+ {
+ if( aEvent != null )
+ {
+ if( log.isDebugEnabled() )
+ {
+ log.debug( "attachment cache entry removed: " + aEvent.getKey() );
+ }
+
+ CacheEntry e = aEvent.getEntry();
+
+ if( e != null )
+ {
+ Attachment item = (Attachment) e.getContent();
+
+ if( item != null )
+ {
+ m_allItems.remove( item.getName() );
+ }
+ }
+ }
+ }
+
+ public void cacheEntryUpdated( CacheEntryEvent aEvent )
+ {
+ if( log.isDebugEnabled() )
+ {
+ log.debug( "attachment cache entry updated: " + aEvent.getKey() );
+ }
+
+ Attachment item = (Attachment) aEvent.getEntry().getContent();
+
+ if( item != null )
+ {
+ // Item added or replaced.
+ m_allItems.put( item.getName(), item );
+ }
+ else
+ {
+ m_allItems.remove( aEvent.getKey() );
+ }
+ }
+
+ public void cacheEntryAdded( CacheEntryEvent aEvent )
+ {
+ cacheEntryUpdated( aEvent );
+ }
+
+ public void cachePatternFlushed( CachePatternEvent aEvent )
+ {
+ // do nothing
+ }
+
+ public void cacheGroupFlushed( CacheGroupEvent aEvent )
+ {
+ // do nothing
+ }
+
+ public void cacheFlushed( CachewideEvent aEvent )
+ {
+ // do nothing
+ }
+
+ public void cacheEntryFlushed( CacheEntryEvent aEvent )
+ {
+ cacheEntryRemoved( aEvent );
+ }
}
+
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -46,7 +47,6 @@
* <p>
* Since 2.1.52 uses the OSCache library from OpenSymphony.
*
- * @author Janne Jalkanen
* @since 1.6.4
* @see RepositoryModifiedException
*/
@@ -95,13 +95,19 @@
*/
public static final String PROP_CACHECHECKINTERVAL = "jspwiki.cachingProvider.cacheCheckInterval";
+
+ /**
+ * The capacity of the cache.
+ */
public static final String PROP_CACHECAPACITY = "jspwiki.cachingProvider.capacity";
private static final int DEFAULT_CACHECAPACITY = 1000; // Good most wikis
private static final String OSCACHE_ALGORITHM = "com.opensymphony.oscache.base.algorithm.LRUCache";
-
+ /**
+ * {@inheritDoc}
+ */
public void initialize( WikiEngine engine, Properties properties )
throws NoRequiredPropertyException,
IOException
@@ -308,6 +314,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public boolean pageExists( String pageName, int version )
{
if( pageName == null ) return false;
@@ -378,6 +387,9 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
public boolean pageExists( String pageName )
{
if( pageName == null ) return false;
@@ -460,6 +472,7 @@
}
/**
+ * {@inheritDoc}
* @throws RepositoryModifiedException If the page has been externally modified.
*/
public String getPageText( String pageName, int version )
@@ -562,6 +575,9 @@
return text;
}
+ /**
+ * {@inheritDoc}
+ */
public void putPageText( WikiPage page, String text )
throws ProviderException
{
@@ -587,7 +603,9 @@
}
}
-
+ /**
+ * {@inheritDoc}
+ */
public Collection getAllPages()
throws ProviderException
{
@@ -621,17 +639,26 @@
return all;
}
+ /**
+ * {@inheritDoc}
+ */
public Collection getAllChangedSince( Date date )
{
return m_provider.getAllChangedSince( date );
}
+ /**
+ * {@inheritDoc}
+ */
public int getPageCount()
throws ProviderException
{
return m_provider.getPageCount();
}
+ /**
+ * {@inheritDoc}
+ */
public Collection findPages( QueryItem[] query )
{
//
@@ -658,7 +685,7 @@
{
String data = m_provider.getPageText(page.getName(), page.getVersion());
- WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( page );
+ WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, page );
MarkupParser parser = mgr.getParser( ctx, data );
parser.parse();
@@ -670,6 +697,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public WikiPage getPageInfo( String pageName, int version )
throws ProviderException,
RepositoryModifiedException
@@ -711,6 +741,9 @@
return page;
}
+ /**
+ * {@inheritDoc}
+ */
public List getVersionHistory( String pageName )
throws ProviderException
{
@@ -745,6 +778,9 @@
return history;
}
+ /**
+ * {@inheritDoc}
+ */
public synchronized String getProviderInfo()
{
return "Real provider: "+m_provider.getClass().getName()+
@@ -755,6 +791,9 @@
". Cache consistency checks: "+m_expiryPeriod+"s";
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteVersion( String pageName, int version )
throws ProviderException
{
@@ -783,6 +822,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public void deletePage( String pageName )
throws ProviderException
{
@@ -799,6 +841,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public void movePage( String from,
String to )
throws ProviderException
@@ -823,6 +868,7 @@
/**
* Returns the actual used provider.
* @since 2.0
+ * @return The real provider.
*/
public WikiPageProvider getRealProvider()
{
@@ -835,23 +881,22 @@
* of all pages currently in cache, we'll have to check this
* ourselves.
*
- * @author jalkanen
*
* @since 2.4
*/
private static class CacheItemCollector
implements CacheEntryEventListener
{
- private Map m_allItems = new HashMap();
+ private Map<String, WikiPage> m_allItems = new Hashtable<String, WikiPage>();
/**
* Returns a clone of the set - you cannot manipulate this.
*
- * @return
+ * @return A Set of WikiPage objects.
*/
public Set getAllItems()
{
- Set ret = new TreeSet();
+ Set<WikiPage> ret = new TreeSet<WikiPage>();
ret.addAll(m_allItems.values());
return ret;
@@ -885,7 +930,7 @@
if( item != null )
{
- m_allItems.remove( item );
+ m_allItems.remove( item.getName() );
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FastSearch.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FastSearch.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FastSearch.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FastSearch.java Sun Aug 3 05:22:13 2008
@@ -1,23 +1,23 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2003 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
/**
@@ -25,7 +25,6 @@
* will never attempt to search on its own; it will always pass any searches
* through to the actual provider.
*
- * @author Janne Jalkanen
* @since 2.1.57
*/
public interface FastSearch
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FileSystemProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FileSystemProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FileSystemProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/FileSystemProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -32,7 +33,6 @@
* who insist on using Windows or other software which makes assumptions
* on the files contents based on its name.
*
- * @author Janne Jalkanen
*/
public class FileSystemProvider
extends AbstractFileProvider
@@ -43,6 +43,9 @@
*/
public static final String PROP_EXT = ".properties";
+ /**
+ * {@inheritDoc}
+ */
public void putPageText( WikiPage page, String text )
throws ProviderException
{
@@ -129,6 +132,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public WikiPage getPageInfo( String page, int version )
throws ProviderException
{
@@ -150,6 +156,9 @@
return p;
}
+ /**
+ * {@inheritDoc}
+ */
public void deletePage(String pageName) throws ProviderException
{
super.deletePage(pageName);
@@ -160,6 +169,9 @@
if( file.exists() ) file.delete();
}
+ /**
+ * {@inheritDoc}
+ */
public void movePage( String from,
String to )
throws ProviderException
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/NoSuchVersionException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/NoSuchVersionException.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/NoSuchVersionException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/NoSuchVersionException.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+ 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
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
+ http://www.apache.org/licenses/LICENSE-2.0
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -27,6 +28,11 @@
{
private static final long serialVersionUID = 0L;
+ /**
+ * Creates a ProviderException.
+ *
+ * @param msg {@inheritDoc}
+ */
public NoSuchVersionException( String msg )
{
super( msg );
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/ProviderException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/ProviderException.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/ProviderException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/ProviderException.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -32,6 +33,11 @@
{
private static final long serialVersionUID = 0L;
+ /**
+ * Creates a ProviderException.
+ *
+ * @param msg {@inheritDoc}
+ */
public ProviderException( String msg )
{
super( msg );
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -50,8 +51,6 @@
* If you decide to dabble with the default commands, please make sure
* that you do not check the default archive suffix ",v". File deletion
* depends on it.
- *
- * @author Janne Jalkanen
*/
// FIXME: Not all commands read their format from the property file yet.
public class RCSFileProvider
@@ -66,10 +65,19 @@
private static final Logger log = Logger.getLogger(RCSFileProvider.class);
+ /** Property name for the checkin command. Value is <tt>{@value}</tt>. */
public static final String PROP_CHECKIN = "jspwiki.rcsFileProvider.checkinCommand";
+
+ /** Property name for the checkout command. Value is <tt>{@value}</tt>. */
public static final String PROP_CHECKOUT = "jspwiki.rcsFileProvider.checkoutCommand";
+
+ /** Property name for the log command. Value is <tt>{@value}</tt>. */
public static final String PROP_LOG = "jspwiki.rcsFileProvider.logCommand";
+
+ /** Property name for the full log command. Value is <tt>{@value}</tt>. */
public static final String PROP_FULLLOG = "jspwiki.rcsFileProvider.fullLogCommand";
+
+ /** Property name for the checkout version command. Value is <tt>{@value}</tt>. */
public static final String PROP_CHECKOUTVERSION = "jspwiki.rcsFileProvider.checkoutVersionCommand";
private static final String PATTERN_DATE = "^date:\\s*(.*\\d);";
@@ -82,8 +90,11 @@
// Date format parsers, placed here to save on object creation
private SimpleDateFormat m_rcsdatefmt = new SimpleDateFormat( RCSFMT_DATE );
- private SimpleDateFormat m_rcsdatefmt_utc = new SimpleDateFormat( RCSFMT_DATE_UTC );
+ private SimpleDateFormat m_rcsdatefmtUTC = new SimpleDateFormat( RCSFMT_DATE_UTC );
+ /**
+ * {@inheritDoc}
+ */
public void initialize( WikiEngine engine, Properties props )
throws NoRequiredPropertyException,
IOException
@@ -111,6 +122,9 @@
log.debug("checkoutversion="+m_checkoutVersionCommand);
}
+ /**
+ * {@inheritDoc}
+ */
// NB: This is a very slow method.
public WikiPage getPageInfo( String page, int version )
@@ -238,6 +252,9 @@
return info;
}
+ /**
+ * {@inheritDoc}
+ */
public String getPageText( String page, int version )
throws ProviderException
{
@@ -354,6 +371,10 @@
/**
* Puts the page into RCS and makes sure there is a fresh copy in
* the directory as well.
+ *
+ * @param page {@inheritDoc}
+ * @param text {@inheritDoc}
+ * @throws {@inheritDoc}
*/
public void putPageText( WikiPage page, String text )
throws ProviderException
@@ -370,7 +391,7 @@
String cmd = m_checkinCommand;
String author = page.getAuthor();
- if( author == null ) author = "unknown";
+ if( author == null ) author = "unknown"; // Should be localized but cannot due to missing WikiContext
String changenote = (String)page.getAttribute(WikiPage.CHANGENOTE);
if( changenote == null ) changenote = "";
@@ -434,6 +455,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
// FIXME: Put the rcs date formats into properties as well.
public List getVersionHistory( String page )
{
@@ -443,7 +467,7 @@
log.debug("Getting RCS version history");
- ArrayList list = new ArrayList();
+ ArrayList<WikiPage> list = new ArrayList<WikiPage>();
try
{
@@ -482,7 +506,7 @@
list.add( info );
}
- if( matcher.contains( line, datepattern ) )
+ if( matcher.contains( line, datepattern ) && info != null )
{
MatchResult result = matcher.getMatch();
@@ -491,14 +515,14 @@
info.setLastModified( d );
}
- if( matcher.contains( line, userpattern ) )
+ if( matcher.contains( line, userpattern ) && info != null )
{
MatchResult result = matcher.getMatch();
info.setAuthor( TextUtil.urlDecodeUTF8(result.group(1)) );
}
- if( matcher.contains( line, notepattern ) )
+ if( matcher.contains( line, notepattern ) && info != null )
{
MatchResult result = matcher.getMatch();
@@ -544,6 +568,9 @@
/**
* Removes the page file and the RCS archive from the repository.
* This method assumes that the page archive ends with ",v".
+ *
+ * @param page {@inheritDoc}
+ * @throws {@inheritDoc}
*/
public void deletePage( String page )
throws ProviderException
@@ -575,6 +602,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public void deleteVersion( String page, int version )
{
String line = "<rcs not run>";
@@ -642,7 +672,7 @@
* util method to parse a date string in Local and UTC formats. This method is synchronized
* because SimpleDateFormat is not thread-safe.
*
- * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228335
+ * @see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228335">Sun bug 4228335</a>
*/
private synchronized Date parseDate( String str )
{
@@ -658,7 +688,7 @@
try
{
- d = m_rcsdatefmt_utc.parse( str );
+ d = m_rcsdatefmtUTC.parse( str );
return d;
}
catch ( ParseException pe )
@@ -667,6 +697,9 @@
return d;
}
+ /**
+ * {@inheritDoc}
+ */
public void movePage( String from,
String to )
throws ProviderException
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RepositoryModifiedException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RepositoryModifiedException.java?rev=682148&r1=682147&r2=682148&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RepositoryModifiedException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/RepositoryModifiedException.java Sun Aug 3 05:22:13 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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 com.ecyrd.jspwiki.providers;
@@ -28,7 +29,6 @@
* the page is handled as completely, and we don't get the same exception
* again.
*
- * @author Janne Jalkanen
* @since 2.1.25
*/
public class RepositoryModifiedException
@@ -41,7 +41,7 @@
/**
* Constructs the exception.
*
- * @param msg
+ * @param msg The message
* @param pageName The name of the page which was modified
*/
public RepositoryModifiedException( String msg, String pageName )
@@ -51,6 +51,11 @@
m_page = pageName;
}
+ /**
+ * Return the page name given in the constructor.
+ *
+ * @return The page name.
+ */
public String getPageName()
{
return m_page;