001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018 */ 019package org.apache.wiki.api.providers; 020 021import org.apache.wiki.api.core.Page; 022import org.apache.wiki.api.exceptions.ProviderException; 023import org.apache.wiki.api.search.QueryItem; 024import org.apache.wiki.api.search.SearchResult; 025 026import java.util.Collection; 027import java.util.Date; 028import java.util.List; 029 030 031/** 032 * Each Wiki page provider should implement this interface. 033 * <P> 034 * You can build whatever page providers based on this, just leave the unused methods do something useful. 035 * <P> 036 * WikiPageProvider uses Strings and ints to refer to pages. This may be a bit odd, since WikiAttachmentProviders all use Attachment 037 * instead of name/version. We will perhaps modify these in the future. In the mean time, name/version is quite sufficient. 038 * <P> 039 * FIXME: In reality we should have an AbstractWikiPageProvider, which would provide intelligent backups for subclasses. 040 */ 041public interface PageProvider extends WikiProvider { 042 043 /** 044 * Attempts to save the page text for page "page". Note that the provider creates a new version regardless of what the version 045 * parameter of the WikiPage is. 046 * 047 * @param page The WikiPage to save 048 * @param text The text to save. 049 * @throws ProviderException If something goes wrong. 050 */ 051 void putPageText( Page page, String text ) throws ProviderException; 052 053 /** 054 * Return true, if page exists. 055 * 056 * @param page The page name. 057 * @return true, if the page exists; false otherwise. 058 */ 059 boolean pageExists( String page ); 060 061 /** 062 * Return true, if page with a particular version exists. 063 * 064 * @param page The page name to check for 065 * @param version The version to check 066 * @return True, if page exists; false otherwise. 067 */ 068 boolean pageExists( String page, int version ); 069 070 /** 071 * Finds pages based on the query. Only applicable to providers which implement the FastSearch interface. Otherwise JSPWiki 072 * will use its internal cache. 073 * <p> 074 * This method should really be a part of the FastSearch IF. 075 * 076 * @param query An array of QueryItems to match 077 * @return A Collection of WikiPages. 078 */ 079 Collection< SearchResult > findPages( QueryItem[] query ); 080 081 /** 082 * Returns info about the page. 083 * 084 * @return A filled WikiPage. 085 * @param page The page name 086 * @param version The version number 087 * @throws ProviderException If something goes wrong. 088 */ 089 Page getPageInfo( String page, int version ) throws ProviderException; 090 091 /** 092 * Returns all pages. Each element in the returned Collection should be a WikiPage. 093 * 094 * @return A collection of WikiPages 095 * @throws ProviderException If something goes wrong. 096 */ 097 Collection< Page > getAllPages() throws ProviderException; 098 099 /** 100 * Gets a list of recent changes. 101 * 102 * @param date The date to check from 103 * @return A Collection of WikiPages 104 * @since 1.6.4 105 */ 106 Collection< Page > getAllChangedSince( Date date ); 107 108 /** 109 * Gets the number of pages. 110 * 111 * @return The number of pages in the repository 112 * @throws ProviderException If something goes wrong 113 * @since 1.6.4 114 */ 115 int getPageCount() throws ProviderException; 116 117 /** 118 * Returns version history. Each element should be a WikiPage. 119 * 120 * @param page The name of the page to get the history from. 121 * @return A collection of WikiPages. 122 * @throws ProviderException If something goes wrong. 123 */ 124 List< Page > getVersionHistory( String page ) throws ProviderException; 125 126 /** 127 * Gets a specific version out of the repository. 128 * 129 * @param page Name of the page to fetch. 130 * @param version Version of the page to fetch. 131 * @return The content of the page, or null, if the page does not exist. 132 * @throws ProviderException If something goes wrong. 133 */ 134 String getPageText( String page, int version ) throws ProviderException; 135 136 /** 137 * Removes a specific version from the repository. The implementations should really do no more security checks, since that is the 138 * domain of the PageManager. Just delete it as efficiently as you can. 139 * 140 * @since 2.0.17. 141 * @param pageName Name of the page to be removed. 142 * @param version Version of the page to be removed. May be LATEST_VERSION. 143 * @throws ProviderException If the page cannot be removed for some reason. 144 */ 145 void deleteVersion( String pageName, int version ) throws ProviderException; 146 147 /** 148 * Removes an entire page from the repository. The implementations should really do no more security checks, since that is the domain 149 * of the PageManager. Just delete it as efficiently as you can. You should also delete any auxiliary files that belong to this page, 150 * IF they were created by this provider. 151 * 152 * <P>The reason why this is named differently from deleteVersion() (logically, this method should be an overloaded version) is that 153 * I want to be absolutely sure I don't accidentally use the wrong method. With overloading something like that happens sometimes... 154 * 155 * @since 2.0.17. 156 * @param pageName Name of the page to be removed completely. 157 * @throws ProviderException If the page could not be removed for some reason. 158 */ 159 void deletePage( String pageName ) throws ProviderException; 160 161 /** 162 * Move a page 163 * 164 * @param from Name of the page to move. 165 * @param to New name of the page. 166 * @throws ProviderException If the page could not be moved for some reason. 167 */ 168 void movePage( String from, String to ) throws ProviderException; 169 170}