001: package com.ecyrd.jspwiki.providers;
002:
003: import java.util.*;
004: import com.ecyrd.jspwiki.*;
005:
006: /**
007: * This is a simple provider that is used by some of the tests. It has some
008: * specific behaviours, like it always contains a single page.
009: */
010: public class VerySimpleProvider implements WikiPageProvider {
011: /** The last request is stored here. */
012: public String m_latestReq = null;
013: /** The version number of the last request is stored here. */
014: public int m_latestVers = -123989;
015:
016: /**
017: * This provider has only a single page, when you ask
018: * a list of all pages.
019: */
020: public static final String PAGENAME = "foo";
021:
022: /**
023: * The name of the page list.
024: */
025: public static final String AUTHOR = "default-author";
026:
027: private WikiEngine m_engine;
028:
029: public void initialize(WikiEngine engine, Properties props) {
030: m_engine = engine;
031: }
032:
033: public String getProviderInfo() {
034: return "Very Simple Provider.";
035: }
036:
037: public void putPageText(WikiPage page, String text)
038: throws ProviderException {
039: }
040:
041: /**
042: * Always returns true.
043: */
044: public boolean pageExists(String page) {
045: return true;
046: }
047:
048: /**
049: * Always returns null.
050: */
051: public Collection findPages(QueryItem[] query) {
052: return null;
053: }
054:
055: /**
056: * Returns always a valid WikiPage.
057: */
058: public WikiPage getPageInfo(String page, int version) {
059: m_latestReq = page;
060: m_latestVers = version;
061:
062: WikiPage p = new WikiPage(m_engine, page);
063: p.setVersion(5);
064: p.setAuthor(AUTHOR);
065: p.setLastModified(new Date(0L));
066: return p;
067: }
068:
069: /**
070: * Returns a single page.
071: */
072: public Collection getAllPages() {
073: Vector v = new Vector();
074: v.add(getPageInfo(PAGENAME, 5));
075: return v;
076: }
077:
078: /**
079: * Returns the same as getAllPages().
080: */
081: public Collection getAllChangedSince(Date date) {
082: return getAllPages();
083: }
084:
085: /**
086: * Always returns 1.
087: */
088: public int getPageCount() {
089: return 1;
090: }
091:
092: /**
093: * Always returns an empty list.
094: */
095: public List getVersionHistory(String page) {
096: return new Vector();
097: }
098:
099: /**
100: * Stores the page and version into public fields of this class,
101: * then returns an empty string.
102: */
103: public String getPageText(String page, int version) {
104: m_latestReq = page;
105: m_latestVers = version;
106:
107: return "";
108: }
109:
110: public void deleteVersion(String page, int version) {
111: }
112:
113: public void deletePage(String page) {
114: }
115:
116: /* (non-Javadoc)
117: * @see com.ecyrd.jspwiki.providers.WikiPageProvider#movePage(java.lang.String, java.lang.String)
118: */
119: public void movePage(String from, String to)
120: throws ProviderException {
121: // TODO Auto-generated method stub
122:
123: }
124:
125: }
|