chris@3: /*
chris@3:  *   SONEWS News Server
chris@3:  *   see AUTHORS for the list of contributors
chris@3:  *
chris@3:  *   This program is free software: you can redistribute it and/or modify
chris@3:  *   it under the terms of the GNU General Public License as published by
chris@3:  *   the Free Software Foundation, either version 3 of the License, or
chris@3:  *   (at your option) any later version.
chris@3:  *
chris@3:  *   This program is distributed in the hope that it will be useful,
chris@3:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
chris@3:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
chris@3:  *   GNU General Public License for more details.
chris@3:  *
chris@3:  *   You should have received a copy of the GNU General Public License
chris@3:  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
chris@3:  */
chris@3: package org.sonews.storage;
chris@3: 
chris@3: import java.util.List;
chris@3: import org.sonews.feed.Subscription;
chris@3: import org.sonews.util.Pair;
chris@3: 
chris@3: /**
chris@3:  * A generic storage backend interface.
chris@3:  * @author Christian Lins
chris@3:  * @since sonews/1.0
chris@3:  */
cli@42: public interface Storage {
chris@3: 
cli@37: 	/**
cli@37: 	 * Stores the given Article in the storage.
cli@37: 	 * @param art
cli@37: 	 * @throws StorageBackendException
cli@37: 	 */
cli@37: 	void addArticle(Article art)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	void addEvent(long timestamp, int type, long groupID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	void addGroup(String groupname, int flags)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int countArticles()
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int countGroups()
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	void delete(String messageID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	Article getArticle(String messageID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	Article getArticle(long articleIndex, long groupID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@48: 	List<Pair<Long, String>> getArticleHeaders(Group group, long start, long end,
cli@42: 			String header, String pattern)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	long getArticleIndex(Article art, Group group)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	List<Long> getArticleNumbers(long groupID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	String getConfigValue(String key)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
cli@48: 			Group group)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	double getEventsPerHour(int key, long gid)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int getFirstArticleNumber(Group group)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	Group getGroup(String name)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@48: 	List<Group> getGroups()
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	/**
cli@37: 	 * Retrieves the collection of groupnames that are associated with the
cli@37: 	 * given list address.
cli@37: 	 * @param inetaddress
cli@37: 	 * @return
cli@37: 	 * @throws StorageBackendException
cli@37: 	 */
cli@37: 	List<String> getGroupsForList(String listAddress)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int getLastArticleNumber(Group group)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	/**
cli@37: 	 * Returns a list of email addresses that are related to the given
cli@37: 	 * groupname. In most cases the list may contain only one entry.
cli@37: 	 * @param groupname
cli@37: 	 * @return
cli@37: 	 * @throws StorageBackendException
cli@37: 	 */
cli@37: 	List<String> getListsForGroup(String groupname)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	String getOldestArticle()
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	int getPostingsCount(String groupname)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	List<Subscription> getSubscriptions(int type)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	boolean isArticleExisting(String messageID)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	boolean isGroupExisting(String groupname)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	void purgeGroup(Group group)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	void setConfigValue(String key, String value)
cli@42: 			throws StorageBackendException;
chris@3: 
cli@37: 	/**
cli@37: 	 * Updates headers and channel references of the given article.
cli@37: 	 * @param article
cli@37: 	 * @return
cli@37: 	 * @throws StorageBackendException
cli@37: 	 */
cli@37: 	boolean update(Article article)
cli@42: 			throws StorageBackendException;
cli@24: 
cli@37: 	boolean update(Group group)
cli@42: 			throws StorageBackendException;
chris@3: }