PullFeeder sends an addition "MODE READER" to peers.
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/>.
19 package org.sonews.storage;
21 import java.sql.SQLException;
22 import java.util.List;
23 import org.sonews.util.Log;
24 import org.sonews.util.Pair;
27 * Represents a logical Group within this newsserver.
28 * @author Christian Lins
31 // TODO: This class should not be public!
32 public class Group extends Channel
36 private int flags = -1;
37 private String name = null;
40 * Returns a Group identified by its full name.
44 public static Group getByName(final String name)
48 return StorageManager.current().getGroup(name);
50 catch(StorageBackendException ex)
58 * @return List of all groups this server handles.
60 public static List<Channel> getAll()
64 return StorageManager.current().getGroups();
66 catch(StorageBackendException ex)
68 Log.msg(ex.getMessage(), false);
77 public Group(final String name, final long id, final int flags)
85 public boolean equals(Object obj)
87 if(obj instanceof Group)
89 return ((Group)obj).id == this.id;
97 public Article getArticle(long idx)
98 throws StorageBackendException
100 return StorageManager.current().getArticle(idx, this.id);
103 public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
104 throws StorageBackendException
106 return StorageManager.current().getArticleHeads(this, first, last);
109 public List<Long> getArticleNumbers()
110 throws StorageBackendException
112 return StorageManager.current().getArticleNumbers(id);
115 public long getFirstArticleNumber()
116 throws StorageBackendException
118 return StorageManager.current().getFirstArticleNumber(this);
121 public int getFlags()
126 public long getIndexOf(Article art)
127 throws StorageBackendException
129 return StorageManager.current().getArticleIndex(art, this);
133 * Returns the group id.
135 public long getInternalID()
142 public boolean isDeleted()
144 return (this.flags & DELETED) != 0;
147 public boolean isMailingList()
149 return (this.flags & MAILINGLIST) != 0;
152 public boolean isWriteable()
157 public long getLastArticleNumber()
158 throws StorageBackendException
160 return StorageManager.current().getLastArticleNumber(this);
163 public String getName()
169 * Performs this.flags |= flag to set a specified flag and updates the data
170 * in the JDBCDatabase.
173 public void setFlag(final int flag)
178 public void setName(final String name)
184 * @return Number of posted articles in this group.
185 * @throws java.sql.SQLException
187 public long getPostingsCount()
188 throws StorageBackendException
190 return StorageManager.current().getPostingsCount(this.name);
194 * Updates flags and name in the backend.
197 throws StorageBackendException
199 StorageManager.current().update(this);