src/org/sonews/storage/Storage.java
changeset 35 ed84c8bdd87b
parent 24 2ff819fa5be1
child 37 74139325d305
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/org/sonews/storage/Storage.java	Sun Aug 29 17:28:58 2010 +0200
     1.3 @@ -0,0 +1,150 @@
     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.List;
    1.25 +import org.sonews.feed.Subscription;
    1.26 +import org.sonews.util.Pair;
    1.27 +
    1.28 +/**
    1.29 + * A generic storage backend interface.
    1.30 + * @author Christian Lins
    1.31 + * @since sonews/1.0
    1.32 + */
    1.33 +public interface Storage
    1.34 +{
    1.35 +
    1.36 +  /**
    1.37 +   * Stores the given Article in the storage.
    1.38 +   * @param art
    1.39 +   * @throws StorageBackendException
    1.40 +   */
    1.41 +  void addArticle(Article art)
    1.42 +    throws StorageBackendException;
    1.43 +
    1.44 +  void addEvent(long timestamp, int type, long groupID)
    1.45 +    throws StorageBackendException;
    1.46 +
    1.47 +  void addGroup(String groupname, int flags)
    1.48 +    throws StorageBackendException;
    1.49 +
    1.50 +  int countArticles()
    1.51 +    throws StorageBackendException;
    1.52 +
    1.53 +  int countGroups()
    1.54 +    throws StorageBackendException;
    1.55 +
    1.56 +  void delete(String messageID)
    1.57 +    throws StorageBackendException;
    1.58 +
    1.59 +  Article getArticle(String messageID)
    1.60 +    throws StorageBackendException;
    1.61 +
    1.62 +  Article getArticle(long articleIndex, long groupID)
    1.63 +    throws StorageBackendException;
    1.64 +
    1.65 +  List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
    1.66 +    throws StorageBackendException;
    1.67 +
    1.68 +  List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end,
    1.69 +    String header, String pattern)
    1.70 +    throws StorageBackendException;
    1.71 +
    1.72 +  long getArticleIndex(Article art, Group group)
    1.73 +    throws StorageBackendException;
    1.74 +
    1.75 +  List<Long> getArticleNumbers(long groupID)
    1.76 +    throws StorageBackendException;
    1.77 +
    1.78 +  String getConfigValue(String key)
    1.79 +    throws StorageBackendException;
    1.80 +
    1.81 +  int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
    1.82 +    Channel channel)
    1.83 +    throws StorageBackendException;
    1.84 +
    1.85 +  double getEventsPerHour(int key, long gid)
    1.86 +    throws StorageBackendException;
    1.87 +
    1.88 +  int getFirstArticleNumber(Group group)
    1.89 +    throws StorageBackendException;
    1.90 +
    1.91 +  Group getGroup(String name)
    1.92 +    throws StorageBackendException;
    1.93 +
    1.94 +  List<Channel> getGroups()
    1.95 +    throws StorageBackendException;
    1.96 +
    1.97 +  /**
    1.98 +   * Retrieves the collection of groupnames that are associated with the
    1.99 +   * given list address.
   1.100 +   * @param inetaddress
   1.101 +   * @return
   1.102 +   * @throws StorageBackendException
   1.103 +   */
   1.104 +  List<String> getGroupsForList(String listAddress)
   1.105 +    throws StorageBackendException;
   1.106 +
   1.107 +  int getLastArticleNumber(Group group)
   1.108 +    throws StorageBackendException;
   1.109 +
   1.110 +  /**
   1.111 +   * Returns a list of email addresses that are related to the given
   1.112 +   * groupname. In most cases the list may contain only one entry.
   1.113 +   * @param groupname
   1.114 +   * @return
   1.115 +   * @throws StorageBackendException
   1.116 +   */
   1.117 +  List<String> getListsForGroup(String groupname)
   1.118 +    throws StorageBackendException;
   1.119 +
   1.120 +  String getOldestArticle()
   1.121 +    throws StorageBackendException;
   1.122 +
   1.123 +  int getPostingsCount(String groupname)
   1.124 +    throws StorageBackendException;
   1.125 +
   1.126 +  List<Subscription> getSubscriptions(int type)
   1.127 +    throws StorageBackendException;
   1.128 +
   1.129 +  boolean isArticleExisting(String messageID)
   1.130 +    throws StorageBackendException;
   1.131 +
   1.132 +  boolean isGroupExisting(String groupname)
   1.133 +    throws StorageBackendException;
   1.134 +
   1.135 +  void purgeGroup(Group group)
   1.136 +    throws StorageBackendException;
   1.137 +
   1.138 +  void setConfigValue(String key, String value)
   1.139 +    throws StorageBackendException;
   1.140 +
   1.141 +  /**
   1.142 +   * Updates headers and channel references of the given article.
   1.143 +   * @param article
   1.144 +   * @return
   1.145 +   * @throws StorageBackendException
   1.146 +   */
   1.147 +  boolean update(Article article)
   1.148 +    throws StorageBackendException;
   1.149 +
   1.150 +  boolean update(Group group)
   1.151 +    throws StorageBackendException;
   1.152 +
   1.153 +}