src/org/sonews/storage/Channel.java
author cli
Mon Aug 30 00:20:06 2010 +0200 (2010-08-30)
changeset 39 73b21e9f3958
parent 37 74139325d305
child 42 7f84f4de2893
permissions -rw-r--r--
Some work on XDAEMON command.
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@39
    42
cli@37
    43
	/**
cli@37
    44
	 * If this flag is set the Group is marked as readonly and the posting
cli@37
    45
	 * is prohibited. This can be useful for groups that are synced only in
cli@37
    46
	 * one direction.
cli@37
    47
	 */
cli@37
    48
	public static final int READONLY = 0x2;
cli@39
    49
cli@37
    50
	/**
cli@37
    51
	 * If this flag is set the Group is marked as deleted and must not occur
cli@37
    52
	 * in any output. The deletion is done lazily by a low priority daemon.
cli@37
    53
	 */
cli@37
    54
	public static final int DELETED = 0x80;
chris@3
    55
cli@37
    56
	public static List<Channel> getAll()
cli@37
    57
	{
cli@37
    58
		List<Channel> all = new ArrayList<Channel>();
chris@3
    59
cli@37
    60
		/*List<Channel> agroups = AggregatedGroup.getAll();
cli@37
    61
		if(agroups != null)
cli@37
    62
		{
cli@37
    63
		all.addAll(agroups);
cli@37
    64
		}*/
chris@3
    65
cli@37
    66
		List<Channel> groups = Group.getAll();
cli@37
    67
		if (groups != null) {
cli@37
    68
			all.addAll(groups);
cli@37
    69
		}
chris@3
    70
cli@37
    71
		return all;
cli@37
    72
	}
chris@3
    73
cli@37
    74
	public static Channel getByName(String name)
cli@37
    75
		throws StorageBackendException
cli@37
    76
	{
cli@37
    77
		return StorageManager.current().getGroup(name);
cli@37
    78
	}
chris@3
    79
cli@37
    80
	public abstract Article getArticle(long idx)
cli@37
    81
		throws StorageBackendException;
chris@3
    82
cli@37
    83
	public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
cli@37
    84
		final long first, final long last)
cli@37
    85
		throws StorageBackendException;
chris@3
    86
cli@37
    87
	public abstract List<Long> getArticleNumbers()
cli@37
    88
		throws StorageBackendException;
chris@3
    89
cli@37
    90
	public abstract long getFirstArticleNumber()
cli@37
    91
		throws StorageBackendException;
chris@3
    92
cli@37
    93
	public abstract long getIndexOf(Article art)
cli@37
    94
		throws StorageBackendException;
chris@3
    95
cli@37
    96
	public abstract long getInternalID();
chris@3
    97
cli@37
    98
	public abstract long getLastArticleNumber()
cli@37
    99
		throws StorageBackendException;
chris@3
   100
cli@37
   101
	public abstract String getName();
chris@3
   102
cli@37
   103
	public abstract long getPostingsCount()
cli@37
   104
		throws StorageBackendException;
chris@3
   105
cli@37
   106
	public abstract boolean isDeleted();
chris@3
   107
cli@37
   108
	public abstract boolean isWriteable();
chris@3
   109
}