org/sonews/storage/Channel.java
author cli
Sun May 09 12:38:46 2010 +0200 (2010-05-09)
changeset 30 146b3275b792
parent 3 2fdc9cc89502
child 31 087ef6fe6a1a
permissions -rw-r--r--
The StorageBackendException is catched two times so that the user see the "500 internal server error" only at the second catch (probably fixes #5).
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
chris@3
    36
  /**
chris@3
    37
   * If this flag is set the Group is no real newsgroup but a mailing list
chris@3
    38
   * mirror. In that case every posting and receiving mails must go through
chris@3
    39
   * the mailing list gateway.
chris@3
    40
   */
chris@3
    41
  public static final int MAILINGLIST = 0x1;
chris@3
    42
chris@3
    43
  /**
chris@3
    44
   * If this flag is set the Group is marked as readonly and the posting
chris@3
    45
   * is prohibited. This can be useful for groups that are synced only in
chris@3
    46
   * one direction.
chris@3
    47
   */
chris@3
    48
  public static final int READONLY    = 0x2;
chris@3
    49
chris@3
    50
  /**
chris@3
    51
   * If this flag is set the Group is marked as deleted and must not occur
chris@3
    52
   * in any output. The deletion is done lazily by a low priority daemon.
chris@3
    53
   */
chris@3
    54
  public static final int DELETED     = 0x80;
chris@3
    55
chris@3
    56
  public static List<Channel> getAll()
chris@3
    57
  {
chris@3
    58
    List<Channel> all = new ArrayList<Channel>();
chris@3
    59
chris@3
    60
    /*List<Channel> agroups = AggregatedGroup.getAll();
chris@3
    61
    if(agroups != null)
chris@3
    62
    {
chris@3
    63
      all.addAll(agroups);
chris@3
    64
    }*/
chris@3
    65
chris@3
    66
    List<Channel> groups = Group.getAll();
chris@3
    67
    if(groups != null)
chris@3
    68
    {
chris@3
    69
      all.addAll(groups);
chris@3
    70
    }
chris@3
    71
chris@3
    72
    return all;
chris@3
    73
  }
chris@3
    74
chris@3
    75
  public static Channel getByName(String name)
chris@3
    76
  {
cli@13
    77
    return Group.getByName(name);
chris@3
    78
  }
chris@3
    79
chris@3
    80
  public abstract Article getArticle(long idx)
chris@3
    81
    throws StorageBackendException;
chris@3
    82
chris@3
    83
  public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
chris@3
    84
    final long first, final long last)
chris@3
    85
    throws StorageBackendException;
chris@3
    86
chris@3
    87
  public abstract List<Long> getArticleNumbers()
chris@3
    88
    throws StorageBackendException;
chris@3
    89
chris@3
    90
  public abstract long getFirstArticleNumber()
chris@3
    91
    throws StorageBackendException;
chris@3
    92
chris@3
    93
  public abstract long getIndexOf(Article art)
chris@3
    94
    throws StorageBackendException;
chris@3
    95
chris@3
    96
  public abstract long getInternalID();
chris@3
    97
chris@3
    98
  public abstract long getLastArticleNumber()
chris@3
    99
    throws StorageBackendException;
chris@3
   100
chris@3
   101
  public abstract String getName();
chris@3
   102
  
chris@3
   103
  public abstract long getPostingsCount()
chris@3
   104
    throws StorageBackendException;
chris@3
   105
chris@3
   106
  public abstract boolean isDeleted();
chris@3
   107
chris@3
   108
  public abstract boolean isWriteable();
chris@3
   109
chris@3
   110
}