src/org/sonews/storage/Channel.java
changeset 35 ed84c8bdd87b
parent 31 087ef6fe6a1a
child 37 74139325d305
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/org/sonews/storage/Channel.java	Sun Aug 29 17:28:58 2010 +0200
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + *   SONEWS News Server
     1.6 + *   see AUTHORS for the list of contributors
     1.7 + *
     1.8 + *   This program is free software: you can redistribute it and/or modify
     1.9 + *   it under the terms of the GNU General Public License as published by
    1.10 + *   the Free Software Foundation, either version 3 of the License, or
    1.11 + *   (at your option) any later version.
    1.12 + *
    1.13 + *   This program is distributed in the hope that it will be useful,
    1.14 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 + *   GNU General Public License for more details.
    1.17 + *
    1.18 + *   You should have received a copy of the GNU General Public License
    1.19 + *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 + */
    1.21 +
    1.22 +package org.sonews.storage;
    1.23 +
    1.24 +import java.util.ArrayList;
    1.25 +import java.util.List;
    1.26 +import org.sonews.util.Pair;
    1.27 +
    1.28 +/**
    1.29 + * A logical communication Channel is the a generic structural element for sets
    1.30 + * of messages; e.g. a Newsgroup for a set of Articles.
    1.31 + * A Channel can either be a real set of messages or an aggregated set of
    1.32 + * several subsets.
    1.33 + * @author Christian Lins
    1.34 + * @since sonews/1.0
    1.35 + */
    1.36 +public abstract class Channel
    1.37 +{
    1.38 +
    1.39 +  /**
    1.40 +   * If this flag is set the Group is no real newsgroup but a mailing list
    1.41 +   * mirror. In that case every posting and receiving mails must go through
    1.42 +   * the mailing list gateway.
    1.43 +   */
    1.44 +  public static final int MAILINGLIST = 0x1;
    1.45 +
    1.46 +  /**
    1.47 +   * If this flag is set the Group is marked as readonly and the posting
    1.48 +   * is prohibited. This can be useful for groups that are synced only in
    1.49 +   * one direction.
    1.50 +   */
    1.51 +  public static final int READONLY    = 0x2;
    1.52 +
    1.53 +  /**
    1.54 +   * If this flag is set the Group is marked as deleted and must not occur
    1.55 +   * in any output. The deletion is done lazily by a low priority daemon.
    1.56 +   */
    1.57 +  public static final int DELETED     = 0x80;
    1.58 +
    1.59 +  public static List<Channel> getAll()
    1.60 +  {
    1.61 +    List<Channel> all = new ArrayList<Channel>();
    1.62 +
    1.63 +    /*List<Channel> agroups = AggregatedGroup.getAll();
    1.64 +    if(agroups != null)
    1.65 +    {
    1.66 +      all.addAll(agroups);
    1.67 +    }*/
    1.68 +
    1.69 +    List<Channel> groups = Group.getAll();
    1.70 +    if(groups != null)
    1.71 +    {
    1.72 +      all.addAll(groups);
    1.73 +    }
    1.74 +
    1.75 +    return all;
    1.76 +  }
    1.77 +
    1.78 +  public static Channel getByName(String name)
    1.79 +    throws StorageBackendException
    1.80 +  {
    1.81 +    return StorageManager.current().getGroup(name);
    1.82 +  }
    1.83 +
    1.84 +  public abstract Article getArticle(long idx)
    1.85 +    throws StorageBackendException;
    1.86 +
    1.87 +  public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
    1.88 +    final long first, final long last)
    1.89 +    throws StorageBackendException;
    1.90 +
    1.91 +  public abstract List<Long> getArticleNumbers()
    1.92 +    throws StorageBackendException;
    1.93 +
    1.94 +  public abstract long getFirstArticleNumber()
    1.95 +    throws StorageBackendException;
    1.96 +
    1.97 +  public abstract long getIndexOf(Article art)
    1.98 +    throws StorageBackendException;
    1.99 +
   1.100 +  public abstract long getInternalID();
   1.101 +
   1.102 +  public abstract long getLastArticleNumber()
   1.103 +    throws StorageBackendException;
   1.104 +
   1.105 +  public abstract String getName();
   1.106 +  
   1.107 +  public abstract long getPostingsCount()
   1.108 +    throws StorageBackendException;
   1.109 +
   1.110 +  public abstract boolean isDeleted();
   1.111 +
   1.112 +  public abstract boolean isWriteable();
   1.113 +
   1.114 +}