Hooray... sonews/0.5.0 final
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Remove all lines to abort the collapse operation.
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.daemon.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
35 * If this flag is set the Group is no real newsgroup but a mailing list
36 * mirror. In that case every posting and receiving mails must go through
37 * the mailing list gateway.
39 public static final int MAILINGLIST = 0x1;
42 * If this flag is set the Group is marked as readonly and the posting
43 * is prohibited. This can be useful for groups that are synced only in
46 public static final int READONLY = 0x2;
49 * If this flag is set the Group is marked as deleted and must not occur
50 * in any output. The deletion is done lazily by a low priority daemon.
52 public static final int DELETED = 0x128;
55 private int flags = -1;
56 private String name = null;
59 * Returns a Group identified by its full name.
63 public static Group getByName(final String name)
67 return Database.getInstance().getGroup(name);
69 catch(SQLException ex)
77 * @return List of all groups this server handles.
79 public static List<Group> getAll()
83 return Database.getInstance().getGroups();
85 catch(SQLException ex)
87 Log.msg(ex.getMessage(), false);
93 * Private constructor.
97 Group(final String name, final long id, final int flags)
105 public boolean equals(Object obj)
107 if(obj instanceof Group)
109 return ((Group)obj).id == this.id;
117 public List<Pair<Long, ArticleHead>> getArticleHeads(final int first, final int last)
120 return Database.getInstance().getArticleHeads(this, first, last);
123 public List<Long> getArticleNumbers()
126 return Database.getInstance().getArticleNumbers(id);
129 public int getFirstArticleNumber()
132 return Database.getInstance().getFirstArticleNumber(this);
136 * Returns the group id.
145 public boolean isMailingList()
147 return (this.flags & MAILINGLIST) != 0;
150 public int getLastArticleNumber()
153 return Database.getInstance().getLastArticleNumber(this);
156 public String getName()
162 * Performs this.flags |= flag to set a specified flag and updates the data
166 public void setFlag(final int flag)
171 public void setName(final String name)
177 * @return Number of posted articles in this group.
178 * @throws java.sql.SQLException
180 public int getPostingsCount()
183 return Database.getInstance().getPostingsCount(this.name);