HSQLDB backend support completed, but untested.
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package org.sonews.storage;
20 import java.sql.SQLException;
21 import java.util.List;
22 import org.sonews.util.Log;
23 import org.sonews.util.Pair;
26 * Represents a logical Group within this newsserver.
27 * @author Christian Lins
30 // TODO: This class should not be public!
31 public class Group extends Channel {
34 private int flags = -1;
35 private String name = null;
38 * @return List of all groups this server handles.
40 public static List<Channel> getAll() {
42 return StorageManager.current().getGroups();
43 } catch (StorageBackendException ex) {
44 Log.get().severe(ex.getMessage());
53 public Group(final String name, final long id, final int flags) {
60 public boolean equals(Object obj) {
61 if (obj instanceof Group) {
62 return ((Group) obj).id == this.id;
68 public Article getArticle(long idx)
69 throws StorageBackendException {
70 return StorageManager.current().getArticle(idx, this.id);
73 public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
74 throws StorageBackendException {
75 return StorageManager.current().getArticleHeads(this, first, last);
78 public List<Long> getArticleNumbers()
79 throws StorageBackendException {
80 return StorageManager.current().getArticleNumbers(id);
83 public long getFirstArticleNumber()
84 throws StorageBackendException {
85 return StorageManager.current().getFirstArticleNumber(this);
88 public int getFlags() {
92 public long getIndexOf(Article art)
93 throws StorageBackendException {
94 return StorageManager.current().getArticleIndex(art, this);
98 * Returns the group id.
100 public long getInternalID() {
106 public boolean isDeleted() {
107 return (this.flags & DELETED) != 0;
110 public boolean isMailingList() {
111 return (this.flags & MAILINGLIST) != 0;
114 public boolean isWriteable() {
118 public long getLastArticleNumber()
119 throws StorageBackendException {
120 return StorageManager.current().getLastArticleNumber(this);
123 public String getName() {
128 * Performs this.flags |= flag to set a specified flag and updates the data
129 * in the JDBCDatabase.
132 public void setFlag(final int flag) {
136 public void setName(final String name) {
141 * @return Number of posted articles in this group.
142 * @throws java.sql.SQLException
144 public long getPostingsCount()
145 throws StorageBackendException {
146 return StorageManager.current().getPostingsCount(this.name);
150 * Updates flags and name in the backend.
153 throws StorageBackendException {
154 StorageManager.current().update(this);