org/sonews/storage/Channel.java
changeset 12 bb6990c0dd1a
child 13 de98fd5b35f5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/org/sonews/storage/Channel.java	Thu Aug 20 14:31:19 2009 +0200
     1.3 @@ -0,0 +1,121 @@
     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 +  {
    1.80 +    Channel channel;
    1.81 +    
    1.82 +    // Check if it's an aggregated group
    1.83 +    channel = AggregatedGroup.getByName(name);
    1.84 +
    1.85 +    // If it's not an aggregate is probably a "real" group
    1.86 +    if(channel == null)
    1.87 +    {
    1.88 +      channel = Group.getByName(name);
    1.89 +    }
    1.90 +
    1.91 +    return channel;
    1.92 +  }
    1.93 +
    1.94 +  public abstract Article getArticle(long idx)
    1.95 +    throws StorageBackendException;
    1.96 +
    1.97 +  public abstract List<Pair<Long, ArticleHead>> getArticleHeads(
    1.98 +    final long first, final long last)
    1.99 +    throws StorageBackendException;
   1.100 +
   1.101 +  public abstract List<Long> getArticleNumbers()
   1.102 +    throws StorageBackendException;
   1.103 +
   1.104 +  public abstract long getFirstArticleNumber()
   1.105 +    throws StorageBackendException;
   1.106 +
   1.107 +  public abstract long getIndexOf(Article art)
   1.108 +    throws StorageBackendException;
   1.109 +
   1.110 +  public abstract long getInternalID();
   1.111 +
   1.112 +  public abstract long getLastArticleNumber()
   1.113 +    throws StorageBackendException;
   1.114 +
   1.115 +  public abstract String getName();
   1.116 +  
   1.117 +  public abstract long getPostingsCount()
   1.118 +    throws StorageBackendException;
   1.119 +
   1.120 +  public abstract boolean isDeleted();
   1.121 +
   1.122 +  public abstract boolean isWriteable();
   1.123 +
   1.124 +}