src/org/sonews/storage/Channel.java
author cli
Tue, 07 Jun 2011 09:23:34 +0200
changeset 43 7d0e65712a95
parent 42 7f84f4de2893
permissions -rwxr-xr-x
Adapt config sample to use hsqldb
     1 /*
     2  *   SONEWS News Server
     3  *   see AUTHORS for the list of contributors
     4  *
     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.
     9  *
    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.
    14  *
    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/>.
    17  */
    18 package org.sonews.storage;
    19 
    20 import java.util.ArrayList;
    21 import java.util.List;
    22 import org.sonews.util.Pair;
    23 
    24 /**
    25  * A logical communication Channel is the a generic structural element for sets
    26  * of messages; e.g. a Newsgroup for a set of Articles.
    27  * A Channel can either be a real set of messages or an aggregated set of
    28  * several subsets.
    29  * @author Christian Lins
    30  * @since sonews/1.0
    31  */
    32 public abstract class Channel {
    33 
    34 	/**
    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.
    38 	 */
    39 	public static final int MAILINGLIST = 0x1;
    40 	/**
    41 	 * If this flag is set the Group is marked as readonly and the posting
    42 	 * is prohibited. This can be useful for groups that are synced only in
    43 	 * one direction.
    44 	 */
    45 	public static final int READONLY = 0x2;
    46 	/**
    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.
    49 	 */
    50 	public static final int DELETED = 0x80;
    51 
    52 	public static List<Channel> getAll() {
    53 		List<Channel> all = new ArrayList<Channel>();
    54 
    55 		/*List<Channel> agroups = AggregatedGroup.getAll();
    56 		if(agroups != null)
    57 		{
    58 		all.addAll(agroups);
    59 		}*/
    60 
    61 		List<Channel> groups = Group.getAll();
    62 		if (groups != null) {
    63 			all.addAll(groups);
    64 		}
    65 
    66 		return all;
    67 	}
    68 
    69 	public static Channel getByName(String name)
    70 			throws StorageBackendException {
    71 		return StorageManager.current().getGroup(name);
    72 	}
    73 
    74 	public abstract Article getArticle(long idx)
    75 			throws StorageBackendException;
    76 
    77 	public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
    78 			final long first, final long last)
    79 			throws StorageBackendException;
    80 
    81 	public abstract List<Long> getArticleNumbers()
    82 			throws StorageBackendException;
    83 
    84 	public abstract long getFirstArticleNumber()
    85 			throws StorageBackendException;
    86 
    87 	public abstract long getIndexOf(Article art)
    88 			throws StorageBackendException;
    89 
    90 	public abstract long getInternalID();
    91 
    92 	public abstract long getLastArticleNumber()
    93 			throws StorageBackendException;
    94 
    95 	public abstract String getName();
    96 
    97 	public abstract long getPostingsCount()
    98 			throws StorageBackendException;
    99 
   100 	public abstract boolean isDeleted();
   101 
   102 	public abstract boolean isWriteable();
   103 }