src/org/sonews/storage/Channel.java
author cli
Sun, 29 Aug 2010 18:17:37 +0200
changeset 37 74139325d305
parent 35 ed84c8bdd87b
child 39 73b21e9f3958
permissions -rw-r--r--
Switch intent style to Original K&R / Linux / Kernel.
chris@3
     1
/*
chris@3
     2
 *   SONEWS News Server
chris@3
     3
 *   see AUTHORS for the list of contributors
chris@3
     4
 *
chris@3
     5
 *   This program is free software: you can redistribute it and/or modify
chris@3
     6
 *   it under the terms of the GNU General Public License as published by
chris@3
     7
 *   the Free Software Foundation, either version 3 of the License, or
chris@3
     8
 *   (at your option) any later version.
chris@3
     9
 *
chris@3
    10
 *   This program is distributed in the hope that it will be useful,
chris@3
    11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
chris@3
    12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
chris@3
    13
 *   GNU General Public License for more details.
chris@3
    14
 *
chris@3
    15
 *   You should have received a copy of the GNU General Public License
chris@3
    16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
chris@3
    17
 */
chris@3
    18
chris@3
    19
package org.sonews.storage;
chris@3
    20
chris@3
    21
import java.util.ArrayList;
chris@3
    22
import java.util.List;
chris@3
    23
import org.sonews.util.Pair;
chris@3
    24
chris@3
    25
/**
chris@3
    26
 * A logical communication Channel is the a generic structural element for sets
chris@3
    27
 * of messages; e.g. a Newsgroup for a set of Articles.
chris@3
    28
 * A Channel can either be a real set of messages or an aggregated set of
chris@3
    29
 * several subsets.
chris@3
    30
 * @author Christian Lins
chris@3
    31
 * @since sonews/1.0
chris@3
    32
 */
chris@3
    33
public abstract class Channel
chris@3
    34
{
chris@3
    35
cli@37
    36
	/**
cli@37
    37
	 * If this flag is set the Group is no real newsgroup but a mailing list
cli@37
    38
	 * mirror. In that case every posting and receiving mails must go through
cli@37
    39
	 * the mailing list gateway.
cli@37
    40
	 */
cli@37
    41
	public static final int MAILINGLIST = 0x1;
cli@37
    42
	/**
cli@37
    43
	 * If this flag is set the Group is marked as readonly and the posting
cli@37
    44
	 * is prohibited. This can be useful for groups that are synced only in
cli@37
    45
	 * one direction.
cli@37
    46
	 */
cli@37
    47
	public static final int READONLY = 0x2;
cli@37
    48
	/**
cli@37
    49
	 * If this flag is set the Group is marked as deleted and must not occur
cli@37
    50
	 * in any output. The deletion is done lazily by a low priority daemon.
cli@37
    51
	 */
cli@37
    52
	public static final int DELETED = 0x80;
chris@3
    53
cli@37
    54
	public static List<Channel> getAll()
cli@37
    55
	{
cli@37
    56
		List<Channel> all = new ArrayList<Channel>();
chris@3
    57
cli@37
    58
		/*List<Channel> agroups = AggregatedGroup.getAll();
cli@37
    59
		if(agroups != null)
cli@37
    60
		{
cli@37
    61
		all.addAll(agroups);
cli@37
    62
		}*/
chris@3
    63
cli@37
    64
		List<Channel> groups = Group.getAll();
cli@37
    65
		if (groups != null) {
cli@37
    66
			all.addAll(groups);
cli@37
    67
		}
chris@3
    68
cli@37
    69
		return all;
cli@37
    70
	}
chris@3
    71
cli@37
    72
	public static Channel getByName(String name)
cli@37
    73
		throws StorageBackendException
cli@37
    74
	{
cli@37
    75
		return StorageManager.current().getGroup(name);
cli@37
    76
	}
chris@3
    77
cli@37
    78
	public abstract Article getArticle(long idx)
cli@37
    79
		throws StorageBackendException;
chris@3
    80
cli@37
    81
	public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
cli@37
    82
		final long first, final long last)
cli@37
    83
		throws StorageBackendException;
chris@3
    84
cli@37
    85
	public abstract List<Long> getArticleNumbers()
cli@37
    86
		throws StorageBackendException;
chris@3
    87
cli@37
    88
	public abstract long getFirstArticleNumber()
cli@37
    89
		throws StorageBackendException;
chris@3
    90
cli@37
    91
	public abstract long getIndexOf(Article art)
cli@37
    92
		throws StorageBackendException;
chris@3
    93
cli@37
    94
	public abstract long getInternalID();
chris@3
    95
cli@37
    96
	public abstract long getLastArticleNumber()
cli@37
    97
		throws StorageBackendException;
chris@3
    98
cli@37
    99
	public abstract String getName();
chris@3
   100
cli@37
   101
	public abstract long getPostingsCount()
cli@37
   102
		throws StorageBackendException;
chris@3
   103
cli@37
   104
	public abstract boolean isDeleted();
chris@3
   105
cli@37
   106
	public abstract boolean isWriteable();
chris@3
   107
}