src/org/sonews/storage/Channel.java
author cli
Sun Aug 29 18:17:37 2010 +0200 (2010-08-29)
changeset 37 74139325d305
parent 35 ed84c8bdd87b
child 39 73b21e9f3958
permissions -rw-r--r--
Switch intent style to Original K&R / Linux / Kernel.
     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 
    19 package org.sonews.storage;
    20 
    21 import java.util.ArrayList;
    22 import java.util.List;
    23 import org.sonews.util.Pair;
    24 
    25 /**
    26  * A logical communication Channel is the a generic structural element for sets
    27  * of messages; e.g. a Newsgroup for a set of Articles.
    28  * A Channel can either be a real set of messages or an aggregated set of
    29  * several subsets.
    30  * @author Christian Lins
    31  * @since sonews/1.0
    32  */
    33 public abstract class Channel
    34 {
    35 
    36 	/**
    37 	 * If this flag is set the Group is no real newsgroup but a mailing list
    38 	 * mirror. In that case every posting and receiving mails must go through
    39 	 * the mailing list gateway.
    40 	 */
    41 	public static final int MAILINGLIST = 0x1;
    42 	/**
    43 	 * If this flag is set the Group is marked as readonly and the posting
    44 	 * is prohibited. This can be useful for groups that are synced only in
    45 	 * one direction.
    46 	 */
    47 	public static final int READONLY = 0x2;
    48 	/**
    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.
    51 	 */
    52 	public static final int DELETED = 0x80;
    53 
    54 	public static List<Channel> getAll()
    55 	{
    56 		List<Channel> all = new ArrayList<Channel>();
    57 
    58 		/*List<Channel> agroups = AggregatedGroup.getAll();
    59 		if(agroups != null)
    60 		{
    61 		all.addAll(agroups);
    62 		}*/
    63 
    64 		List<Channel> groups = Group.getAll();
    65 		if (groups != null) {
    66 			all.addAll(groups);
    67 		}
    68 
    69 		return all;
    70 	}
    71 
    72 	public static Channel getByName(String name)
    73 		throws StorageBackendException
    74 	{
    75 		return StorageManager.current().getGroup(name);
    76 	}
    77 
    78 	public abstract Article getArticle(long idx)
    79 		throws StorageBackendException;
    80 
    81 	public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
    82 		final long first, final long last)
    83 		throws StorageBackendException;
    84 
    85 	public abstract List<Long> getArticleNumbers()
    86 		throws StorageBackendException;
    87 
    88 	public abstract long getFirstArticleNumber()
    89 		throws StorageBackendException;
    90 
    91 	public abstract long getIndexOf(Article art)
    92 		throws StorageBackendException;
    93 
    94 	public abstract long getInternalID();
    95 
    96 	public abstract long getLastArticleNumber()
    97 		throws StorageBackendException;
    98 
    99 	public abstract String getName();
   100 
   101 	public abstract long getPostingsCount()
   102 		throws StorageBackendException;
   103 
   104 	public abstract boolean isDeleted();
   105 
   106 	public abstract boolean isWriteable();
   107 }