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 |
package org.sonews.storage;
|
chris@3
|
19 |
|
chris@3
|
20 |
import java.util.List;
|
chris@3
|
21 |
import org.sonews.feed.Subscription;
|
chris@3
|
22 |
import org.sonews.util.Pair;
|
chris@3
|
23 |
|
chris@3
|
24 |
/**
|
chris@3
|
25 |
* A generic storage backend interface.
|
chris@3
|
26 |
* @author Christian Lins
|
chris@3
|
27 |
* @since sonews/1.0
|
chris@3
|
28 |
*/
|
cli@42
|
29 |
public interface Storage {
|
chris@3
|
30 |
|
cli@37
|
31 |
/**
|
cli@37
|
32 |
* Stores the given Article in the storage.
|
cli@37
|
33 |
* @param art
|
cli@37
|
34 |
* @throws StorageBackendException
|
cli@37
|
35 |
*/
|
cli@37
|
36 |
void addArticle(Article art)
|
cli@42
|
37 |
throws StorageBackendException;
|
chris@3
|
38 |
|
cli@37
|
39 |
void addEvent(long timestamp, int type, long groupID)
|
cli@42
|
40 |
throws StorageBackendException;
|
chris@3
|
41 |
|
cli@37
|
42 |
void addGroup(String groupname, int flags)
|
cli@42
|
43 |
throws StorageBackendException;
|
chris@3
|
44 |
|
cli@37
|
45 |
int countArticles()
|
cli@42
|
46 |
throws StorageBackendException;
|
chris@3
|
47 |
|
cli@37
|
48 |
int countGroups()
|
cli@42
|
49 |
throws StorageBackendException;
|
chris@3
|
50 |
|
cli@37
|
51 |
void delete(String messageID)
|
cli@42
|
52 |
throws StorageBackendException;
|
chris@3
|
53 |
|
cli@37
|
54 |
Article getArticle(String messageID)
|
cli@42
|
55 |
throws StorageBackendException;
|
chris@3
|
56 |
|
cli@37
|
57 |
Article getArticle(long articleIndex, long groupID)
|
cli@42
|
58 |
throws StorageBackendException;
|
chris@3
|
59 |
|
cli@37
|
60 |
List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
|
cli@42
|
61 |
throws StorageBackendException;
|
chris@3
|
62 |
|
cli@48
|
63 |
List<Pair<Long, String>> getArticleHeaders(Group group, long start, long end,
|
cli@42
|
64 |
String header, String pattern)
|
cli@42
|
65 |
throws StorageBackendException;
|
chris@3
|
66 |
|
cli@37
|
67 |
long getArticleIndex(Article art, Group group)
|
cli@42
|
68 |
throws StorageBackendException;
|
chris@3
|
69 |
|
cli@37
|
70 |
List<Long> getArticleNumbers(long groupID)
|
cli@42
|
71 |
throws StorageBackendException;
|
chris@3
|
72 |
|
cli@37
|
73 |
String getConfigValue(String key)
|
cli@42
|
74 |
throws StorageBackendException;
|
chris@3
|
75 |
|
cli@37
|
76 |
int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
|
cli@48
|
77 |
Group group)
|
cli@42
|
78 |
throws StorageBackendException;
|
chris@3
|
79 |
|
cli@37
|
80 |
double getEventsPerHour(int key, long gid)
|
cli@42
|
81 |
throws StorageBackendException;
|
chris@3
|
82 |
|
cli@37
|
83 |
int getFirstArticleNumber(Group group)
|
cli@42
|
84 |
throws StorageBackendException;
|
chris@3
|
85 |
|
cli@37
|
86 |
Group getGroup(String name)
|
cli@42
|
87 |
throws StorageBackendException;
|
chris@3
|
88 |
|
cli@48
|
89 |
List<Group> getGroups()
|
cli@42
|
90 |
throws StorageBackendException;
|
chris@3
|
91 |
|
cli@37
|
92 |
/**
|
cli@37
|
93 |
* Retrieves the collection of groupnames that are associated with the
|
cli@37
|
94 |
* given list address.
|
cli@37
|
95 |
* @param inetaddress
|
cli@37
|
96 |
* @return
|
cli@37
|
97 |
* @throws StorageBackendException
|
cli@37
|
98 |
*/
|
cli@37
|
99 |
List<String> getGroupsForList(String listAddress)
|
cli@42
|
100 |
throws StorageBackendException;
|
chris@3
|
101 |
|
cli@37
|
102 |
int getLastArticleNumber(Group group)
|
cli@42
|
103 |
throws StorageBackendException;
|
chris@3
|
104 |
|
cli@37
|
105 |
/**
|
cli@37
|
106 |
* Returns a list of email addresses that are related to the given
|
cli@37
|
107 |
* groupname. In most cases the list may contain only one entry.
|
cli@37
|
108 |
* @param groupname
|
cli@37
|
109 |
* @return
|
cli@37
|
110 |
* @throws StorageBackendException
|
cli@37
|
111 |
*/
|
cli@37
|
112 |
List<String> getListsForGroup(String groupname)
|
cli@42
|
113 |
throws StorageBackendException;
|
chris@3
|
114 |
|
cli@37
|
115 |
String getOldestArticle()
|
cli@42
|
116 |
throws StorageBackendException;
|
chris@3
|
117 |
|
cli@37
|
118 |
int getPostingsCount(String groupname)
|
cli@42
|
119 |
throws StorageBackendException;
|
chris@3
|
120 |
|
cli@37
|
121 |
List<Subscription> getSubscriptions(int type)
|
cli@42
|
122 |
throws StorageBackendException;
|
chris@3
|
123 |
|
cli@37
|
124 |
boolean isArticleExisting(String messageID)
|
cli@42
|
125 |
throws StorageBackendException;
|
chris@3
|
126 |
|
cli@37
|
127 |
boolean isGroupExisting(String groupname)
|
cli@42
|
128 |
throws StorageBackendException;
|
chris@3
|
129 |
|
cli@37
|
130 |
void purgeGroup(Group group)
|
cli@42
|
131 |
throws StorageBackendException;
|
chris@3
|
132 |
|
cli@37
|
133 |
void setConfigValue(String key, String value)
|
cli@42
|
134 |
throws StorageBackendException;
|
chris@3
|
135 |
|
cli@37
|
136 |
/**
|
cli@37
|
137 |
* Updates headers and channel references of the given article.
|
cli@37
|
138 |
* @param article
|
cli@37
|
139 |
* @return
|
cli@37
|
140 |
* @throws StorageBackendException
|
cli@37
|
141 |
*/
|
cli@37
|
142 |
boolean update(Article article)
|
cli@42
|
143 |
throws StorageBackendException;
|
cli@24
|
144 |
|
cli@37
|
145 |
boolean update(Group group)
|
cli@42
|
146 |
throws StorageBackendException;
|
chris@3
|
147 |
}
|