Some work on XDAEMON command.
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 * @return List of all groups this server handles.
42 public static List<Channel> getAll()
45 return StorageManager.current().getGroups();
46 } catch (StorageBackendException ex) {
47 Log.get().severe(ex.getMessage());
56 public Group(final String name, final long id, final int flags)
64 public boolean equals(Object obj)
66 if (obj instanceof Group) {
67 return ((Group) obj).id == this.id;
73 public Article getArticle(long idx)
74 throws StorageBackendException
76 return StorageManager.current().getArticle(idx, this.id);
79 public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
80 throws StorageBackendException
82 return StorageManager.current().getArticleHeads(this, first, last);
85 public List<Long> getArticleNumbers()
86 throws StorageBackendException
88 return StorageManager.current().getArticleNumbers(id);
91 public long getFirstArticleNumber()
92 throws StorageBackendException
94 return StorageManager.current().getFirstArticleNumber(this);
102 public long getIndexOf(Article art)
103 throws StorageBackendException
105 return StorageManager.current().getArticleIndex(art, this);
109 * Returns the group id.
111 public long getInternalID()
118 public boolean isDeleted()
120 return (this.flags & DELETED) != 0;
123 public boolean isMailingList()
125 return (this.flags & MAILINGLIST) != 0;
128 public boolean isWriteable()
133 public long getLastArticleNumber()
134 throws StorageBackendException
136 return StorageManager.current().getLastArticleNumber(this);
139 public String getName()
145 * Performs this.flags |= flag to set a specified flag and updates the data
146 * in the JDBCDatabase.
149 public void setFlag(final int flag)
154 public void setName(final String name)
160 * @return Number of posted articles in this group.
161 * @throws java.sql.SQLException
163 public long getPostingsCount()
164 throws StorageBackendException
166 return StorageManager.current().getPostingsCount(this.name);
170 * Updates flags and name in the backend.
173 throws StorageBackendException
175 StorageManager.current().update(this);