Drupal: text/plain – odkazy budou označené 'apostrofy' místo "uvozovkami".
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
33 * If this flag is set the Group is no real newsgroup but a mailing list
34 * mirror. In that case every posting and receiving mails must go through
35 * the mailing list gateway.
37 public static final int MAILINGLIST = 0x1;
40 * If this flag is set the Group is marked as readonly and the posting
41 * is prohibited. This can be useful for groups that are synced only in
44 public static final int READONLY = 0x2;
47 * If this flag is set the Group is marked as deleted and must not occur
48 * in any output. The deletion is done lazily by a low priority daemon.
50 public static final int DELETED = 0x80;
53 private int flags = -1;
54 private String name = null;
57 * @return List of all groups this server handles.
59 public static List<Group> getAll() {
61 return StorageManager.current().getGroups();
62 } catch (StorageBackendException ex) {
63 Log.get().severe(ex.getMessage());
74 public Group(final String name, final long id, final int flags) {
81 public boolean equals(Object obj) {
82 if (obj instanceof Group) {
83 return ((Group) obj).id == this.id;
89 public Article getArticle(long idx)
90 throws StorageBackendException {
91 return StorageManager.current().getArticle(idx, this.id);
94 public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
95 throws StorageBackendException {
96 return StorageManager.current().getArticleHeads(this, first, last);
99 public List<Long> getArticleNumbers()
100 throws StorageBackendException {
101 return StorageManager.current().getArticleNumbers(id);
104 public long getFirstArticleNumber()
105 throws StorageBackendException {
106 return StorageManager.current().getFirstArticleNumber(this);
109 public int getFlags() {
113 public long getIndexOf(Article art)
114 throws StorageBackendException {
115 return StorageManager.current().getArticleIndex(art, this);
119 * Returns the group id.
121 public long getInternalID() {
126 public boolean isDeleted() {
127 return (this.flags & DELETED) != 0;
130 public boolean isMailingList() {
131 return (this.flags & MAILINGLIST) != 0;
134 public boolean isWriteable() {
138 public long getLastArticleNumber()
139 throws StorageBackendException {
140 return StorageManager.current().getLastArticleNumber(this);
143 public String getName() {
148 * Performs this.flags |= flag to set a specified flag and updates the data
149 * in the JDBCDatabase.
152 public void setFlag(final int flag) {
156 public void unsetFlag(final int flag) {
160 public void setName(final String name) {
165 * @return Number of posted articles in this group.
166 * @throws java.sql.SQLException
168 public long getPostingsCount()
169 throws StorageBackendException {
170 return StorageManager.current().getPostingsCount(this.name);
174 * Updates flags and name in the backend.
177 throws StorageBackendException {
178 StorageManager.current().update(this);