org/sonews/storage/Storage.java
author cli
Thu, 20 Aug 2009 14:31:19 +0200
changeset 12 bb6990c0dd1a
parent 3 2fdc9cc89502
child 14 efce4ec25564
permissions -rw-r--r--
Merging fixes from sonews/1.0.3
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.List;
chris@3
    22
import javax.mail.internet.InternetAddress;
chris@3
    23
import org.sonews.feed.Subscription;
chris@3
    24
import org.sonews.util.Pair;
chris@3
    25
chris@3
    26
/**
chris@3
    27
 * A generic storage backend interface.
chris@3
    28
 * @author Christian Lins
chris@3
    29
 * @since sonews/1.0
chris@3
    30
 */
chris@3
    31
public interface Storage
chris@3
    32
{
chris@3
    33
cli@12
    34
  /**
cli@12
    35
   * Stores the given Article in the storage.
cli@12
    36
   * @param art
cli@12
    37
   * @throws StorageBackendException
cli@12
    38
   */
chris@3
    39
  void addArticle(Article art)
chris@3
    40
    throws StorageBackendException;
chris@3
    41
chris@3
    42
  void addEvent(long timestamp, int type, long groupID)
chris@3
    43
    throws StorageBackendException;
chris@3
    44
chris@3
    45
  void addGroup(String groupname, int flags)
chris@3
    46
    throws StorageBackendException;
chris@3
    47
chris@3
    48
  int countArticles()
chris@3
    49
    throws StorageBackendException;
chris@3
    50
chris@3
    51
  int countGroups()
chris@3
    52
    throws StorageBackendException;
chris@3
    53
chris@3
    54
  void delete(String messageID)
chris@3
    55
    throws StorageBackendException;
chris@3
    56
chris@3
    57
  Article getArticle(String messageID)
chris@3
    58
    throws StorageBackendException;
chris@3
    59
chris@3
    60
  Article getArticle(long articleIndex, long groupID)
chris@3
    61
    throws StorageBackendException;
chris@3
    62
chris@3
    63
  List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
chris@3
    64
    throws StorageBackendException;
chris@3
    65
chris@3
    66
  List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end,
chris@3
    67
    String header, String pattern)
chris@3
    68
    throws StorageBackendException;
chris@3
    69
chris@3
    70
  long getArticleIndex(Article art, Group group)
chris@3
    71
    throws StorageBackendException;
chris@3
    72
chris@3
    73
  List<Long> getArticleNumbers(long groupID)
chris@3
    74
    throws StorageBackendException;
chris@3
    75
chris@3
    76
  String getConfigValue(String key)
chris@3
    77
    throws StorageBackendException;
chris@3
    78
chris@3
    79
  int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
chris@3
    80
    Channel channel)
chris@3
    81
    throws StorageBackendException;
chris@3
    82
chris@3
    83
  double getEventsPerHour(int key, long gid)
chris@3
    84
    throws StorageBackendException;
chris@3
    85
chris@3
    86
  int getFirstArticleNumber(Group group)
chris@3
    87
    throws StorageBackendException;
chris@3
    88
chris@3
    89
  Group getGroup(String name)
chris@3
    90
    throws StorageBackendException;
chris@3
    91
chris@3
    92
  List<Channel> getGroups()
chris@3
    93
    throws StorageBackendException;
chris@3
    94
chris@3
    95
  List<String> getGroupsForList(InternetAddress inetaddress)
chris@3
    96
    throws StorageBackendException;
chris@3
    97
chris@3
    98
  int getLastArticleNumber(Group group)
chris@3
    99
    throws StorageBackendException;
chris@3
   100
cli@12
   101
  /**
cli@12
   102
   * Returns a list of email addresses that are related to the given
cli@12
   103
   * groupname. In most cases the list may contain only one entry.
cli@12
   104
   * @param groupname
cli@12
   105
   * @return
cli@12
   106
   * @throws StorageBackendException
cli@12
   107
   */
cli@12
   108
  List<String> getListsForGroup(String groupname)
chris@3
   109
    throws StorageBackendException;
chris@3
   110
chris@3
   111
  String getOldestArticle()
chris@3
   112
    throws StorageBackendException;
chris@3
   113
chris@3
   114
  int getPostingsCount(String groupname)
chris@3
   115
    throws StorageBackendException;
chris@3
   116
chris@3
   117
  List<Subscription> getSubscriptions(int type)
chris@3
   118
    throws StorageBackendException;
chris@3
   119
chris@3
   120
  boolean isArticleExisting(String messageID)
chris@3
   121
    throws StorageBackendException;
chris@3
   122
chris@3
   123
  boolean isGroupExisting(String groupname)
chris@3
   124
    throws StorageBackendException;
chris@3
   125
chris@3
   126
  void purgeGroup(Group group)
chris@3
   127
    throws StorageBackendException;
chris@3
   128
chris@3
   129
  void setConfigValue(String key, String value)
chris@3
   130
    throws StorageBackendException;
chris@3
   131
chris@3
   132
  boolean update(Group group)
chris@3
   133
    throws StorageBackendException;
chris@3
   134
chris@3
   135
}