org/sonews/storage/Storage.java
author cli
Sun Aug 29 17:03:21 2010 +0200 (2010-08-29)
changeset 33 f9bf183447d1
parent 14 efce4ec25564
permissions -rw-r--r--
Article(javax.mail.Message) now has a safe method to read the byte body from the given message object (fixes #16).
     1 /*
     2  *   SONEWS News Server
     3  *   see AUTHORS for the list of contributors
     4  *
     5  *   This program is free software: you can redistribute it and/or modify
     6  *   it under the terms of the GNU General Public License as published by
     7  *   the Free Software Foundation, either version 3 of the License, or
     8  *   (at your option) any later version.
     9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 
    19 package org.sonews.storage;
    20 
    21 import java.util.List;
    22 import org.sonews.feed.Subscription;
    23 import org.sonews.util.Pair;
    24 
    25 /**
    26  * A generic storage backend interface.
    27  * @author Christian Lins
    28  * @since sonews/1.0
    29  */
    30 public interface Storage
    31 {
    32 
    33   /**
    34    * Stores the given Article in the storage.
    35    * @param art
    36    * @throws StorageBackendException
    37    */
    38   void addArticle(Article art)
    39     throws StorageBackendException;
    40 
    41   void addEvent(long timestamp, int type, long groupID)
    42     throws StorageBackendException;
    43 
    44   void addGroup(String groupname, int flags)
    45     throws StorageBackendException;
    46 
    47   int countArticles()
    48     throws StorageBackendException;
    49 
    50   int countGroups()
    51     throws StorageBackendException;
    52 
    53   void delete(String messageID)
    54     throws StorageBackendException;
    55 
    56   Article getArticle(String messageID)
    57     throws StorageBackendException;
    58 
    59   Article getArticle(long articleIndex, long groupID)
    60     throws StorageBackendException;
    61 
    62   List<Pair<Long, ArticleHead>> getArticleHeads(Group group, long first, long last)
    63     throws StorageBackendException;
    64 
    65   List<Pair<Long, String>> getArticleHeaders(Channel channel, long start, long end,
    66     String header, String pattern)
    67     throws StorageBackendException;
    68 
    69   long getArticleIndex(Article art, Group group)
    70     throws StorageBackendException;
    71 
    72   List<Long> getArticleNumbers(long groupID)
    73     throws StorageBackendException;
    74 
    75   String getConfigValue(String key)
    76     throws StorageBackendException;
    77 
    78   int getEventsCount(int eventType, long startTimestamp, long endTimestamp,
    79     Channel channel)
    80     throws StorageBackendException;
    81 
    82   double getEventsPerHour(int key, long gid)
    83     throws StorageBackendException;
    84 
    85   int getFirstArticleNumber(Group group)
    86     throws StorageBackendException;
    87 
    88   Group getGroup(String name)
    89     throws StorageBackendException;
    90 
    91   List<Channel> getGroups()
    92     throws StorageBackendException;
    93 
    94   /**
    95    * Retrieves the collection of groupnames that are associated with the
    96    * given list address.
    97    * @param inetaddress
    98    * @return
    99    * @throws StorageBackendException
   100    */
   101   List<String> getGroupsForList(String listAddress)
   102     throws StorageBackendException;
   103 
   104   int getLastArticleNumber(Group group)
   105     throws StorageBackendException;
   106 
   107   /**
   108    * Returns a list of email addresses that are related to the given
   109    * groupname. In most cases the list may contain only one entry.
   110    * @param groupname
   111    * @return
   112    * @throws StorageBackendException
   113    */
   114   List<String> getListsForGroup(String groupname)
   115     throws StorageBackendException;
   116 
   117   String getOldestArticle()
   118     throws StorageBackendException;
   119 
   120   int getPostingsCount(String groupname)
   121     throws StorageBackendException;
   122 
   123   List<Subscription> getSubscriptions(int type)
   124     throws StorageBackendException;
   125 
   126   boolean isArticleExisting(String messageID)
   127     throws StorageBackendException;
   128 
   129   boolean isGroupExisting(String groupname)
   130     throws StorageBackendException;
   131 
   132   void purgeGroup(Group group)
   133     throws StorageBackendException;
   134 
   135   void setConfigValue(String key, String value)
   136     throws StorageBackendException;
   137 
   138   /**
   139    * Updates headers and channel references of the given article.
   140    * @param article
   141    * @return
   142    * @throws StorageBackendException
   143    */
   144   boolean update(Article article)
   145     throws StorageBackendException;
   146 
   147   boolean update(Group group)
   148     throws StorageBackendException;
   149 
   150 }