src/org/sonews/storage/Storage.java
author cli
Sun, 29 Aug 2010 23:23:15 +0200
changeset 38 fdfc7225f799
parent 37 74139325d305
child 42 7f84f4de2893
permissions -rw-r--r--
Implement JDBCDatabase.update(Article) method to fix issue #7.
chris@3
     1
/*
chris@3
     2
 *   SONEWS News Server
chris@3
     3
 *   see AUTHORS for the list of contributors
chris@3
     4
 *
chris@3
     5
 *   This program is free software: you can redistribute it and/or modify
chris@3
     6
 *   it under the terms of the GNU General Public License as published by
chris@3
     7
 *   the Free Software Foundation, either version 3 of the License, or
chris@3
     8
 *   (at your option) any later version.
chris@3
     9
 *
chris@3
    10
 *   This program is distributed in the hope that it will be useful,
chris@3
    11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
chris@3
    12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
chris@3
    13
 *   GNU General Public License for more details.
chris@3
    14
 *
chris@3
    15
 *   You should have received a copy of the GNU General Public License
chris@3
    16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
chris@3
    17
 */
chris@3
    18
chris@3
    19
package org.sonews.storage;
chris@3
    20
chris@3
    21
import java.util.List;
chris@3
    22
import org.sonews.feed.Subscription;
chris@3
    23
import org.sonews.util.Pair;
chris@3
    24
chris@3
    25
/**
chris@3
    26
 * A generic storage backend interface.
chris@3
    27
 * @author Christian Lins
chris@3
    28
 * @since sonews/1.0
chris@3
    29
 */
chris@3
    30
public interface Storage
chris@3
    31
{
chris@3
    32
cli@37
    33
	/**
cli@37
    34
	 * Stores the given Article in the storage.
cli@37
    35
	 * @param art
cli@37
    36
	 * @throws StorageBackendException
cli@37
    37
	 */
cli@37
    38
	void addArticle(Article art)
cli@37
    39
		throws StorageBackendException;
chris@3
    40
cli@37
    41
	void addEvent(long timestamp, int type, long groupID)
cli@37
    42
		throws StorageBackendException;
chris@3
    43
cli@37
    44
	void addGroup(String groupname, int flags)
cli@37
    45
		throws StorageBackendException;
chris@3
    46
cli@37
    47
	int countArticles()
cli@37
    48
		throws StorageBackendException;
chris@3
    49
cli@37
    50
	int countGroups()
cli@37
    51
		throws StorageBackendException;
chris@3
    52
cli@37
    53
	void delete(String messageID)
cli@37
    54
		throws StorageBackendException;
chris@3
    55
cli@37
    56
	Article getArticle(String messageID)
cli@37
    57
		throws StorageBackendException;
chris@3
    58
cli@37
    59
	Article getArticle(long articleIndex, long groupID)
cli@37
    60
		throws StorageBackendException;
chris@3
    61
cli@37
    62
	List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
cli@37
    63
		throws StorageBackendException;
chris@3
    64
cli@37
    65
	List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end,
cli@37
    66
		String header, String pattern)
cli@37
    67
		throws StorageBackendException;
chris@3
    68
cli@37
    69
	long getArticleIndex(Article art, Group group)
cli@37
    70
		throws StorageBackendException;
chris@3
    71
cli@37
    72
	List<Long> getArticleNumbers(long groupID)
cli@37
    73
		throws StorageBackendException;
chris@3
    74
cli@37
    75
	String getConfigValue(String key)
cli@37
    76
		throws StorageBackendException;
chris@3
    77
cli@37
    78
	int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
cli@37
    79
		Channel channel)
cli@37
    80
		throws StorageBackendException;
chris@3
    81
cli@37
    82
	double getEventsPerHour(int key, long gid)
cli@37
    83
		throws StorageBackendException;
chris@3
    84
cli@37
    85
	int getFirstArticleNumber(Group group)
cli@37
    86
		throws StorageBackendException;
chris@3
    87
cli@37
    88
	Group getGroup(String name)
cli@37
    89
		throws StorageBackendException;
chris@3
    90
cli@37
    91
	List<Channel> getGroups()
cli@37
    92
		throws StorageBackendException;
chris@3
    93
cli@37
    94
	/**
cli@37
    95
	 * Retrieves the collection of groupnames that are associated with the
cli@37
    96
	 * given list address.
cli@37
    97
	 * @param inetaddress
cli@37
    98
	 * @return
cli@37
    99
	 * @throws StorageBackendException
cli@37
   100
	 */
cli@37
   101
	List<String> getGroupsForList(String listAddress)
cli@37
   102
		throws StorageBackendException;
chris@3
   103
cli@37
   104
	int getLastArticleNumber(Group group)
cli@37
   105
		throws StorageBackendException;
chris@3
   106
cli@37
   107
	/**
cli@37
   108
	 * Returns a list of email addresses that are related to the given
cli@37
   109
	 * groupname. In most cases the list may contain only one entry.
cli@37
   110
	 * @param groupname
cli@37
   111
	 * @return
cli@37
   112
	 * @throws StorageBackendException
cli@37
   113
	 */
cli@37
   114
	List<String> getListsForGroup(String groupname)
cli@37
   115
		throws StorageBackendException;
chris@3
   116
cli@37
   117
	String getOldestArticle()
cli@37
   118
		throws StorageBackendException;
chris@3
   119
cli@37
   120
	int getPostingsCount(String groupname)
cli@37
   121
		throws StorageBackendException;
chris@3
   122
cli@37
   123
	List<Subscription> getSubscriptions(int type)
cli@37
   124
		throws StorageBackendException;
chris@3
   125
cli@37
   126
	boolean isArticleExisting(String messageID)
cli@37
   127
		throws StorageBackendException;
chris@3
   128
cli@37
   129
	boolean isGroupExisting(String groupname)
cli@37
   130
		throws StorageBackendException;
chris@3
   131
cli@37
   132
	void purgeGroup(Group group)
cli@37
   133
		throws StorageBackendException;
chris@3
   134
cli@37
   135
	void setConfigValue(String key, String value)
cli@37
   136
		throws StorageBackendException;
chris@3
   137
cli@37
   138
	/**
cli@37
   139
	 * Updates headers and channel references of the given article.
cli@37
   140
	 * @param article
cli@37
   141
	 * @return
cli@37
   142
	 * @throws StorageBackendException
cli@37
   143
	 */
cli@37
   144
	boolean update(Article article)
cli@37
   145
		throws StorageBackendException;
cli@24
   146
cli@37
   147
	boolean update(Group group)
cli@37
   148
		throws StorageBackendException;
chris@3
   149
}