franta-hg@63
|
1 |
/*
|
franta-hg@63
|
2 |
* SONEWS News Server
|
franta-hg@63
|
3 |
* see AUTHORS for the list of contributors
|
franta-hg@63
|
4 |
*
|
franta-hg@63
|
5 |
* This program is free software: you can redistribute it and/or modify
|
franta-hg@63
|
6 |
* it under the terms of the GNU General Public License as published by
|
franta-hg@63
|
7 |
* the Free Software Foundation, either version 3 of the License, or
|
franta-hg@63
|
8 |
* (at your option) any later version.
|
franta-hg@63
|
9 |
*
|
franta-hg@63
|
10 |
* This program is distributed in the hope that it will be useful,
|
franta-hg@63
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
franta-hg@63
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
franta-hg@63
|
13 |
* GNU General Public License for more details.
|
franta-hg@63
|
14 |
*
|
franta-hg@63
|
15 |
* You should have received a copy of the GNU General Public License
|
franta-hg@63
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
franta-hg@63
|
17 |
*/
|
franta-hg@63
|
18 |
package org.sonews.storage.impl;
|
franta-hg@63
|
19 |
|
franta-hg@68
|
20 |
import java.io.UnsupportedEncodingException;
|
franta-hg@68
|
21 |
import java.sql.Connection;
|
franta-hg@68
|
22 |
import java.sql.DriverManager;
|
franta-hg@68
|
23 |
import java.sql.PreparedStatement;
|
franta-hg@68
|
24 |
import java.sql.ResultSet;
|
franta-hg@64
|
25 |
import java.sql.SQLException;
|
franta-hg@68
|
26 |
import java.sql.Statement;
|
franta-hg@68
|
27 |
import java.util.ArrayList;
|
franta-hg@65
|
28 |
import java.util.Collections;
|
franta-hg@64
|
29 |
import java.util.List;
|
franta-hg@65
|
30 |
import java.util.logging.Level;
|
franta-hg@66
|
31 |
import java.util.logging.Logger;
|
franta-hg@68
|
32 |
import javax.mail.internet.MimeUtility;
|
franta-hg@68
|
33 |
import org.sonews.config.Config;
|
franta-hg@64
|
34 |
import org.sonews.feed.Subscription;
|
franta-hg@64
|
35 |
import org.sonews.storage.Article;
|
franta-hg@64
|
36 |
import org.sonews.storage.ArticleHead;
|
franta-hg@64
|
37 |
import org.sonews.storage.Group;
|
franta-hg@64
|
38 |
import org.sonews.storage.Storage;
|
franta-hg@64
|
39 |
import org.sonews.storage.StorageBackendException;
|
franta-hg@64
|
40 |
import org.sonews.util.Pair;
|
franta-hg@64
|
41 |
|
franta-hg@63
|
42 |
/**
|
franta-hg@63
|
43 |
*
|
franta-hg@63
|
44 |
* @author František Kučera (frantovo.cz)
|
franta-hg@63
|
45 |
*/
|
franta-hg@64
|
46 |
public class DrupalDatabase implements Storage {
|
franta-hg@67
|
47 |
|
franta-hg@66
|
48 |
private static final Logger log = Logger.getLogger(DrupalDatabase.class.getName());
|
franta-hg@68
|
49 |
public static final String CRLF = "\r\n";
|
franta-hg@68
|
50 |
public static final int MAX_RESTARTS = 2;
|
franta-hg@68
|
51 |
/** How many times the database connection was reinitialized */
|
franta-hg@68
|
52 |
protected int restarts = 0;
|
franta-hg@68
|
53 |
protected Connection conn = null;
|
franta-hg@68
|
54 |
|
franta-hg@68
|
55 |
public DrupalDatabase() throws StorageBackendException {
|
franta-hg@68
|
56 |
connectDatabase();
|
franta-hg@68
|
57 |
}
|
franta-hg@68
|
58 |
|
franta-hg@68
|
59 |
private void connectDatabase() throws StorageBackendException {
|
franta-hg@68
|
60 |
try {
|
franta-hg@68
|
61 |
// Load database driver
|
franta-hg@68
|
62 |
String driverClass = Config.inst().get(Config.LEVEL_FILE, Config.STORAGE_DBMSDRIVER, "java.lang.Object");
|
franta-hg@68
|
63 |
Class.forName(driverClass);
|
franta-hg@68
|
64 |
|
franta-hg@68
|
65 |
// Establish database connection
|
franta-hg@68
|
66 |
String url = Config.inst().get(Config.LEVEL_FILE, Config.STORAGE_DATABASE, "<not specified>");
|
franta-hg@68
|
67 |
String username = Config.inst().get(Config.LEVEL_FILE, Config.STORAGE_USER, "root");
|
franta-hg@68
|
68 |
String password = Config.inst().get(Config.LEVEL_FILE, Config.STORAGE_PASSWORD, "");
|
franta-hg@68
|
69 |
conn = DriverManager.getConnection(url, username, password);
|
franta-hg@68
|
70 |
|
franta-hg@68
|
71 |
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
|
franta-hg@68
|
72 |
if (conn.getTransactionIsolation() != Connection.TRANSACTION_SERIALIZABLE) {
|
franta-hg@68
|
73 |
log.warning("Database is NOT fully serializable!");
|
franta-hg@68
|
74 |
}
|
franta-hg@68
|
75 |
} catch (Exception e) {
|
franta-hg@68
|
76 |
throw new StorageBackendException(e);
|
franta-hg@68
|
77 |
}
|
franta-hg@68
|
78 |
}
|
franta-hg@68
|
79 |
|
franta-hg@68
|
80 |
protected static void close(Connection connection, Statement statement, ResultSet resultSet) {
|
franta-hg@68
|
81 |
if (resultSet != null) {
|
franta-hg@68
|
82 |
try {
|
franta-hg@68
|
83 |
resultSet.close();
|
franta-hg@68
|
84 |
} catch (Exception e) {
|
franta-hg@68
|
85 |
}
|
franta-hg@68
|
86 |
}
|
franta-hg@68
|
87 |
if (statement != null) {
|
franta-hg@68
|
88 |
try {
|
franta-hg@68
|
89 |
statement.close();
|
franta-hg@68
|
90 |
} catch (Exception e) {
|
franta-hg@68
|
91 |
}
|
franta-hg@68
|
92 |
}
|
franta-hg@68
|
93 |
if (connection != null) {
|
franta-hg@68
|
94 |
try {
|
franta-hg@68
|
95 |
connection.close();
|
franta-hg@68
|
96 |
} catch (Exception e) {
|
franta-hg@68
|
97 |
}
|
franta-hg@68
|
98 |
}
|
franta-hg@68
|
99 |
}
|
franta-hg@64
|
100 |
|
franta-hg@64
|
101 |
/**
|
franta-hg@68
|
102 |
*
|
franta-hg@68
|
103 |
* @param messageID {0}-{1}-{2}@domain.tld where {0} is nntp_id and {1} is group_id and {2} is group_name
|
franta-hg@68
|
104 |
* @return array where [0] = nntp_id and [1] = group_id and [2] = group_name or returns null if messageID is invalid
|
franta-hg@64
|
105 |
*/
|
franta-hg@68
|
106 |
private static String[] parseMessageID(String messageID) {
|
franta-hg@68
|
107 |
if (messageID.matches("[0-9]+\\-[0-9]+\\-[a-z0-9\\.]+@.+")) {
|
franta-hg@68
|
108 |
return messageID.split("@")[0].split("\\-");
|
franta-hg@68
|
109 |
} else {
|
franta-hg@68
|
110 |
return null;
|
franta-hg@68
|
111 |
}
|
franta-hg@68
|
112 |
}
|
franta-hg@68
|
113 |
|
franta-hg@68
|
114 |
private static Long parseArticleID(String messageID) {
|
franta-hg@68
|
115 |
String[] localPart = parseMessageID(messageID);
|
franta-hg@68
|
116 |
if (localPart == null) {
|
franta-hg@68
|
117 |
return null;
|
franta-hg@68
|
118 |
} else {
|
franta-hg@68
|
119 |
return Long.parseLong(localPart[0]);
|
franta-hg@68
|
120 |
}
|
franta-hg@68
|
121 |
}
|
franta-hg@68
|
122 |
|
franta-hg@68
|
123 |
private static Long parseGroupID(String messageID) {
|
franta-hg@68
|
124 |
String[] localPart = parseMessageID(messageID);
|
franta-hg@68
|
125 |
if (localPart == null) {
|
franta-hg@68
|
126 |
return null;
|
franta-hg@68
|
127 |
} else {
|
franta-hg@68
|
128 |
return Long.parseLong(localPart[1]);
|
franta-hg@68
|
129 |
}
|
franta-hg@68
|
130 |
}
|
franta-hg@68
|
131 |
|
franta-hg@68
|
132 |
private static String parseGroupName(String messageID) {
|
franta-hg@68
|
133 |
String[] localPart = parseMessageID(messageID);
|
franta-hg@68
|
134 |
if (localPart == null) {
|
franta-hg@68
|
135 |
return null;
|
franta-hg@68
|
136 |
} else {
|
franta-hg@68
|
137 |
return localPart[2];
|
franta-hg@68
|
138 |
}
|
franta-hg@68
|
139 |
}
|
franta-hg@68
|
140 |
|
franta-hg@68
|
141 |
private static String constructHeaders(ResultSet rs) throws SQLException, UnsupportedEncodingException {
|
franta-hg@68
|
142 |
StringBuilder sb = new StringBuilder();
|
franta-hg@68
|
143 |
|
franta-hg@68
|
144 |
sb.append("Message-id: ");
|
franta-hg@68
|
145 |
sb.append(rs.getInt("id"));
|
franta-hg@68
|
146 |
sb.append("-");
|
franta-hg@68
|
147 |
sb.append(rs.getInt("group_id"));
|
franta-hg@68
|
148 |
sb.append("-");
|
franta-hg@68
|
149 |
sb.append(rs.getString("group_name"));
|
franta-hg@68
|
150 |
sb.append("@");
|
franta-hg@68
|
151 |
sb.append("nntp.kinderporno.cz");
|
franta-hg@68
|
152 |
sb.append(CRLF);
|
franta-hg@68
|
153 |
|
franta-hg@68
|
154 |
sb.append("From: ");
|
franta-hg@68
|
155 |
sb.append(MimeUtility.encodeWord(rs.getString("sender_name")));
|
franta-hg@68
|
156 |
sb.append(" <>");
|
franta-hg@68
|
157 |
sb.append(CRLF);
|
franta-hg@68
|
158 |
|
franta-hg@68
|
159 |
sb.append("Subject: ");
|
franta-hg@68
|
160 |
sb.append(MimeUtility.encodeWord(rs.getString("subject")));
|
franta-hg@68
|
161 |
sb.append(CRLF);
|
franta-hg@68
|
162 |
|
franta-hg@68
|
163 |
|
franta-hg@68
|
164 |
|
franta-hg@68
|
165 |
return sb.toString();
|
franta-hg@64
|
166 |
}
|
franta-hg@64
|
167 |
|
franta-hg@64
|
168 |
@Override
|
franta-hg@67
|
169 |
public List<Group> getGroups() throws StorageBackendException {
|
franta-hg@68
|
170 |
PreparedStatement ps = null;
|
franta-hg@68
|
171 |
ResultSet rs = null;
|
franta-hg@68
|
172 |
try {
|
franta-hg@68
|
173 |
ps = conn.prepareStatement("SELECT * FROM nntp_group");
|
franta-hg@68
|
174 |
rs = ps.executeQuery();
|
franta-hg@68
|
175 |
List<Group> skupiny = new ArrayList<Group>();
|
franta-hg@68
|
176 |
|
franta-hg@68
|
177 |
while (rs.next()) {
|
franta-hg@68
|
178 |
skupiny.add(new Group(rs.getString("name"), rs.getInt("id"), Group.READONLY));
|
franta-hg@68
|
179 |
}
|
franta-hg@68
|
180 |
|
franta-hg@68
|
181 |
return skupiny;
|
franta-hg@68
|
182 |
} catch (Exception e) {
|
franta-hg@68
|
183 |
throw new StorageBackendException(e);
|
franta-hg@68
|
184 |
} finally {
|
franta-hg@68
|
185 |
close(null, ps, rs);
|
franta-hg@68
|
186 |
}
|
franta-hg@64
|
187 |
}
|
franta-hg@64
|
188 |
|
franta-hg@64
|
189 |
@Override
|
franta-hg@67
|
190 |
public Group getGroup(String name) throws StorageBackendException {
|
franta-hg@68
|
191 |
PreparedStatement ps = null;
|
franta-hg@68
|
192 |
ResultSet rs = null;
|
franta-hg@68
|
193 |
try {
|
franta-hg@68
|
194 |
ps = conn.prepareStatement("SELECT * FROM nntp_group WHERE name = ?");
|
franta-hg@68
|
195 |
ps.setString(1, name);
|
franta-hg@68
|
196 |
rs = ps.executeQuery();
|
franta-hg@68
|
197 |
|
franta-hg@68
|
198 |
while (rs.next()) {
|
franta-hg@68
|
199 |
return new Group(rs.getString("name"), rs.getInt("id"), Group.READONLY);
|
franta-hg@68
|
200 |
}
|
franta-hg@68
|
201 |
|
franta-hg@68
|
202 |
return null;
|
franta-hg@68
|
203 |
} catch (Exception e) {
|
franta-hg@68
|
204 |
throw new StorageBackendException(e);
|
franta-hg@68
|
205 |
} finally {
|
franta-hg@68
|
206 |
close(null, ps, rs);
|
franta-hg@68
|
207 |
}
|
franta-hg@64
|
208 |
}
|
franta-hg@64
|
209 |
|
franta-hg@64
|
210 |
@Override
|
franta-hg@67
|
211 |
public boolean isGroupExisting(String groupname) throws StorageBackendException {
|
franta-hg@68
|
212 |
return getGroup(groupname) != null;
|
franta-hg@64
|
213 |
}
|
franta-hg@64
|
214 |
|
franta-hg@64
|
215 |
@Override
|
franta-hg@64
|
216 |
public Article getArticle(String messageID) throws StorageBackendException {
|
franta-hg@68
|
217 |
Long articleID = parseArticleID(messageID);
|
franta-hg@68
|
218 |
Long groupID = parseGroupID(messageID);
|
franta-hg@68
|
219 |
|
franta-hg@68
|
220 |
if (articleID == null || groupID == null) {
|
franta-hg@68
|
221 |
log.log(Level.SEVERE, "Invalid messageID: {0}", new Object[]{messageID});
|
franta-hg@68
|
222 |
return null;
|
franta-hg@68
|
223 |
} else {
|
franta-hg@68
|
224 |
return getArticle(articleID, groupID);
|
franta-hg@68
|
225 |
}
|
franta-hg@64
|
226 |
}
|
franta-hg@64
|
227 |
|
franta-hg@64
|
228 |
@Override
|
franta-hg@68
|
229 |
public Article getArticle(long articleID, long groupID) throws StorageBackendException {
|
franta-hg@68
|
230 |
PreparedStatement ps = null;
|
franta-hg@68
|
231 |
ResultSet rs = null;
|
franta-hg@68
|
232 |
try {
|
franta-hg@68
|
233 |
ps = conn.prepareStatement("SELECT * FROM nntp_article WHERE id = ? AND group_id = ?");
|
franta-hg@68
|
234 |
ps.setLong(1, articleID);
|
franta-hg@68
|
235 |
ps.setLong(2, groupID);
|
franta-hg@68
|
236 |
rs = ps.executeQuery();
|
franta-hg@68
|
237 |
|
franta-hg@68
|
238 |
if (rs.next()) {
|
franta-hg@68
|
239 |
String headers = constructHeaders(rs);
|
franta-hg@68
|
240 |
byte[] body = rs.getString("text").getBytes();
|
franta-hg@68
|
241 |
|
franta-hg@68
|
242 |
return new Article(headers, body);
|
franta-hg@68
|
243 |
} else {
|
franta-hg@68
|
244 |
return null;
|
franta-hg@68
|
245 |
}
|
franta-hg@68
|
246 |
} catch (Exception e) {
|
franta-hg@68
|
247 |
throw new StorageBackendException(e);
|
franta-hg@68
|
248 |
} finally {
|
franta-hg@68
|
249 |
close(null, ps, rs);
|
franta-hg@68
|
250 |
}
|
franta-hg@64
|
251 |
}
|
franta-hg@64
|
252 |
|
franta-hg@64
|
253 |
@Override
|
franta-hg@64
|
254 |
public List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last) throws StorageBackendException {
|
franta-hg@68
|
255 |
PreparedStatement ps = null;
|
franta-hg@68
|
256 |
ResultSet rs = null;
|
franta-hg@68
|
257 |
try {
|
franta-hg@68
|
258 |
ps = conn.prepareStatement("SELECT * FROM nntp_article WHERE group_id = ? AND id >= ? AND id <= ?");
|
franta-hg@68
|
259 |
ps.setLong(1, group.getInternalID());
|
franta-hg@68
|
260 |
ps.setLong(2, first);
|
franta-hg@68
|
261 |
ps.setLong(3, last);
|
franta-hg@68
|
262 |
rs = ps.executeQuery();
|
franta-hg@68
|
263 |
|
franta-hg@68
|
264 |
List<Pair<Long, ArticleHead>> heads = new ArrayList<Pair<Long, ArticleHead>>();
|
franta-hg@68
|
265 |
|
franta-hg@68
|
266 |
while (rs.next()) {
|
franta-hg@68
|
267 |
String headers = constructHeaders(rs);
|
franta-hg@68
|
268 |
heads.add(new Pair<Long, ArticleHead>(rs.getLong("id"), new ArticleHead(headers)));
|
franta-hg@68
|
269 |
}
|
franta-hg@68
|
270 |
|
franta-hg@68
|
271 |
return heads;
|
franta-hg@68
|
272 |
} catch (Exception e) {
|
franta-hg@68
|
273 |
throw new StorageBackendException(e);
|
franta-hg@68
|
274 |
} finally {
|
franta-hg@68
|
275 |
close(null, ps, rs);
|
franta-hg@68
|
276 |
}
|
franta-hg@64
|
277 |
}
|
franta-hg@64
|
278 |
|
franta-hg@64
|
279 |
@Override
|
franta-hg@64
|
280 |
public List<Pair<Long, String>> getArticleHeaders(Group group, long start, long end, String header, String pattern) throws StorageBackendException {
|
franta-hg@66
|
281 |
log.log(Level.SEVERE, "TODO: getArticleHeaders {0} / {1} / {2} / {3} / {4}", new Object[]{group, start, end, header, pattern});
|
franta-hg@65
|
282 |
/** TODO: */
|
franta-hg@65
|
283 |
return Collections.emptyList();
|
franta-hg@64
|
284 |
}
|
franta-hg@64
|
285 |
|
franta-hg@64
|
286 |
@Override
|
franta-hg@68
|
287 |
public long getArticleIndex(Article article, Group group) throws StorageBackendException {
|
franta-hg@68
|
288 |
Long id = parseArticleID(article.getMessageID());
|
franta-hg@68
|
289 |
if (id == null) {
|
franta-hg@68
|
290 |
throw new StorageBackendException("Invalid messageID: " + article.getMessageID());
|
franta-hg@68
|
291 |
} else {
|
franta-hg@68
|
292 |
return id;
|
franta-hg@68
|
293 |
}
|
franta-hg@64
|
294 |
}
|
franta-hg@64
|
295 |
|
franta-hg@64
|
296 |
@Override
|
franta-hg@64
|
297 |
public List<Long> getArticleNumbers(long groupID) throws StorageBackendException {
|
franta-hg@68
|
298 |
PreparedStatement ps = null;
|
franta-hg@68
|
299 |
ResultSet rs = null;
|
franta-hg@68
|
300 |
try {
|
franta-hg@68
|
301 |
ps = conn.prepareStatement("SELECT id FROM nntp_article WHERE group_id = ?");
|
franta-hg@68
|
302 |
ps.setLong(1, groupID);
|
franta-hg@68
|
303 |
rs = ps.executeQuery();
|
franta-hg@68
|
304 |
List<Long> articleNumbers = new ArrayList<Long>();
|
franta-hg@68
|
305 |
while (rs.next()) {
|
franta-hg@68
|
306 |
articleNumbers.add(rs.getLong(1));
|
franta-hg@68
|
307 |
}
|
franta-hg@68
|
308 |
return articleNumbers;
|
franta-hg@68
|
309 |
} catch (Exception e) {
|
franta-hg@68
|
310 |
throw new StorageBackendException(e);
|
franta-hg@68
|
311 |
} finally {
|
franta-hg@68
|
312 |
close(null, ps, rs);
|
franta-hg@68
|
313 |
}
|
franta-hg@64
|
314 |
}
|
franta-hg@64
|
315 |
|
franta-hg@64
|
316 |
@Override
|
franta-hg@67
|
317 |
public int getFirstArticleNumber(Group group) throws StorageBackendException {
|
franta-hg@68
|
318 |
PreparedStatement ps = null;
|
franta-hg@68
|
319 |
ResultSet rs = null;
|
franta-hg@68
|
320 |
try {
|
franta-hg@68
|
321 |
ps = conn.prepareStatement("SELECT min(id) FROM nntp_article WHERE group_id = ?");
|
franta-hg@68
|
322 |
ps.setLong(1, group.getInternalID());
|
franta-hg@68
|
323 |
rs = ps.executeQuery();
|
franta-hg@68
|
324 |
rs.next();
|
franta-hg@68
|
325 |
return rs.getInt(1);
|
franta-hg@68
|
326 |
} catch (Exception e) {
|
franta-hg@68
|
327 |
throw new StorageBackendException(e);
|
franta-hg@68
|
328 |
} finally {
|
franta-hg@68
|
329 |
close(null, ps, rs);
|
franta-hg@68
|
330 |
}
|
franta-hg@67
|
331 |
}
|
franta-hg@67
|
332 |
|
franta-hg@67
|
333 |
@Override
|
franta-hg@67
|
334 |
public int getLastArticleNumber(Group group) throws StorageBackendException {
|
franta-hg@68
|
335 |
PreparedStatement ps = null;
|
franta-hg@68
|
336 |
ResultSet rs = null;
|
franta-hg@68
|
337 |
try {
|
franta-hg@68
|
338 |
ps = conn.prepareStatement("SELECT max(id) FROM nntp_article WHERE group_id = ?");
|
franta-hg@68
|
339 |
ps.setLong(1, group.getInternalID());
|
franta-hg@68
|
340 |
rs = ps.executeQuery();
|
franta-hg@68
|
341 |
rs.next();
|
franta-hg@68
|
342 |
return rs.getInt(1);
|
franta-hg@68
|
343 |
} catch (Exception e) {
|
franta-hg@68
|
344 |
throw new StorageBackendException(e);
|
franta-hg@68
|
345 |
} finally {
|
franta-hg@68
|
346 |
close(null, ps, rs);
|
franta-hg@68
|
347 |
}
|
franta-hg@67
|
348 |
}
|
franta-hg@67
|
349 |
|
franta-hg@67
|
350 |
@Override
|
franta-hg@67
|
351 |
public boolean isArticleExisting(String messageID) throws StorageBackendException {
|
franta-hg@68
|
352 |
Long articleID = parseArticleID(messageID);
|
franta-hg@68
|
353 |
Long groupID = parseGroupID(messageID);
|
franta-hg@68
|
354 |
|
franta-hg@68
|
355 |
if (articleID == null || groupID == null) {
|
franta-hg@68
|
356 |
return false;
|
franta-hg@68
|
357 |
} else {
|
franta-hg@68
|
358 |
PreparedStatement ps = null;
|
franta-hg@68
|
359 |
ResultSet rs = null;
|
franta-hg@68
|
360 |
try {
|
franta-hg@68
|
361 |
ps = conn.prepareStatement("SELECT count(*) FROM nntp_article WHERE id = ? AND group_id = ?");
|
franta-hg@68
|
362 |
ps.setLong(1, articleID);
|
franta-hg@68
|
363 |
ps.setLong(2, groupID);
|
franta-hg@68
|
364 |
rs = ps.executeQuery();
|
franta-hg@68
|
365 |
|
franta-hg@68
|
366 |
rs.next();
|
franta-hg@68
|
367 |
return rs.getInt(1) == 1;
|
franta-hg@68
|
368 |
} catch (Exception e) {
|
franta-hg@68
|
369 |
throw new StorageBackendException(e);
|
franta-hg@68
|
370 |
} finally {
|
franta-hg@68
|
371 |
close(null, ps, rs);
|
franta-hg@68
|
372 |
}
|
franta-hg@68
|
373 |
}
|
franta-hg@67
|
374 |
}
|
franta-hg@67
|
375 |
|
franta-hg@67
|
376 |
//
|
franta-hg@67
|
377 |
// --- zatím neimplementovat ---
|
franta-hg@67
|
378 |
//
|
franta-hg@67
|
379 |
@Override
|
franta-hg@67
|
380 |
public void addArticle(Article art) throws StorageBackendException {
|
franta-hg@67
|
381 |
log.log(Level.SEVERE, "TODO: addArticle {0}", new Object[]{art});
|
franta-hg@67
|
382 |
}
|
franta-hg@67
|
383 |
|
franta-hg@67
|
384 |
@Override
|
franta-hg@67
|
385 |
public void addEvent(long timestamp, int type, long groupID) throws StorageBackendException {
|
franta-hg@67
|
386 |
log.log(Level.SEVERE, "TODO: addEvent {0} / {1} / {2}", new Object[]{timestamp, type, groupID});
|
franta-hg@67
|
387 |
}
|
franta-hg@67
|
388 |
|
franta-hg@67
|
389 |
@Override
|
franta-hg@67
|
390 |
public void addGroup(String groupname, int flags) throws StorageBackendException {
|
franta-hg@67
|
391 |
log.log(Level.SEVERE, "TODO: addGroup {0} / {1}", new Object[]{groupname, flags});
|
franta-hg@67
|
392 |
}
|
franta-hg@67
|
393 |
|
franta-hg@67
|
394 |
@Override
|
franta-hg@67
|
395 |
public int countArticles() throws StorageBackendException {
|
franta-hg@67
|
396 |
log.log(Level.SEVERE, "TODO: countArticles");
|
franta-hg@67
|
397 |
return 0;
|
franta-hg@67
|
398 |
}
|
franta-hg@67
|
399 |
|
franta-hg@67
|
400 |
@Override
|
franta-hg@67
|
401 |
public int countGroups() throws StorageBackendException {
|
franta-hg@67
|
402 |
log.log(Level.SEVERE, "TODO: countGroups");
|
franta-hg@67
|
403 |
return 0;
|
franta-hg@67
|
404 |
}
|
franta-hg@67
|
405 |
|
franta-hg@67
|
406 |
@Override
|
franta-hg@67
|
407 |
public void delete(String messageID) throws StorageBackendException {
|
franta-hg@67
|
408 |
log.log(Level.SEVERE, "TODO: delete {0}", new Object[]{messageID});
|
franta-hg@67
|
409 |
}
|
franta-hg@67
|
410 |
|
franta-hg@67
|
411 |
@Override
|
franta-hg@64
|
412 |
public String getConfigValue(String key) throws StorageBackendException {
|
franta-hg@66
|
413 |
log.log(Level.SEVERE, "TODO: getConfigValue {0}", new Object[]{key});
|
franta-hg@65
|
414 |
return null;
|
franta-hg@64
|
415 |
}
|
franta-hg@64
|
416 |
|
franta-hg@64
|
417 |
@Override
|
franta-hg@64
|
418 |
public int getEventsCount(int eventType, long startTimestamp, long endTimestamp, Group group) throws StorageBackendException {
|
franta-hg@66
|
419 |
log.log(Level.SEVERE, "TODO: getEventsCount {0} / {1} / {2} / {3}", new Object[]{eventType, startTimestamp, endTimestamp, group});
|
franta-hg@65
|
420 |
return 0;
|
franta-hg@64
|
421 |
}
|
franta-hg@64
|
422 |
|
franta-hg@64
|
423 |
@Override
|
franta-hg@64
|
424 |
public double getEventsPerHour(int key, long gid) throws StorageBackendException {
|
franta-hg@66
|
425 |
log.log(Level.SEVERE, "TODO: getEventsPerHour {0} / {1}", new Object[]{key, gid});
|
franta-hg@65
|
426 |
return 0;
|
franta-hg@64
|
427 |
}
|
franta-hg@64
|
428 |
|
franta-hg@64
|
429 |
@Override
|
franta-hg@64
|
430 |
public List<String> getGroupsForList(String listAddress) throws StorageBackendException {
|
franta-hg@66
|
431 |
log.log(Level.SEVERE, "TODO: getGroupsForList {0}", new Object[]{listAddress});
|
franta-hg@65
|
432 |
return Collections.emptyList();
|
franta-hg@64
|
433 |
}
|
franta-hg@64
|
434 |
|
franta-hg@64
|
435 |
@Override
|
franta-hg@64
|
436 |
public List<String> getListsForGroup(String groupname) throws StorageBackendException {
|
franta-hg@66
|
437 |
log.log(Level.SEVERE, "TODO: getListsForGroup {0}", new Object[]{groupname});
|
franta-hg@65
|
438 |
return Collections.emptyList();
|
franta-hg@64
|
439 |
}
|
franta-hg@64
|
440 |
|
franta-hg@64
|
441 |
@Override
|
franta-hg@64
|
442 |
public String getOldestArticle() throws StorageBackendException {
|
franta-hg@66
|
443 |
log.log(Level.SEVERE, "TODO: getOldestArticle");
|
franta-hg@65
|
444 |
return null;
|
franta-hg@64
|
445 |
}
|
franta-hg@64
|
446 |
|
franta-hg@64
|
447 |
@Override
|
franta-hg@64
|
448 |
public int getPostingsCount(String groupname) throws StorageBackendException {
|
franta-hg@66
|
449 |
log.log(Level.SEVERE, "TODO: getPostingsCount {0}", new Object[]{groupname});
|
franta-hg@65
|
450 |
return 0;
|
franta-hg@64
|
451 |
}
|
franta-hg@64
|
452 |
|
franta-hg@64
|
453 |
@Override
|
franta-hg@64
|
454 |
public List<Subscription> getSubscriptions(int type) throws StorageBackendException {
|
franta-hg@66
|
455 |
log.log(Level.SEVERE, "TODO: getSubscriptions {0}", new Object[]{type});
|
franta-hg@65
|
456 |
return Collections.emptyList();
|
franta-hg@64
|
457 |
}
|
franta-hg@64
|
458 |
|
franta-hg@64
|
459 |
@Override
|
franta-hg@64
|
460 |
public void purgeGroup(Group group) throws StorageBackendException {
|
franta-hg@66
|
461 |
log.log(Level.SEVERE, "TODO: purgeGroup {0}", new Object[]{group});
|
franta-hg@64
|
462 |
}
|
franta-hg@64
|
463 |
|
franta-hg@64
|
464 |
@Override
|
franta-hg@64
|
465 |
public void setConfigValue(String key, String value) throws StorageBackendException {
|
franta-hg@66
|
466 |
log.log(Level.SEVERE, "TODO: setConfigValue {0} = {1}", new Object[]{key, value});
|
franta-hg@64
|
467 |
}
|
franta-hg@64
|
468 |
|
franta-hg@64
|
469 |
@Override
|
franta-hg@64
|
470 |
public boolean update(Article article) throws StorageBackendException {
|
franta-hg@66
|
471 |
log.log(Level.SEVERE, "TODO: update {0}", new Object[]{article});
|
franta-hg@65
|
472 |
throw new StorageBackendException("Not implemented yet.");
|
franta-hg@64
|
473 |
}
|
franta-hg@64
|
474 |
|
franta-hg@64
|
475 |
@Override
|
franta-hg@64
|
476 |
public boolean update(Group group) throws StorageBackendException {
|
franta-hg@66
|
477 |
log.log(Level.SEVERE, "TODO: update {0}", new Object[]{group});
|
franta-hg@65
|
478 |
throw new StorageBackendException("Not implemented yet.");
|
franta-hg@64
|
479 |
}
|
franta-hg@63
|
480 |
}
|